Exemplo n.º 1
0
        public void Process()
        {
            var player = GameStateSingleton.Instance.State.Player;

            if (_userInputConfiguration.Close)
            {
                _window.Close();
            }

            if (_userInputConfiguration.End)
            {
                GameStateSingleton.Instance.State.GameRunning = false;
                _facade.RemoveAll();
            }

            if (_userInputConfiguration.Save)
            {
                _facade.CreateSave();
            }

            if (_userInputConfiguration.LoadSave)
            {
                _facade.LoadSave();
            }

            if (player.State.Health <= 0)
            {
                return;
            }

            if (_userInputConfiguration.Up && player.WillNotCollide(0, -1))
            {
                if (!player.State.Stunned)
                {
                    player.State.Y -= player.State.Velocity;
                }
            }
            else
            {
                if (!player.State.Stunned)
                {
                    player.State.Y += player.State.Velocity;
                }
            }

            if (_userInputConfiguration.Down && player.WillNotCollide(0, 1))
            {
                if (!player.State.Stunned)
                {
                    player.State.Y += player.State.Velocity;
                }
            }
            else
            {
                if (!player.State.Stunned)
                {
                    player.State.Y -= player.State.Velocity;
                }
            }

            if (_userInputConfiguration.Left && player.WillNotCollide(-1, 0))
            {
                if (!player.State.Stunned)
                {
                    player.State.X -= player.State.Velocity;
                }
            }
            else
            {
                player.State.X += player.State.Velocity;
            }

            if (_userInputConfiguration.Right && player.WillNotCollide(1, 0))
            {
                if (!player.State.Stunned)
                {
                    player.State.X += player.State.Velocity;
                }
            }
            else
            {
                if (!player.State.Stunned)
                {
                    player.State.X -= player.State.Velocity;
                }
            }
        }