|
@@ -30,26 +30,25 @@ namespace GFGGame
|
|
private List<int> _listData = null;//当前选择的资源数据
|
|
private List<int> _listData = null;//当前选择的资源数据
|
|
private List<int> _equipRoleData = new List<int>();//当前穿戴的角色数据
|
|
private List<int> _equipRoleData = new List<int>();//当前穿戴的角色数据
|
|
private Dictionary<int, List<int>> _equipSceneData = new Dictionary<int, List<int>>();//当前穿戴的场景数据
|
|
private Dictionary<int, List<int>> _equipSceneData = new Dictionary<int, List<int>>();//当前穿戴的场景数据
|
|
- private Dictionary<GameObject, Vector2> _equipPos = new Dictionary<GameObject, Vector2>();
|
|
|
|
- private Dictionary<GameObject, Vector2> _mousePos = new Dictionary<GameObject, Vector2>();
|
|
|
|
private Dictionary<GameObject, float> _equipDistance = new Dictionary<GameObject, float>();
|
|
private Dictionary<GameObject, float> _equipDistance = new Dictionary<GameObject, float>();
|
|
- // private GameObject hitGameObj;//当前选中的物体
|
|
|
|
- private GameObject hitParentGameObj;//当前选中的父物体(需要进行移动缩放旋转的物体)
|
|
|
|
- private GameObject memoryHitParentGameObj;//当前选中的父物体(需要进行移动缩放旋转的物体)
|
|
|
|
|
|
+
|
|
|
|
+ private GameObject hitGameObj;//当前选中的物体(单指拖动,双指缩放旋转)
|
|
|
|
+ private GameObject memoryHitGameObj;//当前选中的物体(单指缩放旋转)
|
|
|
|
|
|
private Vector3 distance = Vector3.zero;//点击位置和点击物体原点的距离,用于
|
|
private Vector3 distance = Vector3.zero;//点击位置和点击物体原点的距离,用于
|
|
private Vector2 lastPos = Vector2.zero;//上一次移动后从物体中心到鼠标位置的方向
|
|
private Vector2 lastPos = Vector2.zero;//上一次移动后从物体中心到鼠标位置的方向
|
|
|
|
|
|
- private float _startDistance;//从物体中心到缩放按钮的距离
|
|
|
|
|
|
+ // private float _startDistance;//从物体中心到缩放按钮的距离
|
|
|
|
|
|
|
|
|
|
private SwipeGesture swipeGesture;
|
|
private SwipeGesture swipeGesture;
|
|
private PinchGesture pinchGesture;
|
|
private PinchGesture pinchGesture;
|
|
private RotationGesture rotationGesture;
|
|
private RotationGesture rotationGesture;
|
|
|
|
|
|
- // 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()
|
|
{
|
|
{
|
|
base.OnInit();
|
|
base.OnInit();
|
|
@@ -116,7 +115,7 @@ namespace GFGGame
|
|
|
|
|
|
UpdateBg(ItemCfgArray.Instance.GetCfg(equipDataCache.bgId));
|
|
UpdateBg(ItemCfgArray.Instance.GetCfg(equipDataCache.bgId));
|
|
UpdateBody();
|
|
UpdateBody();
|
|
- AddEquipTiemToScene();
|
|
|
|
|
|
+ UpdateScene();
|
|
|
|
|
|
}
|
|
}
|
|
/************************************************************UI界面*********************************************************/
|
|
/************************************************************UI界面*********************************************************/
|
|
@@ -193,7 +192,7 @@ namespace GFGGame
|
|
|
|
|
|
case EnumPhotographType.SCENE:
|
|
case EnumPhotographType.SCENE:
|
|
|
|
|
|
- UpdateScene(itemCfg, false, maxLayer);
|
|
|
|
|
|
+ AddSceneItem(itemCfg, false, maxLayer);
|
|
break;
|
|
break;
|
|
case EnumPhotographType.EFFECT:
|
|
case EnumPhotographType.EFFECT:
|
|
|
|
|
|
@@ -205,51 +204,50 @@ namespace GFGGame
|
|
private void OnTouchUIBegin(EventContext context)
|
|
private void OnTouchUIBegin(EventContext context)
|
|
{
|
|
{
|
|
context.CaptureTouch();
|
|
context.CaptureTouch();
|
|
- if (_ui.m_ComSelectRes.target.visible == true) return;
|
|
|
|
- //两根手指点击屏幕||两根手指点过屏幕
|
|
|
|
- if (Stage.inst.touchCount > 1 && hitParentGameObj != null) return;//只监听一根手指
|
|
|
|
- if (IsTouchUI) return;
|
|
|
|
|
|
+
|
|
|
|
+ if (_ui.m_ComSelectRes.target.visible == true) return;//添加道具不监听场景点击
|
|
|
|
+ if (Stage.inst.touchCount > 1 && hitGameObj != null || Stage.inst.touchCount == 1 && context.inputEvent.touchId != 0) return;//两根手指&&两指不是同时按下||一根手指但属于中途换指
|
|
|
|
+ if (PhotographDataManager.Instance.IsTouchUI(this.viewCom)) 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)
|
|
{
|
|
{
|
|
maxLayer++;
|
|
maxLayer++;
|
|
- hitParentGameObj = SceneController.GetFirstHitObj(hit2Ds);
|
|
|
|
|
|
+ hitGameObj = SceneController.GetFirstHitObj(hit2Ds);
|
|
|
|
|
|
_ui.m_comSelectBox.m_btnDelete.visible = true;
|
|
_ui.m_comSelectBox.m_btnDelete.visible = true;
|
|
- if (hitParentGameObj.name == "Body")//主角不可删除
|
|
|
|
|
|
+ if (hitGameObj.name == "Body")//主角不可删除
|
|
{
|
|
{
|
|
_ui.m_comSelectBox.m_btnDelete.visible = false;
|
|
_ui.m_comSelectBox.m_btnDelete.visible = false;
|
|
}
|
|
}
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
- if (hitParentGameObj.name != "BgRes")//背景不可改动层级
|
|
|
|
|
|
+ if (hitGameObj.name != "BgRes")//背景不可改动层级
|
|
{
|
|
{
|
|
- hitParentGameObj.GetComponent<SpriteRenderer>().sortingOrder = maxLayer;
|
|
|
|
- hitParentGameObj = hitParentGameObj.transform.parent.gameObject;
|
|
|
|
|
|
+ hitGameObj.GetComponent<SpriteRenderer>().sortingOrder = maxLayer;
|
|
|
|
+ hitGameObj = hitGameObj.transform.parent.gameObject;
|
|
_ui.m_comSelectBox.target.visible = true;
|
|
_ui.m_comSelectBox.target.visible = true;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- distance = Input.mousePosition - Camera.main.WorldToScreenPoint(hitParentGameObj.transform.position);
|
|
|
|
|
|
+ distance = Input.mousePosition - Camera.main.WorldToScreenPoint(hitGameObj.transform.position);
|
|
|
|
|
|
|
|
|
|
- if (_ui.m_comSelectBox.target.data == null || _ui.m_comSelectBox.target.data as GameObject != hitParentGameObj)
|
|
|
|
- {
|
|
|
|
- lastPos = Vector2.zero;
|
|
|
|
- _ui.m_comSelectBox.target.rotation = -hitParentGameObj.transform.eulerAngles.z;
|
|
|
|
- _ui.m_comSelectBox.target.size = SceneController.GetGameObjectSize(hitParentGameObj);
|
|
|
|
- }
|
|
|
|
- _ui.m_comSelectBox.target.data = hitParentGameObj;
|
|
|
|
|
|
+ // if (memoryHitParentGameObj == null || memoryHitParentGameObj as GameObject != hitParentGameObj)
|
|
|
|
+ // {
|
|
|
|
+ lastPos = Vector2.zero;
|
|
|
|
+ _ui.m_comSelectBox.target.rotation = -hitGameObj.transform.eulerAngles.z;
|
|
|
|
+ _ui.m_comSelectBox.target.size = SceneController.GetGameObjectSize(hitGameObj);
|
|
|
|
+ // }
|
|
|
|
+ memoryHitGameObj = hitGameObj;
|
|
|
|
|
|
ControllerSelectBoxPos();
|
|
ControllerSelectBoxPos();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
private void OnTouchUIMove(EventContext context)
|
|
private void OnTouchUIMove(EventContext context)
|
|
{
|
|
{
|
|
- if (hitParentGameObj == null) return;//未选中任何物体
|
|
|
|
- if (Stage.inst.touchCount > 1 || isTwoTouchPoint) return; //只监听1根手指
|
|
|
|
- if (IsTouchUI) return;
|
|
|
|
|
|
+ if (hitGameObj == null) return;//未选中任何物体
|
|
|
|
+ if (Stage.inst.touchCount > 1) return; //只监听1根手指
|
|
|
|
+ if (PhotographDataManager.Instance.IsTouchUI(this.viewCom)) return;
|
|
|
|
|
|
Debug.Log("拖动");
|
|
Debug.Log("拖动");
|
|
ControllerObjectPos();
|
|
ControllerObjectPos();
|
|
@@ -259,106 +257,97 @@ namespace GFGGame
|
|
private void OnTouchUIEnd(EventContext context)
|
|
private void OnTouchUIEnd(EventContext context)
|
|
{
|
|
{
|
|
if (Stage.inst.touchCount > 1 || context.inputEvent.touchId != 0) return; //只监听1根手指
|
|
if (Stage.inst.touchCount > 1 || context.inputEvent.touchId != 0) return; //只监听1根手指
|
|
- hitParentGameObj = null;
|
|
|
|
- if (Stage.inst.touchCount == 0)
|
|
|
|
- {
|
|
|
|
- isTwoTouchPoint = false;
|
|
|
|
- }
|
|
|
|
|
|
+ hitGameObj = null;
|
|
|
|
+ // if (Stage.inst.touchCount == 0)
|
|
|
|
+ // {
|
|
|
|
+ // isTwoTouchPoint = false;
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
//选中物体的位置
|
|
//选中物体的位置
|
|
private void ControllerObjectPos()
|
|
private void ControllerObjectPos()
|
|
{
|
|
{
|
|
- hitParentGameObj.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition - distance);
|
|
|
|
- if (hitParentGameObj.name == "BgRes")
|
|
|
|
|
|
+ hitGameObj.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition - distance);
|
|
|
|
+ if (hitGameObj.name == "BgRes")
|
|
{
|
|
{
|
|
- Vector2 size = hitParentGameObj.GetComponent<SpriteRenderer>().size;
|
|
|
|
|
|
+ Vector2 size = hitGameObj.GetComponent<SpriteRenderer>().size;
|
|
Vector2 uiSize = _ui.target.size;
|
|
Vector2 uiSize = _ui.target.size;
|
|
float deviationWidth = (size.x - uiSize.x / 100) / 2;
|
|
float deviationWidth = (size.x - uiSize.x / 100) / 2;
|
|
float deviationHeigh = (size.y - uiSize.y / 100) / 2;
|
|
float deviationHeigh = (size.y - uiSize.y / 100) / 2;
|
|
- Vector2 pos = hitParentGameObj.transform.position;
|
|
|
|
|
|
+ Vector2 pos = hitGameObj.transform.position;
|
|
if (pos.x <= -deviationWidth)
|
|
if (pos.x <= -deviationWidth)
|
|
{
|
|
{
|
|
- hitParentGameObj.transform.position = new Vector2(-deviationWidth, hitParentGameObj.transform.position.y);
|
|
|
|
|
|
+ hitGameObj.transform.position = new Vector2(-deviationWidth, hitGameObj.transform.position.y);
|
|
}
|
|
}
|
|
if (pos.x >= deviationWidth)
|
|
if (pos.x >= deviationWidth)
|
|
{
|
|
{
|
|
- hitParentGameObj.transform.position = new Vector2(deviationWidth, hitParentGameObj.transform.position.y);
|
|
|
|
|
|
+ hitGameObj.transform.position = new Vector2(deviationWidth, hitGameObj.transform.position.y);
|
|
}
|
|
}
|
|
if (pos.y <= -deviationHeigh)
|
|
if (pos.y <= -deviationHeigh)
|
|
{
|
|
{
|
|
- hitParentGameObj.transform.position = new Vector2(hitParentGameObj.transform.position.x, -deviationHeigh);
|
|
|
|
|
|
+ hitGameObj.transform.position = new Vector2(hitGameObj.transform.position.x, -deviationHeigh);
|
|
}
|
|
}
|
|
if (pos.y >= deviationHeigh)
|
|
if (pos.y >= deviationHeigh)
|
|
{
|
|
{
|
|
- hitParentGameObj.transform.position = new Vector2(hitParentGameObj.transform.position.x, deviationHeigh);
|
|
|
|
|
|
+ hitGameObj.transform.position = new Vector2(hitGameObj.transform.position.x, deviationHeigh);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
//选中框的位置
|
|
//选中框的位置
|
|
private void ControllerSelectBoxPos()
|
|
private void ControllerSelectBoxPos()
|
|
{
|
|
{
|
|
- SceneController.SetGameObjectCenter(hitParentGameObj);
|
|
|
|
-
|
|
|
|
- //位置:角色、道具、npc全用对应父物体的位置
|
|
|
|
- Vector2 objScreenPos = Camera.main.WorldToScreenPoint(hitParentGameObj.transform.position);
|
|
|
|
|
|
+ // SceneController.SetGameObjectCenter(hitGameObj);
|
|
|
|
+ Vector2 objScreenPos = Camera.main.WorldToScreenPoint(hitGameObj.transform.position);
|
|
Vector2 localPos = this.viewCom.GlobalToLocal(new Vector2(objScreenPos.x, (Screen.height - objScreenPos.y)));
|
|
Vector2 localPos = this.viewCom.GlobalToLocal(new Vector2(objScreenPos.x, (Screen.height - objScreenPos.y)));
|
|
-
|
|
|
|
- _ui.m_comSelectBox.target.position = localPos;//(localPos.x, localPos.y);
|
|
|
|
-
|
|
|
|
|
|
+ _ui.m_comSelectBox.target.position = localPos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnTouchBtnSizeBegin(EventContext context)
|
|
private void OnTouchBtnSizeBegin(EventContext context)
|
|
{
|
|
{
|
|
- // isTouchUI = true;
|
|
|
|
|
|
|
|
- GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
|
|
+ // GameObject memoryHitParentGameObj = this.memoryHitParentGameObj as GameObject;
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
Vector2 screenPos = this.viewCom.GlobalToLocal(_ui.m_comSelectBox.m_btnSize.LocalToGlobal(Vector2.zero));
|
|
Vector2 screenPos = this.viewCom.GlobalToLocal(_ui.m_comSelectBox.m_btnSize.LocalToGlobal(Vector2.zero));
|
|
Vector2 pt = new Vector2(screenPos.x, screenPos.y);
|
|
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);
|
|
Vector2 pt2 = new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y);
|
|
- Debug.Log("pt1" + pt1 + " pt2:" + pt2);
|
|
|
|
|
|
|
|
- if (!_equipDistance.ContainsKey(gameObject))
|
|
|
|
|
|
+ if (!_equipDistance.ContainsKey(memoryHitGameObj))
|
|
{
|
|
{
|
|
- float distance = Vector2.Distance(pt, pt2) / gameObject.transform.localScale.x;
|
|
|
|
- _equipDistance.Add(gameObject, distance);
|
|
|
|
|
|
+ float distance = Vector2.Distance(pt, pt2) / memoryHitGameObj.transform.localScale.x;
|
|
|
|
+ _equipDistance.Add(memoryHitGameObj, distance);
|
|
}
|
|
}
|
|
- _startDistance = _equipDistance[gameObject];
|
|
|
|
- Debug.Log("_startDistance:" + _startDistance);
|
|
|
|
|
|
+ // _startDistance = _equipDistance[memoryHitGameObj];
|
|
|
|
+ // Debug.Log("_startDistance:" + _startDistance);
|
|
|
|
|
|
}
|
|
}
|
|
private void OnTouchBtnSizeMove(EventContext context)
|
|
private void OnTouchBtnSizeMove(EventContext context)
|
|
{
|
|
{
|
|
- GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
- if (gameObject == null) return;
|
|
|
|
|
|
+ // GameObject memoryHitParentGameObj = this.memoryHitParentGameObj as GameObject;
|
|
|
|
+ if (memoryHitGameObj == null) return;
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
Vector2 pt1 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.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);
|
|
Vector2 pt2 = new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y);
|
|
Vector2 curPos = pt1 - pt2;
|
|
Vector2 curPos = pt1 - pt2;
|
|
- Debug.Log("pt1" + pt1 + " pt2:" + pt2 + " curPos:" + curPos + " lastPos:" + lastPos);
|
|
|
|
|
|
+
|
|
float angle = Vector3.Angle(lastPos, curPos); //求出两向量之间的夹角
|
|
float angle = Vector3.Angle(lastPos, curPos); //求出两向量之间的夹角
|
|
Vector3 normal = Vector3.Cross(lastPos, curPos);//叉乘求出法线向量
|
|
Vector3 normal = Vector3.Cross(lastPos, curPos);//叉乘求出法线向量
|
|
angle *= Mathf.Sign(Vector3.Dot(normal, Vector3.forward)); //Mathf.Sign()求符号,Vector3.Dot()求方向,求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向
|
|
angle *= Mathf.Sign(Vector3.Dot(normal, Vector3.forward)); //Mathf.Sign()求符号,Vector3.Dot()求方向,求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向
|
|
lastPos = curPos;
|
|
lastPos = curPos;
|
|
- ControllerRotate(angle, gameObject);
|
|
|
|
- Debug.Log("angle:" + angle);
|
|
|
|
|
|
+ ControllerRotate(angle, memoryHitGameObj);
|
|
|
|
|
|
- float dist = Vector2.Distance(pt1, pt2);
|
|
|
|
- Debug.Log("dist:" + dist);
|
|
|
|
|
|
|
|
- float ss = dist / _startDistance;
|
|
|
|
|
|
+ float dist = Vector2.Distance(pt1, pt2);
|
|
|
|
+ float ss = dist / _equipDistance[memoryHitGameObj];
|
|
float newValue = Mathf.Clamp(ss, 0.1f, 2);
|
|
float newValue = Mathf.Clamp(ss, 0.1f, 2);
|
|
- ControllerScale(newValue, gameObject);
|
|
|
|
|
|
+ ControllerScale(newValue, memoryHitGameObj);
|
|
|
|
|
|
}
|
|
}
|
|
private void OnTouchBtnSizeEnd(EventContext context)
|
|
private void OnTouchBtnSizeEnd(EventContext context)
|
|
{
|
|
{
|
|
- // isTouchUI = false;
|
|
|
|
lastPos = Vector2.zero;
|
|
lastPos = Vector2.zero;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -367,19 +356,32 @@ namespace GFGGame
|
|
//双指缩放
|
|
//双指缩放
|
|
private void OnPinch(EventContext context)
|
|
private void OnPinch(EventContext context)
|
|
{
|
|
{
|
|
- // GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
- if (hitParentGameObj == null) return;
|
|
|
|
- if (hitParentGameObj.name == "BgRes") return;//背景不可以缩放、旋转
|
|
|
|
- isTwoTouchPoint = true;
|
|
|
|
|
|
|
|
- GTween.Kill(hitParentGameObj);
|
|
|
|
|
|
+ if (hitGameObj == null) return;
|
|
|
|
+ if (hitGameObj.name == "BgRes") return;//背景不可以缩放、旋转
|
|
|
|
+ // isTwoTouchPoint = true;
|
|
|
|
|
|
|
|
+ GTween.Kill(hitGameObj);
|
|
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(hitGameObj.transform.localScale.x + gesture.delta, 0.3f, 2);
|
|
Debug.Log("双指缩放:" + newValue);
|
|
Debug.Log("双指缩放:" + newValue);
|
|
|
|
|
|
- ControllerScale(newValue, hitParentGameObj);
|
|
|
|
|
|
+ ControllerScale(newValue, hitGameObj);
|
|
}
|
|
}
|
|
|
|
+ private void OnRotate(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ Debug.Log("双指旋转hitGameObj:" + hitGameObj);
|
|
|
|
+ if (hitGameObj == null) return;
|
|
|
|
+ Debug.Log("双指旋转name:" + hitGameObj.name);
|
|
|
|
+ if (hitGameObj.name == "BgRes") return;//背景不可以缩放、旋转
|
|
|
|
+ // isTwoTouchPoint = true;
|
|
|
|
+
|
|
|
|
+ GTween.Kill(hitGameObj.transform);
|
|
|
|
+ RotationGesture gesture = (RotationGesture)context.sender;
|
|
|
|
+ Debug.Log("双指旋转:" + gesture.delta);
|
|
|
|
+ ControllerRotate(gesture.delta, hitGameObj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private void ControllerScale(float value, GameObject gameObject)
|
|
private void ControllerScale(float value, GameObject gameObject)
|
|
{
|
|
{
|
|
@@ -388,23 +390,6 @@ namespace GFGGame
|
|
Vector2 size = SceneController.GetGameObjectSize(gameObject);
|
|
Vector2 size = SceneController.GetGameObjectSize(gameObject);
|
|
_ui.m_comSelectBox.target.SetSize(size.x, size.y);
|
|
_ui.m_comSelectBox.target.SetSize(size.x, size.y);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- private void OnRotate(EventContext context)
|
|
|
|
- {
|
|
|
|
- // GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
- if (hitParentGameObj == null) return;
|
|
|
|
- if (hitParentGameObj.name == "BgRes") return;//背景不可以缩放、旋转
|
|
|
|
- isTwoTouchPoint = true;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- GTween.Kill(hitParentGameObj.transform);
|
|
|
|
-
|
|
|
|
- RotationGesture gesture = (RotationGesture)context.sender;
|
|
|
|
- Debug.Log("双指旋转:" + gesture.delta);
|
|
|
|
-
|
|
|
|
- ControllerRotate(gesture.delta, hitParentGameObj);
|
|
|
|
- }
|
|
|
|
private void ControllerRotate(float value, GameObject gameObject)
|
|
private void ControllerRotate(float value, GameObject gameObject)
|
|
{
|
|
{
|
|
gameObject.transform.Rotate(Vector3.forward, -value, Space.World);
|
|
gameObject.transform.Rotate(Vector3.forward, -value, Space.World);
|
|
@@ -421,6 +406,27 @@ namespace GFGGame
|
|
spr.sortingOrder = ItemTypeCfgArray.Instance.GetCfg(ConstDressUpItemType.BEI_JING).defaultLayer;
|
|
spr.sortingOrder = ItemTypeCfgArray.Instance.GetCfg(ConstDressUpItemType.BEI_JING).defaultLayer;
|
|
SceneController.PhotographAddCollider(tf.gameObject);
|
|
SceneController.PhotographAddCollider(tf.gameObject);
|
|
}
|
|
}
|
|
|
|
+ //主角
|
|
|
|
+ private void UpdateBody()
|
|
|
|
+ {
|
|
|
|
+ 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()
|
|
|
|
+ {
|
|
|
|
+ ICollection keys = _equipSceneData.Keys;
|
|
|
|
+ foreach (int key in keys)
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < _equipSceneData[key].Count; i++)
|
|
|
|
+ {
|
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
|
|
+ int defaultLayer = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).defaultLayer;
|
|
|
|
+ AddSceneItem(itemCfg, true, defaultLayer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
private void UpdateNpc(ItemCfg itemCfg)
|
|
private void UpdateNpc(ItemCfg itemCfg)
|
|
{
|
|
{
|
|
maxLayer++;
|
|
maxLayer++;
|
|
@@ -438,12 +444,14 @@ namespace GFGGame
|
|
SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, itemCfg.id, tf, resPath);
|
|
SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, itemCfg.id, tf, resPath);
|
|
SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
spr.sortingOrder = 1000;
|
|
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 UpdateEffect()
|
|
|
|
+ {
|
|
|
|
|
|
}
|
|
}
|
|
- private void UpdateScene(ItemCfg itemCfg, bool isDefaultLayer, int layer)
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void AddSceneItem(ItemCfg itemCfg, bool isDefaultLayer, int layer)
|
|
{
|
|
{
|
|
|
|
|
|
maxLayer = layer < maxLayer ? maxLayer : layer;
|
|
maxLayer = layer < maxLayer ? maxLayer : layer;
|
|
@@ -481,50 +489,10 @@ namespace GFGGame
|
|
SpriteRenderer spr = parentGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
|
SpriteRenderer spr = parentGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
|
spr.sortingOrder = layer;
|
|
spr.sortingOrder = layer;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
- //主角
|
|
|
|
- private void UpdateBody()
|
|
|
|
- {
|
|
|
|
|
|
|
|
- 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 AddEquipTiemToScene()
|
|
|
|
- {
|
|
|
|
- ICollection keys = _equipSceneData.Keys;
|
|
|
|
- foreach (int key in keys)
|
|
|
|
- {
|
|
|
|
- for (int i = 0; i < _equipSceneData[key].Count; i++)
|
|
|
|
- {
|
|
|
|
- // SceneController.AddItemToScene(_sceneObject, key, i);
|
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
|
|
- int defaultLayer = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).defaultLayer;
|
|
|
|
- UpdateScene(itemCfg, true, defaultLayer);
|
|
|
|
- // PhotographDataManager.Instance.GetMaxLayer(maxLayer, false, itemCfg, out maxLayer);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
- //滤镜效果
|
|
|
|
- private void UpdateEffect()
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- 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()
|
|
{
|
|
{
|
|
@@ -546,39 +514,29 @@ namespace GFGGame
|
|
private void OnClickBtnBg()
|
|
private void OnClickBtnBg()
|
|
{
|
|
{
|
|
_ui.m_ComSelectRes.target.visible = false;
|
|
_ui.m_ComSelectRes.target.visible = false;
|
|
-
|
|
|
|
}
|
|
}
|
|
- private void OnClickBtnChoose()
|
|
|
|
|
|
+ private void OnTouchBtnFlipBegin()//翻转
|
|
{
|
|
{
|
|
- _ui.m_ComSelectRes.target.visible = true;
|
|
|
|
- _ui.m_comSelectBox.target.visible = false;
|
|
|
|
- hitParentGameObj = null;
|
|
|
|
- }
|
|
|
|
- private void OnTouchBtnFlipBegin()
|
|
|
|
- {
|
|
|
|
- // isTouchUI = true;
|
|
|
|
- Transform transform = (_ui.m_comSelectBox.target.data as GameObject).transform;
|
|
|
|
|
|
+ Transform transform = memoryHitGameObj.transform;
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
{
|
|
- transform.GetChild(i).Rotate(Vector3.up, 180, Space.World);
|
|
|
|
|
|
+ transform.GetChild(i).Rotate(Vector3.up, 180, Space.Self);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private void OnTouchBtnFlipEnd()
|
|
private void OnTouchBtnFlipEnd()
|
|
{
|
|
{
|
|
- // isTouchUI = false;
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- private void OnTouchBtnDeleteBegin()
|
|
|
|
|
|
+ private void OnTouchBtnDeleteBegin()//删除
|
|
{
|
|
{
|
|
- // isTouchUI = true;
|
|
|
|
- GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
- if (gameObject.transform.gameObject == bodyParent)
|
|
|
|
|
|
+ if (memoryHitGameObj.transform.gameObject == bodyParent)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- else if (gameObject.transform.gameObject == npcParent)
|
|
|
|
|
|
+ else if (memoryHitGameObj.transform.gameObject == npcParent)
|
|
{
|
|
{
|
|
- SpriteRenderer spriteRenderer = gameObject.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
|
|
|
|
|
+ SpriteRenderer spriteRenderer = memoryHitGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
|
if (spriteRenderer != null)
|
|
if (spriteRenderer != null)
|
|
{
|
|
{
|
|
GameObject.Destroy(spriteRenderer);
|
|
GameObject.Destroy(spriteRenderer);
|
|
@@ -586,14 +544,21 @@ namespace GFGGame
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- GameObject.DestroyImmediate(gameObject);
|
|
|
|
|
|
+ GameObject.DestroyImmediate(memoryHitGameObj);
|
|
}
|
|
}
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
|
|
|
|
}
|
|
}
|
|
private void OnTouchBtnDeleteEnd()
|
|
private void OnTouchBtnDeleteEnd()
|
|
{
|
|
{
|
|
- // isTouchUI = false;
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void OnClickBtnChoose()
|
|
|
|
+ {
|
|
|
|
+ _ui.m_ComSelectRes.target.visible = true;
|
|
|
|
+ _ui.m_comSelectBox.target.visible = false;
|
|
|
|
+ hitGameObj = null;
|
|
|
|
+ memoryHitGameObj = null;
|
|
}
|
|
}
|
|
private void OnClickBtnPhotograph()
|
|
private void OnClickBtnPhotograph()
|
|
{
|
|
{
|
|
@@ -612,7 +577,6 @@ namespace GFGGame
|
|
|
|
|
|
ViewManager.Show<PhotographSaveView>(tex);
|
|
ViewManager.Show<PhotographSaveView>(tex);
|
|
_ui.target.visible = true;
|
|
_ui.target.visible = true;
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void OnClickBtnBack()
|
|
private void OnClickBtnBack()
|
|
@@ -632,7 +596,8 @@ namespace GFGGame
|
|
equipDataCache = null;
|
|
equipDataCache = null;
|
|
_equipRoleData.Clear();
|
|
_equipRoleData.Clear();
|
|
_equipSceneData.Clear();
|
|
_equipSceneData.Clear();
|
|
- hitParentGameObj = null;
|
|
|
|
|
|
+ hitGameObj = null;
|
|
|
|
+ memoryHitGameObj = null;
|
|
|
|
|
|
pinchGesture.onAction.Remove(OnPinch);
|
|
pinchGesture.onAction.Remove(OnPinch);
|
|
rotationGesture.onAction.Remove(OnRotate);
|
|
rotationGesture.onAction.Remove(OnRotate);
|