using System.Collections; using System.Collections.Generic; using TMPro; using Unity.Mathematics; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; using Valve.VR.InteractionSystem; public class Fruits : MonoBehaviour { public GameObject applePNG; public GameObject bananaPNG; public GameObject cherryPNG; public GameObject cheesePNG; public GameObject melonPNG; public GameObject timer; public Canvas winningScreen; public Canvas HUD; public Texture foundAppleTXT; public Texture foundBananaTXT; public Texture foundCherryTXT; public Texture foundCheeseTXT; public Texture foundMelonTXT; public Texture noAppleTXT; public Texture noBananaTXT; public Texture noCherryTXT; public Texture noCheeseTXT; public Texture noMelonTXT; public GameObject apple; public GameObject banana; public GameObject cheese; public GameObject cherry; public GameObject melon; public bool isAppleCollected; public bool isBananaCollected; public bool isCheeseCollected; public bool isCherryCollected; public bool isMelonCollected; public float time; void Start() { HUD.enabled = true; time = 300; winningScreen.enabled = false; isAppleCollected = false; isBananaCollected = false; isCherryCollected = false; isCheeseCollected = false; isMelonCollected = false; applePNG.GetComponent().texture = noAppleTXT; bananaPNG.GetComponent().texture = noBananaTXT; cheesePNG.GetComponent().texture = noCheeseTXT; cherryPNG.GetComponent().texture = noCherryTXT; melonPNG.GetComponent().texture = noMelonTXT; } // Update is called once per frame void Update() { if(isAppleCollected) { applePNG.GetComponent().texture = foundAppleTXT; } if (isBananaCollected) { bananaPNG.GetComponent().texture = foundBananaTXT; } if (isCheeseCollected) { cheesePNG.GetComponent().texture = foundCheeseTXT; } if (isCherryCollected) { cherryPNG.GetComponent().texture = foundCherryTXT; } if (isMelonCollected) { melonPNG.GetComponent().texture = foundMelonTXT; } int minutes = Mathf.FloorToInt(time / 60F); int seconds = Mathf.FloorToInt(time - minutes * 60); string niceTime = string.Format("{0:0}:{1:00}", minutes, seconds); timer.GetComponent().text = niceTime; time = time - Time.deltaTime; if (isAppleCollected && isBananaCollected && isCheeseCollected && isCherryCollected && isMelonCollected) { winningScreen.enabled=true; HUD.enabled = false; } if (time <= 0) { winningScreen.enabled = true; HUD.enabled = false; } } }