void OnMouseDown() { if (PutCanvasM.CanOperate == false) { return; } RaycastHit hit; if (WndManager.IsHitNGUI(out hit))//当点击到UI时不做处理 { return; } if (Input.touchCount >= 2) { return; } m_bMouseDown = true; m_bLongTouch = false; m_bTouchMoveChange = true; m_fMouseDownTime = Time.time; m_vtotalmouseDelta = Vector2.zero; m_vlastFirstTouch = GetTouchPos(0); m_isDrag = false; if (SystemInfo.deviceType == DeviceType.Desktop) { m_v3MouseTouchDown = Input.mousePosition; } else { m_v3MouseTouchDown = Input.GetTouch(0).position; } //获取按下时画布格子 Vector3 m_v3TouchScreenPos = new Vector3(m_v3MouseTouchDown.x, m_v3MouseTouchDown.y, -Camera.main.transform.position.z); Vector3 m_v3TouchWorldPos = Camera.main.ScreenToWorldPoint(m_v3TouchScreenPos); Vector3 v3dLocalPos = BattleEnvironmentM.World2LocalPos(m_v3TouchWorldPos); m_roomGridTouchDown = RoomMap.FindRoomGrid(v3dLocalPos); if (m_roomGridTouchDown == null) { return; } m_curClickType = RoomMap.PickupShipBuildType(m_roomGridTouchDown, v3dLocalPos, m_roomGridTouchDown.mPosRoomGrid.Layer); CanvasCore buildRoomCoreTouchDown = m_roomGridTouchDown.GetBuildRoom(); if (TouchMove.g_bSetParaing == true) { return; } TouchMove curTouchMove = TouchMoveManager.GetCurTouchMove(); if (null != curTouchMove) { //如果当前选中的是房间,新选中的不管是什么都不做变更 //如果当前选中的不是房间,但是新选中的对象和当前选中的一样则也不变量。 if (curTouchMove.IsContainsRoomGrid(m_roomGridTouchDown)) { TouchMove selNewTouchMov = PutCanvasM.GetTouchMoveByRoomGrid(m_roomGridTouchDown, m_curClickType); if (curTouchMove.MyCore().m_type == ShipBuildType.BuildRoom || selNewTouchMov != null && selNewTouchMov == curTouchMove) { curTouchMove.PlayEditSelectAnimationEnd(); //恢复上个房间内陷阱/角色 动画 curTouchMove.OnMouseDown(); m_bTouchMoveChange = false; } } PutCanvasM.ClearNoLinkList(); } else { //判断选中物件是否在上次保存失败的物件上,如果是则直接选择 bool bInNoLinkList = false; if (buildRoomCoreTouchDown != null) { TouchMove selNewTouchMov = PutCanvasM.GetTouchMoveByCore(buildRoomCoreTouchDown); if (null == selNewTouchMov) { List <CanvasCore> childCores = m_roomGridTouchDown.GetOtherBuild(); for (int i = 0; i < childCores.Count; i++) { selNewTouchMov = PutCanvasM.GetTouchMoveByCore(childCores[i]); break; } } if (null != selNewTouchMov && PutCanvasM.NoLinkListContain(selNewTouchMov.MyCore())) { PutCanvasM.ClearNoLinkList(); TouchMoveManager.SetCurTouchMove(selNewTouchMov); selNewTouchMov.PlayEditSelectAnimationEnd(); //恢复上个房间内陷阱/角色 动画 selNewTouchMov.OnMouseDown(); m_bTouchMoveChange = false; bInNoLinkList = true; } } if (bInNoLinkList == false) { PutCanvasM.ClearNoLinkList(); } } }