예제 #1
0
        // init invoked from TouchFSM
        public void fire(Events e, TouchScreenPosition t)
        {
            //States oldState = currentState;

            switch (currentState)
            {
            case States.FollowingPlayer:
                switch (e)
                {
                case Events.Press:
                    if (!touchModel.isGuiItem(t))
                    {
                        uiPlayAreaPressSignal.Dispatch(t);
                    }
                    break;

                case Events.Pan:
                    currentState = States.Pan;
                    break;

                case Events.LongPress:
                    currentState = States.PlayerAction;
                    uiPlayerActionSignal.Dispatch(t, true);
                    break;

                default:
                    break;
                }
                break;

            case States.Menu:
                break;

            case States.Pan:
                switch (e)
                {
                case Events.Press:
                    currentState = States.FollowingPlayer;
                    uiPanBackToPlayerSignal.Dispatch();
                    break;

                default:
                    break;
                }
                break;

            case States.PlayerAction:
                switch (e)
                {
                case Events.Release:
                    currentState = States.FollowingPlayer;
                    uiPlayerActionSignal.Dispatch(t, false);
                    break;
                }
                break;
            }

            // UnityEngine.Debug.Log ("UIFSM - " + oldState + " (" + e +") -> " + currentState);
        }
예제 #2
0
 public static bool IsTouchOnWater(TouchScreenPosition touchScreenPosition)
 {
     return
         (Physics2D.GetRayIntersection(
              new Ray(
                  (Vector3)touchScreenPosition.world - Vector3.forward,
                  Vector3.forward),
              Mathf.Infinity
              ).transform == null);
 }
예제 #3
0
        void OnPlayerActionSignal(TouchScreenPosition notUsedHere, bool startOrStop)
        {
            // if current inventory item is drill then start or stop drilling
            if (inventoryModel.getCurrentInvItem().id == InvItem.IDType.DrillActive)
            {
                view.isDrillingGameInputEventReceived = startOrStop;
            }

            // stop drilling if this is false even if not the drill is active
            if (!startOrStop)
            {
                view.isDrillingGameInputEventReceived = false;
            }
        }
