Пример #1
0
        public void Die()
        {
            SoundBoard.PlayPlayerDie();
            healthValue = 0f;       // On death, set healthValue to 0 on UI
            Destroy(gameObject);    // On death, destroy gameObject

            gameOverTimer = 4;      // Sets the time until the game ends after dying
            if (gameOverTimer <= 0) // If timer has reached 0
            {
                Game.GameOver();    // Game Over
            }
        }
Пример #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")      // If object tagged as "Player" triggers the box...
     {
         if (battleBegun == false)              // If battle has NOT begun
         {
             SoundBoard.PlayBossFightMusic();   // Play Boss fight music
             BossController.battleBegun = true; // set battle begun to true
             Destroy(gameObject);               // Destroy the trigger box
         }
     }
 }
Пример #3
0
        private void SpawnGoodBullet() // Method to spawn GoodBullets
        {
            if (timerSpawnBullet > 0)
            {
                return;                                                                                   // If still on cooldown, don't spawn a bullet
            }
            SoundBoard.PlayPlayerShoot();                                                                 // Play player shoot sound
            GoodBullet p = Instantiate(prefabGoodBullet, barrel.transform.position, Quaternion.identity); // Instantiate a bullet at the barrel of the pod

            p.InitBullet(transform.forward * 20);                                                         // Sest the velocity of the bullet

            timerSpawnBullet = 1 / roundsPerSecond;                                                       // Sets the cooldown before another bullet can spawn
        }
Пример #4
0
        public AudioSource player;              // Variable referencing the Audio Source in the scene used to play sounds and music
        #endregion

        void Start()
        {
            if (main == null)
            {
                main   = this;
                player = GetComponent <AudioSource>();
            }
            else
            {
                Destroy(this.gameObject);
            }

            PlayAmbientMusic(); // Plays ambient music on start
        }
Пример #5
0
        void SpawnGoodBullet()
        {
            SoundBoard.PlayPlayerShoot();
            if (timerSpawnBullet > 0)
            {
                return;                       // need to wait longer
            }
            if (roundsInClip <= 0)
            {
                return;                    // no ammo
            }
            GoodBullet p = Instantiate(prefabGoodBullet, transform.position, Quaternion.identity);

            p.InitBullet(transform.forward * 20);

            roundsInClip--;
            timerSpawnBullet = 1 / roundsPerSecond;
        }
Пример #6
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
            }
        }
Пример #7
0
        private void SpawnBadBullet()
        {
            if (cooldownShoot > 0)
            {
                return;                    // still on cooldown
            }
            SoundBoard.PlayTurretShoot();

            BadBullet p1 = Instantiate(prefabBadBullet, barrel1.transform.position, barrel1.rotation); // instantiates a bullet on each barrel
            BadBullet p2 = Instantiate(prefabBadBullet, barrel2.transform.position, barrel2.rotation);
            BadBullet p3 = Instantiate(prefabBadBullet, barrel3.transform.position, barrel3.rotation);
            BadBullet p4 = Instantiate(prefabBadBullet, barrel4.transform.position, barrel4.rotation);

            p1.InitBullet(barrel1.transform.forward * 10); // launches the bullet on each barrel forward
            p2.InitBullet(barrel2.transform.forward * 10);
            p3.InitBullet(barrel3.transform.forward * 10);
            p4.InitBullet(barrel4.transform.forward * 10);

            cooldownShoot = 1 / roundsPerSecond; // resets the cooldown timer
        }
Пример #8
0
        public void Die()                 // Method runs when an enemy's health reaches or passes 0
        {
            Destroy(gameObject);          // Destroys the dead enemy

            if (gameObject == boss)       // If dead enemy is the boss...
            {
                SoundBoard.PlayBossDie(); // Play boss death sound

                nextLevelTimer = 4;       // Sets the time until the game ends after beating the boss
                if (nextLevelTimer <= 0)  // If timer has reached 0
                {
                    Game.GotoNextLevel(); // Go to next level
                }
            }

            if (gameObject == turret)       // If dead enemy is a turret...
            {
                SoundBoard.PlayTurretDie(); // Play turret death sound
            }
        }
Пример #9
0
        // Health behavior:
        public void TakeDamage(float amt)
        {
            if (cooldownInvulnerability > 0)
            {
                return;                     // still have i-frames, dont take damage
            }
            cooldownInvulnerability = .25f; // cooldown till you can take damage
            amt = BadBullet.damageAmount;
            if (amt < 0)
            {
                amt = 0;                  // Negative numbers ignored
            }
            damageTaken = true;           // Tells the game that the player took damage

            if (shielding)                // If player is shielding...
            {
                currShieldHealth -= amt;  // Deal damage to the shield
                SoundBoard.PlayPlayerDamage();
                if (currShieldHealth < 1) // If shield health is below 1...
                {
                    SoundBoard.PlayPlayerShieldOff();
                    currentHealthState = HealthState.Regular; // Switch back to Regular HealthState
                    shielding          = false;               // Turn off shield
                }
            }
            else
            {
                health -= amt; // If not shielding, deal damage to player health
                SoundBoard.PlayPlayerDamage();
            }

            //if (health > 0) SoundEffectBoard.PlayDamage(); // plays damage audio
            if (health <= 0)
            {
                Die(); // if health drops to/below zero do Die method
                //SoundEffectBoard.PlayDie(); // plays death audio
            }
            damageTaken = false; // Player no longer taking damage
        }
Пример #10
0
 /// <summary>
 /// This function moves the player while they are dashing
 /// </summary>
 private void DashThePlayer()
 {
     pawn.Move(dashDirection * Time.deltaTime * 2.5f * dashSpeed); // Calculates where to dash the player and how fast
     SoundBoard.PlayPlayerDash();                                  // Play the Dash sound
 }
