Beispiel #1
0
        void OnMouseUpAsButton()
        {
            if ((bool)GameState.getInstance().get(getKey()))
            {
                return;
            }

            if (GameState.getInstance().has(InventoryRenderer.ACTIVE_ITEM_GAME_STATE_KEY))
            {
                string item = (string)GameState.getInstance().get(InventoryRenderer.ACTIVE_ITEM_GAME_STATE_KEY);

                if (item != null && item.Equals(keyId))
                {
                    GameState.getInstance().put(getKey(), true);
                    locked.setActive(true);

                    lockAudio.clip = unlockSound;
                    lockAudio.Play();

                    if (consumeItem)
                    {
                        GameState.getInstance().removeItem(keyId);
                    }
                }
            }
        }
        public bool isMet()
        {
            if (!GameState.getInstance().has(gameStateKey))
            {
                return(false);
            }

            return(val.Equals(GameState.getInstance().get(gameStateKey)));
        }
Beispiel #3
0
        void Start()
        {
            if (!GameState.getInstance().has(gameStateKey))
            {
                GameState.getInstance().put(gameStateKey, UNSOLVED_STATE);
            }

            state = (int)GameState.getInstance().get(gameStateKey);
            setSolved(state == SOLVED_STATE);
            if (state == UNSOLVED_STATE)
            {
                GameState.getInstance().addListener(this);
            }
        }
Beispiel #4
0
        void Start()
        {
            lck        = gameObject.GetComponents(typeof(Lock))[0] as Lock;
            isUnlocked = (bool)GameState.getInstance().get(lck.getKey());

            if (isUnlocked)
            {
                addKeyModel();
            }
            else
            {
                GameState.getInstance().addListener(this);
            }
        }
Beispiel #5
0
        void Awake()
        {
            if (unlockSound == null)
            {
                unlockSound = Resources.Load("Sound Effects/Lock") as AudioClip;
            }

            lockAudio = gameObject.AddComponent(typeof(AudioSource)) as AudioSource;

            if (!GameState.getInstance().has(getKey()))
            {
                GameState.getInstance().put(getKey(), false);
            }

            locked.setActive((bool)GameState.getInstance().get(getKey()));
        }
Beispiel #6
0
        public void stateChanged(String stateKey, object oldValue, object newValue)
        {
            if (state == SOLVED_STATE)
            {
                return;
            }

            bool found = false;

            foreach (PuzzleCondition p in conditions)
            {
                if (p.getKey().Equals(stateKey))
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                return;
            }

            foreach (PuzzleCondition p in conditions)
            {
                if (!p.isMet())
                {
                    return;
                }
            }

            // All conditions are met
            state = SOLVED_STATE;
            GameState.getInstance().put(gameStateKey, state);
            doSolve();
        }