예제 #4
0
        // checks if the touch is within any GUI item or not
        public bool isGuiItem(TouchScreenPosition tsp)
        {
            // invert y as screen is bottom-up, GUI is top-down
            tsp.pixel.y = Screen.height - tsp.pixel.y;

            foreach (Rect guiRect in guiRectList)
            {
                // check if the touch is within a GUI item
                if (guiRect.Contains(tsp.pixel))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #5
0
        public bool isTouchWithinEllipse(TouchScreenPosition t)
        {
            // if the touch is within the smoke bomb ellipse
            GameObject e = smokeBombCircleGameObject;

            float rx = e.GetComponent <SpriteRenderer>().sprite.bounds.extents.x;
            float ry = e.GetComponent <SpriteRenderer>().sprite.bounds.extents.y;

            float h = e.transform.position.x;
            float k = e.transform.position.y;

            float x = t.world.x;
            float y = t.world.y;

            // check if the touch is within the ellipse
            return((x - h) * (x - h) / rx / rx + (y - k) * (y - k) / ry / ry < 1);
        }
        void dispatchFireTouchEventSignal(TouchFSM.Events e, Vector2 firstFingerPixelPosition)
        {
            TouchScreenPosition p = new TouchScreenPosition()
            {
                pixel = firstFingerPixelPosition,

                screen = new Vector2(
                    (firstFingerPixelPosition).x / Screen.width,
                    (firstFingerPixelPosition).y / Screen.height),

                world = (Vector2)cam.ScreenToWorldPoint(new Vector3(
                                                            (firstFingerPixelPosition).x,
                                                            (firstFingerPixelPosition).y
                                                            ))
            };

            _fireTouchEventSignal.Dispatch(e, p);
        }
예제 #7
0
 void OnPlayerGotoSignal(TouchScreenPosition p)
 {
     view.playClickAnimationAt(p.world, gameModel.pauseStatus == TeamBrookvale.Game.PauseStatus.RUN);
 }
예제 #8
0
        // SHOULD NOT BE CALLED DIRECTLY, only through InventoryEventFireSignal
        public InvItem.IDType fire(Events e, TouchScreenPosition t)
        {
            // InvItem.IDType prevStateId = currentStateId;

            // any state transitions except in uboat

            if (currentStateId != InvItem.IDType.UBoat)
            {
                switch (e)
                {
                case Events.ApproachUBoat:
                    currentStateId = InvItem.IDType.UBoat;
                    break;

                case Events.ApproachDrillableShip:
                    currentStateId = InvItem.IDType.DrillActive;
                    break;

                case Events.ApproachSunkShip:
                    currentStateId = InvItem.IDType.DrillInactive;
                    break;

                case Events.ApproachBridgeOrDamWithoutLocalBomb:
                    currentStateId = InvItem.IDType.TimeBombActive;
                    break;

                case Events.ApproachBridgeOrDamWithLocalBomb:
                    currentStateId = InvItem.IDType.TimeBombInactive;
                    break;

                case Events.ApproachBridgeOrDamWithAllBombs:
                    currentStateId = InvItem.IDType.TimeBombInactiveTick;
                    break;

                case Events.AbandonShipBridgeOrDam:
                    currentStateId = InvItem.IDType.SmokeBombInactive;
                    break;

                default:
                    break;
                }
            }

            // state dependent transitions
            switch (currentStateId)
            {
            case InvItem.IDType.SmokeBombInactive:
                if ((e == Events.ButtonPush || e == Events.MoreSmokeBombs) && smokeBombsLeft > 0 && cachedIsSmokeBombEnabledOnThisLevel)
                {
                    currentStateId = InvItem.IDType.SmokeBombActive;
                }
                break;

            // Smoke bomb explosion is handled by PlayerActionCommand
            case InvItem.IDType.SmokeBombActive:
                if (e == Events.ButtonPush || e == Events.TouchOutOfSmokeBombCircle || e == Events.TouchWithinSmokeBombCircle)
                {
                    currentStateId = InvItem.IDType.SmokeBombInactive;
                }
                break;

            case InvItem.IDType.UBoat:
                if (e == Events.AbandonUBoat)
                {
                    currentStateId = InvItem.IDType.SmokeBombInactive;
                }
                break;

            default:
                break;
            }

            // Debug.Log (prevStateId + " ("+e+") -> " + currentStateId);

            return(currentStateId);
        }
예제 #9
0
 void OnPlayerGotoSignal(TouchScreenPosition touchScreenPosition)
 {
     playerModel.pathGoal = touchScreenPosition.world;
 }
예제 #10
0
        // Fired by FireTouchEventCommand
        public States fireTouchEvent(Events e, TouchScreenPosition t)
        {
            //States oldState = currentState;

            switch (currentState)
            {
            case States.Idle:
                switch (e)
                {
                case Events.FirstFingerBegan:
                    currentState = States.FirstFingerBegan;
                    break;

                default:
                    break;
                }
                break;

            case States.FirstFingerBegan:
                switch (e)
                {
                case Events.FirstFingerMoved:
                    currentState = States.Pan;
                    uiFSM.fire(UIFSM.Events.Pan, t);
                    break;

                case Events.AnyFingersEnded:
                    currentState = States.Idle;
                    uiFSM.fire(UIFSM.Events.Press, t);
                    break;

                case Events.SecondFingerBegan:
                    currentState = States.SecondFingerBegan;
                    break;

                case Events.FirstFingerLongTouch:
                    currentState = States.LongPress;
                    uiFSM.fire(UIFSM.Events.LongPress, t);
                    break;

                default:
                    break;
                }
                break;

            case States.SecondFingerBegan:
                switch (e)
                {
                case Events.AnyFingersEnded:
                    currentState = States.Idle;
                    break;

                case Events.FirstFingerMoved:
                    currentState = States.Pan;
                    uiFSM.fire(UIFSM.Events.Pan, t);
                    break;

                case Events.PinchZoom:
                    currentState = States.PinchZoom;
                    break;

                default:
                    break;
                }
                break;

            case States.Pan:
                switch (e)
                {
                case Events.PinchZoom:
                    currentState = States.PinchZoom;
                    break;

                case Events.AnyFingersEnded:
                    currentState = States.Idle;
                    break;

                default:
                    break;
                }
                break;

            case States.PinchZoom:
                switch (e)
                {
                case Events.AnyFingersEnded:
                    currentState = States.Idle;
                    break;

                default:
                    break;
                }
                break;

            case States.LongPress:
                switch (e)
                {
                case Events.AnyFingersEnded:
                    uiFSM.fire(UIFSM.Events.Release, t);
                    currentState = States.Idle;
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }

            // UnityEngine.Debug.Log ("TouchFSM - " + oldState + " (" + e +") -> " + currentState);

            return(currentState);
        }
예제 #11
0
 public void fireTouchEvent(TouchFSM.Events e, TouchScreenPosition t)
 {
     currentState = touchFSM.fireTouchEvent(e, t);
 }
예제 #12
0
 internal void OnSmokeBombExplodedSignal(TouchScreenPosition t)
 {
     OnSmokeBombExplodedSignal(t.world, Const.SpotlightReturnToNormalTime);
 }