Example #1
0
    //this gets called by the Damage IEnumerator in this script
    public IEnumerator Death()
    {
        alive          = false;
        lives         -= 1;
        hud.lives     -= 1;
        allKnow.lives -= 1;
        deathSpot      = transform.position;

        if (lives <= 0)
        {
            Caching.CleanCache();
            Application.Quit();
            //UnityEditor.EditorApplication.isPlaying = false;
        }

        if (checkPoint)
        {
            StartCoroutine(checkPoint.ResetToCheckPoint());
        }

        death.Play();
        StartCoroutine(weaponDetectorScript.DestroyHeld());
        StartCoroutine(weaponDetectorScript.CatalogWeapons());
        StartCoroutine(weaponDetectorScript.Distract());
        StartCoroutine(weaponDetectorScript.StopChargeNoise());
        StartCoroutine(chargeDisplay.StopCharger());
        StartCoroutine(chargeDisplay.ResetAnimation());
        StartCoroutine(ReverseCrouch());

        getDamage.enabled    = false;
        spriteHero.enabled   = false;
        spriteArm.enabled    = false;
        spriteShield.enabled = false;
        spriteHammer.enabled = false;

        rigidbody2D.velocity          = new Vector2(0f, 0f);
        rigidbody2D.gravityScale      = 0f;
        weaponCol.enabled             = false;
        shieldCol.enabled             = false;
        weaponDetectorScript.occupied = true;

        if (GetComponent <Unfreeze> ())
        {
            Component.Destroy(gameObject.GetComponent <Unfreeze>());
        }

        foreach (Collider2D col in GetComponents <Collider2D>())
        {
            col.enabled = false;
        }

        runningSpeed = 0f;
        jumpSpeed    = 0f;
        fallSpeed    = 0f;
        maxVelocity  = Vector2.zero;
        rigidbody2D.Sleep();
        locationFreeze = true;

        yield return(new WaitForSeconds(time2Respawn));

        StartCoroutine(Rebirth());
        if (Application.loadedLevelName == "HeliRoom")
        {
            HeliRoom heliRoom = GameObject.Find("HeliRoom_Manager").GetComponent <HeliRoom>();
            StartCoroutine(heliRoom.SpawnCopters());
        }
    }