Exemplo n.º 1
0
        /// <summary>
        /// Actualiza la aplicación
        /// </summary>
        /// <param name="gameTime">Tiempo de juego</param>
        protected override void Update(GameTime gameTime)
        {
            // Fin de captura de salida de usuario
            InputHandler.Begin();

            // Salir
            if (InputHandler.KeyPressed(Keys.Escape))
            {
                this.Exit();
            }

            // Reinicio
            if (InputHandler.KeyPressed(Keys.R))
            {
                this.Reset();
            }

            #region Tanque 1

            // Captura de disparo del tanque 1
            if (InputHandler.KeyPressed(Keys.Enter))
            {
                this.Fire(gameTime, this.m_Tank_1, this.m_CurrentShotType_1);
            }

            // Cambios de munición del tanque 1
            if (InputHandler.KeyPressed(Keys.D1))
            {
                m_CurrentShotType_1 = ShotType.HeavyBolter;
            }

            if (InputHandler.KeyPressed(Keys.D2))
            {
                m_CurrentShotType_1 = ShotType.FlameThrower;
            }

            if (InputHandler.KeyPressed(Keys.D3))
            {
                m_CurrentShotType_1 = ShotType.Artillery;
            }

            if (InputHandler.KeyPressed(Keys.D4))
            {
                m_CurrentShotType_1 = ShotType.Laser;
            }

            // Movimiento del tanque 1
            if (InputHandler.KeyPressing(Keys.Up))
            {
                m_Tank_1.GoForward(5f);
            }

            if (InputHandler.KeyPressing(Keys.Down))
            {
                m_Tank_1.GoBackward(5f);
            }

            if (InputHandler.KeyPressing(Keys.Left))
            {
                m_Tank_1.TurnLeft(0.01f);
            }

            if (InputHandler.KeyPressing(Keys.Right))
            {
                m_Tank_1.TurnRight(0.01f);
            }

            #endregion

            #region Tanque 2

            // Captura de disparo del tanque 2
            if (InputHandler.KeyPressed(Keys.Space))
            {
                this.Fire(gameTime, this.m_Tank_2, this.m_CurrentShotType_2);
            }

            // Cambios de munición del tanque 2
            if (InputHandler.KeyPressed(Keys.D7))
            {
                m_CurrentShotType_2 = ShotType.HeavyBolter;
            }

            if (InputHandler.KeyPressed(Keys.D8))
            {
                m_CurrentShotType_2 = ShotType.FlameThrower;
            }

            if (InputHandler.KeyPressed(Keys.D9))
            {
                m_CurrentShotType_2 = ShotType.Artillery;
            }

            if (InputHandler.KeyPressed(Keys.D0))
            {
                m_CurrentShotType_2 = ShotType.Laser;
            }

            // Movimiento del tanque 2
            if (InputHandler.KeyPressing(Keys.I))
            {
                m_Tank_2.GoForward(5f);
            }

            if (InputHandler.KeyPressing(Keys.K))
            {
                m_Tank_2.GoBackward(5f);
            }

            if (InputHandler.KeyPressing(Keys.J))
            {
                m_Tank_2.TurnLeft(0.01f);
            }

            if (InputHandler.KeyPressing(Keys.L))
            {
                m_Tank_2.TurnRight(0.01f);
            }

            #endregion

            this.Physics.Update(gameTime);

            // Fin de captura de entrada de usuario
            InputHandler.End();

            // Actualización base
            base.Update(gameTime);
        }