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");
                }
            }
        }
Exemple #2
0
        protected void OnLoadZooSceneFinished(Message msg)
        {
            cacheTrans  = FingerCamera.GetInstance().cacheTrans;
            cacheCam    = FingerCamera.GetInstance().cacheCam;
            crossPoint  = FingerCamera.GetInstance().crossPoint;
            tryPoint    = FingerCamera.GetInstance().tryPoint;
            moveToPoint = FingerCamera.GetInstance().moveToPoint;


            this.cacheTrans.position = editorInitPos;
            //FingerCamera.GetInstance().cacheTrans.position = editorInitPos;
            this.cacheCam.orthographicSize = this.maxOrthographicSize;
            //FingerCamera.GetInstance().cacheCam.orthographicSize = this.maxOrthographicSize;
            dragMoveTo = cacheTrans.position;

            LogWarp.LogFormat("camera {0}", GetLoadGroup());
            if (LoadingMgr.Inst.runTimeLoaderType == RunTimeLoaderType.Game)
            {
                offset = (Config.globalConfig.getInstace().InitMaxGroupNum - GetLoadGroup()) * Config.globalConfig.getInstace().ZooPartResLen;

                gameCamLeftUpPos    = editorCamLeftUpPos;
                gameCamLeftUpPos.x += offset;

                gameCamRightUpPos    = editorCamRightUpPos;
                gameCamRightUpPos.x += offset;
            }

            cameraArea.Clear();
            cameraArea.Add(Math_F.Vector3_2D(editorCamLeftDownPos));
            cameraArea.Add(Math_F.Vector3_2D(gameCamLeftUpPos));
            cameraArea.Add(Math_F.Vector3_2D(gameCamRightUpPos));
            cameraArea.Add(Math_F.Vector3_2D(editorCamRightDownPos));

#if UNITY_EDITOR
            SetRange();
#else
            GameObject.Find("camer_range").SetActive(false);
#endif
        }