Пример #11
0
        void Update()
        {
            FollowPlayer();
            AimAtMouse();

            batteryValue = currBattery; // Sets the batteryValue to the tracked current battery

            if (timerSpawnBullet > 0)
            {
                timerSpawnBullet -= Time.deltaTime; // if the timer is GREATER THAN 0, countdown the timer
            }
            switch (currentPodState)                // State Switcher
            {
            case PodState.Regular:                  // Regular State: Follows player, depletes battery
                // Behavior
                currBattery   -= Time.deltaTime;    // Battery drops over time
                podStatus.text = ("ONLINE");        // UI tells player the pod is online

                // Transition
                if (Input.GetButton("Fire1"))
                {
                    currentPodState = PodState.Shooting;
                }                                         // If player presses "Left Click", switch to Shooting state
                if (Input.GetButtonDown("FollowerPower")) // If player presses "F"...
                {
                    SoundBoard.PlayPlayerShieldOff();     // Play Player Shield Off Sound
                    currentPodState = PodState.Charging;  // Switch to charging state
                }

                if (currBattery <= batteryMin)           // if current battery is LESS THAN or EQUAL TO minimum battery...
                {
                    SoundBoard.PlayPlayerShieldOff();    // Play player shield off sound
                    currentPodState = PodState.Charging; // switch to charging state
                }

                break;

            case PodState.Shooting:            // Shooting State: Follows player, Shoots when player shoots, depletes battery
                // Behavior
                currBattery -= Time.deltaTime; // battery drops over time
                SpawnGoodBullet();
                podStatus.text = ("FIRING");   // UI tells player the pod is firing

                // Transition
                if (!Input.GetButton("Fire1"))
                {
                    currentPodState = PodState.Regular;
                }                                        // If player is not left clicking, switch to regular state

                if (currBattery <= batteryMin)           // if current battery is LESS THAN or EQUAL TO minimum battery...
                {
                    SoundBoard.PlayPlayerShieldOff();    // Player player shield off sound
                    currentPodState = PodState.Charging; // switch to charging state
                }

                break;

            case PodState.Charging:                     // Charging State: Follows player, charges battery
                // Behavior
                currBattery   += Time.deltaTime * 1.5f; // current battery increases over time
                podStatus.text = ("CHARGING");          // UI tells player the pod is charging

                // Transition
                if (Input.GetButtonDown("FollowerPower")) // If player presses "F"
                {
                    SoundBoard.PlayPlayerShieldOn();      // Play player shield on sound
                    currentPodState = PodState.Regular;   // Switch to regular state
                }

                if (currBattery >= batteryMax)
                {
                    currentPodState = PodState.Off;
                }                                                                      // If current battery is GREATER THAN or EQUAL TO maximum battery, switch to Off state

                break;

            case PodState.Off:                // Off State: Do nothing
                // Behavior
                podStatus.text = ("OFFLINE"); // UI tells player the pod is offline

                // Transition
                if (Input.GetButtonDown("FollowerPower")) // If player presses "F"
                {
                    SoundBoard.PlayPlayerShieldOn();      // Play player shield on sound
                    currentPodState = PodState.Regular;   // Switch to regular state
                }

                break;
            }
        }
Пример #12
0
        void Update()
        {
            EnemyHealth health = TripleB.GetComponentInParent <EnemyHealth>(); // Gets a reference to the EnemyHealth class for access to the health variable

            currHealth  = health.health;                                       // Tracks the boss' current health in the Enemy State script is makes it accessible here
            healthValue = currHealth;                                          // sets the healthValue to the players current health to be communicated to the UI

            if (currHealth <= 50)
            {
                currHealth = 0f; healthDisplayText.text = "0%";
            }

            if (cooldownShoot > 0)               // If cooldown is GREATER THAN 0...
            {
                cooldownShoot -= Time.deltaTime; // count down the cooldown timer
            }

            switch (currentBossState) // State Switcher
            {
            case BossState.Idling:    // Idle State: No Actions
                // Transitions
                if (battleBegun)
                {
                    currentBossState = BossState.Attacking;
                }                                                                // If player triggers battleBegun box, switch to attacking state

                break;

            case BossState.Attacking:     // Attack State: Tracking and Shooting at Player
                // Behavior
                FollowPlayer();
                ShootPlayer();

                // Transitions
                if (currHealth <= rageTrigger)
                {
                    currentBossState = BossState.Raging;
                }                                                                           // If current health is LESS THAN or EQUAL TO the rage trigger, switch to raging state
                break;

            case BossState.SummoningPillar:     // Summoning Pillar State: Summons Pillar(s) to obstruct players movement and line of sight
                // Behavior


                // Transitions


                break;

            case BossState.SummoningTurrets:     // Summoning Turret State: Summons Turret(s) to attack player
                // Behavior


                // Transitions


                break;

            case BossState.Spinshotting:     // Spinshotting State: Boss begins spinning rapidly while shooting at a higher rate of fire
                // Behavior
                FollowPlayer();

                // Transitions


                break;

            case BossState.Raging:                  // Raging State: Boss enters an infinite Spinshotting state after reaching a health threshold
                // Behavior
                if (!isRaging)                      // If NOT raging...
                {
                    SoundBoard.PlayBossRageMusic(); // Begin playing boss rage music
                    isRaging        = true;         // tells game the boss is in rage mode
                    roundsPerSecond = 12;           // Increases rate of fire
                    roundsInClipMax = 50;           // Increases max ammo in clip
                }

                FollowPlayer();
                ShootPlayer();

                break;
            }
        }