Exemplo n.º 1
0
 void Update()
 {
     if (_transition.IsStateActive())
     {
         if (_paused)
         {
             if (Input.GetKeyDown(KeyCode.Escape))
             {
                 CloseQuickMenu();
             }
             if (Input.GetKeyDown(KeyCode.R))
             {
                 Restart();
             }
         }
         else
         {
             if (Input.GetKeyDown(KeyCode.Escape))
             {
                 OpenQuickMenu();
             }
             if (Input.GetKeyDown(KeyCode.R))
             {
                 Restart();
             }
         }
     }
 }
Exemplo n.º 2
0
    void Update()
    {
        if (_transition.IsStateActive())
        {
            if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))
            {
                var oldItem = _selectedItem;

                do
                {
                    _selectedItem = (_items.Count + _selectedItem - 1) % _items.Count;
                } while (_selectedItem != oldItem && _items[_selectedItem].Locked);

                MoveArrow(_selectedItem);
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S))
            {
                var oldItem = _selectedItem;

                do
                {
                    _selectedItem = (_selectedItem + 1) % _items.Count;
                } while (_selectedItem != oldItem && _items[_selectedItem].Locked);

                MoveArrow(_selectedItem);
            }
            else if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
            {
                AudioPlayer.PlaySound("select");
                var action = _items[_selectedItem].Action;
                action();
            }
        }
    }
Exemplo n.º 3
0
 private void Update()
 {
     if (_transition.IsStateActive())
     {
         // reset unlocked levels when d + l held
         if (Input.GetKey(KeyCode.D) && Input.GetKey(KeyCode.L))
         {
             if (PlayerPrefs.GetString("unlocked_levels") != defaultUnlockedLevels)
             {
                 PlayerPrefs.SetString("unlocked_levels", defaultUnlockedLevels);
                 PlayerPrefs.Save();
                 AudioPlayer.PlaySound("push");
             }
         }
     }
 }
Exemplo n.º 4
0
        /**
         * Checks keyboard input and calls TryMove if necessary.
         */
        void Update()
        {
            if (!MoveFinalized())
            {
                if (MapUpdateNeeded())
                {
                    UpdateAfterMove();
                }
            }
            else if (_gameplay.IsPlaying() && _stateTransition.IsStateActive())
            {
                int up    = Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W) ? 1 : 0;
                int down  = Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S) ? 1 : 0;
                int right = Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D) ? 1 : 0;
                int left  = Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A) ? 1 : 0;

                // only one is pressed
                if (up + down + right + left == 1)
                {
                    if (up > 0)
                    {
                        TryMove(MoveDirection.Up);
                    }
                    else if (down > 0)
                    {
                        TryMove(MoveDirection.Down);
                    }
                    else if (left > 0)
                    {
                        TryMove(MoveDirection.Left);
                    }
                    else if (right > 0)
                    {
                        TryMove(MoveDirection.Right);
                    }
                }
            }
        }