コード例 #1
0
        public override void Execute()
        {
            // Fire event in the model
            InvItem.IDType currentStateId = model.fire(e, t);

            // Dispatch the new icon
            currentInventoryIconSignal.Dispatch(currentStateId);
        }
コード例 #2
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);
        }
コード例 #3
0
 public void OnCurrentInventoryIconSignal(InvItem.IDType id)
 {
     // show circle if current item is smokebomb
     showCircle(id == InvItem.IDType.SmokeBombActive);
 }