|
@@ -47,7 +47,7 @@ namespace GFGGame
|
|
private PinchGesture pinchGesture;
|
|
private PinchGesture pinchGesture;
|
|
private RotationGesture rotationGesture;
|
|
private RotationGesture rotationGesture;
|
|
|
|
|
|
- private bool isTouchUI = false;//点击在m_comSelectBox按钮上
|
|
|
|
|
|
+ // private bool isTouchUI = false;//点击在m_comSelectBox按钮上
|
|
private bool isTwoTouchPoint = false;
|
|
private bool isTwoTouchPoint = false;
|
|
private int maxLayer = int.MinValue;//最上层的层级数
|
|
private int maxLayer = int.MinValue;//最上层的层级数
|
|
protected override void OnInit()
|
|
protected override void OnInit()
|
|
@@ -112,10 +112,11 @@ namespace GFGGame
|
|
RefreshList(EnumPhotographType.BG);
|
|
RefreshList(EnumPhotographType.BG);
|
|
DisposeEquipData();
|
|
DisposeEquipData();
|
|
|
|
|
|
- SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, EnumPhotographType.BG, equipDataCache.bgId, maxLayer, out maxLayer);
|
|
|
|
|
|
+ // SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, EnumPhotographType.BG, equipDataCache.bgId);
|
|
|
|
|
|
|
|
+ UpdateBg(ItemCfgArray.Instance.GetCfg(equipDataCache.bgId));
|
|
UpdateBody();
|
|
UpdateBody();
|
|
- UpdateScene();
|
|
|
|
|
|
+ AddEquipTiemToScene();
|
|
|
|
|
|
}
|
|
}
|
|
/************************************************************UI界面*********************************************************/
|
|
/************************************************************UI界面*********************************************************/
|
|
@@ -161,34 +162,54 @@ namespace GFGGame
|
|
private void OnListItemClick(EventContext context)
|
|
private void OnListItemClick(EventContext context)
|
|
{
|
|
{
|
|
int itemID = (int)((context.data as GObject).data);
|
|
int itemID = (int)((context.data as GObject).data);
|
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
|
|
|
|
+
|
|
EnumPhotographType type = (EnumPhotographType)_ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
|
|
EnumPhotographType type = (EnumPhotographType)_ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
|
|
|
|
+
|
|
switch (type)
|
|
switch (type)
|
|
{
|
|
{
|
|
case EnumPhotographType.BG:
|
|
case EnumPhotographType.BG:
|
|
|
|
+ UpdateBg(itemCfg);
|
|
|
|
+ break;
|
|
|
|
+
|
|
case EnumPhotographType.BORDER:
|
|
case EnumPhotographType.BORDER:
|
|
|
|
+ if (_listData.IndexOf(itemID) == 0)
|
|
|
|
+ {
|
|
|
|
+ Transform tf = _sceneObject.transform.Find("Border/BorderRes");
|
|
|
|
+ SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
|
+ if (spr != null)
|
|
|
|
+ {
|
|
|
|
+ GameObject.Destroy(spr);
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ UpdateBorder(itemCfg);
|
|
|
|
+ break;
|
|
|
|
+
|
|
case EnumPhotographType.NPC:
|
|
case EnumPhotographType.NPC:
|
|
- SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, type, itemID, maxLayer, out maxLayer);
|
|
|
|
|
|
+
|
|
|
|
+ UpdateNpc(itemCfg);
|
|
break;
|
|
break;
|
|
|
|
|
|
case EnumPhotographType.SCENE:
|
|
case EnumPhotographType.SCENE:
|
|
|
|
|
|
- PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemID, out _equipSceneData);
|
|
|
|
- SceneController.AddItemToScene(_sceneObject, itemID, _equipSceneData[itemID].Count - 1, maxLayer + 1);
|
|
|
|
- maxLayer++;
|
|
|
|
|
|
+ UpdateScene(itemCfg, false, maxLayer);
|
|
break;
|
|
break;
|
|
case EnumPhotographType.EFFECT:
|
|
case EnumPhotographType.EFFECT:
|
|
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /************************** **********************************场景*********************************************************/
|
|
|
|
|
|
+ /************************************************************场景*********************************************************/
|
|
|
|
|
|
private void OnTouchUIBegin(EventContext context)
|
|
private void OnTouchUIBegin(EventContext context)
|
|
{
|
|
{
|
|
context.CaptureTouch();
|
|
context.CaptureTouch();
|
|
if (_ui.m_ComSelectRes.target.visible == true) return;
|
|
if (_ui.m_ComSelectRes.target.visible == true) return;
|
|
- if (Stage.inst.touchCount > 1 || context.inputEvent.touchId != 0 || isTwoTouchPoint) return;//只监听一根手指
|
|
|
|
- if (isTouchUI) return;
|
|
|
|
|
|
+ //两根手指点击屏幕||两根手指点过屏幕
|
|
|
|
+ if (Stage.inst.touchCount > 1 || isTwoTouchPoint) return;//只监听一根手指
|
|
|
|
+
|
|
|
|
+ if (IsTouchUI) return;
|
|
|
|
|
|
RaycastHit2D[] hit2Ds = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
|
RaycastHit2D[] hit2Ds = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
|
if (hit2Ds.Length > 0)
|
|
if (hit2Ds.Length > 0)
|
|
@@ -229,7 +250,7 @@ namespace GFGGame
|
|
{
|
|
{
|
|
if (hitParentGameObj == null) return;//未选中任何物体
|
|
if (hitParentGameObj == null) return;//未选中任何物体
|
|
if (Stage.inst.touchCount > 1 || context.inputEvent.touchId != 0 || isTwoTouchPoint) return; //只监听1根手指
|
|
if (Stage.inst.touchCount > 1 || context.inputEvent.touchId != 0 || isTwoTouchPoint) return; //只监听1根手指
|
|
- if (isTouchUI) return;
|
|
|
|
|
|
+ if (IsTouchUI) return;
|
|
|
|
|
|
Debug.Log("拖动");
|
|
Debug.Log("拖动");
|
|
ControllerObjectPos();
|
|
ControllerObjectPos();
|
|
@@ -293,7 +314,7 @@ namespace GFGGame
|
|
|
|
|
|
private void OnTouchBtnSizeBegin(EventContext context)
|
|
private void OnTouchBtnSizeBegin(EventContext context)
|
|
{
|
|
{
|
|
- isTouchUI = true;
|
|
|
|
|
|
+ // isTouchUI = true;
|
|
|
|
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
@@ -338,7 +359,7 @@ namespace GFGGame
|
|
}
|
|
}
|
|
private void OnTouchBtnSizeEnd(EventContext context)
|
|
private void OnTouchBtnSizeEnd(EventContext context)
|
|
{
|
|
{
|
|
- isTouchUI = false;
|
|
|
|
|
|
+ // isTouchUI = false;
|
|
lastPos = Vector2.zero;
|
|
lastPos = Vector2.zero;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -347,17 +368,18 @@ namespace GFGGame
|
|
//双指缩放
|
|
//双指缩放
|
|
private void OnPinch(EventContext context)
|
|
private void OnPinch(EventContext context)
|
|
{
|
|
{
|
|
- if (hitParentGameObj == null) return;
|
|
|
|
- if (hitParentGameObj.name == "BgRes") return;//背景不可以缩放、旋转
|
|
|
|
|
|
+ GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
+ // if (hitParentGameObj == null) return;
|
|
|
|
+ if (gameObject.name == "BgRes") return;//背景不可以缩放、旋转
|
|
isTwoTouchPoint = true;
|
|
isTwoTouchPoint = true;
|
|
|
|
|
|
- GTween.Kill(hitParentGameObj);
|
|
|
|
|
|
+ GTween.Kill(gameObject);
|
|
|
|
|
|
PinchGesture gesture = (PinchGesture)context.sender;
|
|
PinchGesture gesture = (PinchGesture)context.sender;
|
|
- float newValue = Mathf.Clamp(hitParentGameObj.transform.localScale.x + gesture.delta, 0.3f, 2);
|
|
|
|
|
|
+ float newValue = Mathf.Clamp(gameObject.transform.localScale.x + gesture.delta, 0.3f, 2);
|
|
Debug.Log("双指缩放:" + newValue);
|
|
Debug.Log("双指缩放:" + newValue);
|
|
|
|
|
|
- ControllerScale(newValue, hitParentGameObj);
|
|
|
|
|
|
+ ControllerScale(newValue, gameObject);
|
|
}
|
|
}
|
|
|
|
|
|
private void ControllerScale(float value, GameObject gameObject)
|
|
private void ControllerScale(float value, GameObject gameObject)
|
|
@@ -371,17 +393,18 @@ namespace GFGGame
|
|
|
|
|
|
private void OnRotate(EventContext context)
|
|
private void OnRotate(EventContext context)
|
|
{
|
|
{
|
|
- if (hitParentGameObj == null) return;
|
|
|
|
- if (hitParentGameObj.name == "BgRes") return;//背景不可以缩放、旋转
|
|
|
|
|
|
+ GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
+ // if (hitParentGameObj == null) return;
|
|
|
|
+ if (gameObject.name == "BgRes") return;//背景不可以缩放、旋转
|
|
isTwoTouchPoint = true;
|
|
isTwoTouchPoint = true;
|
|
|
|
|
|
|
|
|
|
- GTween.Kill(hitParentGameObj.transform);
|
|
|
|
|
|
+ GTween.Kill(gameObject.transform);
|
|
|
|
|
|
RotationGesture gesture = (RotationGesture)context.sender;
|
|
RotationGesture gesture = (RotationGesture)context.sender;
|
|
Debug.Log("双指旋转:" + gesture.delta);
|
|
Debug.Log("双指旋转:" + gesture.delta);
|
|
|
|
|
|
- ControllerRotate(gesture.delta, hitParentGameObj);
|
|
|
|
|
|
+ ControllerRotate(gesture.delta, gameObject);
|
|
}
|
|
}
|
|
private void ControllerRotate(float value, GameObject gameObject)
|
|
private void ControllerRotate(float value, GameObject gameObject)
|
|
{
|
|
{
|
|
@@ -389,23 +412,100 @@ namespace GFGGame
|
|
_ui.m_comSelectBox.target.rotation += value;
|
|
_ui.m_comSelectBox.target.rotation += value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private void UpdateBg(ItemCfg itemCfg)
|
|
|
|
+ {
|
|
|
|
+ Transform tf = _sceneObject.transform.Find("Bg/BgRes");
|
|
|
|
+ string resPath = ResPathUtil.GetDressUpPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
|
|
|
|
+ SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, itemCfg == null ? equipDataCache.bgId : itemCfg.id, tf, resPath);
|
|
|
|
+ SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
|
+ spr.sortingOrder = ItemTypeCfgArray.Instance.GetCfg(ConstDressUpItemType.BEI_JING).defaultLayer;
|
|
|
|
+ SceneController.PhotographAddCollider(tf.gameObject);
|
|
|
|
+ }
|
|
|
|
+ private void UpdateNpc(ItemCfg itemCfg)
|
|
|
|
+ {
|
|
|
|
+ maxLayer++;
|
|
|
|
+ Transform tf = _sceneObject.transform.Find("Scene/Npc/NpcRes");
|
|
|
|
+ string resPath = ResPathUtil.GetNpcPicFPath(itemCfg.res);
|
|
|
|
+ SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, itemCfg.id, tf, resPath);
|
|
|
|
+ SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
|
+ spr.sortingOrder = maxLayer;
|
|
|
|
+ SceneController.PhotographAddCollider(tf.gameObject);
|
|
|
|
+ }
|
|
|
|
+ private void UpdateBorder(ItemCfg itemCfg)
|
|
|
|
+ {
|
|
|
|
+ Transform tf = _sceneObject.transform.Find("Border/BorderRes");
|
|
|
|
+ string resPath = ResPathUtil.GetPhotographFPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
|
|
|
|
+ SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, itemCfg.id, tf, resPath);
|
|
|
|
+ SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
|
+ spr.sortingOrder = 1000;
|
|
|
|
+ // float width = UnityEngine.Screen.width / spr.bounds.size.x;
|
|
|
|
+ // float height = UnityEngine.Screen.height / spr.bounds.size.y;
|
|
|
|
+ // spr.size = new Vector2(spr.size.x * width, spr.size.y * height);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void UpdateScene(ItemCfg itemCfg, bool isDefaultLayer, int layer)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ maxLayer = layer < maxLayer ? maxLayer : layer;
|
|
|
|
+ if (!isDefaultLayer)
|
|
|
|
+ {
|
|
|
|
+ maxLayer = layer + 1;
|
|
|
|
+ layer = maxLayer;
|
|
|
|
+ }
|
|
|
|
+ int index = 0;
|
|
|
|
+
|
|
|
|
+ GameObject parentGameObj;
|
|
|
|
+ if (itemCfg.resLayer1 > 0)
|
|
|
|
+ {
|
|
|
|
+ if (!isDefaultLayer)
|
|
|
|
+ {
|
|
|
|
+ PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemCfg.id, out _equipSceneData);
|
|
|
|
+ }
|
|
|
|
+ index = _equipSceneData[itemCfg.id].Count - 1;
|
|
|
|
+
|
|
|
|
+ parentGameObj = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, index, 0));
|
|
|
|
+ SceneController.AddItemToScene(_sceneObject, parentGameObj, itemCfg.id, itemCfg.resLayer1);
|
|
|
|
+ SpriteRenderer spr = parentGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
|
|
|
+ spr.sortingOrder = layer;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (itemCfg.resLayer2 > 0)
|
|
|
|
+ {
|
|
|
|
+ if (!isDefaultLayer)
|
|
|
|
+ {
|
|
|
|
+ PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemCfg.id, out _equipSceneData);
|
|
|
|
+ }
|
|
|
|
+ index = _equipSceneData[itemCfg.id].Count - 1;
|
|
|
|
+ parentGameObj = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, index, 1));
|
|
|
|
+ SceneController.AddItemToScene(_sceneObject, parentGameObj, itemCfg.id, itemCfg.resLayer2);
|
|
|
|
+ SpriteRenderer spr = parentGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
|
|
|
+ spr.sortingOrder = layer;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
//主角
|
|
//主角
|
|
private void UpdateBody()
|
|
private void UpdateBody()
|
|
{
|
|
{
|
|
|
|
|
|
SceneController.UpdatePhotographBody(_equipRoleData.ToArray(), _sceneObject, false, null, false, bodyParent);
|
|
SceneController.UpdatePhotographBody(_equipRoleData.ToArray(), _sceneObject, false, null, false, bodyParent);
|
|
|
|
+ int layer = _sceneObject.transform.Find("Scene/Role/Body").GetComponent<SpriteRenderer>().sortingOrder;
|
|
|
|
+ maxLayer = layer < maxLayer ? maxLayer : layer;
|
|
}
|
|
}
|
|
- //场景道具
|
|
|
|
- private void UpdateScene()
|
|
|
|
|
|
+ //添加初始场景道具
|
|
|
|
+ private void AddEquipTiemToScene()
|
|
{
|
|
{
|
|
ICollection keys = _equipSceneData.Keys;
|
|
ICollection keys = _equipSceneData.Keys;
|
|
foreach (int key in keys)
|
|
foreach (int key in keys)
|
|
{
|
|
{
|
|
for (int i = 0; i < _equipSceneData[key].Count; i++)
|
|
for (int i = 0; i < _equipSceneData[key].Count; i++)
|
|
{
|
|
{
|
|
- SceneController.AddItemToScene(_sceneObject, key, i);
|
|
|
|
|
|
+ // SceneController.AddItemToScene(_sceneObject, key, i);
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
- PhotographDataManager.Instance.GetMaxLayer(maxLayer, false, itemCfg, out maxLayer);
|
|
|
|
|
|
+ int defaultLayer = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).defaultLayer;
|
|
|
|
+ UpdateScene(itemCfg, true, defaultLayer);
|
|
|
|
+ // PhotographDataManager.Instance.GetMaxLayer(maxLayer, false, itemCfg, out maxLayer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -416,7 +516,15 @@ namespace GFGGame
|
|
{
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ private bool IsTouchUI
|
|
|
|
+ {
|
|
|
|
+ get
|
|
|
|
+ {
|
|
|
|
+ GObject obj = GRoot.inst.touchTarget;
|
|
|
|
|
|
|
|
+ return _ui.m_comSelectBox.m_btnSize.GetChild("icon").asLoader == obj || _ui.m_comSelectBox.m_btnDelete.GetChild("icon").asLoader == obj || _ui.m_comSelectBox.m_btnFlip.GetChild("icon").asLoader == obj || _ui.m_btnBack == obj || _ui.m_btnChoose.GetChild("icon").asLoader == obj || _ui.m_btnPhotograph.GetChild("icon").asLoader == obj;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
private void DisposeEquipData()
|
|
private void DisposeEquipData()
|
|
@@ -449,7 +557,7 @@ namespace GFGGame
|
|
}
|
|
}
|
|
private void OnTouchBtnFlipBegin()
|
|
private void OnTouchBtnFlipBegin()
|
|
{
|
|
{
|
|
- isTouchUI = true;
|
|
|
|
|
|
+ // isTouchUI = true;
|
|
Transform transform = (_ui.m_comSelectBox.target.data as GameObject).transform;
|
|
Transform transform = (_ui.m_comSelectBox.target.data as GameObject).transform;
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
{
|
|
@@ -458,12 +566,12 @@ namespace GFGGame
|
|
}
|
|
}
|
|
private void OnTouchBtnFlipEnd()
|
|
private void OnTouchBtnFlipEnd()
|
|
{
|
|
{
|
|
- isTouchUI = false;
|
|
|
|
|
|
+ // isTouchUI = false;
|
|
}
|
|
}
|
|
|
|
|
|
private void OnTouchBtnDeleteBegin()
|
|
private void OnTouchBtnDeleteBegin()
|
|
{
|
|
{
|
|
- isTouchUI = true;
|
|
|
|
|
|
+ // isTouchUI = true;
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
if (gameObject.transform.gameObject == bodyParent)
|
|
if (gameObject.transform.gameObject == bodyParent)
|
|
{
|
|
{
|
|
@@ -486,7 +594,7 @@ namespace GFGGame
|
|
}
|
|
}
|
|
private void OnTouchBtnDeleteEnd()
|
|
private void OnTouchBtnDeleteEnd()
|
|
{
|
|
{
|
|
- isTouchUI = false;
|
|
|
|
|
|
+ // isTouchUI = false;
|
|
}
|
|
}
|
|
private void OnClickBtnPhotograph()
|
|
private void OnClickBtnPhotograph()
|
|
{
|
|
{
|