// Update is called once per frame void Update() { updateTileCounter(); if (levels[currentLevel].limitMoves == 0) //infinite moves if no limit is set { movesText.text = "\u221E"; //set text to infinite symbol } else //when limit is set { movesText.text = moveCounter.ToString(); //set text to move counter if (moveCounter < 1 && (clearTiles == false || hm.currentHealth < 100)) //trigger game lost if out of moves to clear criteria { display.DisplayDeathUI(); } } }
private void CheckState() //function to do things according to the state of the health { if (currentHealth >= 100 && criteria.clearTiles == true) //if currentHealth is greater than 100 and tile criteria is cleared, it means that the player won { display.DisplayWinUI(); //displays the Win UI if (criteria.currentLevel + 1 == Player.m3unlockedlevels) //check if playing level is same as unlocked level { if (Player.m3unlockedlevels < 6) //when completing levels 1-5 { Player.coins += 10; //award 10 coins for passing level (one time claim) Debug.Log("You got 10 coins for winning this level!"); StartCoroutine(Login.UpdateCoins()); coinsChange = true; } else if (Player.m3unlockedlevels < 11) //when completing levels 6-10 { Player.coins += 30; //award 30 coins for passing level (one time claim) Debug.Log("You got 30 coins for winning this level!"); StartCoroutine(Login.UpdateCoins()); coinsChange = true; } else if (Player.m3unlockedlevels < 16) //when completing levels 11-15 { Player.coins += 50; //award 50 coins for passing level (one time claim) Debug.Log("You got 50 coins for winning this level!"); StartCoroutine(Login.UpdateCoins()); coinsChange = true; } else if (Player.m3unlockedlevels < 21) //when completing levels 16-20 { Player.coins += 60; //award 60 coins for passing level (one time claim) Debug.Log("You got 60 coins for winning this level!"); StartCoroutine(Login.UpdateCoins()); coinsChange = true; } else if (Player.m3unlockedlevels < 26) //when completing levels 21-25 { if (Player.m3unlockedlevels == 25) { Player.dateEndM3 = System.DateTime.Now; Player.m3Duration = (Player.dateEndM3 - Player.dateStartM3).ToString(); } Player.coins += 80; //award 80 coins for passing level (one time claim) Debug.Log("You got 80 coins for winning this level!"); StartCoroutine(Login.UpdateCoins()); coinsChange = true; } Player.m3unlockedlevels += 1; //increase unlocked level Player.Save(); StartCoroutine(Login.UpdateCoins()); StartCoroutine(Login.UpdateLives()); } } else if (currentHealth < 1) //if currentHealth is lesser than 1, meaning 0, it means that the player lost { display.DisplayDeathUI(); //displays the Death UI } else if (currentHealth < min_neutralHealth && currentHealth > 1) //red health, sick state { healthState = HealthStates.Sick; //nm.DisplayNotification(0); sr.sprite = sprites[0]; bannerSleep.SetActive(true); bannerEat.SetActive(false); bannerRun.SetActive(false); SetBoolActiveSleep(); SetBoolInactiveRun(); SetBoolInactiveEat(); if (!audiosrc.isPlaying) { audiosrc.Play(); } } else if (currentHealth >= min_neutralHealth && currentHealth < min_healthyHealth) //yellow health, neutral health { healthState = HealthStates.Neutral; //nm.DisplayNotification(1); sr.sprite = sprites[1]; if (audiosrc.isPlaying) { audiosrc.Stop(); } bannerSleep.SetActive(false); bannerEat.SetActive(true); bannerRun.SetActive(false); SetBoolActiveEat(); SetBoolInactiveRun(); SetBoolInactiveSleep(); } else if (currentHealth >= min_healthyHealth && currentHealth < 100f) //green health, healthy state { healthState = HealthStates.Healthy; //nm.DisplayNotification(2); sr.sprite = sprites[2]; if (audiosrc.isPlaying) { audiosrc.Stop(); } bannerSleep.SetActive(false); bannerEat.SetActive(false); bannerRun.SetActive(true); SetBoolActiveRun(); SetBoolInactiveEat(); SetBoolInactiveSleep(); } SetBonus(healthState); }