Exemplo n.º 1
0
        //Checks the keyboard input for any attacks that the hero has fired
        //Fires attack if correct key is pressed/ammo is available
        public void FireAttack()
        {
            //Current key state for this frame called in UpdateMovement()
            if ((currentKeyState.IsKeyDown(Keys.Space) && oldKeyState.IsKeyUp(Keys.Space)) || (currentPadState.IsButtonDown(Buttons.RightTrigger) && oldPadState.IsButtonUp(Buttons.RightTrigger)))
            {
                //If we have ammo left
                if (numAttacks < GameConstants.heroNumAttacks)
                {
                    //Fire Attack
                    onScreenAttacks[numAttacks] = new HeroAttack(position, rotation);
                    numAttacks++;

                    //Play Sound Effect
                    Game1.heroAttackSound.Play();
                }
            }
        }
Exemplo n.º 2
0
        //Checks the keyboard input for any attacks that the hero has fired
        //Fires attack if correct key is pressed/ammo is available
        public void FireAttack()
        {
            //Current key state for this frame called in UpdateMovement()
            if ((currentKeyState.IsKeyDown(Keys.Space) && oldKeyState.IsKeyUp(Keys.Space)) || (currentPadState.IsButtonDown(Buttons.RightTrigger) && oldPadState.IsButtonUp(Buttons.RightTrigger)))
            {
                //If we have ammo left
                if (numAttacks < GameConstants.heroNumAttacks)
                {
                    //Fire Attack
                    onScreenAttacks[numAttacks] = new HeroAttack(position, rotation);
                    numAttacks++;

                    //Play Sound Effect
                    Game1.heroAttackSound.Play();
                }
            }
        }