Beispiel #1
0
    //  Cuando el jugador muere
    public void playerDied(string playerTag)
    {
        //buscamos el objeto stats
        StatCounter stats = GameObject.Find("Stats").GetComponent <StatCounter>();

        //y llamamos el metodo LostLife
        stats.LostLife(playerTag);

        if (stats.getLives(playerTag) > 0)
        {
            if (playerTag == "Player1")//lo reaparecemos
            {
                GameObject.FindWithTag(playerTag).GetComponent <PlayerController>().Respawn();
            }
            else if (playerTag == "Player2")//lo reaparecemos
            {
                GameObject.FindWithTag(playerTag).GetComponent <PlayerController1>().Respawn();
            }
        }
        else if (stats.singlePlayer)
        {
            LoadLevel("Lose");
        }
        else
        {
            LoadLevel("Win");
        }
    }