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:
@ -293,23 +293,29 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -160,16 +160,19 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
|
||||
private void DoAMineSpawn()
|
||||
{
|
||||
GameObject newMine = Instantiate(minePrefab);
|
||||
MineHoverMovement mineMovement = newMine.GetComponent<MineHoverMovement>();
|
||||
if (mineMovement)
|
||||
if (!freezeMovement)
|
||||
{
|
||||
mineMovement.startPositionVector = transform.position + (-transform.forward * 2.0f);
|
||||
mineMovement.startHeight = GetCurrentHeight() - 0.5f;
|
||||
}
|
||||
GameObject newMine = Instantiate(minePrefab);
|
||||
MineHoverMovement mineMovement = newMine.GetComponent<MineHoverMovement>();
|
||||
if (mineMovement)
|
||||
{
|
||||
mineMovement.startPositionVector = transform.position + (-transform.forward * 2.0f);
|
||||
mineMovement.startHeight = GetCurrentHeight() - 0.5f;
|
||||
}
|
||||
|
||||
newMine.SetActive(true);
|
||||
_canSpawnMine = false;
|
||||
newMine.SetActive(true);
|
||||
_canSpawnMine = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -352,23 +355,29 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -281,23 +281,29 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -277,23 +277,29 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
/// Method to toggle the debug console
|
||||
/// </summary>
|
||||
public void ToggleDebugConsole(bool force = false)
|
||||
{
|
||||
{
|
||||
if (_toggleWindow && !force)
|
||||
{
|
||||
Time.timeScale = 1.0f;
|
||||
@ -35,10 +35,10 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!_toggleWindow)
|
||||
{
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Draw the GUI box for the console box at the top of the screen
|
||||
GUI.Box(new Rect(0, 0, Screen.width, 30), "");
|
||||
GUI.backgroundColor = new Color(0, 0, 0, 0);
|
||||
@ -87,11 +87,11 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
_prevCommands.Add(_commandIn);
|
||||
_prevCommandIndex = _prevCommands.Count - 1;
|
||||
}
|
||||
_commandIn = "";
|
||||
_commandIn = "";
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for user input
|
||||
GUI.SetNextControlName("DebugConsole");
|
||||
@ -105,10 +105,10 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
/// </summary>
|
||||
/// <param name="currentCommand">Command string to parse</param>
|
||||
private void ParseCommand(string currentCommand)
|
||||
{
|
||||
{
|
||||
// Split the command by its space characters, first command part should always be the actual command with parameters following
|
||||
string[] commandParts = currentCommand.ToLower().Split(' ');
|
||||
switch(commandParts[0])
|
||||
switch (commandParts[0])
|
||||
{
|
||||
// Suicide player
|
||||
case "die":
|
||||
@ -255,11 +255,11 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
{
|
||||
if (levelsToJump > 0)
|
||||
{
|
||||
GameManager.Instance.level = GameManager.Instance.level + levelsToJump;
|
||||
GameManager.Instance.WarpLevels(levelsToJump);
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleFreezeAll()
|
||||
private void ToggleFreezeAll()
|
||||
{
|
||||
GameObject[] currentEnemies = GameObject.FindGameObjectsWithTag("Enemy");
|
||||
foreach (GameObject currentEnemy in currentEnemies)
|
||||
@ -294,7 +294,7 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
/// </summary>
|
||||
private void HealPlayer()
|
||||
{
|
||||
GameManager.Instance.lives = 10;
|
||||
GameManager.Instance.AddLife(10);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -315,10 +315,7 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
/// <param name="amount">Amount of cores to add</param>
|
||||
private void AddCore(int amount)
|
||||
{
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
GameManager.Instance.AddCore();
|
||||
}
|
||||
GameManager.Instance.AddCore(amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CoresMeter : MonoBehaviour
|
||||
{
|
||||
public Slider CoreMeterBar;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
CoreMeterBar.value = GameManager.Instance.getCoreCount();
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HealthBar : MonoBehaviour
|
||||
{
|
||||
public Slider health;
|
||||
|
||||
public void Health(int newHealth)
|
||||
{
|
||||
health.value = newHealth;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Spedometer : MonoBehaviour
|
||||
{
|
||||
public Slider speed;
|
||||
// Start is called before the first frame update
|
||||
public void SpeedSlider(float newSpeed)
|
||||
{
|
||||
speed.value = newSpeed;
|
||||
}
|
||||
|
||||
}
|
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);
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00d71e82bde684141adba79767a86c48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 89607df382a24b247a2c89ef9c74ad9c
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b3816330663a0944905e7c6c2c19ca2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5933daae7cbc4b841bffbf4413124c75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: e5451741203141a44b82c792b5968990
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -26,6 +26,11 @@ public class MainMenuEngine : MonoBehaviour
|
||||
|
||||
private GameObject _lastControlSelected;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GameManager.Instance.currentGameState = GameState.MAINMENU;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -74,7 +79,7 @@ public class MainMenuEngine : MonoBehaviour
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
SceneManager.LoadScene("Rules");
|
||||
SceneManager.LoadSceneAsync("Rules");
|
||||
}
|
||||
|
||||
public void Quit()
|
@ -27,6 +27,11 @@ public class RulesMenuEngine : MonoBehaviour
|
||||
|
||||
private GameObject _lastControlSelected;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GameManager.Instance.currentGameState = GameState.RULESMENU;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -52,7 +57,7 @@ public class RulesMenuEngine : MonoBehaviour
|
||||
|
||||
public void ChangeScene()
|
||||
{
|
||||
SceneManager.LoadScene("Game");
|
||||
SceneManager.LoadSceneAsync("Game");
|
||||
}
|
||||
|
||||
public void PlayMenuClick()
|
@ -17,6 +17,8 @@ public class TimerHelper
|
||||
|
||||
private bool _timerRepeats;
|
||||
|
||||
private bool _hasBeedStarted = false;
|
||||
|
||||
private TimerDirection _timerDirection;
|
||||
|
||||
public TimerHelper(float timeMax, bool repeating = true, TimerDirection direction = TimerDirection.TimerIncrement)
|
||||
@ -53,8 +55,25 @@ public class TimerHelper
|
||||
}
|
||||
}
|
||||
|
||||
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++;
|
||||
@ -81,6 +100,7 @@ public class TimerHelper
|
||||
{
|
||||
_timerTick = 0.0f;
|
||||
}
|
||||
_hasBeedStarted = false;
|
||||
}
|
||||
|
||||
}
|
8
Assets/Scripts/PowerUps.meta
Normal file
8
Assets/Scripts/PowerUps.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a94b9ab9a65b7d4281a89b39bf67995
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/Scripts/PowerUps/LifePowerUpEffect.cs
Normal file
25
Assets/Scripts/PowerUps/LifePowerUpEffect.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LifePowerUpEffect : PowerUpEffect
|
||||
{
|
||||
public int lifeIncreaseAmount;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
GameManager.Instance.AddLife(lifeIncreaseAmount);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/LifePowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/LifePowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38843c78ccdea3f468613761e6ca170f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
94
Assets/Scripts/PowerUps/MagnetEmbedPowerUpEffect.cs
Normal file
94
Assets/Scripts/PowerUps/MagnetEmbedPowerUpEffect.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MagnetEmbedPowerUpEffect : PowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
|
||||
public float magnetPowerForce;
|
||||
public float magnetPowerRange;
|
||||
|
||||
public float magnetPowerCooldown;
|
||||
private bool _magnetPowerCooldown;
|
||||
private TimerHelper _magnetPowerCooldownTimer;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
_magnetPowerCooldown = false;
|
||||
_magnetPowerCooldownTimer = new TimerHelper(magnetPowerCooldown, false);
|
||||
}
|
||||
|
||||
public override void OnPickUp()
|
||||
{
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
if (!_magnetPowerCooldown)
|
||||
{
|
||||
foreach (BlackHoleForce currentBHF in BlackHoleManager.blackHoleForceObjects)
|
||||
{
|
||||
GameObject currentObject = currentBHF.gameObject;
|
||||
if (currentObject.tag != "Player")
|
||||
{
|
||||
Vector3 directionToObject = gameObject.transform.position - currentObject.transform.position;
|
||||
float distanceToObject = directionToObject.magnitude;
|
||||
if (distanceToObject <= magnetPowerRange)
|
||||
{
|
||||
Rigidbody currentRigidBody = currentObject.GetComponent<Rigidbody>();
|
||||
if (currentRigidBody != null)
|
||||
{
|
||||
currentRigidBody.AddForce(directionToObject * magnetPowerForce, ForceMode.VelocityChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_magnetPowerCooldown = true;
|
||||
_magnetPowerCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override float CooldownStatus()
|
||||
{
|
||||
return _magnetPowerCooldownTimer.Position;
|
||||
}
|
||||
|
||||
public override bool PowerUpReady()
|
||||
{
|
||||
if (_magnetPowerCooldown)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_magnetPowerCooldown)
|
||||
{
|
||||
if (_magnetPowerCooldownTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_magnetPowerCooldown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/MagnetEmbedPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/MagnetEmbedPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b99a08d84424e940ba294b1935e85aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
48
Assets/Scripts/PowerUps/MagnetPowerUpEffect.cs
Normal file
48
Assets/Scripts/PowerUps/MagnetPowerUpEffect.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MagnetPowerUpEffect : PowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
public GameObject coredVersionGO;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
}
|
||||
|
||||
public override void OnPickUp()
|
||||
{
|
||||
Transform coreHolder = _player.transform.Find("PlayerModel/CoreHolder");
|
||||
for (int i = 0; i < coreHolder.transform.childCount; i++)
|
||||
{
|
||||
Destroy(coreHolder.GetChild(i).gameObject);
|
||||
}
|
||||
GameObject newSpecialCore = Instantiate(coredVersionGO, coreHolder);
|
||||
PowerUpEffect newMagnetEffect = newSpecialCore.GetComponent<MagnetEmbedPowerUpEffect>();
|
||||
_playerObjectShared.AttachPickUp(newMagnetEffect);
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override float CooldownStatus()
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public override bool PowerUpReady()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/MagnetPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/MagnetPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e91865b301eca594f92d1768cbfa74ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
35
Assets/Scripts/PowerUps/PowerUpEffect.cs
Normal file
35
Assets/Scripts/PowerUps/PowerUpEffect.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PowerUpEffect : MonoBehaviour
|
||||
{
|
||||
public string powerUpName;
|
||||
public string powerUpDesc;
|
||||
public GameObject powerUpModel;
|
||||
|
||||
public virtual void OnPickUp()
|
||||
{
|
||||
ApplyEffect();
|
||||
}
|
||||
|
||||
public virtual void ApplyEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool OnUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual float CooldownStatus()
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public virtual bool PowerUpReady()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/PowerUps/PowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/PowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 181a54eb9a6eb354d893a404c3543c3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Scripts/PowerUps/ShieldPowerUpEffect.cs
Normal file
33
Assets/Scripts/PowerUps/ShieldPowerUpEffect.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShieldPowerUpEffect : PowerUpEffect
|
||||
{
|
||||
public float immunityLength;
|
||||
private GameObject _player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
if (_player != null)
|
||||
{
|
||||
PlayerColliderManager currentPCM = _player.GetComponent<PlayerColliderManager>();
|
||||
if (currentPCM != null)
|
||||
{
|
||||
currentPCM.SetImmune(immunityLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/ShieldPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/ShieldPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8a8ce1843264e04d9d1caed1f1ce82b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -138,21 +138,27 @@ public class AsteroidHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
//ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
//ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
//ProcessPostMovement();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
//ProcessPostMovement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using UnityEngine;
|
||||
public class BasicEnemySpawning : ObjectSpawning
|
||||
{
|
||||
public GameObject enemyPrefab;
|
||||
public EnemyType spawnersEnemyType;
|
||||
public EnemyTypeName spawnersEnemyType;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -29,8 +29,6 @@ public class BasicEnemySpawning : ObjectSpawning
|
||||
/// </summary>
|
||||
protected override void DoASpawn()
|
||||
{
|
||||
int spawnLevel = GameManager.Instance.level;
|
||||
|
||||
float xPos = Random.Range(-xSpawnRange, xSpawnRange);
|
||||
float yPos = Random.Range(-ySpawnRange, ySpawnRange);
|
||||
float zPos = Random.Range(-zSpawnRange, zSpawnRange);
|
||||
@ -57,6 +55,7 @@ public class BasicEnemySpawning : ObjectSpawning
|
||||
if (newSpawnShared)
|
||||
{
|
||||
newSpawnShared.Spawner = this;
|
||||
newSpawnShared.enemyTypeName = spawnersEnemyType;
|
||||
}
|
||||
|
||||
newSpawn.SetActive(true);
|
||||
|
@ -305,23 +305,29 @@ public class BasicFollowEnemyHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAIPhysics(Time.fixedDeltaTime);
|
||||
ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
ProcessCooldowns(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class BlackHoleManager : MonoBehaviour
|
||||
// Vars for dealing with the blackhole SFX
|
||||
private AudioSource _currentAudioSource;
|
||||
public AudioClip blackHoleAmbiantSFX;
|
||||
public int maxAudioSize = 70;
|
||||
public int maxAudioSize = 10;
|
||||
public bool playBlackHoleAmbiantNoise;
|
||||
|
||||
/// <summary>
|
||||
@ -77,7 +77,10 @@ public class BlackHoleManager : MonoBehaviour
|
||||
BlackHoleAudio();
|
||||
if (timedGrow)
|
||||
{
|
||||
TimedGrow();
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
TimedGrow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,10 +124,13 @@ public class BlackHoleManager : MonoBehaviour
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
// Apply force to every blackhole force object in the list
|
||||
foreach (BlackHoleForce bhfObject in blackHoleForceObjects)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
bhfObject.ApplyBlackHoleForce(gravityPullFoce * Time.fixedDeltaTime);
|
||||
// Apply force to every blackhole force object in the list
|
||||
foreach (BlackHoleForce bhfObject in blackHoleForceObjects)
|
||||
{
|
||||
bhfObject.ApplyBlackHoleForce(gravityPullFoce * Time.fixedDeltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,32 +7,27 @@ public class BoundaryLightManager : MonoBehaviour
|
||||
public Light currentLight;
|
||||
public float startIntensity;
|
||||
public float lightLifeTime;
|
||||
private TimerHelper _lightTimer;
|
||||
|
||||
private float _currentTick;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
currentLight.intensity = startIntensity;
|
||||
_currentTick = 0.0f;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
currentLight.intensity = startIntensity;
|
||||
_lightTimer = new TimerHelper(lightLifeTime, false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
currentLight.intensity = Mathf.Lerp(startIntensity, 0, _currentTick / lightLifeTime);
|
||||
if (_currentTick >= lightLifeTime)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentTick = Mathf.Clamp(_currentTick + Time.deltaTime, 0, lightLifeTime);
|
||||
currentLight.intensity = startIntensity - Mathf.Lerp(0, startIntensity, _lightTimer.Position);
|
||||
if (_lightTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,6 @@ public class ColliderManager : MonoBehaviour
|
||||
DoAwakeTasks();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <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>
|
||||
|
@ -11,6 +11,8 @@ public class CoreColliderManager : ColliderManager
|
||||
public AudioClip corePickupSFX;
|
||||
private AudioSource _audioSource;
|
||||
|
||||
private TimerHelper _scoreValueTimer = new TimerHelper(20.0f, false, TimerDirection.TimerDecrement);
|
||||
|
||||
public override void DoAwakeTasks()
|
||||
{
|
||||
GameObject playerGO = GameObject.Find("Player");
|
||||
@ -57,6 +59,8 @@ public class CoreColliderManager : ColliderManager
|
||||
_audioSource.PlayOneShot(corePickupSFX);
|
||||
}
|
||||
GameManager.Instance.AddCore();
|
||||
int pickUpScore = (int)(100.0f * (1.0f + (1.0f * _scoreValueTimer.Position)));
|
||||
GameManager.Instance.AddScore(pickUpScore - (pickUpScore % 10));
|
||||
|
||||
if (transform.childCount > 0)
|
||||
{
|
||||
@ -69,4 +73,12 @@ public class CoreColliderManager : ColliderManager
|
||||
Destroy(gameObject, 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
_scoreValueTimer.HasTicked(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class CoreHoverMovement : HoverMovement
|
||||
{
|
||||
// Cores dont move at the moment but the movescript can be used above if they need to orbit around the blackhole
|
||||
_rngHorz = 0;
|
||||
_rngVert = 0;
|
||||
_rngVert = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -138,21 +138,27 @@ public class CoreHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
//ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
//ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,5 +4,33 @@ using UnityEngine;
|
||||
|
||||
public class CoreObjectShared : ObjectShared
|
||||
{
|
||||
// Helper class incase we need to track a variable over multiple scripts
|
||||
private GameObject _currentPlayer;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
private Rigidbody _objectRigidBody;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_currentPlayer = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _currentPlayer.GetComponent<PlayerObjectShared>();
|
||||
_objectRigidBody = gameObject.GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (_currentPlayer != null)
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
if (_playerObjectShared != null)
|
||||
{
|
||||
Vector3 directionToPlayer = transform.position - _currentPlayer.transform.position;
|
||||
float distanceToPlayer = directionToPlayer.magnitude;
|
||||
if (distanceToPlayer <= _playerObjectShared.coreMagnetRange)
|
||||
{
|
||||
_objectRigidBody.AddForce(-directionToPlayer * distanceToPlayer * _playerObjectShared.coreMagnetForce * Time.fixedDeltaTime, ForceMode.VelocityChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,21 @@ public class EnemyColliderManager : ColliderManager
|
||||
public AudioClip coreSpawnedSFX;
|
||||
|
||||
private bool _enemyDestroyed = false;
|
||||
private TimerHelper _deathTimer;
|
||||
private TimerHelper _particleTimer;
|
||||
|
||||
// The position the enemy died
|
||||
private Vector3 _deathPos;
|
||||
private float _deathHeight;
|
||||
|
||||
public List<GameObject> enemyLoot;
|
||||
public List<float> enemyLootChance;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_deathTimer = new TimerHelper(coreSpawnDelayTime, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trigger the enemy death without a collision, this is mostly for the debug menu and testing but could be called in a case where you need it to die.
|
||||
/// </summary>
|
||||
@ -56,7 +66,7 @@ public class EnemyColliderManager : ColliderManager
|
||||
{
|
||||
case "Player":
|
||||
// We were killed by the player above
|
||||
DestoryEnemy();
|
||||
DestoryEnemy(true);
|
||||
break;
|
||||
case "Enemy":
|
||||
// Bounce other enemies back
|
||||
@ -141,72 +151,129 @@ public class EnemyColliderManager : ColliderManager
|
||||
gameObject.GetComponent<Rigidbody>().AddForce(collisionPos * bounceForce, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delayed core spawning method, this allows the ship to "die" and play its animation and then for the spawn to appear.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerator DelayedCoreSpawn()
|
||||
private void SpawnCore()
|
||||
{
|
||||
bool timeWaited = false;
|
||||
bool waitEnded = false;
|
||||
|
||||
while (!waitEnded)
|
||||
GameObject newCore = Instantiate(shipCore);
|
||||
CoreHoverMovement coreMovement = newCore.GetComponent<CoreHoverMovement>();
|
||||
if (coreMovement)
|
||||
{
|
||||
if (timeWaited)
|
||||
coreMovement.startPositionVector = _deathPos;
|
||||
coreMovement.startHeight = _deathHeight;
|
||||
}
|
||||
|
||||
newCore.SetActive(true);
|
||||
AudioSource newCoreAS = newCore.GetComponent<AudioSource>();
|
||||
newCoreAS.PlayOneShot(coreSpawnedSFX);
|
||||
ObjectSpawning attachedShared = gameObject.GetComponent<EnemyObjectShared>().Spawner;
|
||||
if (attachedShared)
|
||||
{
|
||||
// Reduce the spawner objects count
|
||||
attachedShared.ReduceSpawnedCount();
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void SpawnLoot()
|
||||
{
|
||||
int currentLootCount = 0;
|
||||
foreach (GameObject currentLoot in enemyLoot)
|
||||
{
|
||||
float currentRoll = Random.Range(0.0f, 1.0f) * 100.0f;
|
||||
|
||||
if (currentRoll <= enemyLootChance[currentLootCount])
|
||||
{
|
||||
// Spawn a new core at the death location
|
||||
GameObject newCore = Instantiate(shipCore);
|
||||
CoreHoverMovement coreMovement = newCore.GetComponent<CoreHoverMovement>();
|
||||
if (coreMovement)
|
||||
GameObject newLoot = Instantiate(currentLoot);
|
||||
PowerUpHoverMovement lootMovement = newLoot.GetComponent<PowerUpHoverMovement>();
|
||||
if (lootMovement)
|
||||
{
|
||||
coreMovement.startPositionVector = _deathPos;
|
||||
coreMovement.startHeight = _deathHeight;
|
||||
lootMovement.startPositionVector = _deathPos;
|
||||
lootMovement.startHeight = _deathHeight;
|
||||
}
|
||||
|
||||
newCore.SetActive(true);
|
||||
AudioSource newCoreAS = newCore.GetComponent<AudioSource>();
|
||||
newCoreAS.PlayOneShot(coreSpawnedSFX);
|
||||
newLoot.SetActive(true);
|
||||
AudioSource newLootAS = newLoot.GetComponent<AudioSource>();
|
||||
newLootAS.PlayOneShot(coreSpawnedSFX);
|
||||
}
|
||||
|
||||
StopCoroutine("DelayedCoreSpawn");
|
||||
ObjectSpawning attachedShared = gameObject.GetComponent<EnemyObjectShared>().Spawner;
|
||||
if (attachedShared)
|
||||
{
|
||||
// Reduce the spawner objects count
|
||||
attachedShared.ReduceSpawnedCount();
|
||||
}
|
||||
Destroy(gameObject);
|
||||
waitEnded = true;
|
||||
currentLootCount++;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_enemyDestroyed)
|
||||
{
|
||||
if (_deathTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
SpawnCore();
|
||||
SpawnLoot();
|
||||
}
|
||||
else
|
||||
{
|
||||
timeWaited = true;
|
||||
if (!_particleTimer.Started || _particleTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
int randDir = Random.Range(0, 4);
|
||||
float randOffset = Random.Range(0.0f, 2.0f);
|
||||
|
||||
Vector3 offsetDir;
|
||||
switch (randDir)
|
||||
{
|
||||
case 1:
|
||||
offsetDir = Vector3.down * randOffset;
|
||||
break;
|
||||
case 2:
|
||||
offsetDir = Vector3.right * randOffset;
|
||||
break;
|
||||
case 3:
|
||||
offsetDir = Vector3.left * randOffset;
|
||||
break;
|
||||
default:
|
||||
case 0:
|
||||
offsetDir = Vector3.up * randOffset;
|
||||
break;
|
||||
}
|
||||
|
||||
ParticleSystem boomboom = Instantiate(effectA);
|
||||
ParticleSystem boomboom2 = Instantiate(effectB);
|
||||
boomboom.transform.position = _deathPos + offsetDir;
|
||||
boomboom2.transform.position = _deathPos + offsetDir;
|
||||
if (_attachedAudioSource)
|
||||
{
|
||||
_attachedAudioSource.PlayOneShot(shipDeathSFX);
|
||||
}
|
||||
|
||||
if (!_particleTimer.Started)
|
||||
{
|
||||
_particleTimer.HasTicked(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
yield return new WaitForSeconds(coreSpawnDelayTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method for destroying the enemy game object, it starts a coroutine to allow for an animation to be played.
|
||||
/// </summary>
|
||||
public void DestoryEnemy()
|
||||
public void DestoryEnemy(bool addScore = false)
|
||||
{
|
||||
if (!_enemyDestroyed)
|
||||
{
|
||||
// Store the position of death since the AI still moves after the models been deactivated.
|
||||
_deathPos = transform.position;
|
||||
_deathHeight = gameObject.GetComponent<HoverMovement>().GetCurrentHeight();
|
||||
if (_attachedAudioSource)
|
||||
if (addScore)
|
||||
{
|
||||
_attachedAudioSource.PlayOneShot(shipDeathSFX);
|
||||
EnemyObjectShared currentEnemyOS = gameObject.GetComponent<EnemyObjectShared>();
|
||||
if (currentEnemyOS != null)
|
||||
{
|
||||
GameManager.Instance.AddScore(GameManager.Instance.GetCurrentLevelEnemyStats(currentEnemyOS.enemyTypeName).Score);
|
||||
}
|
||||
}
|
||||
|
||||
// Start the delayed core spawn coroutine, this can probs be replaced once the death animations are in to spawn once that has ended.
|
||||
StartCoroutine("DelayedCoreSpawn");
|
||||
ParticleSystem boomboom = Instantiate(effectA);
|
||||
ParticleSystem boomboom2 = Instantiate(effectB);
|
||||
boomboom.transform.position = _deathPos;
|
||||
boomboom2.transform.position = _deathPos;
|
||||
// Store the position of death since the AI still moves after the models been deactivated.
|
||||
_deathPos = transform.position;
|
||||
HoverMovement currentHoverMovement = gameObject.GetComponent<HoverMovement>();
|
||||
currentHoverMovement.freezeMovement = true;
|
||||
_deathHeight = currentHoverMovement.GetCurrentHeight();
|
||||
shipModel.SetActive(false);
|
||||
_particleTimer = new TimerHelper(0.3f);
|
||||
gameObject.tag = "Dead";
|
||||
gameObject.layer = LayerMask.NameToLayer("NoCollide");
|
||||
_enemyDestroyed = true;
|
||||
|
@ -216,21 +216,27 @@ public class EnemyHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
ProcessJump();
|
||||
}
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ using UnityEngine;
|
||||
|
||||
public class EnemyObjectShared : ObjectShared
|
||||
{
|
||||
public EnemyTypeName enemyTypeName;
|
||||
|
||||
// Tracking the spawner this gameObject was created by so we can reduce the counter for it later
|
||||
private ObjectSpawning _spawner;
|
||||
|
||||
@ -73,17 +75,32 @@ public class EnemyObjectShared : ObjectShared
|
||||
_didSpawnInVFX = true;
|
||||
}
|
||||
|
||||
if (_engineFailing)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
if (!_engineDead)
|
||||
if (_engineFailing)
|
||||
{
|
||||
if (_deadEngineCheckTick >= deadEngineRecheckTime)
|
||||
if (!_engineDead)
|
||||
{
|
||||
int rngRoll = Random.Range(0, 100);
|
||||
if (rngRoll <= deadEngineChance)
|
||||
if (_deadEngineCheckTick >= deadEngineRecheckTime)
|
||||
{
|
||||
DoFailure();
|
||||
int rngRoll = Random.Range(0, 100);
|
||||
if (rngRoll <= deadEngineChance)
|
||||
{
|
||||
DoFailure();
|
||||
}
|
||||
_deadEngineCheckTick = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_deadEngineCheckTick += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_deadEngineCheckTick >= deadEngineInitialCheckTime)
|
||||
{
|
||||
_engineFailing = true;
|
||||
_deadEngineCheckTick = 0.0f;
|
||||
}
|
||||
else
|
||||
@ -92,17 +109,5 @@ public class EnemyObjectShared : ObjectShared
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_deadEngineCheckTick >= deadEngineInitialCheckTime)
|
||||
{
|
||||
_engineFailing = true;
|
||||
_deadEngineCheckTick = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_deadEngineCheckTick += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,42 +2,68 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class GameEngine : MonoBehaviour
|
||||
{
|
||||
[Header("Game Attributes")]
|
||||
public GameObject currentBlackHole;
|
||||
public GameObject currentPlayer;
|
||||
public static GameObject mainPlayer;
|
||||
private PlayerHoverMovement _playerHoverMovement;
|
||||
private BlackHoleManager _currentBlackHoleManager;
|
||||
public float arenaSize;
|
||||
|
||||
[Header("Sound Elements")]
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
|
||||
//public TMPro.TextMeshProUGUI coreCountText;
|
||||
|
||||
// might need it for core bar
|
||||
// public coresmeter corebar;
|
||||
public HealthBar livesBar;
|
||||
[Header("Gameplay UI Elements")]
|
||||
public GameObject livesBar;
|
||||
public GameObject coresText;
|
||||
public GameObject coresBar;
|
||||
public GameObject coresFillBar;
|
||||
public GameObject boostStatus;
|
||||
public GameObject scoreText;
|
||||
public GameObject levelText;
|
||||
|
||||
public float arenaSize;
|
||||
|
||||
private BlackHoleManager _currentBlackHoleManager;
|
||||
[Header("Pause Menu Elements")]
|
||||
public TMPro.TextMeshProUGUI versionText;
|
||||
public GameObject pauseMenu;
|
||||
public GameObject mainPausePanel;
|
||||
public GameObject optionsPanel;
|
||||
public GameObject confirmPanel;
|
||||
public static bool isPaused = false;
|
||||
public GameObject pauseMenuFirstItem;
|
||||
private GameObject _lastControlSelected;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
{
|
||||
// Make sure godmode is off when starting.
|
||||
GameManager.Instance.currentGameState = GameState.GAME;
|
||||
GameManager.Instance.godMode = false;
|
||||
GameManager.Instance.SetupLevel();
|
||||
|
||||
// Get the current blackhole so we have easy access to its variables
|
||||
_currentBlackHoleManager = currentBlackHole.GetComponent<BlackHoleManager>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Make sure godmode is off when starting.
|
||||
GameManager.Instance.godMode = false;
|
||||
GameManager.Instance.SetupLevel();
|
||||
|
||||
// Start the game, make sure the play GO is active
|
||||
currentPlayer.SetActive(true);
|
||||
if (currentBGMManager)
|
||||
{
|
||||
currentBGMManager.StartAudioQueueAndPlay(0);
|
||||
}
|
||||
|
||||
_playerHoverMovement = currentPlayer.GetComponent<PlayerHoverMovement>();
|
||||
versionText.text = versionText.text.Replace("{versionNo}", GameManager.Instance.CurrentVersion);
|
||||
mainPlayer = currentPlayer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -49,13 +75,246 @@ public class GameEngine : MonoBehaviour
|
||||
return _currentBlackHoleManager.currentBlackHoleRadius;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void UpdateLifeBar()
|
||||
{
|
||||
// Keep the core counter upto date with the current number of cores in the gamemanager
|
||||
//coreCountText.text = GameManager.Instance.getCoreCount().ToString();
|
||||
|
||||
livesBar.Health(GameManager.Instance.GetLives());
|
||||
//corebar.pickupcore(GameManager.Instance.getCoreCount());
|
||||
if (livesBar != null)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
Transform currentLife = livesBar.transform.Find("Life" + i.ToString());
|
||||
if (currentLife != null)
|
||||
{
|
||||
if (i <= GameManager.Instance.CurrentLives)
|
||||
{
|
||||
currentLife.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLife.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform lifeOverflow = livesBar.transform.Find("LifeOverflow");
|
||||
if (lifeOverflow != null)
|
||||
{
|
||||
if (GameManager.Instance.CurrentLives > 5)
|
||||
{
|
||||
lifeOverflow.gameObject.SetActive(true);
|
||||
lifeOverflow.GetComponent<TMPro.TextMeshProUGUI>().text = "(+" + (GameManager.Instance.CurrentLives - 5).ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
lifeOverflow.GetComponent<TMPro.TextMeshProUGUI>().text = "(+0)";
|
||||
lifeOverflow.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCoresBar()
|
||||
{
|
||||
float corePowerPercent = (float)GameManager.Instance.CurrentCores / (float)GameManager.Instance.CurrentNeededCores;
|
||||
|
||||
if (coresText != null)
|
||||
{
|
||||
coresText.GetComponent<TMPro.TextMeshProUGUI>().text = "Core Power: " + Mathf.RoundToInt(corePowerPercent * 100.0f) + "%";
|
||||
}
|
||||
|
||||
if (coresBar != null)
|
||||
{
|
||||
if (coresFillBar != null)
|
||||
{
|
||||
RectTransform fillBarImage = coresFillBar.GetComponent<RectTransform>();
|
||||
RectTransform parentBar = fillBarImage.parent.GetComponent<RectTransform>();
|
||||
float leftOffset = parentBar.rect.size.x - (parentBar.rect.size.x * corePowerPercent);
|
||||
fillBarImage.offsetMin = new Vector2(leftOffset, 0);
|
||||
//fillBarImage.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, leftOffset);
|
||||
}
|
||||
//for (int i = 0; i < 6; i++)
|
||||
//{
|
||||
// Transform currentCore = coresBar.transform.Find("Core" + i.ToString());
|
||||
// if (currentCore != null)
|
||||
// {
|
||||
// if (i <= GameManager.Instance.CurrentCores)
|
||||
// {
|
||||
// currentCore.gameObject.SetActive(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// currentCore.gameObject.SetActive(false);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//Transform coreOverflow = coresBar.transform.Find("CoreOverflow");
|
||||
//if (coreOverflow != null)
|
||||
//{
|
||||
// if (GameManager.Instance.CurrentCores > 5)
|
||||
// {
|
||||
// coreOverflow.gameObject.SetActive(true);
|
||||
// coreOverflow.GetComponent<TMPro.TextMeshProUGUI>().text = "(+" + (GameManager.Instance.CurrentCores - 5).ToString() + ")";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// coreOverflow.GetComponent<TMPro.TextMeshProUGUI>().text = "(+0)";
|
||||
// coreOverflow.gameObject.SetActive(false);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScore()
|
||||
{
|
||||
if (scoreText != null)
|
||||
{
|
||||
scoreText.GetComponent<TMPro.TextMeshProUGUI>().text = GameManager.Instance.CurrentScore.ToString().PadLeft(10, '0');
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLevel()
|
||||
{
|
||||
if (levelText != null)
|
||||
{
|
||||
levelText.GetComponent<TMPro.TextMeshProUGUI>().text = (GameManager.Instance.CurrentLevel + 1).ToString().PadLeft(2, '0');
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBoostStatus()
|
||||
{
|
||||
if (boostStatus != null)
|
||||
{
|
||||
if (_playerHoverMovement != null)
|
||||
{
|
||||
if (_playerHoverMovement.BoostReady)
|
||||
{
|
||||
boostStatus.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
boostStatus.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void LateUpdate()
|
||||
{
|
||||
UpdateLifeBar();
|
||||
UpdateCoresBar();
|
||||
UpdateScore();
|
||||
UpdateLevel();
|
||||
UpdateBoostStatus();
|
||||
|
||||
if (Input.GetButtonDown("Cancel"))
|
||||
{
|
||||
if (!isPaused)
|
||||
{
|
||||
isPaused = true;
|
||||
pauseMenu.SetActive(true);
|
||||
EventSystem.current.SetSelectedGameObject(pauseMenuFirstItem);
|
||||
_lastControlSelected = pauseMenuFirstItem;
|
||||
Time.timeScale = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnpauseGame();
|
||||
}
|
||||
}
|
||||
|
||||
if (isPaused)
|
||||
{
|
||||
float horzLRot = -Input.GetAxis("Horizontal");
|
||||
if (horzLRot != 0)
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject == null)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_lastControlSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastControlSelected = EventSystem.current.currentSelectedGameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UnpauseGame()
|
||||
{
|
||||
isPaused = false;
|
||||
mainPausePanel.SetActive(true);
|
||||
optionsPanel.SetActive(false);
|
||||
confirmPanel.SetActive(false);
|
||||
pauseMenu.SetActive(false);
|
||||
Time.timeScale = 1.0f;
|
||||
}
|
||||
|
||||
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 ResumeGame()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
UnpauseGame();
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
|
||||
Time.timeScale = 1.0f;
|
||||
SceneManager.LoadSceneAsync("MainMenu");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ public class MineHoverMovement : HoverMovement
|
||||
{
|
||||
// Cores dont move at the moment but the movescript can be used above if they need to orbit around the blackhole
|
||||
_rngHorz = 0;
|
||||
_rngVert = 0;
|
||||
_rngVert = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -135,21 +135,27 @@ public class MineHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
//ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
//ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ public class MineObjectShared : ObjectShared
|
||||
public float flashLength;
|
||||
public float flashDistance;
|
||||
|
||||
public bool selfDetonate;
|
||||
public float selfDetonateTime;
|
||||
private float _selfDetonateTick;
|
||||
private TimerHelper _selfDetonateTimer;
|
||||
|
||||
private GameObject _player;
|
||||
|
||||
@ -27,6 +28,7 @@ public class MineObjectShared : ObjectShared
|
||||
_defaultMineEmissionColor = mineModel.GetComponent<MeshRenderer>().materials[0].GetColor("_EmissionColor");
|
||||
_flashLevel = 0;
|
||||
_player = GameObject.Find("Player");
|
||||
_selfDetonateTimer = new TimerHelper(selfDetonateTime, false);
|
||||
}
|
||||
|
||||
// Helper class incase we need to track a variable over multiple scripts
|
||||
@ -69,21 +71,23 @@ public class MineObjectShared : ObjectShared
|
||||
}
|
||||
}
|
||||
|
||||
if (_selfDetonateTick >= selfDetonateTime)
|
||||
if (selfDetonate)
|
||||
{
|
||||
MineColliderManager currentMineCM = gameObject.GetComponent<MineColliderManager>();
|
||||
if (currentMineCM != null)
|
||||
if (_selfDetonateTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
currentMineCM.HitMine();
|
||||
}
|
||||
_selfDetonateTick = 0.0f;
|
||||
MineColliderManager currentMineCM = gameObject.GetComponent<MineColliderManager>();
|
||||
if (currentMineCM != null)
|
||||
{
|
||||
currentMineCM.HitMine();
|
||||
}
|
||||
_selfDetonateTimer.RestartTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
mineModel.GetComponent<MeshRenderer>().materials[0].SetColor("_Color", Color.Lerp(_defaultMineColor, colorFlash, _selfDetonateTimer.Position));
|
||||
mineModel.GetComponent<MeshRenderer>().materials[0].SetColor("_EmissionColor", Color.Lerp(_defaultMineEmissionColor, colorFlash, _selfDetonateTimer.Position));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mineModel.GetComponent<MeshRenderer>().materials[0].SetColor("_Color", Color.Lerp(_defaultMineColor, colorFlash, (_selfDetonateTick / selfDetonateTime)));
|
||||
mineModel.GetComponent<MeshRenderer>().materials[0].SetColor("_EmissionColor", Color.Lerp(_defaultMineEmissionColor, colorFlash, (_selfDetonateTick / selfDetonateTime)));
|
||||
_selfDetonateTick += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class ObjectSpawning : MonoBehaviour
|
||||
|
||||
// The interval the spawner is ran/checked at
|
||||
public float spawnMaxIntervalTime;
|
||||
private float _spawnCurrentIntervalTime;
|
||||
private TimerHelper _spawnCurrentTimer;
|
||||
|
||||
public bool debugSpawn;
|
||||
|
||||
@ -39,7 +39,7 @@ public class ObjectSpawning : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_spawnCurrentIntervalTime = 2.0f;
|
||||
_spawnCurrentTimer = new TimerHelper(spawnMaxIntervalTime);
|
||||
}
|
||||
|
||||
protected virtual void DoASpawn()
|
||||
@ -52,26 +52,27 @@ public class ObjectSpawning : MonoBehaviour
|
||||
|
||||
private void Update()
|
||||
{
|
||||
GetCurrentCount();
|
||||
|
||||
// Can this spawner curerntly spawn?
|
||||
if (canSpawn)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
// Check if the wait for the spawning tick before spawning
|
||||
if (_spawnCurrentIntervalTime >= spawnMaxIntervalTime)
|
||||
GetCurrentCount();
|
||||
|
||||
// Can this spawner curerntly spawn?
|
||||
if (canSpawn)
|
||||
{
|
||||
if (objectCount < _numberToSpawn)
|
||||
if (_spawnCurrentTimer.TimesRun == 0)
|
||||
{
|
||||
// The child scripts spawn script is run
|
||||
DoASpawn();
|
||||
_spawnCurrentTimer.HasTicked(spawnMaxIntervalTime - Time.deltaTime);
|
||||
}
|
||||
|
||||
// Restart the current spawn tick
|
||||
_spawnCurrentIntervalTime = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_spawnCurrentIntervalTime += Time.deltaTime;
|
||||
// Check if the wait for the spawning tick before spawning
|
||||
if (_spawnCurrentTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
if (objectCount < _numberToSpawn)
|
||||
{
|
||||
// The child scripts spawn script is run
|
||||
DoASpawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class PlayerColliderManager : ColliderManager
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
enemyColliderManager.DestoryEnemy();
|
||||
enemyColliderManager.DestoryEnemy(true);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
|
@ -9,7 +9,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
{
|
||||
// Residual Thrust variables to handle the "glide" after the gameObject has moved
|
||||
public float residualThrustStep;
|
||||
public float residualThrustMax;
|
||||
public float residualThrustMax;
|
||||
public float residualThrustTimeTickMax;
|
||||
public float residualThrustDecayRate;
|
||||
public float residualThrustIdleDecayRate;
|
||||
@ -19,11 +19,9 @@ public class PlayerHoverMovement : HoverMovement
|
||||
public float jumpForce;
|
||||
public float jumpMaxTime;
|
||||
|
||||
public Spedometer speedUI;
|
||||
|
||||
private float _residualThrust;
|
||||
private float _residualThrustCurrentTime;
|
||||
|
||||
|
||||
private float _currentJumpTime;
|
||||
private bool _isJumping;
|
||||
|
||||
@ -51,6 +49,23 @@ public class PlayerHoverMovement : HoverMovement
|
||||
private Gradient _defaultTrailGradient;
|
||||
private float _defaultTrailMultiplier;
|
||||
|
||||
public bool BoostReady
|
||||
{
|
||||
get
|
||||
{
|
||||
bool result;
|
||||
if (!_isBoosting && !_boostingCoolingDown)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method for toggling the boost trail particle effects for the player
|
||||
/// </summary>
|
||||
@ -100,7 +115,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
{
|
||||
_defaultTrailGradient = _playerTrails[0].colorGradient;
|
||||
_defaultTrailMultiplier = _playerTrails[0].widthMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
_currentAudioSource = gameObject.GetComponent<AudioSource>();
|
||||
base.DoAwakeTasks();
|
||||
@ -114,7 +129,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
{
|
||||
// Get the Horz and Vert axis from the controls
|
||||
float horzInput = Input.GetAxis("Horizontal");
|
||||
float vertInput = Input.GetAxis("Vertical");
|
||||
float vertInput = Input.GetAxis("Vertical");
|
||||
|
||||
// Check horz direction value, pos = Right, neg = Left
|
||||
if (horzInput > 0)
|
||||
@ -122,7 +137,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
_turnDirection = 1;
|
||||
}
|
||||
else if (horzInput < 0)
|
||||
{
|
||||
{
|
||||
_turnDirection = -1;
|
||||
}
|
||||
else
|
||||
@ -142,7 +157,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
{
|
||||
_thrustDirection *= boostModifier;
|
||||
}
|
||||
|
||||
|
||||
// Check if we still have residual thrust to add
|
||||
if (_residualThrust < residualThrustMax)
|
||||
{
|
||||
@ -157,9 +172,9 @@ public class PlayerHoverMovement : HoverMovement
|
||||
{
|
||||
if (_residualThrustCurrentTime >= residualThrustTimeTickMax)
|
||||
{
|
||||
_residualThrust -= residualThrustDecayRate;
|
||||
}
|
||||
_thrustDirection = _residualThrust / residualThrustMax;
|
||||
_residualThrust -= residualThrustDecayRate;
|
||||
}
|
||||
_thrustDirection = _residualThrust / residualThrustMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -178,7 +193,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
{
|
||||
if (_residualThrustCurrentTime >= residualThrustTimeTickMax)
|
||||
{
|
||||
_residualThrust -= residualThrustIdleDecayRate;
|
||||
_residualThrust -= residualThrustIdleDecayRate;
|
||||
}
|
||||
_thrustDirection = _residualThrust / residualThrustMax;
|
||||
}
|
||||
@ -196,7 +211,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
_residualThrustCurrentTime += currentTimeStep;
|
||||
}
|
||||
|
||||
@ -207,14 +222,14 @@ public class PlayerHoverMovement : HoverMovement
|
||||
{
|
||||
// Check if the boost is on cooldown otherwise boost
|
||||
if (!_boostingCoolingDown)
|
||||
{
|
||||
{
|
||||
_isBoosting = true;
|
||||
ToggleBoostEffects();
|
||||
if (_currentAudioSource)
|
||||
{
|
||||
_currentAudioSource.PlayOneShot(boostSFX);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentAudioSource)
|
||||
@ -268,11 +283,11 @@ public class PlayerHoverMovement : HoverMovement
|
||||
// Check if the jump button
|
||||
if (Input.GetButtonDown("Jump") && !_isJumping)
|
||||
{
|
||||
_isJumping = true;
|
||||
_isJumping = true;
|
||||
}
|
||||
|
||||
// Run any base class stuff
|
||||
base.ProcessPreMovement(currentTimeStep);
|
||||
base.ProcessPreMovement(currentTimeStep);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -293,29 +308,33 @@ public class PlayerHoverMovement : HoverMovement
|
||||
else
|
||||
{
|
||||
_currentJumpTime += Time.fixedDeltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
testHeight = _currentHeight;
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
|
||||
speedUI.SpeedSlider(_thrustDirection);
|
||||
testHeight = _currentHeight;
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,60 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum PowerUpType
|
||||
{
|
||||
None,
|
||||
ForceMagnet,
|
||||
TurboBoost,
|
||||
EmergencyDrop
|
||||
}
|
||||
|
||||
public class PlayerObjectShared : ObjectShared
|
||||
{
|
||||
// Helper class incase we need to track a variable over multiple scripts
|
||||
public float coreMagnetRange;
|
||||
public float coreMagnetForce;
|
||||
private AudioSource _currentAudioSource;
|
||||
|
||||
public AudioClip badPowerUp;
|
||||
|
||||
[SerializeField]
|
||||
private PowerUpEffect _currentPowerUpEffect;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_currentAudioSource = gameObject.GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
public bool AttachPickUp(PowerUpEffect newEffect)
|
||||
{
|
||||
_currentPowerUpEffect = newEffect;
|
||||
_currentPowerUpEffect.ApplyEffect();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetButtonDown("Fire2"))
|
||||
{
|
||||
if (_currentPowerUpEffect != null)
|
||||
{
|
||||
if (!_currentPowerUpEffect.OnUseEffect())
|
||||
{
|
||||
if (_currentAudioSource != null)
|
||||
{
|
||||
Debug.Log("Used by failed");
|
||||
_currentAudioSource.PlayOneShot(badPowerUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentAudioSource != null)
|
||||
{
|
||||
Debug.Log("None Exist failed");
|
||||
_currentAudioSource.PlayOneShot(badPowerUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,10 @@ using UnityEngine;
|
||||
|
||||
public class PowerUpColliderManager : ColliderManager
|
||||
{
|
||||
public AudioClip corePickupSFX;
|
||||
public PowerUpEffect powerUpEffect;
|
||||
public AudioClip tokenPickupSFX;
|
||||
private AudioSource _audioSource;
|
||||
private bool _powerUpCollected = false;
|
||||
|
||||
public override void DoAwakeTasks()
|
||||
{
|
||||
@ -45,24 +47,18 @@ public class PowerUpColliderManager : ColliderManager
|
||||
public void PickupCore()
|
||||
{
|
||||
// If the core has been collected ignore it.
|
||||
if (!_coreCollected)
|
||||
if (!_powerUpCollected)
|
||||
{
|
||||
_coreCollected = true;
|
||||
_powerUpCollected = true;
|
||||
|
||||
if (_audioSource != null)
|
||||
{
|
||||
_audioSource.PlayOneShot(corePickupSFX);
|
||||
}
|
||||
GameManager.Instance.AddCore();
|
||||
|
||||
if (transform.childCount > 0)
|
||||
{
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
transform.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
_audioSource.PlayOneShot(tokenPickupSFX);
|
||||
}
|
||||
|
||||
Destroy(gameObject, 2.0f);
|
||||
powerUpEffect.OnPickUp();
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,21 +135,27 @@ public class PowerUpHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
//ProcessJump();
|
||||
if (objectIsActive)
|
||||
{
|
||||
//ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectIsActive)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
if (objectIsActive)
|
||||
{
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,10 @@ using UnityEngine;
|
||||
|
||||
public class PowerUpObjectShared : ObjectShared
|
||||
{
|
||||
private GameObject _currentPlayer;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
private Rigidbody _objectRigidBody;
|
||||
|
||||
// Tracking the spawner this gameObject was created by so we can reduce the counter for it later
|
||||
private ObjectSpawning _spawner;
|
||||
|
||||
@ -18,4 +22,30 @@ public class PowerUpObjectShared : ObjectShared
|
||||
_spawner = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_currentPlayer = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _currentPlayer.GetComponent<PlayerObjectShared>();
|
||||
_objectRigidBody = gameObject.GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (_currentPlayer != null)
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
if (_playerObjectShared != null)
|
||||
{
|
||||
Vector3 directionToPlayer = transform.position - _currentPlayer.transform.position;
|
||||
float distanceToPlayer = directionToPlayer.magnitude;
|
||||
if (distanceToPlayer <= _playerObjectShared.coreMagnetRange)
|
||||
{
|
||||
_objectRigidBody.AddForce(-directionToPlayer * distanceToPlayer * _playerObjectShared.coreMagnetForce * Time.fixedDeltaTime, ForceMode.VelocityChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,72 +39,40 @@ public class PowerUpSpawning : ObjectSpawning
|
||||
if (debugSpawn)
|
||||
{
|
||||
/*
|
||||
In Congress, July 4, 1776
|
||||
|
||||
In Congress, July 4, 1776
|
||||
The unanimous Declaration of the thirteen united States of America, When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.
|
||||
|
||||
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness.--That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, --That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient causes; and accordingly all experience hath shewn, that mankind are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms to which they are accustomed. But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security.--Such has been the patient sufferance of these Colonies; and such is now the necessity which constrains them to alter their former Systems of Government. The history of the present King of Great Britain is a history of repeated injuries and usurpations, all having in direct object the establishment of an absolute Tyranny over these States. To prove this, let Facts be submitted to a candid world.
|
||||
|
||||
He has refused his Assent to Laws, the most wholesome and necessary for the public good.
|
||||
|
||||
He has forbidden his Governors to pass Laws of immediate and pressing importance, unless suspended in their operation till his Assent should be obtained; and when so suspended, he has utterly neglected to attend to them.
|
||||
|
||||
He has refused to pass other Laws for the accommodation of large districts of people, unless those people would relinquish the right of Representation in the Legislature, a right inestimable to them and formidable to tyrants only.
|
||||
|
||||
He has called together legislative bodies at places unusual, uncomfortable, and distant from the depository of their public Records, for the sole purpose of fatiguing them into compliance with his measures.
|
||||
|
||||
He has dissolved Representative Houses repeatedly, for opposing with manly firmness his invasions on the rights of the people.
|
||||
|
||||
He has refused for a long time, after such dissolutions, to cause others to be elected; whereby the Legislative powers, incapable of Annihilation, have returned to the People at large for their exercise; the State remaining in the mean time exposed to all the dangers of invasion from without, and convulsions within.
|
||||
|
||||
He has endeavoured to prevent the population of these States; for that purpose obstructing the Laws for Naturalization of Foreigners; refusing to pass others to encourage their migrations hither, and raising the conditions of new Appropriations of Lands.
|
||||
|
||||
He has obstructed the Administration of Justice, by refusing his Assent to Laws for establishing Judiciary powers.
|
||||
|
||||
He has made Judges dependent on his Will alone, for the tenure of their offices, and the amount and payment of their salaries.
|
||||
|
||||
He has erected a multitude of New Offices, and sent hither swarms of Officers to harrass our people, and eat out their substance.
|
||||
|
||||
He has kept among us, in times of peace, Standing Armies without the Consent of our legislatures.
|
||||
|
||||
He has affected to render the Military independent of and superior to the Civil power.
|
||||
|
||||
He has combined with others to subject us to a jurisdiction foreign to our constitution, and unacknowledged by our laws; giving his Assent to their Acts of pretended Legislation:
|
||||
|
||||
For Quartering large bodies of armed troops among us:
|
||||
|
||||
For protecting them, by a mock Trial, from punishment for any Murders which they should commit on the Inhabitants of these States:
|
||||
|
||||
For cutting off our Trade with all parts of the world:
|
||||
|
||||
For imposing Taxes on us without our Consent:
|
||||
|
||||
For depriving us in many cases, of the benefits of Trial by Jury:
|
||||
|
||||
For transporting us beyond Seas to be tried for pretended offences
|
||||
|
||||
For abolishing the free System of English Laws in a neighbouring Province, establishing therein an Arbitrary government, and enlarging its Boundaries so as to render it at once an example and fit instrument for introducing the same absolute rule into these Colonies:
|
||||
|
||||
For taking away our Charters, abolishing our most valuable Laws, and altering fundamentally the Forms of our Governments:
|
||||
|
||||
For suspending our own Legislatures, and declaring themselves invested with power to legislate for us in all cases whatsoever.
|
||||
|
||||
He has abdicated Government here, by declaring us out of his Protection and waging War against us.
|
||||
|
||||
He has plundered our seas, ravaged our Coasts, burnt our towns, and destroyed the lives of our people.
|
||||
|
||||
He is at this time transporting large Armies of foreign Mercenaries to compleat the works of death, desolation and tyranny, already begun with circumstances of Cruelty & perfidy scarcely paralleled in the most barbarous ages, and totally unworthy the Head of a civilized nation.
|
||||
|
||||
He has constrained our fellow Citizens taken Captive on the high Seas to bear Arms against their Country, to become the executioners of their friends and Brethren, or to fall themselves by their Hands.
|
||||
|
||||
He has excited domestic insurrections amongst us, and has endeavoured to bring on the inhabitants of our frontiers, the merciless Indian Savages, whose known rule of warfare, is an undistinguished destruction of all ages, sexes and conditions.
|
||||
|
||||
In every stage of these Oppressions We have Petitioned for Redress in the most humble terms: Our repeated Petitions have been answered only by repeated injury. A Prince whose character is thus marked by every act which may define a Tyrant, is unfit to be the ruler of a free people.
|
||||
|
||||
Nor have We been wanting in attentions to our Brittish brethren. We have warned them from time to time of attempts by their legislature to extend an unwarrantable jurisdiction over us. We have reminded them of the circumstances of our emigration and settlement here. We have appealed to their native justice and magnanimity, and we have conjured them by the ties of our common kindred to disavow these usurpations, which, would inevitably interrupt our connections and correspondence. They too have been deaf to the voice of justice and of consanguinity. We must, therefore, acquiesce in the necessity, which denounces our Separation, and hold them, as we hold the rest of mankind, Enemies in War, in Peace Friends.
|
||||
|
||||
We, therefore, the Representatives of the united States of America, in General Congress, Assembled, appealing to the Supreme Judge of the world for the rectitude of our intentions, do, in the Name, and by Authority of the good People of these Colonies, solemnly publish and declare, That these United Colonies are, and of Right ought to be Free and Independent States; that they are Absolved from all Allegiance to the British Crown, and that all political connection between them and the State of Great Britain, is and ought to be totally dissolved; and that as Free and Independent States, they have full Power to levy War, conclude Peace, contract Alliances, establish Commerce, and to do all other Acts and Things which Independent States may of right do. And for the support of this Declaration, with a firm reliance on the protection of divine Providence, we mutually pledge to each other our Lives, our Fortunes and our sacred Honor.
|
||||
*/
|
||||
We, therefore, the Representatives of the united States of America, in General Congress, Assembled, appealing to the Supreme Judge of the world for the rectitude of our intentions, do, in the Name, and by Authority of the good People of these Colonies, solemnly publish and declare, That these United Colonies are, and of Right ought to be Free and Independent States; that they are Absolved from all Allegiance to the British Crown, and that all political connection between them and the State of Great Britain, is and ought to be totally dissolved; and that as Free and Independent States, they have full Power to levy War, conclude Peace, contract Alliances, establish Commerce, and to do all other Acts and Things which Independent States may of right do. And for the support of this Declaration, with a firm reliance on the protection of divine Providence, we mutually pledge to each other our Lives, our Fortunes and our sacred Honor.
|
||||
*/
|
||||
GameObject currentPlayer = GameObject.Find("Player");
|
||||
xPos = currentPlayer.transform.position.x;
|
||||
zPos = currentPlayer.transform.position.z;
|
||||
|
Reference in New Issue
Block a user