void OnDrag(DragGesture gesture)
        {
            if (!HomeBuildingManager.GetInstance().Contains(gesture.Selection))
            {
                return;
            }

            //相机停止移动
            FingerCamera.GetInstance().couldDrag = false;
            // first finger
            FingerGestures.Finger finger = gesture.Fingers[0];

            if (gesture.Phase == ContinuousGesturePhase.Started)
            {
                dragFingerIndex = finger.Index;
            }
            else if (finger.Index == dragFingerIndex)  // gesture in progress, make sure that this event comes from the finger that is dragging our dragObject
            {
                if (gesture.Phase == ContinuousGesturePhase.Updated)
                {
                    //transform.position = ScreenPointToWorldPlane(gesture.Position);
                    gesture.Selection.transform.position = ScreenPointToWorldPlane(gesture.Position);
                }
                else
                {
                    dragFingerIndex = -1;
                    FingerCamera.GetInstance().couldDrag = true;
                    var gridPos    = HomeGridManager.GetInstance().WorldPosToGridPos(gesture.Selection.transform.position);
                    var cellCenter = HomeGridManager.GetInstance().GridPosToCellCenterInWorld(gridPos);
                    //transform.position = cellCenter;
                    gesture.Selection.transform.position = cellCenter;
                    SoundManager.GetInstance().PlaySound("sound/build_pickup_05");
                }
            }
        }
Example #2
0
 void InitHomeGrid()
 {
     HomeGridManager.GetInstance().center    = Vector3.zero;
     HomeGridManager.GetInstance().cellSize  = 1;
     HomeGridManager.GetInstance().gridSize  = 100;
     HomeGridManager.GetInstance().color     = Color.green;
     HomeGridManager.GetInstance().couldDraw = true;
 }
Example #3
0
 void Update()
 {
     if (HomeGridManager.GetInstance().couldDraw&& !isInit)
     {
         grid = new GL_Grid();
         grid.Init(HomeGridManager.GetInstance().center,
                   HomeGridManager.GetInstance().cellSize,
                   HomeGridManager.GetInstance().gridSize,
                   HomeGridManager.GetInstance().color);
         isInit = true;
     }
 }