Exemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            if (Position.Y > 1080)
            {
                new ResetCommand().Execute(this);
            }

            // get input and excecute commands
            foreach (IGameCommand command in keyboardReader.ReadCommands())
            {
                command.Execute(this);
            }
            foreach (IGameCommand command in mouseReader.ReadCommands())
            {
                command.Execute(this);
            }

            // get input and excecute abilities
            foreach (IAbility ability in keyboardReader.ReadAbilities())
            {
                ability.Execute();
            }
            foreach (IAbility ability in mouseReader.ReadAbilities())
            {
                ability.Execute();
            }

            PrevPosition = Position;

            // Apply the physics (Gravity and Friction)
            phyma.ApplyPhysics(this);

            // Accelerate the velocity
            //Velocity = Acceleration;
            //System.Diagnostics.Debug.WriteLine("Velocity: " + Velocity);

            // Create the new collisionbox for the next position
            CollisionBox = new Rectangle((int)(Position.X), (int)(Position.Y), (int)(319 * Scale), (int)(486 * Scale));

            CollisionHandler.Move(this, gameTime);

            CollisionBox = new Rectangle((int)(Position.X), (int)(Position.Y), (int)(319 * Scale), (int)(486 * Scale));

            if (Position.Y > 2000)
            {
                new ResetCommand().Execute(this);
            }

            if (Health <= 0)
            {
                new ResetCommand().Execute(this);
            }

            animation.Update(gameTime, Position);
        }