Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (heatUp == true)
        {
            coolDown = false;

            if (!isPlayingSound)
            {
                bR_Audio.Play("LaserMelt");
                isPlayingSound = true;
            }

            MeltMetalWall();
        }

        else
        {
            coolDown = true;

            if (isPlayingSound)
            {
                bR_Audio.Stop("LaserMelt");
                isPlayingSound = false;
            }

            CoolMetalWall();
        }
    }
Ejemplo n.º 2
0
    public void RespawnPlayer()
    {
        // Kill all enemies in the scene before respawning the player
        EnemyPointValue[] enemies = GameObject.FindObjectsOfType <EnemyPointValue>();

        foreach (EnemyPointValue e in enemies)
        {
            e.enabled = false;
            Destroy(e.gameObject);
        }

        // Remove all bombs from the scene before respawning the player
        Bomb[] bombs = GameObject.FindObjectsOfType <Bomb>();

        foreach (Bomb b in bombs)
        {
            b.enabled = false;
            Destroy(b.gameObject);
        }

        // Stop the arena music if it is playing, and return to the level theme
        if (audioManager != null)
        {
            audioManager.Stop("ArenaMusic");
            audioManager.Stop("BombFuse");
            audioManager.Stop("BombBeep");
            audioManager.Stop("BombExplosion");
            audioManager.Play(SceneManager.GetActiveScene().name);
        }

        Time.timeScale = 1f;
        gamePaused     = false;
        DeathMenu.SetActive(false);

        Player.GetComponent <BR_MeleeAttacks>().RevertPlayerChargeMelee();

        if (currentCheckpoint == null)
        {
            // If the player has yet to reach a checkpoint (or no checkpoint exixts), reload the scene upon player death/respawn
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }

        else
        {
            if (Checkpoints.Length == 0)
            {
                Player.GetComponent <BR_PlayerHealth>().health = currentCheckpoint.GetComponent <StartCheckpoint>().currentHealth;
                currentCheckpoint.GetComponent <StartCheckpoint>().Reset();
                Player.transform.position = currentCheckpoint.transform.position;
            }
            else if (Checkpoints.Length > 0)
            {
                Player.GetComponent <BR_PlayerHealth>().health = currentCheckpoint.GetComponent <CheckpointScript>().currentHealth;
                currentCheckpoint.GetComponent <CheckpointScript>().Reset();
                Player.transform.position = currentCheckpoint.transform.position;
            }
            //Player.GetComponent<BR_PlayerHealth>().health = currentCheckpoint.GetComponent<CheckpointScript>().currentHealth;

            //currentCheckpoint.GetComponent<CheckpointScript>().Reset();
            //Player.transform.position = currentCheckpoint.transform.position;
        }

        Player.GetComponent <Damage>().damageTaken = damageTaken;
        Player.GetComponent <BR_PlayerHealth>().UpdateHealthPieces();
        Player.SetActive(true);
    }
Ejemplo n.º 3
0
    private void Explode()
    {
        Instantiate(bombExplosionEffect, transform.position, transform.rotation);

        // Get a list of all the objects within the blast radius upon detonation
        Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius);

        foreach (Collider c in colliders)
        {
            Rigidbody rb = c.GetComponent<Rigidbody>();
            Damage damage = c.GetComponent<Damage>();
            NormalWall wall = c.GetComponent<NormalWall>();
            BombNormalWall bombwall = c.GetComponent<BombNormalWall>();
            Bomb bomb = c.GetComponent<Bomb>();
            BR_PlayerHealth playerHealth = c.GetComponent<BR_PlayerHealth>();

            if (rb != null)
            {
                rb.AddExplosionForce(explosionForce, transform.position, explosionRadius);
            }

            if (damage != null)
            {
                // Player was caught in the explosion
                if (playerHealth != null)
                {
                    // Perform a raycast. Deal damage if no obstructions exist between the explosion and player.
                    RaycastHit hit;
                    if (Physics.Raycast(transform.position, c.transform.position - transform.position, out hit, explosionRadius))
                    {
                        if (hit.collider.gameObject.CompareTag("Wall"))
                        {
                            Debug.Log("Player was protected from a bomb explosion by a wall");
                        }

                        else
                        {
                            playerHealth.DamagePlayer(bombDamage);
                        }
                    }
                }

                // Some other object capable of taking damage was caught in the explosion
                else
                {
                    damage.UpdateDamage(bombDamage);
                }
            }

            if (bomb != null)
            {
                bomb.LightFuse(chainReactionDelay);
            }

            if (wall != null)
            {
                wall.isHit = true;
            }

            if (bombwall != null)
            {
                bombwall.bombwallisHit = true;
            }
        }

        // Play explosion SFX and destroy the object
        audioManager.Stop("BombFuse");
        audioManager.Stop("BombBeep");
        audioManager.Play("BombExplosion");
        hasExploded = true;

        Destroy(gameObject);
        
    }