
Added a Score to the Game Added an actual blackhole material and shader to the black hole Added a new Main menu and How to Play menu system Added Beam swords to all ships (replacing the light saber things the player had) Added a pause menu Overhauled the UI for the game scene Added List to hold the amount of core energy needed for each level Added the URP package for better rendering (apparently) Added a GameState enum to set which part of the game the player is in Added Magnet powerup to game Changed the way powerups are spawned, enemies now have a loot table Changed cores to core energy which is a percentage needed to pass a level Changed all the Ints to Hidden Value ints to maybe stop cheat engine users finding the important values Changed all level loads to use sceneloadasync Updated all of the materials to use URP shaders Removed Junk Files from external sources Rearranged the folders inside the unity project to try and reduce some name length issues
99 lines
3.5 KiB
C#
99 lines
3.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Base class used for the collision interactions between anything that isnt the blackhole, which has its own special class.
|
|
/// </summary>
|
|
public class ColliderManager : MonoBehaviour
|
|
{
|
|
protected AudioSource _attachedAudioSource;
|
|
|
|
/// <summary>
|
|
/// An enum to pass which direction the collision happened.
|
|
/// </summary>
|
|
public enum CollisionDirection
|
|
{
|
|
None,
|
|
Top,
|
|
Bottom
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
// Get the objects audio source, if one is present
|
|
_attachedAudioSource = gameObject.GetComponent<AudioSource>();
|
|
|
|
// Do any tasks the child has to process
|
|
DoAwakeTasks();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method to deal with Awake tasks that a child script needs since you can only have 1 awake between the parent and child.
|
|
/// </summary>
|
|
public virtual void DoAwakeTasks()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method to trigger the attached objects death without a collision but should simulate a collision
|
|
/// </summary>
|
|
public virtual void TriggerDeath()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Process the game objects collision.
|
|
/// </summary>
|
|
/// <param name="direction">Direction the collision happened, typically checking if hit from above or below.</param>
|
|
/// <param name="collision">Collision object holding the details on the collided object.</param>
|
|
/// <param name="wasChild">Was the hit collider a child of this game object.</param>
|
|
public virtual void ProcessCollision(CollisionDirection direction, Collision collision, bool wasChild)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Custom method to deal with child collisions on the game object, this was a test really and most likely wont be used in the final.
|
|
/// </summary>
|
|
/// <param name="collision"></param>
|
|
public void OnCollisionEnterChild(Collision collision)
|
|
{
|
|
DoCollisionEnter(collision, true);
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision collision)
|
|
{
|
|
DoCollisionEnter(collision);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Helper method to process the collision since when testing we needed to different collision detections.
|
|
/// </summary>
|
|
/// <param name="collision">Collider that we hit.</param>
|
|
/// <param name="wasChild">Check if it was a child that was hit.</param>
|
|
private void DoCollisionEnter(Collision collision, bool wasChild = false)
|
|
{
|
|
// Get the collided objects collision manager, if they dont have one then we ignore it since we only want objects to interact when they have to.
|
|
ColliderManager hitCM = collision.gameObject.GetComponent<ColliderManager>();
|
|
if (hitCM != null)
|
|
{
|
|
// Get the vector where the collision happened, and check if it happened above or below.
|
|
//Vector3 collisionHitCheckPosition = collision.gameObject.transform.position - gameObject.transform.position;
|
|
float collisionHitDirection = Vector3.Dot(collision.GetContact(0).normal, collision.transform.up);
|
|
|
|
CollisionDirection direction = CollisionDirection.None;
|
|
if (collisionHitDirection < -0.1f)
|
|
{
|
|
direction = CollisionDirection.Top;
|
|
}
|
|
else if (collisionHitDirection > 0.1f)
|
|
{
|
|
direction = CollisionDirection.Bottom;
|
|
}
|
|
|
|
// Once we know process the collision.
|
|
ProcessCollision(direction, collision, wasChild);
|
|
}
|
|
}
|
|
}
|