Exemplo n.º 1
0
                public override State Update()
                {
                    // behavior:

                    // transitions:
                    if (Input.GetButton("Fire1"))
                    {
                        // if no ammo, go to cooldown:
                        if (PlayerWeapon.roundsInClip <= 0)
                        {
                            SoundBoard.PlayPlayerNoAmmo();
                            return(new States.Cooldown(weapon.reloadTime)); // Originally weapon.roundsInClip
                        }

                        // if ammo, go to shooting:
                        return(new States.Attacking());
                    }
                    if (Input.GetButtonDown("Reload"))
                    {
                        // if clip is full, don't reload:
                        if (PlayerWeapon.roundsInClip > 9)
                        {
                            return(new States.Regular());                               // Originally weapon.roundsInClip
                        }
                        // if clip is not full, reload
                        return(new States.Cooldown(weapon.reloadTime));
                    }
                    return(null);
                }
Exemplo n.º 2
0
        void Update()
        {
            if (Input.GetButtonDown("BulletWipe") && bulletWipes > 0)                     // If player presses "E"...
            {
                bulletWipes--;                                                            // Subtract 1 bullet wipe from wipeCount
                wipeCount.text = bulletWipes.ToString();                                  // Communicates amount of bullet wipes to the UI
                GameObject[] BadBullets = GameObject.FindGameObjectsWithTag("BadBullet"); // Gets a reference to the BadBullets in the scene
                SoundBoard.PlayPlayerWipe();                                              // Plays the bullet wipe sound

                foreach (GameObject BadBullet in BadBullets)                              // for each bad bullet in the scene...
                {
                    Destroy(BadBullet);                                                   // Destroy the bad bullets
                }
            }
            else if (Input.GetButtonDown("BulletWipe") && bulletWipes <= 0) // If no bullet wipes available
            {
                SoundBoard.PlayPlayerNoAmmo();                              // // Play the no ammo sound
            }
        }