Example #1
0
    private void Die()
    {
        // Turn off enemies, harmful objects and enemy spawners
        EnemySpawnerHoming[] spawners = transform.GetComponentsInChildren <EnemySpawnerHoming>();
        foreach (EnemySpawnerHoming esp in spawners)
        {
            esp.enabled = false;
        }

        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
        foreach (GameObject go in enemies)
        {
            go.GetComponent <EnemyShipHoming>().HitByPlayer();
        }

        AuxFunctions.DestroyGameObjectsWithTag("BossBeam");
        AuxFunctions.DestroyGameObjectsWithTag("BossWeakSpot");

        StartCoroutine(AuxFunctions.ShakeCamera(1, 3));

        // You win animation
        GameObject.FindGameObjectWithTag("GameController").GetComponent <Animator>().SetTrigger("win");

        GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>().WaitAndReload(4);

        // Stop this script
        this.enabled = false;
    }
Example #2
0
    void Die()
    {
        // Stop moving
        rb.velocity = new Vector2(0, 0);

        // Turn off enemies, harmful objects and enemy spawners
        EnemySpawnerHoming[] spawners = transform.GetComponentsInChildren <EnemySpawnerHoming>();
        foreach (EnemySpawnerHoming esp in spawners)
        {
            esp.enabled = false;
        }

        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
        foreach (GameObject go in enemies)
        {
            go.GetComponent <EnemyShipHoming>().HitByPlayer();
        }

        AuxFunctions.DestroyGameObjectsWithTag("BossBeam");
        AuxFunctions.DestroyGameObjectsWithTag("BossWeakSpot");

        // Animate death
        animator.SetTrigger("close");
        audioSource.PlayOneShot(deathAudio);
        Instantiate(deathEffect, transform.position, new Quaternion());
        StartCoroutine(AuxFunctions.ShakeCamera(1, 3));

        // You win animation
        GameObject.FindGameObjectWithTag("GameController").GetComponent <Animator>().SetTrigger("win");

        GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>().WaitAndReload(4);

        // Stop this script
        this.enabled = false;
    }