WhackAMole: Moles now descend when hit. Timer affects the speed of moles. TODO comments added, completed tasks removed

ColourSorting: Removed completed tasks from Colours, added Bug comment to pickup script
This commit is contained in:
Santi 2024-06-13 02:19:12 +01:00
parent c39ff0c263
commit 170d11aa4d
5 changed files with 28 additions and 17 deletions

View File

@ -10,9 +10,6 @@ using UnityEngine;
//! Bugs or Issues
//? Questions or Suggestions
//* Cubes need to randomly fall from the sky within the play area at the start of the game,
//* when the player drops it in the right container teleport cube into random location in the air.
//* Containers need to be randomly allocated a colour at the start of the game
//TODO As the timer goes down, the containers have a chance to switch renders/colours
//! Somtimes boxes get thrown further than other times. Boxes also sometimes get thrown into random directions.

View File

@ -9,6 +9,7 @@ using UnityEngine;
//! Bugs or Issues
//? Questions or Suggestions
//TODO Prevent player from moving when they are hitting the moles
public class Hamor : MonoBehaviour
{
public Animator hamorAnimator;

View File

@ -11,15 +11,21 @@ using UnityEngine;
//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
//TODO Prevent player from moving when they are hitting the moles
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 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()
{
@ -29,6 +35,8 @@ public class Moles : MonoBehaviour
//* 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);
@ -58,46 +66,46 @@ public class Moles : MonoBehaviour
case 1:
var boxLocation = Instantiate(mole, hole1.transform.position, Quaternion.identity);
Destroy(boxLocation, lifeTime);
Destroy(boxLocation, timerlifeTime);
break;
case 2:
var boxLocation2 = Instantiate(mole, hole2.transform.position, Quaternion.identity);
Destroy(boxLocation2, lifeTime);
Destroy(boxLocation2, timerlifeTime);
break;
case 3:
var boxLocation3 = Instantiate(mole, hole3.transform.position, Quaternion.identity);
Destroy(boxLocation3, lifeTime);
Destroy(boxLocation3, timerlifeTime);
break;
case 4:
var boxLocation4 = Instantiate(mole, hole4.transform.position, Quaternion.identity);
Destroy(boxLocation4, lifeTime);
Destroy(boxLocation4, timerlifeTime);
break;
case 5:
var boxLocation5 = Instantiate(mole, hole5.transform.position, Quaternion.identity);
Destroy(boxLocation5, lifeTime);
Destroy(boxLocation5, timerlifeTime);
break;
case 6:
var boxLocation6 = Instantiate(mole, hole6.transform.position, Quaternion.identity);
Destroy(boxLocation6, lifeTime);
Destroy(boxLocation6, timerlifeTime);
break;;
case 7:
var boxLocation7 = Instantiate(mole, hole7.transform.position, Quaternion.identity);
Destroy(boxLocation7, lifeTime);
Destroy(boxLocation7, timerlifeTime);
break;
case 8:
var boxLocation8 = Instantiate(mole, hole8.transform.position, Quaternion.identity);
Destroy(boxLocation8, lifeTime);
Destroy(boxLocation8, timerlifeTime);
break;
case 9:
var boxLocation9 = Instantiate(mole, hole9.transform.position, Quaternion.identity);
Destroy(boxLocation9, lifeTime);
Destroy(boxLocation9, timerlifeTime);
break;
}
}
IEnumerator MoleTimer()
{
yield return new WaitForSeconds(defaultSpeed);
yield return new WaitForSeconds(timerSpeed);
moleCanAppear = true;
}
}

View File

@ -19,6 +19,10 @@ public class Moles_IsHit : MonoBehaviour
//* Update is called once per frame
void Update()
{
if(IsHit)
{
//* Slowly move the mole down into the hole
transform.position = new Vector3(transform.position.x, transform.position.y - 0.01f, transform.position.z);
}
}
}

View File

@ -11,6 +11,7 @@ using UnityEngine.UIElements;
//! Bugs or Issues
//? Questions or Suggestions
//! Somtimes boxes get thrown further than other times. Boxes also sometimes get thrown into random directions.
public class PickUpObject : MonoBehaviour
{
public GameObject carryPosition; // blank object, position declares where the object will be teleported to/carried
@ -72,7 +73,7 @@ public class PickUpObject : MonoBehaviour
}
}
// Called when the player is inside a trigger tagged as PickupObject
//* Called when the player is inside a trigger tagged as PickupObject
void OnTriggerStay(Collider otherObject)
{
if(otherObject.gameObject.tag == "PickupObject" && !cooldownActive)
@ -88,7 +89,7 @@ public class PickUpObject : MonoBehaviour
}
}
// If player is not inside trigger, then they probably aren't inside it
//* If player is not inside trigger, then they probably aren't inside it
void OnTriggerExit(Collider otherObject)
{
if(otherObject.gameObject.tag == "PickupObject")