Beispiel #1
0
    private IEnumerator Die()
    {
        isDead = true;

        var time = 1.5f;

        while (time > 0f)
        {
            time -= 0.1f;

            Instantiate(ExplodePrefab, gameObject.transform.position, Quaternion.identity);

            yield return(new WaitForSeconds(0.1f));
        }

        var sr = GetComponent <SpriteRenderer>();

        sr.enabled = false;

        yield return(new WaitForSeconds(0));

        GameUIObject.BlackOut(1f, 3f);

        yield return(new WaitForSeconds(1f));

        PlayerHealth       = 1000;
        sr.enabled         = true;
        HealthBox.text     = "Hull Integrity: " + (PlayerHealth / 10) + "%";
        transform.position = RespawnLocation;
        transform.rotation = Quaternion.AngleAxis(RespawnRotation, Vector3.forward);
        Camera.main.gameObject.transform.position = RespawnLocation;

        rigidbody2D.velocity        = Vector2.zero;
        rigidbody2D.angularVelocity = 0f;

        EnemyHealth = EnemyStartHealth;

        bool wasatboss = IsAtBoss;

        IsAtBoss = false;

        Destroy(CurrentEnemies);
        CurrentEnemies = Instantiate(EnemiesPrefab) as GameObject;

        yield return(new WaitForSeconds(1f));

        IsAtBoss = wasatboss;
        isDead   = false;
    }