Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        thePlayerBody = FindObjectOfType <PlayerController>();
        thePlayerHead = FindObjectOfType <PlayerHeadController>();
        theYogurt     = FindObjectOfType <Yogurt>();

        if (PlayerPrefs.HasKey("CoinCount"))
        {
            coinCount = PlayerPrefs.GetInt("CoinCount");
        }
        else
        {
            coinCount = 0;
        }
        if (PlayerPrefs.HasKey("YogurtCount"))
        {
            yogurtCount = PlayerPrefs.GetInt("YogurtCount");
        }
        else
        {
            yogurtCount = 0;
        }
        if (PlayerPrefs.HasKey("InfinityCount"))
        {
            infinityCount = PlayerPrefs.GetInt("InfinityCount");
        }
        else
        {
            infinityCount = -1;
        }
        if (PlayerPrefs.HasKey("PlayerLives"))
        {
            currentLives = PlayerPrefs.GetInt("PlayerLives");
        }
        else
        {
            currentLives = startingLives;
        }
        coinText.text   = coinCount.ToString();
        yogurtText.text = yogurtCount.ToString();
        livesText.text  = livesCount.ToString();

        healthCount = maxHealth;
//         infinityCount = -1;

        objectsToReset = FindObjectsOfType <ResetOnRespawn>();
//         currentLives = startingLives;
        livesText.text = currentLives.ToString();
    }
Ejemplo n.º 2
0
 private IEnumerator SetPlayerHead()
 {
     while (playerHead == null)
     {
         GameObject[] headObjs = GameObject.FindGameObjectsWithTag("Head");
         foreach (GameObject obj in headObjs)
         {
             PlayerHeadController player = obj.GetComponent <PlayerHeadController>();
             if (player.enabled)
             {
                 playerHead = player;
             }
         }
         yield return(new WaitForSeconds(1f));
     }
 }