Exemple #1
0
        /// <summary>
        /// Handle input that will affect the game world directly (such as moving, attacking, etc)
        /// </summary>
        private void HandleGameActionInput()
        {
            // Decide in which direction (+ is right/bottom) to move the character
            int dx = 0;
            int dy = 0;

            // Check for movement keys
            if (engine.KeyPressed(GameEngine.Command.DOWN))
            {
                dy = 1;
            }
            else if (engine.KeyPressed(GameEngine.Command.UP))
            {
                dy = -1;
            }
            else if (engine.KeyPressed(GameEngine.Command.LEFT))
            {
                dx = -1;
            }
            else if (engine.KeyPressed(GameEngine.Command.RIGHT))
            {
                dx = 1;
            }
            else if (engine.KeyPressed(GameEngine.Command.TOPLEFT))
            {
                dy = -1;
                dx = -1;
            }
            else if (engine.KeyPressed(GameEngine.Command.TOPRIGHT))
            {
                dy = -1;
                dx = 1;
            }
            else if (engine.KeyPressed(GameEngine.Command.BOTLEFT))
            {
                dy = 1;
                dx = -1;
            }
            else if (engine.KeyPressed(GameEngine.Command.BOTRIGHT))
            {
                dy = 1;
                dx = 1;
            }

            // If moving, send to the system
            if (dx != 0 || dy != 0)
            {
                MovementSystem.CheckMovement(Player, dx, dy, EntityManager, dungeon);
                UpdateGame = true;
            }
            else
            {
                UpdateGame = false;
            }
        }