Unity: Added Folders

Catch: Started Code on Catch Game - Objects spawn and player can catch. Comments on progress and next steps
This commit is contained in:
Santi 2024-06-25 00:34:49 +01:00
parent d19aba3a72
commit d37e365d0e
13 changed files with 20 additions and 478 deletions

View File

@ -1,50 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
//* General Comments or Finished Tasks
//TODO Tasks left to be done for game
//! Bugs or Issues
//? Questions or Suggestions
public class BoxTeleport : MonoBehaviour
{
private GameObject currentContainer;
public int waitTime = 3;
public TextMeshProUGUI scoreText;
private int score;
void Start()
{
scoreText.text = "Score: 0";
}
private void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Container")
{
currentContainer = other.gameObject;
//* If the box is not the same colour as the container, teleport the box after a few seconds
if(currentContainer.gameObject.GetComponentInParent<Renderer>().material.name == gameObject.GetComponent<Renderer>().material.name)
{
gameObject.transform.position = new Vector3(Random.Range(10, -10), 15, Random.Range(-10, 10));
score =+ 1;
scoreText.text = "Score: " + score;
}
else
{
StartCoroutine(BoxSpawn());
}
}
}
//* Teleport the box to a random location in the air
IEnumerator BoxSpawn()
{
yield return new WaitForSeconds(waitTime);
gameObject.transform.position = new Vector3(Random.Range(10, -10), 15, Random.Range(-10, 10));
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b82d7abf31c7ee246af2125333411a70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Unity.VisualScripting;
using UnityEngine;
//* General Comments or Finished Tasks
//TODO Tasks left to be done for game
//! Bugs or Issues
//? Questions or Suggestions
public class Colours : MonoBehaviour
{
public GameObject Box;
public GameObject[] containers;
public List<Material> materials = new List<Material>();
private GameObject currentBox;
private int num;
//* Start is called before the first frame update
void Start()
{
//* Instantiate 8 containers with random colours at the start of the game
for (int i = 0; i < containers.Length; i++)
{
currentBox = Instantiate(Box, new Vector3(Random.Range(10, -10), 15, Random.Range(-10, 10)), Quaternion.identity);
num = Random.Range(0, materials.Count);
currentBox.GetComponent<Renderer>().material = materials[num];
containers[i].GetComponent<Renderer>().material = materials[num];
materials.RemoveAt(num);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f07fa7e7d67ec954ca9474c2da335e60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,80 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using TMPro;
using UnityEngine;
//* General Comments or Finished Tasks
//TODO Tasks left to be done for game
//! Bugs or Issues
//? Questions or Suggestions
//* Prevent player from moving when they are hitting the moles
public class Hamor : MonoBehaviour
{
public Animator hamorAnimator;
public GameObject bonkParticles;
public GameObject contact;
public bool particles = false;
public TextMeshProUGUI scoreText;
public int score = 0;
public Moles_IsHit moles;
public Movement movement;
//* Start is called before the first frame update
void Start()
{
}
//* Update is called once per frame
void Update()
{
if(Input.GetMouseButtonDown(0))
{
movement.hammer = true;
hamorAnimator.SetTrigger("Bonk"); //* Play the bonk animation
StartCoroutine(MoveTimer());
}
}
IEnumerator MoveTimer()
{
yield return new WaitForSeconds(1);
movement.hammer = false;
}
IEnumerator BonkTimer()
{
yield return new WaitForSeconds(1);
particles = false;
}
private void OnTriggerEnter(Collider other) {
if(particles == false)
{
if(other.tag != "Player")
{
//* Play the bonk particles
var parLocation = Instantiate(bonkParticles, contact.transform.position, Quaternion.identity);
Destroy(parLocation, 1);
particles = true;
StartCoroutine(BonkTimer());
}
}
if(other.gameObject.tag == "Mole")
{
//* Get the Moles_IsHit script from the mole
moles = other.gameObject.GetComponent<Moles_IsHit>();
//* If the mole has not been hit, increase the score and change bool
if(moles.IsHit == false)
{
score += 1;
scoreText.text = "Score: " + score.ToString();
moles.IsHit = true;
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 388458319b483a949a166a07083c9590
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,110 +0,0 @@
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;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2a05eee06c231ea4f849ab3415485fe1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,28 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//* General Comments or Finished Tasks
//TODO Tasks left to be done for game
//! Bugs or Issues
//? Questions or Suggestions
public class Moles_IsHit : MonoBehaviour
{
public bool IsHit;
//* Start is called before the first frame update
void Start()
{
IsHit = false; //* Mole starts as not being hit
}
//* 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

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: cd50fe78e80ef7046a1452af2b97de93
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,101 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.UIElements;
//* General Comments or Finished Tasks
//TODO Tasks left to be done for game
//! 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
public bool insideTrigger = false; // checks if player is inside the trigger of a pickup object
public bool playerIsCarrying = false; // checks if player is carrying an object
public GameObject nearestCarriableObject;
public GameObject previousObject; // previous object that player was carrying
public GameObject heldObject; // object that player is currently holding
public float throwForce;
/// <summary>
/// Cooldown time between picking up objects in seconds
/// </summary>
public float cooldownSeconds = 1;
public bool cooldownActive = true;
public KeyCode interactKey = KeyCode.F;
// Update is called once per frame
void Update()
{
// * Cubes are quite hot so need time to cool off
cooldownSeconds -= Time.deltaTime;
cooldownActive = cooldownSeconds > 0;
// * Old objects deserve gravity too
if(previousObject != null && previousObject.GetComponent<Rigidbody>().useGravity == false)
{
previousObject.GetComponent<Rigidbody>().useGravity = true;
}
if(insideTrigger && Input.GetKeyDown(KeyCode.F) && !cooldownActive)
{
// * Who needs gravity
nearestCarriableObject.GetComponent<Rigidbody>().useGravity = false;
playerIsCarrying = true;
heldObject = nearestCarriableObject;
cooldownSeconds = 1;
}
// * YEET
else if(playerIsCarrying && Input.GetKeyDown(KeyCode.F))
{
heldObject.GetComponent<Rigidbody>().useGravity = true;
previousObject = heldObject;
playerIsCarrying = false;
previousObject.GetComponent<Rigidbody>().AddForce(transform.forward * throwForce, ForceMode.Impulse);
Debug.Log("Yoted!");
}
// * Cubes not stored above heads are highly dangerous
if(playerIsCarrying)
{
nearestCarriableObject.transform.position = carryPosition.transform.position;
nearestCarriableObject.transform.rotation = carryPosition.transform.rotation;
}
}
//* Called when the player is inside a trigger tagged as PickupObject
void OnTriggerStay(Collider otherObject)
{
if(otherObject.gameObject.tag == "PickupObject" && !cooldownActive)
{
nearestCarriableObject = otherObject.gameObject;
insideTrigger = true;
// * old cube is boring
if(heldObject != null && heldObject != nearestCarriableObject && playerIsCarrying)
{
previousObject = heldObject;
cooldownSeconds = 1;
}
}
}
//* If player is not inside trigger, then they probably aren't inside it
void OnTriggerExit(Collider otherObject)
{
if(otherObject.gameObject.tag == "PickupObject")
{
insideTrigger = false;
}
}
}
//! To make player launch self:
//! add public GameObject player; and place player in it fron inspector
//! in if(insiderTrigger && Input.GetKeyDown(KeyCode.F))
//! Place the code below:
//! player.GetComponent<Rigidbody>().AddForce(transform.forward * throwForce, ForceMode.Impulse);
//! Run the game and press F to launch the player

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: eca94ba4e2f880644ab196f816624ee6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -22,7 +22,7 @@ By Arlo Filley, Santiago Balbuena Goni, and Michael Morbin
- [Concept](#concept) - [Concept](#concept)
- [Mini-Game Concepts](#mini-game-concepts) - [Mini-Game Concepts](#mini-game-concepts)
- [Types](#types) - [Types](#types)
- [Mini-Games](#mini-games) - [Games](#games)
- [Art \& Audio](#art--audio) - [Art \& Audio](#art--audio)
- [By Mikael Morbid](#by-mikael-morbid) - [By Mikael Morbid](#by-mikael-morbid)
- [Design](#design) - [Design](#design)
@ -34,7 +34,7 @@ By Arlo Filley, Santiago Balbuena Goni, and Michael Morbin
- [References](#references) - [References](#references)
- [Websites](#websites) - [Websites](#websites)
- [Software](#software) - [Software](#software)
- [Games](#games) - [Games](#games-1)
# Introduction # Introduction
@ -165,15 +165,25 @@ Minigames will range in type and genre giving the player a diverse playing exper
### Types ### Types
- Memory Games * Memory Games
- Reaction Games * Reaction Games
- Puzzle Games * Puzzle Games
- Rhythm * Rhythm
### Games
* Dodging (Undertale style?)
* Whackamole
* Catch
* Beating With Sticks
* Sorting
* Centre Balance
* Conveyors
* Defend!
* Jump Rope
* Parkour
* QuickShot
### Mini-Games
- Dodging (Undertale style?)
- Whackamole
- Catch
# Art & Audio # Art & Audio
### By Mikael Morbid ### By Mikael Morbid