using System.Collections; using System.Collections.Generic; using JetBrains.Annotations; using Unity.VisualScripting; using UnityEngine; //* General Comments or Finished Tasks //TODO Tasks left to be done for game //! Bugs or Issues //? Questions or Suggestions //TODO Moles need to change textures when hit to show they have been hit - need textures for this //* As the time goes on, moles appear and disappear faster //* Moles that are hit slowly move down into their hole //TODO Ajust the speed of the moles appearing and disappearing based on the time remaining public class Moles : MonoBehaviour { public GameObject hole1, hole2, hole3, hole4, hole5, hole6, hole7, hole8, hole9; public GameObject mole; private float defaultSpeed = 10f; public float timerSpeed; public float lifeTime = 4f; public float timerlifeTime; public bool moleCanAppear = false; public int randomHole, randomHole2, randomHole3; public Timer timer; //* Start is called before the first frame update void Start() { moleCanAppear = true; } //* Update is called once per frame void Update() { timerSpeed = defaultSpeed * (timer.timeRemaining/120); timerlifeTime = lifeTime * (timer.timeRemaining/120); if(moleCanAppear) { randomHole = Random.Range(1, 9); randomHole2 = Random.Range(1, 9); while(randomHole2 == randomHole) { randomHole2 = Random.Range(1, 9); } randomHole3 = Random.Range(1, 9); while(randomHole3 == randomHole || randomHole3 == randomHole2) { randomHole3 = Random.Range(1, 9); } moleCanAppear = false; holeSelection(randomHole); holeSelection(randomHole2); holeSelection(randomHole3); StartCoroutine(MoleTimer()); } } void holeSelection(int randomHole) { //* Prevent the same hole from being selected twice switch (randomHole) { case 1: var boxLocation = Instantiate(mole, hole1.transform.position, Quaternion.identity); Destroy(boxLocation, timerlifeTime); break; case 2: var boxLocation2 = Instantiate(mole, hole2.transform.position, Quaternion.identity); Destroy(boxLocation2, timerlifeTime); break; case 3: var boxLocation3 = Instantiate(mole, hole3.transform.position, Quaternion.identity); Destroy(boxLocation3, timerlifeTime); break; case 4: var boxLocation4 = Instantiate(mole, hole4.transform.position, Quaternion.identity); Destroy(boxLocation4, timerlifeTime); break; case 5: var boxLocation5 = Instantiate(mole, hole5.transform.position, Quaternion.identity); Destroy(boxLocation5, timerlifeTime); break; case 6: var boxLocation6 = Instantiate(mole, hole6.transform.position, Quaternion.identity); Destroy(boxLocation6, timerlifeTime); break;; case 7: var boxLocation7 = Instantiate(mole, hole7.transform.position, Quaternion.identity); Destroy(boxLocation7, timerlifeTime); break; case 8: var boxLocation8 = Instantiate(mole, hole8.transform.position, Quaternion.identity); Destroy(boxLocation8, timerlifeTime); break; case 9: var boxLocation9 = Instantiate(mole, hole9.transform.position, Quaternion.identity); Destroy(boxLocation9, timerlifeTime); break; } } IEnumerator MoleTimer() { yield return new WaitForSeconds(timerSpeed); moleCanAppear = true; } }