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 public class Moles : MonoBehaviour { public GameObject hole1, hole2, hole3, hole4, hole5, hole6, hole7, hole8, hole9; public GameObject mole; private float defaultSpeed = 10f; public float lifeTime = 5f; public bool moleCanAppear = false; public int randomHole, randomHole2, randomHole3; //* Start is called before the first frame update void Start() { moleCanAppear = true; } //* Update is called once per frame void Update() { 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, lifeTime); break; case 2: var boxLocation2 = Instantiate(mole, hole2.transform.position, Quaternion.identity); Destroy(boxLocation2, lifeTime); break; case 3: var boxLocation3 = Instantiate(mole, hole3.transform.position, Quaternion.identity); Destroy(boxLocation3, lifeTime); break; case 4: var boxLocation4 = Instantiate(mole, hole4.transform.position, Quaternion.identity); Destroy(boxLocation4, lifeTime); break; case 5: var boxLocation5 = Instantiate(mole, hole5.transform.position, Quaternion.identity); Destroy(boxLocation5, lifeTime); break; case 6: var boxLocation6 = Instantiate(mole, hole6.transform.position, Quaternion.identity); Destroy(boxLocation6, lifeTime); break;; case 7: var boxLocation7 = Instantiate(mole, hole7.transform.position, Quaternion.identity); Destroy(boxLocation7, lifeTime); break; case 8: var boxLocation8 = Instantiate(mole, hole8.transform.position, Quaternion.identity); Destroy(boxLocation8, lifeTime); break; case 9: var boxLocation9 = Instantiate(mole, hole9.transform.position, Quaternion.identity); Destroy(boxLocation9, lifeTime); break; } } IEnumerator MoleTimer() { yield return new WaitForSeconds(defaultSpeed); moleCanAppear = true; } }