Esempio n. 1
0
        void MenuEngineUpdated(object sender, Menu menu)
        {
            if (menu.GetType() == typeof(Menus.IntroductionScreen))              // IntroductionScreen;
            {
                if (_keyHandler.IsKeyPressed(Key.S) || _keyHandler.IsKeyPressed(Key.D1))
                {
                    ((Menus.IntroductionScreen)menu).GotoChooseSideScreen();
                }
                else if (_keyHandler.IsKeyPressed(Key.H) || _keyHandler.IsKeyPressed(Key.D2))
                {
                    ((Menus.IntroductionScreen)menu).GotoHelpScreen();
                }
                else if (_keyHandler.IsKeyPressed(Key.C) || _keyHandler.IsKeyPressed(Key.D3))
                {
                    ((Menus.IntroductionScreen)menu).GotoCreditsScreen();
                }
                _keyHandler.ClearKeyPresses();
            }
            else if (menu.GetType() == typeof(Menus.ChooseSideScreen))              // ChooseSideScreen;
            {
                if (_keyHandler.IsKeyPressed(Key.M) || _keyHandler.IsKeyPressed(Key.D1))
                {
                    ((Menus.ChooseSideScreen)menu).GotoMe();
                }
                else if (_keyHandler.IsKeyPressed(Key.K) || _keyHandler.IsKeyPressed(Key.D2))
                {
                    ((Menus.ChooseSideScreen)menu).GotoKraker();
                }
                _keyHandler.ClearKeyPresses();
            }
            else if (menu.GetType() == typeof(Menus.HelpScreen))              // HelpMenu;
            {
                if (_keyHandler.IsKeyPressed(Key.Home) || _keyHandler.IsKeyPressed(Key.D1))
                {
                    ((Menus.HelpScreen)menu).GotoBack();
                }
            }
            else if (menu.GetType() == typeof(Menus.CreditsScreen))              // CreditsScreen;
            {
            }
            else if (menu.GetType() == typeof(Menus.LevelHolder))              // LevelHolder;
            {
                if (Player.Dead)
                {
                    return;                               // there's no need to use the keys when player is dead;
                }
                Boolean left  = _keyHandler.IsKeyPressed(Key.A),
                        right = _keyHandler.IsKeyPressed(Key.D);
                if (!(left && right))
                {
                    if (left)                      // move left;
                    {
                        Player.Movement.Left();
                    }
                    else if (right)                      // move right;
                    {
                        Player.Movement.Right();
                    }
                }

                Boolean jump = _keyHandler.IsKeyPressed(Key.W) || _keyHandler.IsKeyPressed(Key.Ctrl),
                        duck = _keyHandler.IsKeyPressed(Key.S) || _keyHandler.IsKeyPressed(Key.Shift);
                if (!(jump && duck))
                {
                    if (jump)                      // jump;
                    {
                        Player.Movement.Jump();
                    }
                    else if (duck)                      // duck;
                    {
                        Player.Movement.Duck();
                    }
                }

                Boolean aimleft  = _keyHandler.IsKeyPressed(Key.Left),
                        aimright = _keyHandler.IsKeyPressed(Key.Right);
                if (!(aimleft && aimright))
                {
                    if (aimleft)                      // aim left;
                    {
                        Player.WeaponEngine.CurrentWeapon.ProjectoryAngle -= 2;
                    }
                    else if (aimright)                      // aim right;
                    {
                        Player.WeaponEngine.CurrentWeapon.ProjectoryAngle += 2;
                    }
                }

                Boolean next = _keyHandler.IsKeyPressed(Key.Down) || _keyHandler.IsKeyPressed(Key.Q),
                        prev = _keyHandler.IsKeyPressed(Key.Up) || _keyHandler.IsKeyPressed(Key.E);
                if (!(next && prev))
                {
                    if (next)                      // change next weapon;
                    {
                        Player.ShuffleWeaponDown();
                        _keyHandler.ClearKeyPresses(Key.Down);
                        _keyHandler.ClearKeyPresses(Key.Q);
                    }
                    else if (prev)                      // change previous weapon;
                    {
                        Player.ShuffleWeaponUp();
                        _keyHandler.ClearKeyPresses(Key.Up);
                        _keyHandler.ClearKeyPresses(Key.E);
                    }
                }

                if (_keyHandler.IsKeyPressed(Key.Space)) // shoot;
                {                                        // todo: remove key.z and fix space commit;
                    Player.Fire();
                    //_keyHandler.ClearKeyPresses(Key.Space);
                }
            }
            else if (menu.GetType() == typeof(Menus.HighScoresScreen))              // HighScoresScreen;
            {
            }
            else if (menu.GetType() == typeof(Menus.EndScreen))              // EndScreen;
            {
                _keyHandler.ClearKeyPresses();
            }
        }