107 lines
3.1 KiB
C#
107 lines
3.1 KiB
C#
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<RawImage>().texture = noAppleTXT;
|
|
bananaPNG.GetComponent<RawImage>().texture = noBananaTXT;
|
|
cheesePNG.GetComponent<RawImage>().texture = noCheeseTXT;
|
|
cherryPNG.GetComponent<RawImage>().texture = noCherryTXT;
|
|
melonPNG.GetComponent<RawImage>().texture = noMelonTXT;
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(isAppleCollected)
|
|
{
|
|
applePNG.GetComponent<RawImage>().texture = foundAppleTXT;
|
|
}
|
|
if (isBananaCollected)
|
|
{
|
|
bananaPNG.GetComponent<RawImage>().texture = foundBananaTXT;
|
|
}
|
|
if (isCheeseCollected)
|
|
{
|
|
cheesePNG.GetComponent<RawImage>().texture = foundCheeseTXT;
|
|
}
|
|
if (isCherryCollected)
|
|
{
|
|
cherryPNG.GetComponent<RawImage>().texture = foundCherryTXT;
|
|
}
|
|
if (isMelonCollected)
|
|
{
|
|
melonPNG.GetComponent<RawImage>().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<TextMeshProUGUI>().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;
|
|
}
|
|
}
|
|
|
|
}
|