|
@@ -30,7 +30,9 @@ 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 GameObject hitGameObj;//当前选中的物体
|
|
// private GameObject hitGameObj;//当前选中的物体
|
|
private GameObject hitParentGameObj;//当前选中的父物体(需要进行移动缩放旋转的物体)
|
|
private GameObject hitParentGameObj;//当前选中的父物体(需要进行移动缩放旋转的物体)
|
|
private GameObject memoryHitParentGameObj;//当前选中的父物体(需要进行移动缩放旋转的物体)
|
|
private GameObject memoryHitParentGameObj;//当前选中的父物体(需要进行移动缩放旋转的物体)
|
|
@@ -44,6 +46,9 @@ namespace GFGGame
|
|
private SwipeGesture swipeGesture;
|
|
private SwipeGesture swipeGesture;
|
|
private PinchGesture pinchGesture;
|
|
private PinchGesture pinchGesture;
|
|
private RotationGesture rotationGesture;
|
|
private RotationGesture rotationGesture;
|
|
|
|
+
|
|
|
|
+ private bool isTouchUI = false;
|
|
|
|
+
|
|
protected override void OnInit()
|
|
protected override void OnInit()
|
|
{
|
|
{
|
|
base.OnInit();
|
|
base.OnInit();
|
|
@@ -56,6 +61,7 @@ namespace GFGGame
|
|
_ui.m_btnChoose.onClick.Add(OnClickBtnChoose);
|
|
_ui.m_btnChoose.onClick.Add(OnClickBtnChoose);
|
|
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
_ui.m_comSelectBox.m_btnDelete.onClick.Add(OnClickBtnDelete);
|
|
_ui.m_comSelectBox.m_btnDelete.onClick.Add(OnClickBtnDelete);
|
|
|
|
+ _ui.m_comSelectBox.m_btnFlip.onClick.Add(OnClickBtnFlip);
|
|
_ui.m_btnPhotograph.onClick.Add(OnClickBtnPhotograph);
|
|
_ui.m_btnPhotograph.onClick.Add(OnClickBtnPhotograph);
|
|
|
|
|
|
_ui.m_ComSelectRes.m_list.itemRenderer = RenderListItem;
|
|
_ui.m_ComSelectRes.m_list.itemRenderer = RenderListItem;
|
|
@@ -179,7 +185,7 @@ namespace GFGGame
|
|
context.CaptureTouch();
|
|
context.CaptureTouch();
|
|
if (_ui.m_ComSelectRes.target.visible == true) return;
|
|
if (_ui.m_ComSelectRes.target.visible == true) return;
|
|
if (context.inputEvent.touchId != 0) return;
|
|
if (context.inputEvent.touchId != 0) return;
|
|
-
|
|
|
|
|
|
+ if (isTouchUI) return;
|
|
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
|
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
|
if (hit.collider != null)
|
|
if (hit.collider != null)
|
|
{
|
|
{
|
|
@@ -187,6 +193,8 @@ namespace GFGGame
|
|
hitParentGameObj = hit.collider.name == "BgRes" ? hit.collider.gameObject : hit.collider.transform.parent.gameObject;
|
|
hitParentGameObj = hit.collider.name == "BgRes" ? hit.collider.gameObject : hit.collider.transform.parent.gameObject;
|
|
distance = Input.mousePosition - Camera.main.WorldToScreenPoint(hitParentGameObj.transform.position);
|
|
distance = Input.mousePosition - Camera.main.WorldToScreenPoint(hitParentGameObj.transform.position);
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
_ui.m_comSelectBox.target.visible = hitParentGameObj.transform.parent.gameObject == bgParent ? false : true;
|
|
_ui.m_comSelectBox.target.visible = hitParentGameObj.transform.parent.gameObject == bgParent ? false : true;
|
|
if (_ui.m_comSelectBox.target.data == null || _ui.m_comSelectBox.target.data as GameObject != hitParentGameObj)
|
|
if (_ui.m_comSelectBox.target.data == null || _ui.m_comSelectBox.target.data as GameObject != hitParentGameObj)
|
|
{
|
|
{
|
|
@@ -195,8 +203,14 @@ namespace GFGGame
|
|
_ui.m_comSelectBox.target.rotation = -hitParentGameObj.transform.eulerAngles.z;
|
|
_ui.m_comSelectBox.target.rotation = -hitParentGameObj.transform.eulerAngles.z;
|
|
_ui.m_comSelectBox.target.size = SceneController.GetGameObjectSize(hitParentGameObj);
|
|
_ui.m_comSelectBox.target.size = SceneController.GetGameObjectSize(hitParentGameObj);
|
|
_ui.m_comSelectBox.target.SetScale(hitParentGameObj.transform.localScale.x, hitParentGameObj.transform.localScale.y);
|
|
_ui.m_comSelectBox.target.SetScale(hitParentGameObj.transform.localScale.x, hitParentGameObj.transform.localScale.y);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ _ui.m_comSelectBox.m_btnDelete.visible = true;
|
|
|
|
+ if (hitParentGameObj == bodyParent)
|
|
|
|
+ {
|
|
|
|
+ _ui.m_comSelectBox.m_btnDelete.visible = false;
|
|
|
|
|
|
|
|
+ }
|
|
_ui.m_comSelectBox.target.data = hitParentGameObj;
|
|
_ui.m_comSelectBox.target.data = hitParentGameObj;
|
|
|
|
|
|
ControllerSelectBoxPos(hitParentGameObj);
|
|
ControllerSelectBoxPos(hitParentGameObj);
|
|
@@ -208,7 +222,9 @@ namespace GFGGame
|
|
{
|
|
{
|
|
if (hitParentGameObj == null) return;//未选中任何物体
|
|
if (hitParentGameObj == null) return;//未选中任何物体
|
|
if (Stage.inst.touchCount > 1) return;//只监听1根手指
|
|
if (Stage.inst.touchCount > 1) return;//只监听1根手指
|
|
|
|
+ if (isTouchUI) return;
|
|
|
|
|
|
|
|
+ Debug.Log("拖动");
|
|
ControllerObjectPos(hitParentGameObj);
|
|
ControllerObjectPos(hitParentGameObj);
|
|
ControllerSelectBoxPos(hitParentGameObj);
|
|
ControllerSelectBoxPos(hitParentGameObj);
|
|
|
|
|
|
@@ -265,11 +281,26 @@ namespace GFGGame
|
|
|
|
|
|
private void OnClickBtnSizeBegin(EventContext context)
|
|
private void OnClickBtnSizeBegin(EventContext context)
|
|
{
|
|
{
|
|
|
|
+ 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;
|
|
|
|
|
|
- Vector2 pt1 = _ui.m_comSelectBox.target.size;// this.viewCom.GlobalToLocal(screenPos); ;
|
|
|
|
- _startDistance = Mathf.Sqrt(pt1.x * pt1.x + pt1.y * pt1.y) / 2;// Vector2.Distance(pt1, pt2);
|
|
|
|
|
|
+ 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 = this.viewCom.GlobalToLocal(new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y));
|
|
|
|
+ // Debug.Log("pt1" + pt1 + " pt2:" + pt2 + " pt:" + pt);
|
|
|
|
+
|
|
|
|
+ if (!_equipDistance.ContainsKey(gameObject))
|
|
|
|
+ {
|
|
|
|
+ float distance = Vector2.Distance(pt, pt2);
|
|
|
|
+ _equipDistance.Add(gameObject, distance);
|
|
|
|
+ }
|
|
|
|
+ _startDistance = _equipDistance[gameObject];
|
|
|
|
+ // _startDistance = Vector2.Distance(pt1, pt2);
|
|
|
|
+ // Vector2 pt1 = _ui.m_comSelectBox.target.size;// this.viewCom.GlobalToLocal(screenPos); ;
|
|
|
|
+ // _startDistance = Vector2.Distance(pt, pt2);
|
|
Debug.Log("_startDistance:" + _startDistance);
|
|
Debug.Log("_startDistance:" + _startDistance);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -293,13 +324,15 @@ namespace GFGGame
|
|
Debug.Log("dist:" + dist);
|
|
Debug.Log("dist:" + dist);
|
|
|
|
|
|
float ss = dist / _startDistance;
|
|
float ss = dist / _startDistance;
|
|
|
|
+ // float local = _equipDistance[gameObject] * gameObject.transform.localScale.x * ss / _equipDistance[gameObject];
|
|
float newValue = Mathf.Clamp(ss, 0.1f, 2);
|
|
float newValue = Mathf.Clamp(ss, 0.1f, 2);
|
|
ControllerScale(newValue, gameObject);
|
|
ControllerScale(newValue, gameObject);
|
|
|
|
|
|
}
|
|
}
|
|
private void OnClickBtnSizeEnd(EventContext context)
|
|
private void OnClickBtnSizeEnd(EventContext context)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ isTouchUI = false;
|
|
|
|
+ lastPos = Vector2.zero;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -321,7 +354,9 @@ namespace GFGGame
|
|
{
|
|
{
|
|
if (value > MaxScale || value < MinScale) return;
|
|
if (value > MaxScale || value < MinScale) return;
|
|
gameObject.transform.localScale = new Vector3(value, value, value);
|
|
gameObject.transform.localScale = new Vector3(value, value, value);
|
|
- _ui.m_comSelectBox.target.SetScale(value, value);
|
|
|
|
|
|
+
|
|
|
|
+ Vector2 size = SceneController.GetGameObjectSize(gameObject);
|
|
|
|
+ _ui.m_comSelectBox.target.SetSize(size.x * value, size.y * value);
|
|
}
|
|
}
|
|
|
|
|
|
private void OnRotate(EventContext context)
|
|
private void OnRotate(EventContext context)
|
|
@@ -414,9 +449,33 @@ namespace GFGGame
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
hitParentGameObj = null;
|
|
hitParentGameObj = null;
|
|
}
|
|
}
|
|
|
|
+ private void OnClickBtnFlip()
|
|
|
|
+ {
|
|
|
|
+ GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
+ gameObject.transform.GetChild(0).Rotate(Vector3.up, 180, Space.World);
|
|
|
|
+
|
|
|
|
+ // gameObject.transform.rotation.x = 180;
|
|
|
|
+ }
|
|
private void OnClickBtnDelete()
|
|
private void OnClickBtnDelete()
|
|
{
|
|
{
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
|
+ if (gameObject.transform.gameObject == bodyParent)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ else if (gameObject.transform.gameObject == npcParent)
|
|
|
|
+ {
|
|
|
|
+ SpriteRenderer spriteRenderer = gameObject.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
|
|
|
+ if (spriteRenderer != null)
|
|
|
|
+ {
|
|
|
|
+ GameObject.Destroy(spriteRenderer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ GameObject.DestroyImmediate(gameObject);
|
|
|
|
+ }
|
|
|
|
+ _ui.m_comSelectBox.target.visible = false;
|
|
|
|
|
|
}
|
|
}
|
|
private void OnClickBtnPhotograph()
|
|
private void OnClickBtnPhotograph()
|