Ejemplo n.º 1
0
    public IEnumerator Kill()
    {
        // Plays anim
        GetComponentInParent <PlayerControl>().enabled = false;
        stats.isAlive = false;
        GetComponentInParent <Rigidbody2D>().bodyType = RigidbodyType2D.Static;
        PlayerAnim.PlayDeath();

        // The rest of function will continue as deathDuration passes
        yield return(new WaitForSeconds(stats.deathDuration));

        if (stats.allowRespawn)
        {
            LevelLoader.ReloadScene();
            PlayerAnim.PlayRespawn();
            GetComponentInParent <PlayerControl>().enabled = true;
            GetComponentInParent <Rigidbody2D>().bodyType  = RigidbodyType2D.Dynamic;
            transform.parent.position = stats.spawnPoint;
            hp = stats.maxHP;
            //stats.isAlive = true;
        }
    }