|
@@ -47,7 +47,8 @@ namespace GFGGame
|
|
|
private PinchGesture pinchGesture;
|
|
|
private RotationGesture rotationGesture;
|
|
|
|
|
|
- private bool isTouchUI = false;
|
|
|
+ private bool isTouchUI = false;//点击在m_comSelectBox按钮上
|
|
|
+ private bool isTouchTwoPoint = false;//双指操作
|
|
|
private int maxLayer = int.MinValue;//最上层的层级数
|
|
|
protected override void OnInit()
|
|
|
{
|
|
@@ -68,19 +69,19 @@ namespace GFGGame
|
|
|
|
|
|
_scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("ScenePhotograph"));
|
|
|
|
|
|
- _ui.target.onTouchBegin.Add(OnClickUIBegin);
|
|
|
- _ui.target.onTouchMove.Add(OnClickUIMove);
|
|
|
- _ui.target.onTouchEnd.Add(OnClickUIEnd);
|
|
|
+ _ui.target.onTouchBegin.Add(OnTouchUIBegin);
|
|
|
+ _ui.target.onTouchMove.Add(OnTouchUIMove);
|
|
|
+ _ui.target.onTouchEnd.Add(OnTouchUIEnd);
|
|
|
|
|
|
- _ui.m_comSelectBox.m_btnSize.onTouchBegin.Add(OnClickBtnSizeBegin);
|
|
|
- _ui.m_comSelectBox.m_btnSize.onTouchMove.Add(OnClickBtnSizeMove);
|
|
|
- _ui.m_comSelectBox.m_btnSize.onTouchEnd.Add(OnClickBtnSizeEnd);
|
|
|
+ _ui.m_comSelectBox.m_btnSize.onTouchBegin.Add(OnTouchBtnSizeBegin);
|
|
|
+ _ui.m_comSelectBox.m_btnSize.onTouchMove.Add(OnTouchBtnSizeMove);
|
|
|
+ _ui.m_comSelectBox.m_btnSize.onTouchEnd.Add(OnTouchBtnSizeEnd);
|
|
|
|
|
|
- _ui.m_comSelectBox.m_btnFlip.onTouchBegin.Add(OnClickBtnFlip);
|
|
|
- _ui.m_comSelectBox.m_btnFlip.onTouchEnd.Add(OnClickBtnFlipEnd);
|
|
|
+ _ui.m_comSelectBox.m_btnFlip.onTouchBegin.Add(OnTouchBtnFlipBegin);
|
|
|
+ _ui.m_comSelectBox.m_btnFlip.onTouchEnd.Add(OnTouchBtnFlipEnd);
|
|
|
|
|
|
- _ui.m_comSelectBox.m_btnDelete.onTouchBegin.Add(OnClickBtnDelete);
|
|
|
- _ui.m_comSelectBox.m_btnDelete.onTouchEnd.Add(OnClickBtnDeleteEnd);
|
|
|
+ _ui.m_comSelectBox.m_btnDelete.onTouchBegin.Add(OnTouchBtnDeleteBegin);
|
|
|
+ _ui.m_comSelectBox.m_btnDelete.onTouchEnd.Add(OnTouchBtnDeleteEnd);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -109,13 +110,13 @@ namespace GFGGame
|
|
|
_ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex = 0;
|
|
|
OnClickBtnChoose();
|
|
|
RefreshList(EnumPhotographType.BG);
|
|
|
- UpdateEquipData();
|
|
|
+ DisposeEquipData();
|
|
|
+
|
|
|
+ SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, EnumPhotographType.BG, equipDataCache.bgId, maxLayer, out maxLayer);
|
|
|
|
|
|
- UpdateBgOrNpcOrBorder(EnumPhotographType.BG, equipDataCache.bgId);
|
|
|
UpdateBody();
|
|
|
UpdateScene();
|
|
|
|
|
|
- // Timers.inst.Add(0.001f, 0, OnTimerListener);
|
|
|
}
|
|
|
/************************************************************UI界面*********************************************************/
|
|
|
private void OnContorllerChanged(EventContext context)
|
|
@@ -166,16 +167,12 @@ namespace GFGGame
|
|
|
case EnumPhotographType.BG:
|
|
|
case EnumPhotographType.BORDER:
|
|
|
case EnumPhotographType.NPC:
|
|
|
- UpdateBgOrNpcOrBorder(type, itemID);
|
|
|
+ SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, type, itemID, maxLayer, out maxLayer);
|
|
|
break;
|
|
|
|
|
|
case EnumPhotographType.SCENE:
|
|
|
- if (!_equipSceneData.ContainsKey(itemID))
|
|
|
- {
|
|
|
- _equipSceneData.Add(itemID, new List<int>());
|
|
|
- }
|
|
|
- _equipSceneData[itemID].Add(itemID);
|
|
|
|
|
|
+ PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemID, out _equipSceneData);
|
|
|
SceneController.AddScene(_sceneObject, itemID, _equipSceneData[itemID].Count - 1, maxLayer + 1);
|
|
|
maxLayer++;
|
|
|
break;
|
|
@@ -186,30 +183,32 @@ namespace GFGGame
|
|
|
}
|
|
|
/************************** **********************************场景*********************************************************/
|
|
|
|
|
|
- private void OnClickUIBegin(EventContext context)
|
|
|
+ private void OnTouchUIBegin(EventContext context)
|
|
|
{
|
|
|
- context.CaptureTouch();
|
|
|
if (_ui.m_ComSelectRes.target.visible == true) return;
|
|
|
- if (context.inputEvent.touchId != 0) return;
|
|
|
+ if (Stage.inst.touchCount > 1) return;//只监听1根手指
|
|
|
if (isTouchUI) return;
|
|
|
+ context.CaptureTouch();
|
|
|
+
|
|
|
RaycastHit2D[] hit2Ds = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
|
|
if (hit2Ds.Length > 0)
|
|
|
{
|
|
|
maxLayer++;
|
|
|
hitParentGameObj = SceneController.GetFirstHitObj(hit2Ds);
|
|
|
+
|
|
|
+ _ui.m_comSelectBox.m_btnDelete.visible = true;
|
|
|
+ if (hitParentGameObj.name == "Body")//主角不可删除
|
|
|
+ {
|
|
|
+ _ui.m_comSelectBox.m_btnDelete.visible = false;
|
|
|
+ }
|
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
|
- if (hitParentGameObj.name != "BgRes")
|
|
|
+ if (hitParentGameObj.name != "BgRes")//背景不可改动层级
|
|
|
{
|
|
|
hitParentGameObj.GetComponent<SpriteRenderer>().sortingOrder = maxLayer;
|
|
|
hitParentGameObj = hitParentGameObj.transform.parent.gameObject;
|
|
|
_ui.m_comSelectBox.target.visible = true;
|
|
|
|
|
|
}
|
|
|
- _ui.m_comSelectBox.m_btnDelete.visible = true;
|
|
|
- if (hitParentGameObj == bodyParent)
|
|
|
- {
|
|
|
- _ui.m_comSelectBox.m_btnDelete.visible = false;
|
|
|
- }
|
|
|
|
|
|
distance = Input.mousePosition - Camera.main.WorldToScreenPoint(hitParentGameObj.transform.position);
|
|
|
|
|
@@ -222,29 +221,29 @@ namespace GFGGame
|
|
|
}
|
|
|
_ui.m_comSelectBox.target.data = hitParentGameObj;
|
|
|
|
|
|
- ControllerSelectBoxPos(hitParentGameObj);
|
|
|
-
|
|
|
+ ControllerSelectBoxPos();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void OnClickUIMove(EventContext context)
|
|
|
+ private void OnTouchUIMove(EventContext context)
|
|
|
{
|
|
|
if (hitParentGameObj == null) return;//未选中任何物体
|
|
|
if (Stage.inst.touchCount > 1) return;//只监听1根手指
|
|
|
if (isTouchUI) return;
|
|
|
|
|
|
Debug.Log("拖动");
|
|
|
- ControllerObjectPos(hitParentGameObj);
|
|
|
- ControllerSelectBoxPos(hitParentGameObj);
|
|
|
+ ControllerObjectPos();
|
|
|
+ ControllerSelectBoxPos();
|
|
|
|
|
|
}
|
|
|
- private void OnClickUIEnd(EventContext context)
|
|
|
+ private void OnTouchUIEnd(EventContext context)
|
|
|
{
|
|
|
+ if (Stage.inst.touchCount > 1) return;//只监听1根手指
|
|
|
if (context.inputEvent.touchId == 0) hitParentGameObj = null;
|
|
|
}
|
|
|
|
|
|
//选中物体的位置
|
|
|
- private void ControllerObjectPos(GameObject hitParentGameObj)
|
|
|
+ private void ControllerObjectPos()
|
|
|
{
|
|
|
hitParentGameObj.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition - distance);
|
|
|
if (hitParentGameObj.name == "BgRes")
|
|
@@ -274,7 +273,7 @@ namespace GFGGame
|
|
|
}
|
|
|
|
|
|
//选中框的位置
|
|
|
- private void ControllerSelectBoxPos(GameObject hitParentGameObj)
|
|
|
+ private void ControllerSelectBoxPos()
|
|
|
{
|
|
|
SceneController.SetGameObjectCenter(hitParentGameObj);
|
|
|
|
|
@@ -288,18 +287,16 @@ namespace GFGGame
|
|
|
|
|
|
|
|
|
|
|
|
- private void OnClickBtnSizeBegin(EventContext context)
|
|
|
+ private void OnTouchBtnSizeBegin(EventContext context)
|
|
|
{
|
|
|
isTouchUI = true;
|
|
|
|
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
|
|
|
|
- Vector2 screenPos = this.viewCom.GlobalToLocal(_ui.m_comSelectBox.m_btnSize.LocalToGlobal(Vector2.zero));
|
|
|
- Vector2 pt = new Vector2(screenPos.x, screenPos.y);
|
|
|
Vector2 pt1 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
|
|
|
Vector2 pt2 = new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y);
|
|
|
- Debug.Log("pt1" + pt1 + " pt2:" + pt2 + " pt:" + pt);
|
|
|
+ Debug.Log("pt1" + pt1 + " pt2:" + pt2);
|
|
|
|
|
|
if (!_equipDistance.ContainsKey(gameObject))
|
|
|
{
|
|
@@ -310,7 +307,7 @@ namespace GFGGame
|
|
|
Debug.Log("_startDistance:" + _startDistance);
|
|
|
|
|
|
}
|
|
|
- private void OnClickBtnSizeMove(EventContext context)
|
|
|
+ private void OnTouchBtnSizeMove(EventContext context)
|
|
|
{
|
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
if (gameObject == null) return;
|
|
@@ -330,12 +327,11 @@ namespace GFGGame
|
|
|
Debug.Log("dist:" + dist);
|
|
|
|
|
|
float ss = dist / _startDistance;
|
|
|
- // float local = _equipDistance[gameObject] * gameObject.transform.localScale.x * ss / _equipDistance[gameObject];
|
|
|
float newValue = Mathf.Clamp(ss, 0.1f, 2);
|
|
|
ControllerScale(newValue, gameObject);
|
|
|
|
|
|
}
|
|
|
- private void OnClickBtnSizeEnd(EventContext context)
|
|
|
+ private void OnTouchBtnSizeEnd(EventContext context)
|
|
|
{
|
|
|
isTouchUI = false;
|
|
|
lastPos = Vector2.zero;
|
|
@@ -347,6 +343,7 @@ namespace GFGGame
|
|
|
private void OnPinch(EventContext context)
|
|
|
{
|
|
|
if (hitParentGameObj == null) return;
|
|
|
+ isTouchTwoPoint = true;
|
|
|
|
|
|
GTween.Kill(hitParentGameObj);
|
|
|
|
|
@@ -366,9 +363,12 @@ namespace GFGGame
|
|
|
_ui.m_comSelectBox.target.SetSize(size.x, size.y);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void OnRotate(EventContext context)
|
|
|
{
|
|
|
if (hitParentGameObj == null) return;
|
|
|
+ isTouchTwoPoint = true;
|
|
|
+
|
|
|
GTween.Kill(hitParentGameObj.transform);
|
|
|
|
|
|
RotationGesture gesture = (RotationGesture)context.sender;
|
|
@@ -380,28 +380,22 @@ namespace GFGGame
|
|
|
gameObject.transform.Rotate(Vector3.forward, -value, Space.World);
|
|
|
_ui.m_comSelectBox.target.rotation += value;
|
|
|
}
|
|
|
- //背景
|
|
|
- private void UpdateBgOrNpcOrBorder(EnumPhotographType type, int itemId)
|
|
|
- {
|
|
|
-
|
|
|
- SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, type, itemId, maxLayer, out maxLayer);
|
|
|
- }
|
|
|
|
|
|
//主角
|
|
|
private void UpdateBody()
|
|
|
{
|
|
|
|
|
|
- // int[] equipDatas = equipDataCache.equipDatas;
|
|
|
- SceneController.UpdateRole(_equipRoleData.ToArray(), _sceneObject, false, null, false, bodyParent);
|
|
|
- if (equipDataCache.IsSuitPic && equipDataCache.suitId > 0)
|
|
|
- {
|
|
|
- SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(equipDataCache.suitId);
|
|
|
- DressUpUtil.UpdateBody(suitCfg.picRes, _sceneObject, false, null, false, bodyParent);
|
|
|
- }
|
|
|
- GameObject gameObject = _sceneObject.transform.Find("Scene/Role/Body").gameObject;
|
|
|
+ // SceneController.UpdateRole(_equipRoleData.ToArray(), _sceneObject, false, null, false, bodyParent);
|
|
|
+ // if (equipDataCache.IsSuitPic && equipDataCache.suitId > 0)
|
|
|
+ // {
|
|
|
+ // SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(equipDataCache.suitId);
|
|
|
+ // DressUpUtil.UpdateBody(suitCfg.picRes, _sceneObject, false, null, false, bodyParent);
|
|
|
+ // }
|
|
|
+ // GameObject gameObject = _sceneObject.transform.Find("Scene/Role/Body").gameObject;
|
|
|
|
|
|
- SceneController.PhotographAddCollider(gameObject);
|
|
|
+ // SceneController.PhotographAddCollider(gameObject);
|
|
|
|
|
|
+ SceneController.UpdatePhotographBody(_equipRoleData.ToArray(), _sceneObject, false, null, false, bodyParent);
|
|
|
}
|
|
|
//场景道具
|
|
|
private void UpdateScene()
|
|
@@ -411,12 +405,9 @@ namespace GFGGame
|
|
|
{
|
|
|
for (int i = 0; i < _equipSceneData[key].Count; i++)
|
|
|
{
|
|
|
-
|
|
|
SceneController.AddScene(_sceneObject, key, i);
|
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
|
- if (itemCfg.resLayer1 > maxLayer) maxLayer = itemCfg.resLayer1;
|
|
|
- if (itemCfg.resLayer2 > maxLayer) maxLayer = itemCfg.resLayer2;
|
|
|
-
|
|
|
+ PhotographDataManager.Instance.GetMaxLayer(maxLayer, false, itemCfg, out maxLayer);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -430,18 +421,14 @@ namespace GFGGame
|
|
|
|
|
|
|
|
|
|
|
|
- private void UpdateEquipData()
|
|
|
+ private void DisposeEquipData()
|
|
|
{
|
|
|
for (int i = 0; i < equipDataCache.equipDatas.Length; i++)
|
|
|
{
|
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(equipDataCache.equipDatas[i]);
|
|
|
if (itemCfg.subType == ConstDressUpItemType.QIAN_JING || itemCfg.subType == ConstDressUpItemType.BEI_SHI || itemCfg.subType == ConstDressUpItemType.HUAN_JING)
|
|
|
{
|
|
|
- if (!_equipSceneData.ContainsKey(itemCfg.id))
|
|
|
- {
|
|
|
- _equipSceneData.Add(itemCfg.id, new List<int>());
|
|
|
- }
|
|
|
- _equipSceneData[itemCfg.id].Add(itemCfg.id);
|
|
|
+ PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemCfg.id, out _equipSceneData);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -462,7 +449,7 @@ namespace GFGGame
|
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
|
hitParentGameObj = null;
|
|
|
}
|
|
|
- private void OnClickBtnFlip()
|
|
|
+ private void OnTouchBtnFlipBegin()
|
|
|
{
|
|
|
isTouchUI = true;
|
|
|
Transform transform = (_ui.m_comSelectBox.target.data as GameObject).transform;
|
|
@@ -471,12 +458,12 @@ namespace GFGGame
|
|
|
transform.GetChild(i).Rotate(Vector3.up, 180, Space.World);
|
|
|
}
|
|
|
}
|
|
|
- private void OnClickBtnFlipEnd()
|
|
|
+ private void OnTouchBtnFlipEnd()
|
|
|
{
|
|
|
isTouchUI = false;
|
|
|
}
|
|
|
|
|
|
- private void OnClickBtnDelete()
|
|
|
+ private void OnTouchBtnDeleteBegin()
|
|
|
{
|
|
|
isTouchUI = true;
|
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
@@ -499,7 +486,7 @@ namespace GFGGame
|
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
|
|
|
|
}
|
|
|
- private void OnClickBtnDeleteEnd()
|
|
|
+ private void OnTouchBtnDeleteEnd()
|
|
|
{
|
|
|
isTouchUI = false;
|
|
|
}
|