Added Accessors for the GameManager to get the Score, Cores and Level values
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
This commit is contained in:
19
Assets/Scripts/Other/BlackHoleDistortionHelper.cs
Normal file
19
Assets/Scripts/Other/BlackHoleDistortionHelper.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BlackHoleDistortionHelper : MonoBehaviour
|
||||
{
|
||||
public Camera mainCamera;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void LateUpdate()
|
||||
{
|
||||
transform.LookAt(gameObject.transform.position + mainCamera.transform.rotation * Vector3.forward, mainCamera.transform.rotation * Vector3.up);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/BlackHoleDistortionHelper.cs.meta
Normal file
11
Assets/Scripts/Other/BlackHoleDistortionHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89607df382a24b247a2c89ef9c74ad9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
41
Assets/Scripts/Other/DeadMenu.cs
Normal file
41
Assets/Scripts/Other/DeadMenu.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class DeadMenu : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
|
||||
// If the BGM manager is present, queue up and play the given track index
|
||||
if (currentBGMManager)
|
||||
{
|
||||
currentBGMManager.StartAudioQueueAndPlay(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReStartGame()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
SceneManager.LoadScene("Main Menu");
|
||||
}
|
||||
public void Quit()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/DeadMenu.cs.meta
Normal file
11
Assets/Scripts/Other/DeadMenu.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3de6b36e04a5c3449c7104442440712
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
107
Assets/Scripts/Other/EnemyType.cs
Normal file
107
Assets/Scripts/Other/EnemyType.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class EnemyType
|
||||
{
|
||||
public class EnemyTypeStat
|
||||
{
|
||||
private int _statLevel;
|
||||
private int _statSpawnCount;
|
||||
private int _statLevelScore;
|
||||
private float _statLifeTime;
|
||||
private float _statFailureChance;
|
||||
|
||||
public int Level
|
||||
{
|
||||
get
|
||||
{
|
||||
return _statLevel;
|
||||
}
|
||||
}
|
||||
public int SpawnCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _statSpawnCount;
|
||||
}
|
||||
}
|
||||
public int Score
|
||||
{
|
||||
get
|
||||
{
|
||||
return _statLevelScore;
|
||||
}
|
||||
}
|
||||
public float LifeTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _statLifeTime;
|
||||
}
|
||||
}
|
||||
public float FailureChance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _statFailureChance;
|
||||
}
|
||||
}
|
||||
|
||||
public EnemyTypeStat(int level, int spawnCount, int levelScore, float lifeTime, float failureChance)
|
||||
{
|
||||
_statLevel = level;
|
||||
_statSpawnCount = spawnCount;
|
||||
_statLevelScore = levelScore;
|
||||
_statLifeTime = lifeTime;
|
||||
_statFailureChance = failureChance;
|
||||
}
|
||||
}
|
||||
|
||||
private List<EnemyTypeStat> _enemyStats = new List<EnemyTypeStat>();
|
||||
|
||||
public bool AddLevelStats(int level, int spawnCount, int scoreAmount, float lifeTime, float failureChance)
|
||||
{
|
||||
if (this[level] == null)
|
||||
{
|
||||
_enemyStats.Add(new EnemyTypeStat(level, spawnCount, scoreAmount, lifeTime, failureChance));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private EnemyTypeStat GetLevelStats(int level)
|
||||
{
|
||||
EnemyTypeStat result = null;
|
||||
if (_enemyStats.Count > 0)
|
||||
{
|
||||
foreach (EnemyTypeStat currentLevelStat in _enemyStats)
|
||||
{
|
||||
if (currentLevelStat.Level == level)
|
||||
{
|
||||
result = currentLevelStat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enemyStats.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public EnemyTypeStat this[int level]
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetLevelStats(level);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/EnemyType.cs.meta
Normal file
11
Assets/Scripts/Other/EnemyType.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30b081cc0ed79f9488a70ebca99f3a73
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
203
Assets/Scripts/Other/HiddenValueInt.cs
Normal file
203
Assets/Scripts/Other/HiddenValueInt.cs
Normal file
@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class HiddenValueInt
|
||||
{
|
||||
private int _offsetSeed;
|
||||
private int _newValue;
|
||||
|
||||
public HiddenValueInt(int value)
|
||||
{
|
||||
Random newRandom = new Random(Environment.TickCount);
|
||||
_offsetSeed = newRandom.Next(int.MinValue, int.MaxValue);
|
||||
_newValue = value ^ _offsetSeed;
|
||||
}
|
||||
|
||||
public void ReSeedValue()
|
||||
{
|
||||
int tempValue = Value;
|
||||
Random newRandom = new Random(Environment.TickCount);
|
||||
_offsetSeed = newRandom.Next(int.MinValue, int.MaxValue);
|
||||
_newValue = tempValue ^ _offsetSeed;
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _offsetSeed ^ _newValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
_newValue = value ^ _offsetSeed;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals(obj as HiddenValueInt);
|
||||
}
|
||||
|
||||
public bool Equals(HiddenValueInt rhs)
|
||||
{
|
||||
if (rhs is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(this, rhs))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GetType() != rhs.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Equals(rhs.Value);
|
||||
}
|
||||
|
||||
public bool Equals(int rhs)
|
||||
{
|
||||
bool result = false;
|
||||
if (Value == rhs)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Value.GetHashCode();
|
||||
}
|
||||
|
||||
public static explicit operator int(HiddenValueInt rhs)
|
||||
{
|
||||
return rhs.Value;
|
||||
}
|
||||
|
||||
public static bool operator ==(HiddenValueInt lhs, HiddenValueInt rhs)
|
||||
{
|
||||
if (lhs is null)
|
||||
{
|
||||
if (rhs is null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return lhs.Equals(rhs);
|
||||
}
|
||||
|
||||
public static bool operator !=(HiddenValueInt lhs, HiddenValueInt rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
public static bool operator ==(HiddenValueInt lhs, int rhs)
|
||||
{
|
||||
if (lhs is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return lhs.Equals(rhs);
|
||||
}
|
||||
|
||||
public static bool operator !=(HiddenValueInt lhs, int rhs)
|
||||
{
|
||||
return !(lhs.Value == rhs);
|
||||
}
|
||||
|
||||
public static bool operator ==(int lhs, HiddenValueInt rhs)
|
||||
{
|
||||
if (rhs is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return rhs.Equals(lhs);
|
||||
}
|
||||
|
||||
public static bool operator !=(int lhs, HiddenValueInt rhs)
|
||||
{
|
||||
return !(lhs == rhs.Value);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator +(HiddenValueInt a, HiddenValueInt b)
|
||||
{
|
||||
int tempInt = a.Value + b.Value;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator +(HiddenValueInt a, int b)
|
||||
{
|
||||
int tempInt = a.Value + b;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator +(int a, HiddenValueInt b)
|
||||
{
|
||||
int tempInt = a + b.Value;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator -(HiddenValueInt a, HiddenValueInt b)
|
||||
{
|
||||
int tempInt = a.Value - b.Value;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator -(HiddenValueInt a, int b)
|
||||
{
|
||||
int tempInt = a.Value - b;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator -(int a, HiddenValueInt b)
|
||||
{
|
||||
int tempInt = a - b.Value;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator *(HiddenValueInt a, HiddenValueInt b)
|
||||
{
|
||||
int tempInt = a.Value * b.Value;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator *(HiddenValueInt a, int b)
|
||||
{
|
||||
int tempInt = a.Value * b;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator *(int a, HiddenValueInt b)
|
||||
{
|
||||
int tempInt = a * b.Value;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator /(HiddenValueInt a, HiddenValueInt b)
|
||||
{
|
||||
int tempInt = a.Value / b.Value;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator /(HiddenValueInt a, int b)
|
||||
{
|
||||
int tempInt = a.Value / b;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
|
||||
public static HiddenValueInt operator /(int a, HiddenValueInt b)
|
||||
{
|
||||
int tempInt = a / b.Value;
|
||||
return new HiddenValueInt(tempInt);
|
||||
}
|
||||
}
|
||||
|
11
Assets/Scripts/Other/HiddenValueInt.cs.meta
Normal file
11
Assets/Scripts/Other/HiddenValueInt.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5451741203141a44b82c792b5968990
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
151
Assets/Scripts/Other/MainMenuEngine.cs
Normal file
151
Assets/Scripts/Other/MainMenuEngine.cs
Normal file
@ -0,0 +1,151 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class MainMenuEngine : MonoBehaviour
|
||||
{
|
||||
public GameObject hudGO;
|
||||
public GameObject joystickGO;
|
||||
public GameObject yolkAGO;
|
||||
public GameObject yolkBGO;
|
||||
public TMPro.TextMeshProUGUI versionText;
|
||||
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
|
||||
public float joystickJiggleSpeed;
|
||||
|
||||
public float flashFrequencyTime;
|
||||
private TimerHelper _flashTimer;
|
||||
|
||||
private MeshRenderer _meshRenderer;
|
||||
private Color _defaultEmissionColor;
|
||||
|
||||
private GameObject _lastControlSelected;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GameManager.Instance.currentGameState = GameState.MAINMENU;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// If the BGM manager is present, queue up and play the given track index
|
||||
if (currentBGMManager)
|
||||
{
|
||||
currentBGMManager.StartAudioQueueAndPlay(0);
|
||||
}
|
||||
|
||||
_flashTimer = new TimerHelper(flashFrequencyTime);
|
||||
_meshRenderer = hudGO.GetComponent<MeshRenderer>();
|
||||
_defaultEmissionColor = _meshRenderer.materials[0].GetColor("_EmissionColor");
|
||||
|
||||
versionText.text = versionText.text.Replace("{versionNo}", GameManager.Instance.CurrentVersion);
|
||||
}
|
||||
|
||||
public void SetupVolumeOptions()
|
||||
{
|
||||
// Gets the volume settings from the player profile and sets it in the game
|
||||
float currentMasterVol = PlayerPrefs.GetFloat("currentMasterVol");
|
||||
GameObject masterVolSliderGo = GameObject.Find("MainVolSlider");
|
||||
|
||||
float currentMusicVol = PlayerPrefs.GetFloat("currentMusicVol");
|
||||
GameObject musicVolSliderGo = GameObject.Find("MusicVolSlider");
|
||||
|
||||
float currentSFXVol = PlayerPrefs.GetFloat("currentSFXVol");
|
||||
GameObject SFXVolSliderGo = GameObject.Find("SfxVolSlider");
|
||||
|
||||
masterVolSliderGo.GetComponent<Slider>().value = currentMasterVol;
|
||||
musicVolSliderGo.GetComponent<Slider>().value = currentMusicVol;
|
||||
SFXVolSliderGo.GetComponent<Slider>().value = currentSFXVol;
|
||||
}
|
||||
|
||||
public void PlayMenuClick()
|
||||
{
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
SceneManager.LoadSceneAsync("Rules");
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetMasterVolume(float value)
|
||||
{
|
||||
// Converts the master volume into decibels and stores it in the player profile
|
||||
GameManager.Instance.currentAudioMixer.SetFloat("masterVol", SharedMethods.ConvertToDecibels(value));
|
||||
PlayerPrefs.SetFloat("currentMasterVol", value);
|
||||
}
|
||||
|
||||
public void SetMusicVolume(float value)
|
||||
{
|
||||
// Converts the music volume into decibels and stores it in the player profile
|
||||
GameManager.Instance.currentAudioMixer.SetFloat("musicVol", SharedMethods.ConvertToDecibels(value));
|
||||
PlayerPrefs.SetFloat("currentMusicVol", value);
|
||||
}
|
||||
|
||||
public void SetSFXVolume(float value)
|
||||
{
|
||||
// Converts the sfx volume into decibels and stores it in the player profile
|
||||
GameManager.Instance.currentAudioMixer.SetFloat("sfxVol", SharedMethods.ConvertToDecibels(value));
|
||||
PlayerPrefs.SetFloat("currentSFXVol", value);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_flashTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
float randomNo = Random.Range(0.0f, 1.0f);
|
||||
_meshRenderer.materials[0].SetColor("_EmissionColor", Color.Lerp(Color.black, _defaultEmissionColor, randomNo));
|
||||
}
|
||||
|
||||
float horzLRot = -Input.GetAxis("Horizontal") * joystickJiggleSpeed;
|
||||
float vertLRot = -45.0f + -Input.GetAxis("Vertical") * joystickJiggleSpeed;
|
||||
joystickGO.transform.eulerAngles = new Vector3(vertLRot, 0.0f, horzLRot);
|
||||
|
||||
if (horzLRot != 0)
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject == null)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_lastControlSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastControlSelected = EventSystem.current.currentSelectedGameObject;
|
||||
}
|
||||
}
|
||||
|
||||
float horzRRot = -25 + -Input.GetAxis("Mouse X") * joystickJiggleSpeed;
|
||||
float vertRRot = -25 + -Input.GetAxis("Mouse Y") * joystickJiggleSpeed;
|
||||
yolkAGO.transform.eulerAngles = new Vector3(vertRRot, 0.0f, 0.0f);
|
||||
yolkBGO.transform.eulerAngles = new Vector3(horzRRot, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/MainMenuEngine.cs.meta
Normal file
11
Assets/Scripts/Other/MainMenuEngine.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb67e4b8899ac3441995a02948824421
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
64
Assets/Scripts/Other/MultiCollider.cs
Normal file
64
Assets/Scripts/Other/MultiCollider.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
/// <summary>
|
||||
/// Class to deal with the other collisions for the core
|
||||
/// </summary>
|
||||
public class MultiCollider : ColliderManager
|
||||
{
|
||||
public AudioClip corePickupSFX;
|
||||
public GameObject radiusToken;
|
||||
public GameObject PlayerOne;
|
||||
public SphereCollider Cores;
|
||||
private GameObject areaAround;
|
||||
|
||||
public int radiusTick;
|
||||
|
||||
// Bool checks if the core has been collected, this is because the ships are made of multiple collision boxes and would trigger more than once.
|
||||
private bool _tokenCollected = false;
|
||||
|
||||
public override void ProcessCollision(CollisionDirection direction, Collision collision, bool wasChild)
|
||||
{
|
||||
GameObject collisionGO;
|
||||
if (wasChild)
|
||||
{
|
||||
collisionGO = collision.transform.parent.gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
collisionGO = collision.gameObject;
|
||||
}
|
||||
|
||||
// Check the tag of the collided object, Direction doesnt matter i assume
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Player":
|
||||
PickupToken();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the core pick up and destroy the core object.
|
||||
/// </summary>
|
||||
public void PickupToken()
|
||||
{
|
||||
// If the core has been collected ignore it.
|
||||
if (!_tokenCollected)
|
||||
{
|
||||
Debug.Log("Pick up radius");
|
||||
_tokenCollected = true;
|
||||
AudioSource.PlayClipAtPoint(corePickupSFX, transform.position);
|
||||
Destroy(radiusToken);
|
||||
while (radiusTick > 0)
|
||||
{
|
||||
Cores.radius = 10;
|
||||
radiusTick -= 1;
|
||||
}
|
||||
Destroy(areaAround);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/MultiCollider.cs.meta
Normal file
11
Assets/Scripts/Other/MultiCollider.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 742ed625e6d4d46439f31a3dd0b6f94c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
28
Assets/Scripts/Other/ParticalCleanUp.cs
Normal file
28
Assets/Scripts/Other/ParticalCleanUp.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ParticalCleanUp : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private float tik;
|
||||
private float end = 2;
|
||||
|
||||
void Start()
|
||||
{
|
||||
tik = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(tik >= end)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
tik += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/ParticalCleanUp.cs.meta
Normal file
11
Assets/Scripts/Other/ParticalCleanUp.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a6542ac5327d9d49b523dee5bff0ba0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Assets/Scripts/Other/RestartLevel.cs
Normal file
17
Assets/Scripts/Other/RestartLevel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class RestartLevel : MonoBehaviour
|
||||
{
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (gameObject.name==("Player")) // need to get this to work when the player dies
|
||||
{
|
||||
Scene scene = SceneManager.GetActiveScene();
|
||||
SceneManager.LoadScene(scene.name);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/RestartLevel.cs.meta
Normal file
11
Assets/Scripts/Other/RestartLevel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39d57a8aa33863c4dbac39c865492676
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/Other/RuleMenu.cs
Normal file
29
Assets/Scripts/Other/RuleMenu.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class RuleMenu : MonoBehaviour
|
||||
{
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// If the BGM manager is present, queue up and play the given track index
|
||||
if (currentBGMManager)
|
||||
{
|
||||
currentBGMManager.StartAudioQueueAndPlay(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
SceneManager.LoadScene("Game");
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/RuleMenu.cs.meta
Normal file
11
Assets/Scripts/Other/RuleMenu.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5678218a3034524ca1d3eb11b13ae1c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
153
Assets/Scripts/Other/RulesMenuEngine.cs
Normal file
153
Assets/Scripts/Other/RulesMenuEngine.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.Playables;
|
||||
|
||||
public class RulesMenuEngine : MonoBehaviour
|
||||
{
|
||||
public GameObject playerCameraGO;
|
||||
public GameObject playerTrailsGO;
|
||||
public ParticleSystem starParticles;
|
||||
public PlayableDirector howToTimeline;
|
||||
private Vector3 _startPosition;
|
||||
|
||||
public GameObject startGameCutscene;
|
||||
|
||||
public GameObject startButton;
|
||||
public GameObject replayButton;
|
||||
public GameObject skipButton;
|
||||
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
|
||||
private bool _cutsceneEnded;
|
||||
|
||||
private GameObject _lastControlSelected;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GameManager.Instance.currentGameState = GameState.RULESMENU;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// If the BGM manager is present, queue up and play the given track index
|
||||
if (currentBGMManager)
|
||||
{
|
||||
currentBGMManager.StartAudioQueueAndPlay(0);
|
||||
}
|
||||
|
||||
_startPosition = playerCameraGO.transform.position;
|
||||
_cutsceneEnded = false;
|
||||
}
|
||||
public void StartGame()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
startGameCutscene.GetComponent<PlayableDirector>().time = 0;
|
||||
startGameCutscene.SetActive(true);
|
||||
}
|
||||
|
||||
public void ChangeScene()
|
||||
{
|
||||
SceneManager.LoadSceneAsync("Game");
|
||||
}
|
||||
|
||||
public void PlayMenuClick()
|
||||
{
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
}
|
||||
|
||||
public void SlowStarRate()
|
||||
{
|
||||
ParticleSystem.MainModule starsMainPS = starParticles.main;
|
||||
starsMainPS.simulationSpeed = 0.1f;
|
||||
}
|
||||
|
||||
public void NormalStarRate()
|
||||
{
|
||||
ParticleSystem.MainModule starsMainPS = starParticles.main;
|
||||
starsMainPS.simulationSpeed = 1.0f;
|
||||
CheckIfEndOfTimeline();
|
||||
}
|
||||
|
||||
public void BoostStarRate()
|
||||
{
|
||||
ParticleSystem.MainModule starsMainPS = starParticles.main;
|
||||
starsMainPS.simulationSpeed = 10.0f;
|
||||
}
|
||||
|
||||
public void EscapeStarRate()
|
||||
{
|
||||
ParticleSystem.MainModule starsMainPS = starParticles.main;
|
||||
starsMainPS.maxParticles = 10000;
|
||||
starsMainPS.simulationSpeed = 100.0f;
|
||||
starsMainPS.startColor = Color.red;
|
||||
}
|
||||
|
||||
public void DoCutSceneSkip()
|
||||
{
|
||||
double fullTime = System.Math.Floor(howToTimeline.time);
|
||||
int previousSecondMark = (int)fullTime % 10;
|
||||
howToTimeline.time = (fullTime - previousSecondMark) + 10;
|
||||
CheckIfEndOfTimeline();
|
||||
}
|
||||
|
||||
public void CheckIfEndOfTimeline()
|
||||
{
|
||||
if ((howToTimeline.time + 11) >= howToTimeline.duration)
|
||||
{
|
||||
skipButton.SetActive(false);
|
||||
EventSystem.current.SetSelectedGameObject(startButton);
|
||||
}
|
||||
}
|
||||
|
||||
public void RestartHowToTimeline()
|
||||
{
|
||||
howToTimeline.gameObject.SetActive(true);
|
||||
skipButton.SetActive(true);
|
||||
NormalStarRate();
|
||||
|
||||
_cutsceneEnded = false;
|
||||
playerCameraGO.transform.position = _startPosition;
|
||||
|
||||
foreach (TrailRenderer currentTrail in playerTrailsGO.GetComponentsInChildren<TrailRenderer>())
|
||||
{
|
||||
currentTrail.Clear();
|
||||
}
|
||||
|
||||
howToTimeline.Play();
|
||||
}
|
||||
|
||||
public void EndHowToTimeline()
|
||||
{
|
||||
howToTimeline.gameObject.SetActive(false);
|
||||
skipButton.SetActive(false);
|
||||
EventSystem.current.SetSelectedGameObject(startButton);
|
||||
replayButton.SetActive(true);
|
||||
playerCameraGO.transform.position = _startPosition;
|
||||
_cutsceneEnded = true;
|
||||
NormalStarRate();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_cutsceneEnded)
|
||||
{
|
||||
//playerTrailsGO.SetActive(true);
|
||||
playerCameraGO.transform.position = playerCameraGO.transform.forward * 0.05f * Time.deltaTime;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/RulesMenuEngine.cs.meta
Normal file
11
Assets/Scripts/Other/RulesMenuEngine.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 827a1b0c975d30a42b0da8b646b159a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
107
Assets/Scripts/Other/TimerHelper.cs
Normal file
107
Assets/Scripts/Other/TimerHelper.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public enum TimerDirection
|
||||
{
|
||||
TimerIncrement,
|
||||
TimerDecrement
|
||||
}
|
||||
|
||||
public class TimerHelper
|
||||
{
|
||||
private float _timerInterval;
|
||||
private float _timerMax;
|
||||
private float _timerTick;
|
||||
|
||||
private int _timesRun;
|
||||
|
||||
private bool _timerRepeats;
|
||||
|
||||
private bool _hasBeedStarted = false;
|
||||
|
||||
private TimerDirection _timerDirection;
|
||||
|
||||
public TimerHelper(float timeMax, bool repeating = true, TimerDirection direction = TimerDirection.TimerIncrement)
|
||||
{
|
||||
_timerMax = timeMax;
|
||||
_timerRepeats = repeating;
|
||||
_timerDirection = direction;
|
||||
|
||||
if (_timerDirection == TimerDirection.TimerDecrement)
|
||||
{
|
||||
_timerInterval = 0.0f;
|
||||
_timerTick = -_timerMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timerInterval = _timerMax;
|
||||
_timerTick = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float CurrentTick
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Abs(_timerTick);
|
||||
}
|
||||
}
|
||||
|
||||
public int TimesRun
|
||||
{
|
||||
get
|
||||
{
|
||||
return _timesRun;
|
||||
}
|
||||
}
|
||||
|
||||
public float Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Abs(_timerTick) / _timerMax;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Started
|
||||
{
|
||||
get
|
||||
{
|
||||
return _hasBeedStarted;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasTicked(float currentTimestamp)
|
||||
{
|
||||
_hasBeedStarted = true;
|
||||
if (_timerTick >= _timerInterval)
|
||||
{
|
||||
_timesRun++;
|
||||
if (_timerRepeats)
|
||||
{
|
||||
RestartTimer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timerTick += currentTimestamp;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void RestartTimer()
|
||||
{
|
||||
if (_timerDirection == TimerDirection.TimerDecrement)
|
||||
{
|
||||
_timerTick = -_timerMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timerTick = 0.0f;
|
||||
}
|
||||
_hasBeedStarted = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
11
Assets/Scripts/Other/TimerHelper.cs.meta
Normal file
11
Assets/Scripts/Other/TimerHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2420aeff9a124cd44a9b49c7e59a399a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
68
Assets/Scripts/Other/laserCollider.cs
Normal file
68
Assets/Scripts/Other/laserCollider.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
/// <summary>
|
||||
/// Class to deal with the other collisions for the core
|
||||
/// </summary>
|
||||
public class laserCollider : ColliderManager
|
||||
{
|
||||
public AudioClip corePickupSFX;
|
||||
public GameObject laserToken;
|
||||
public int laserTick;
|
||||
public GameObject LaserStick1;
|
||||
public GameObject LaserStick2;
|
||||
|
||||
// Bool checks if the core has been collected, this is because the ships are made of multiple collision boxes and would trigger more than once.
|
||||
private bool _tokenCollected = false;
|
||||
|
||||
public override void ProcessCollision(CollisionDirection direction, Collision collision, bool wasChild)
|
||||
{
|
||||
GameObject collisionGO;
|
||||
if (wasChild)
|
||||
{
|
||||
collisionGO = collision.transform.parent.gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
collisionGO = collision.gameObject;
|
||||
}
|
||||
|
||||
// Check the tag of the collided object, Direction doesnt matter i assume
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Player":
|
||||
PickupToken();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the core pick up and destroy the core object.
|
||||
/// </summary>
|
||||
public void PickupToken()
|
||||
{
|
||||
// If the core has been collected ignore it.
|
||||
if (!_tokenCollected)
|
||||
{
|
||||
Debug.Log("Pick up laser");
|
||||
_tokenCollected = true;
|
||||
AudioSource.PlayClipAtPoint(corePickupSFX, transform.position);
|
||||
Destroy(laserToken);
|
||||
while (laserTick != 0)
|
||||
{
|
||||
LaserStick1.transform.localScale = new Vector3(0.07000001f, 1.2f, 0.07000001f);
|
||||
LaserStick1.transform.position = new Vector3(LaserStick1.transform.position.x - 5.27541f,
|
||||
LaserStick1.transform.position.y - 1.240699f, LaserStick1.transform.position.z + 3.87f);
|
||||
|
||||
LaserStick2.transform.localScale = new Vector3(0.07000001f, 1.2f, 0.07000001f);
|
||||
LaserStick2.transform.position = new Vector3(LaserStick2.transform.position.x - 0.2f,
|
||||
LaserStick2.transform.position.y - 1.3f, LaserStick2.transform.position.z + 3.62f);
|
||||
laserTick -= 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/laserCollider.cs.meta
Normal file
11
Assets/Scripts/Other/laserCollider.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7e2c85678107d943bcdd2c894626dba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user