Added new sounds needed for game
Added blackhole swirl texture and materials Added Magnet, Hunter and Drop core powerups and script overhaul for powerups in general Added Scenes and Cinematic changes for the game, win and death screens Added a score Changed the way enemy spawns work Removed unused scripts
This commit is contained in:
@ -5,6 +5,7 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
// Game object to track the player GO
|
||||
private GameObject _player;
|
||||
private GameObject _blackHole;
|
||||
private EnemyColliderManager _enemyColliderManager;
|
||||
|
||||
// Residual Thrust variables to handle the "glide" after the gameObject has moved
|
||||
public float residualThrustStep;
|
||||
@ -33,9 +34,8 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
private bool _charged;
|
||||
private float _currentChargeCooldownTick;
|
||||
|
||||
|
||||
public override void DoAwakeTasks()
|
||||
{
|
||||
protected override void DoAwakeTasks()
|
||||
{
|
||||
base.DoAwakeTasks();
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
// We have to find the player since setting it in the editor doesnt work correctly
|
||||
_player = GameObject.Find("Player");
|
||||
_blackHole = GameObject.Find("BlackHole");
|
||||
_enemyColliderManager = gameObject.GetComponent<EnemyColliderManager>();
|
||||
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
@ -87,6 +88,15 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
void DoAI(float currentTimeStep)
|
||||
{
|
||||
if (_enemyColliderManager.Magnetized)
|
||||
{
|
||||
_noMovement = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_noMovement = false;
|
||||
}
|
||||
|
||||
// Get the Up vector of each gameObject so we can compare its X values rather than the Y
|
||||
Vector3 playerDirection = _player.transform.position - transform.position;
|
||||
|
||||
@ -163,7 +173,7 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
/// Anything in this method can be removed, as long as the _turnDirection and _thrustDirection are set then the parent script with handle the orbit and positioning.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -255,7 +265,7 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
/// <summary>
|
||||
/// Method for dealing with the jump physics, this should be in the fixed update since it uses rigidbody physics
|
||||
/// </summary>
|
||||
void ProcessJump()
|
||||
private void ProcessJump()
|
||||
{
|
||||
// If the enemy is jumping add the jump force
|
||||
if (_isJumping)
|
||||
@ -275,7 +285,7 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessCooldowns(float currentTimeStep)
|
||||
private void ProcessCooldowns(float currentTimeStep)
|
||||
{
|
||||
if (_charged)
|
||||
{
|
||||
@ -310,6 +320,7 @@ public class ChaserEnemyHoverMovement : HoverMovement
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
|
@ -11,6 +11,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
// Game object to track the player GO
|
||||
private GameObject _player;
|
||||
private GameObject _blackHole;
|
||||
private EnemyColliderManager _enemyColliderManager;
|
||||
|
||||
// Residual Thrust variables to handle the "glide" after the gameObject has moved
|
||||
public float residualThrustStep;
|
||||
@ -47,7 +48,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
private float _heightChangeTick;
|
||||
public float heightChangeInterval;
|
||||
|
||||
public override void DoAwakeTasks()
|
||||
protected override void DoAwakeTasks()
|
||||
{
|
||||
base.DoAwakeTasks();
|
||||
}
|
||||
@ -58,6 +59,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
// We have to find the player since setting it in the editor doesnt work correctly
|
||||
_player = GameObject.Find("Player");
|
||||
_blackHole = GameObject.Find("BlackHole");
|
||||
_enemyColliderManager = gameObject.GetComponent<EnemyColliderManager>();
|
||||
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
@ -78,7 +80,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
// Custom start stuff can go here
|
||||
}
|
||||
|
||||
void DoAIPhysics(float currentTimeStep)
|
||||
private void DoAIPhysics(float currentTimeStep)
|
||||
{
|
||||
|
||||
}
|
||||
@ -87,8 +89,17 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
/// Calculates some RNG movement for the attached Enemy.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
void DoAI(float currentTimeStep)
|
||||
private void DoAI(float currentTimeStep)
|
||||
{
|
||||
if (_enemyColliderManager.Magnetized)
|
||||
{
|
||||
_noMovement = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_noMovement = false;
|
||||
}
|
||||
|
||||
// Get the Up vector of each gameObject so we can compare its X values rather than the Y
|
||||
Vector3 playerDirection = _player.transform.position - transform.position;
|
||||
|
||||
@ -180,7 +191,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
/// Anything in this method can be removed, as long as the _turnDirection and _thrustDirection are set then the parent script with handle the orbit and positioning.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -280,7 +291,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
/// <summary>
|
||||
/// Method for dealing with the jump physics, this should be in the fixed update since it uses rigidbody physics
|
||||
/// </summary>
|
||||
void ProcessJump()
|
||||
private void ProcessJump()
|
||||
{
|
||||
// If the enemy is jumping add the jump force
|
||||
if (_isJumping)
|
||||
@ -300,7 +311,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessCooldowns(float currentTimeStep)
|
||||
private void ProcessCooldowns(float currentTimeStep)
|
||||
{
|
||||
if (_emergencyBoosting)
|
||||
{
|
||||
@ -372,6 +383,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
|
@ -7,6 +7,7 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
// Game object to track the player GO
|
||||
private GameObject _player;
|
||||
private GameObject _blackHole;
|
||||
private EnemyColliderManager _enemyColliderManager;
|
||||
|
||||
// Residual Thrust variables to handle the "glide" after the gameObject has moved
|
||||
public float residualThrustStep;
|
||||
@ -34,19 +35,18 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
public float dropCooldownSpeed;
|
||||
private bool _dropped;
|
||||
private float _currentDropCooldownTick;
|
||||
|
||||
|
||||
public override void DoAwakeTasks()
|
||||
protected override void DoAwakeTasks()
|
||||
{
|
||||
base.DoAwakeTasks();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
// We have to find the player since setting it in the editor doesnt work correctly
|
||||
_player = GameObject.Find("Player");
|
||||
_blackHole = GameObject.Find("BlackHole");
|
||||
_enemyColliderManager = gameObject.GetComponent<EnemyColliderManager>();
|
||||
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
@ -64,7 +64,7 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
// Custom start stuff can go here
|
||||
}
|
||||
|
||||
void DoAIPhysics(float currentTimeStep)
|
||||
private void DoAIPhysics(float currentTimeStep)
|
||||
{
|
||||
RaycastHit belowCheck;
|
||||
Physics.SphereCast(transform.position, 5.0f, -transform.up, out belowCheck, 6.0f, LayerMask.GetMask("Player"));
|
||||
@ -87,8 +87,17 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
/// Calculates some RNG movement for the attached Enemy.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
void DoAI(float currentTimeStep)
|
||||
private void DoAI(float currentTimeStep)
|
||||
{
|
||||
if (_enemyColliderManager.Magnetized)
|
||||
{
|
||||
_noMovement = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_noMovement = false;
|
||||
}
|
||||
|
||||
// Get the Up vector of each gameObject so we can compare its X values rather than the Y
|
||||
Vector3 playerDirection = _player.transform.position - transform.position;
|
||||
Vector3 playerLocation = Vector3.ProjectOnPlane(_player.transform.position, Vector3.forward);
|
||||
@ -151,7 +160,7 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
/// Anything in this method can be removed, as long as the _turnDirection and _thrustDirection are set then the parent script with handle the orbit and positioning.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -243,7 +252,7 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
/// <summary>
|
||||
/// Method for dealing with the jump physics, this should be in the fixed update since it uses rigidbody physics
|
||||
/// </summary>
|
||||
void ProcessJump()
|
||||
private void ProcessJump()
|
||||
{
|
||||
// If the enemy is jumping add the jump force
|
||||
if (_isJumping)
|
||||
@ -263,7 +272,7 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessCooldowns(float currentTimeStep)
|
||||
private void ProcessCooldowns(float currentTimeStep)
|
||||
{
|
||||
if (_dropped)
|
||||
{
|
||||
@ -298,6 +307,7 @@ public class DropperEnemyHoverMovement : HoverMovement
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
|
@ -7,6 +7,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
// Game object to track the player GO
|
||||
private GameObject _player;
|
||||
private GameObject _blackHole;
|
||||
private EnemyColliderManager _enemyColliderManager;
|
||||
|
||||
// Residual Thrust variables to handle the "glide" after the gameObject has moved
|
||||
public float residualThrustStep;
|
||||
@ -38,17 +39,18 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
private float _heightChangeTick;
|
||||
public float heightChangeInterval;
|
||||
|
||||
public override void DoAwakeTasks()
|
||||
protected override void DoAwakeTasks()
|
||||
{
|
||||
base.DoAwakeTasks();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
// We have to find the player since setting it in the editor doesnt work correctly
|
||||
_player = GameObject.Find("Player");
|
||||
_blackHole = GameObject.Find("BlackHole");
|
||||
_enemyColliderManager = gameObject.GetComponent<EnemyColliderManager>();
|
||||
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
@ -66,7 +68,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
// Custom start stuff can go here
|
||||
}
|
||||
|
||||
void DoAIPhysics(float currentTimeStep)
|
||||
private void DoAIPhysics(float currentTimeStep)
|
||||
{
|
||||
|
||||
}
|
||||
@ -75,8 +77,17 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
/// Calculates some RNG movement for the attached Enemy.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
void DoAI(float currentTimeStep)
|
||||
private void DoAI(float currentTimeStep)
|
||||
{
|
||||
if (_enemyColliderManager.Magnetized)
|
||||
{
|
||||
_noMovement = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_noMovement = false;
|
||||
}
|
||||
|
||||
// Get the Up vector of each gameObject so we can compare its X values rather than the Y
|
||||
Vector3 playerDirection = _player.transform.position - transform.position;
|
||||
Vector3 playerLocation = Vector3.ProjectOnPlane(_player.transform.position, Vector3.up);
|
||||
@ -150,7 +161,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
/// Anything in this method can be removed, as long as the _turnDirection and _thrustDirection are set then the parent script with handle the orbit and positioning.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -242,7 +253,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
/// <summary>
|
||||
/// Method for dealing with the jump physics, this should be in the fixed update since it uses rigidbody physics
|
||||
/// </summary>
|
||||
void ProcessJump()
|
||||
private void ProcessJump()
|
||||
{
|
||||
// If the enemy is jumping add the jump force
|
||||
if (_isJumping)
|
||||
@ -262,7 +273,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessCooldowns(float currentTimeStep)
|
||||
private void ProcessCooldowns(float currentTimeStep)
|
||||
{
|
||||
if (_heightChangeTick >= heightChangeInterval)
|
||||
{
|
||||
@ -294,6 +305,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoAI(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
|
@ -15,6 +15,8 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
private List<string> _commandOutput = new List<string>();
|
||||
private int _prevCommandIndex = 0;
|
||||
|
||||
private float _prevTimeScale = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Method to toggle the debug console
|
||||
/// </summary>
|
||||
@ -22,11 +24,12 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
{
|
||||
if (_toggleWindow && !force)
|
||||
{
|
||||
Time.timeScale = 1.0f;
|
||||
Time.timeScale = _prevTimeScale;
|
||||
_toggleWindow = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_prevTimeScale = Time.timeScale;
|
||||
Time.timeScale = 0.0f;
|
||||
_toggleWindow = true;
|
||||
}
|
||||
@ -155,6 +158,14 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
case "imreallybadatthisgame":
|
||||
DoLevelJump(100);
|
||||
break;
|
||||
case "iamareallybigcheater":
|
||||
int scoreJump = 1000;
|
||||
if (commandParts.Length > 1)
|
||||
{
|
||||
int.TryParse(commandParts[1], out scoreJump);
|
||||
}
|
||||
DoScoreIncrease(scoreJump);
|
||||
break;
|
||||
// Pick up all current cores floating in the scene
|
||||
case "pickupall":
|
||||
PickupAll();
|
||||
@ -186,6 +197,14 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void DoScoreIncrease(int value)
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
GameManager.Instance.AddScore(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void DoFall()
|
||||
{
|
||||
GameObject[] enemiesSpawned = GameObject.FindGameObjectsWithTag("Enemy");
|
||||
@ -231,6 +250,16 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
case "shield":
|
||||
spawnPrefabId = 8;
|
||||
break;
|
||||
case "magnetcore":
|
||||
spawnPrefabId = 9;
|
||||
break;
|
||||
case "chasecore":
|
||||
spawnPrefabId = 10;
|
||||
break;
|
||||
case "dropcore":
|
||||
spawnPrefabId = 11;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (spawnPrefabId != -1)
|
||||
@ -354,9 +383,12 @@ public class DebugConsoleManager : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.BackQuote) || Input.GetKeyDown(KeyCode.Tilde))
|
||||
{
|
||||
ToggleDebugConsole(true);
|
||||
}
|
||||
if (GameEngine.gameStarted)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.BackQuote) || Input.GetKeyDown(KeyCode.Tilde))
|
||||
{
|
||||
ToggleDebugConsole(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
Assets/Scripts/Other/DeadEngine.cs
Normal file
120
Assets/Scripts/Other/DeadEngine.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class DeadEngine : MonoBehaviour
|
||||
{
|
||||
public GameObject hudGO;
|
||||
public GameObject cockpitGO;
|
||||
public TMPro.TextMeshProUGUI scoreText;
|
||||
|
||||
public float cockpitRotationSpeed;
|
||||
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
|
||||
public float flashFrequencyTime;
|
||||
private TimerHelper _flashTimer;
|
||||
|
||||
private MeshRenderer _meshRenderer;
|
||||
private Color _defaultEmissionColor;
|
||||
|
||||
private GameObject _lastControlSelected;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GameManager.Instance.currentGameState = GameState.DEATHMENU;
|
||||
}
|
||||
|
||||
// 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");
|
||||
_lastControlSelected = EventSystem.current.firstSelectedGameObject;
|
||||
|
||||
scoreText.text = scoreText.text.Replace("{SCORE}", GameManager.Instance.CurrentScore.ToString().PadLeft(10, '0'));
|
||||
}
|
||||
|
||||
public void PlayMenuClick()
|
||||
{
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
}
|
||||
|
||||
public void MainMenuNav()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
SceneManager.LoadSceneAsync("MainMenu");
|
||||
}
|
||||
|
||||
public void GameMenuNav()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
SceneManager.LoadSceneAsync("Game");
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (cockpitGO != null)
|
||||
{
|
||||
cockpitGO.transform.Rotate(Vector3.up, cockpitRotationSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
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 horzIn = Input.GetAxis("Horizontal");
|
||||
float vertIn = Input.GetAxis("Vertical");
|
||||
|
||||
if (horzIn != 0 || vertIn != 0)
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject == null)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_lastControlSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastControlSelected = EventSystem.current.currentSelectedGameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39d57a8aa33863c4dbac39c865492676
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: ad4368d80ced9164286eacd09d291659
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,41 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
593
Assets/Scripts/Other/GameEngine.cs
Normal file
593
Assets/Scripts/Other/GameEngine.cs
Normal file
@ -0,0 +1,593 @@
|
||||
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;
|
||||
public GameObject winCinematicGO;
|
||||
private PlayerHoverMovement _playerHoverMovement;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
private BlackHoleManager _currentBlackHoleManager;
|
||||
public float arenaSize;
|
||||
|
||||
[Header("Sound Elements")]
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public AudioSource currentSFXAudioSource;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
public AudioClip lifeUpSFX;
|
||||
|
||||
//public TMPro.TextMeshProUGUI coreCountText;
|
||||
|
||||
[Header("Gameplay UI Elements")]
|
||||
public GameObject livesBar;
|
||||
public GameObject coresText;
|
||||
public GameObject coresBar;
|
||||
public GameObject coresFillBar;
|
||||
public GameObject boostStatus;
|
||||
public GameObject boostBar;
|
||||
public GameObject abilityDesc;
|
||||
public GameObject abilityStatus;
|
||||
public GameObject abilityBar;
|
||||
public GameObject scoreText;
|
||||
public GameObject levelText;
|
||||
public GameObject startTimeline;
|
||||
public GoTextFadeHelper goText;
|
||||
public GameObject jumpTextGO;
|
||||
|
||||
private bool boostBarShown = false;
|
||||
private bool abilityBarShown = false;
|
||||
|
||||
[Header("Pause Menu Elements")]
|
||||
public TMPro.TextMeshProUGUI versionText;
|
||||
public GameObject pauseMenu;
|
||||
public GameObject mainPausePanel;
|
||||
public GameObject optionsPanel;
|
||||
public GameObject confirmPanel;
|
||||
public static bool isPaused = true;
|
||||
public static bool playerPaused = false;
|
||||
public GameObject pauseMenuFirstItem;
|
||||
private GameObject _lastControlSelected;
|
||||
|
||||
private float _prevTimeScale;
|
||||
|
||||
public static bool gameStarted = false;
|
||||
private bool _musicSwappedA = false;
|
||||
|
||||
private HiddenValueInt _lastScoreCheck;
|
||||
private HiddenValueInt _scorePerLifeUp;
|
||||
private bool _gameOverHit;
|
||||
private bool _playerJumped;
|
||||
private TimerHelper _playerJumpFlash;
|
||||
private bool _winCinematicDone;
|
||||
|
||||
[Header("Dialog Elements")]
|
||||
public GameObject dialogMainUIGO;
|
||||
public float dialogDisplayTime;
|
||||
public AudioClip dialogSFXClip;
|
||||
public List<GameObject> dialogGOList;
|
||||
|
||||
private List<bool> _dialogRanCheck = new List<bool>();
|
||||
private Queue<int> _dialogQueue = new Queue<int>();
|
||||
private int _currentDialogIndex;
|
||||
private TimerHelper _dialogTimer;
|
||||
private bool _dialogActive;
|
||||
|
||||
private TimerHelper _bonusTimeLimit;
|
||||
|
||||
// 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()
|
||||
{
|
||||
// Start the game, make sure the play GO is active
|
||||
//currentPlayer.SetActive(true);
|
||||
gameStarted = false;
|
||||
if (currentBGMManager)
|
||||
{
|
||||
currentBGMManager.StartAudioQueueAndPlay(0);
|
||||
}
|
||||
|
||||
_playerHoverMovement = currentPlayer.GetComponent<PlayerHoverMovement>();
|
||||
_playerObjectShared = currentPlayer.GetComponent<PlayerObjectShared>();
|
||||
versionText.text = versionText.text.Replace("{versionNo}", GameManager.Instance.CurrentVersion);
|
||||
mainPlayer = currentPlayer;
|
||||
_prevTimeScale = 1.0f;
|
||||
_lastScoreCheck = new HiddenValueInt(0);
|
||||
_scorePerLifeUp = new HiddenValueInt(10000);
|
||||
currentPlayer.SetActive(false);
|
||||
startTimeline.SetActive(true);
|
||||
_gameOverHit = false;
|
||||
_playerJumped = false;
|
||||
_playerJumpFlash = new TimerHelper(0.5f);
|
||||
_winCinematicDone = false;
|
||||
|
||||
for (int i = 0; i < dialogGOList.Count; i++)
|
||||
{
|
||||
_dialogRanCheck.Add(false);
|
||||
}
|
||||
|
||||
_bonusTimeLimit = new TimerHelper(1200, false, TimerDirection.TimerDecrement);
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
currentPlayer.SetActive(true);
|
||||
isPaused = false;
|
||||
gameStarted = true;
|
||||
Destroy(startTimeline);
|
||||
currentBGMManager.CreateLoopQueue(1, 2, 3);
|
||||
goText.StartFade();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current blackhole radius
|
||||
/// </summary>
|
||||
/// <returns>Current Blackhole size as a float</returns>
|
||||
public float GetCurrentBlackHoleRadius()
|
||||
{
|
||||
return _currentBlackHoleManager.currentBlackHoleRadius;
|
||||
}
|
||||
|
||||
private void UpdateLifeBar()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScore()
|
||||
{
|
||||
if (scoreText != null)
|
||||
{
|
||||
scoreText.GetComponent<TMPro.TextMeshProUGUI>().text = GameManager.Instance.CurrentScore.ToString().PadLeft(10, '0');
|
||||
}
|
||||
int newLifeCheck = Mathf.FloorToInt(GameManager.Instance.CurrentScore / _scorePerLifeUp.Value);
|
||||
if (_lastScoreCheck.Value < newLifeCheck && !_gameOverHit)
|
||||
{
|
||||
GameManager.Instance.AddLife(_lastScoreCheck.Value - newLifeCheck);
|
||||
_lastScoreCheck.Value = newLifeCheck;
|
||||
if (lifeUpSFX != null)
|
||||
{
|
||||
currentSFXAudioSource.PlayOneShot(lifeUpSFX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
boostBar.SetActive(false);
|
||||
boostBarShown = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (boostBarShown)
|
||||
{
|
||||
if (boostBar != null)
|
||||
{
|
||||
Transform boostFillBar = boostBar.transform.Find("BoostBackgroundBar/BoostFillBar");
|
||||
if (boostFillBar != null)
|
||||
{
|
||||
RectTransform fillBarImage = boostFillBar.gameObject.GetComponent<RectTransform>();
|
||||
RectTransform parentBar = fillBarImage.parent.GetComponent<RectTransform>();
|
||||
float rightOffset = -parentBar.rect.size.x + (parentBar.rect.size.x * _playerHoverMovement.BoostCooldownPosition);
|
||||
fillBarImage.offsetMax = new Vector2(rightOffset, 0);
|
||||
//fillBarImage.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, leftOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boostStatus.SetActive(false);
|
||||
boostBar.SetActive(true);
|
||||
boostBarShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAbilityBar()
|
||||
{
|
||||
if (_playerObjectShared.currentAbility != null)
|
||||
{
|
||||
if (abilityDesc != null)
|
||||
{
|
||||
abilityDesc.SetActive(true);
|
||||
abilityDesc.GetComponent<TMPro.TextMeshProUGUI>().text = _playerObjectShared.currentAbility.uiDescText;
|
||||
}
|
||||
|
||||
if (abilityBar != null)
|
||||
{
|
||||
abilityStatus.GetComponent<TMPro.TextMeshProUGUI>().text = _playerObjectShared.currentAbility.uiReadyText;
|
||||
if (!_playerObjectShared.currentAbility.CooldownStatus)
|
||||
{
|
||||
abilityStatus.SetActive(true);
|
||||
abilityBar.SetActive(false);
|
||||
abilityBarShown = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (abilityBarShown)
|
||||
{
|
||||
if (abilityBar != null)
|
||||
{
|
||||
Transform abilityFillBar = abilityBar.transform.Find("PowerBackgroundBar/PowerFillBar");
|
||||
if (abilityFillBar != null)
|
||||
{
|
||||
RectTransform fillBarImage = abilityFillBar.gameObject.GetComponent<RectTransform>();
|
||||
RectTransform parentBar = fillBarImage.parent.GetComponent<RectTransform>();
|
||||
float leftOffset = parentBar.rect.size.x - (parentBar.rect.size.x * _playerObjectShared.currentAbility.CooldownTimePercent);
|
||||
fillBarImage.offsetMin = new Vector2(leftOffset, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
abilityStatus.SetActive(false);
|
||||
abilityBar.SetActive(true);
|
||||
abilityBarShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
abilityBar.SetActive(false);
|
||||
abilityStatus.SetActive(false);
|
||||
abilityDesc.SetActive(false);
|
||||
abilityBarShown = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void DoDialog(int dialogIndex, bool force = false)
|
||||
{
|
||||
if ((!_dialogActive && !_dialogRanCheck[dialogIndex]) || force)
|
||||
{
|
||||
_currentDialogIndex = dialogIndex;
|
||||
_dialogTimer = new TimerHelper(dialogDisplayTime, false);
|
||||
dialogMainUIGO.SetActive(true);
|
||||
dialogGOList[_currentDialogIndex].SetActive(true);
|
||||
_dialogActive = true;
|
||||
if (dialogSFXClip != null)
|
||||
{
|
||||
currentSFXAudioSource.PlayOneShot(dialogSFXClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void QueueDialog(int dialogIndex)
|
||||
{
|
||||
if (!_dialogRanCheck[dialogIndex])
|
||||
{
|
||||
if (_dialogActive)
|
||||
{
|
||||
_dialogQueue.Enqueue(dialogIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoDialog(dialogIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckDialog(float currentTimeStamp)
|
||||
{
|
||||
if (_dialogActive)
|
||||
{
|
||||
if (_dialogTimer.HasTicked(currentTimeStamp))
|
||||
{
|
||||
_dialogRanCheck[_currentDialogIndex] = true;
|
||||
dialogGOList[_currentDialogIndex].SetActive(false);
|
||||
dialogMainUIGO.SetActive(false);
|
||||
_dialogTimer.RestartTimer();
|
||||
_dialogActive = false;
|
||||
if (_dialogQueue.Count > 0)
|
||||
{
|
||||
DoDialog(_dialogQueue.Dequeue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void LateUpdate()
|
||||
{
|
||||
if (gameStarted)
|
||||
{
|
||||
UpdateLifeBar();
|
||||
UpdateCoresBar();
|
||||
UpdateScore();
|
||||
UpdateLevel();
|
||||
UpdateBoostStatus();
|
||||
UpdateAbilityBar();
|
||||
|
||||
if (GameManager.Instance.CurrentLevel == 3)
|
||||
{
|
||||
if (!_musicSwappedA)
|
||||
{
|
||||
currentBGMManager.QueueIntroThenLoopQueue(4, 5, 6, 7, 6, 8);
|
||||
_musicSwappedA = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (gameStarted)
|
||||
{
|
||||
CheckDialog(Time.deltaTime);
|
||||
|
||||
if (Input.GetButtonDown("Cancel"))
|
||||
{
|
||||
if (!_gameOverHit)
|
||||
{
|
||||
if (!isPaused)
|
||||
{
|
||||
isPaused = true;
|
||||
pauseMenu.SetActive(true);
|
||||
EventSystem.current.SetSelectedGameObject(pauseMenuFirstItem);
|
||||
_lastControlSelected = pauseMenuFirstItem;
|
||||
_prevTimeScale = Time.timeScale;
|
||||
Time.timeScale = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnpauseGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isPaused)
|
||||
{
|
||||
float horzLRot = Input.GetAxis("Horizontal") + Input.GetAxis("Vertical");
|
||||
if (horzLRot != 0)
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject == null)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_lastControlSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastControlSelected = EventSystem.current.currentSelectedGameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!_playerJumped)
|
||||
{
|
||||
if (Input.GetButtonDown("Jump"))
|
||||
{
|
||||
DoDialog(0);
|
||||
_playerJumped = true;
|
||||
jumpTextGO.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jumpTextGO != null)
|
||||
{
|
||||
if (_playerJumpFlash.HasTicked(Time.deltaTime))
|
||||
{
|
||||
jumpTextGO.SetActive(!jumpTextGO.activeSelf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!_gameOverHit)
|
||||
{
|
||||
if (GameManager.Instance.CurrentLevel >= 5)
|
||||
{
|
||||
if (winCinematicGO != null)
|
||||
{
|
||||
winCinematicGO.transform.position = currentPlayer.transform.position;
|
||||
winCinematicGO.transform.rotation = currentPlayer.transform.rotation;
|
||||
winCinematicGO.SetActive(true);
|
||||
currentPlayer.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_winCinematicDone = true;
|
||||
}
|
||||
isPaused = true;
|
||||
_gameOverHit = true;
|
||||
CalcFinalScore(true);
|
||||
}
|
||||
|
||||
if (GameManager.Instance.CurrentLives < 0)
|
||||
{
|
||||
CalcFinalScore(false);
|
||||
GameManager.Instance.DoGameOver();
|
||||
_gameOverHit = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_winCinematicDone)
|
||||
{
|
||||
GameManager.Instance.DoGameWon();
|
||||
_winCinematicDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
_bonusTimeLimit.HasTicked(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void CalcFinalScore(bool wonGame)
|
||||
{
|
||||
int workingScore = GameManager.Instance.CurrentScore;
|
||||
workingScore += 100000 * GameManager.Instance.CurrentLevel;
|
||||
if (wonGame)
|
||||
{
|
||||
workingScore *= Mathf.FloorToInt(_bonusTimeLimit.Position * 10.0f);
|
||||
}
|
||||
GameManager.Instance.SetScore(workingScore);
|
||||
}
|
||||
|
||||
public void FlagWin()
|
||||
{
|
||||
_winCinematicDone = true;
|
||||
}
|
||||
|
||||
public void UnpauseGame()
|
||||
{
|
||||
isPaused = false;
|
||||
mainPausePanel.SetActive(true);
|
||||
optionsPanel.SetActive(false);
|
||||
confirmPanel.SetActive(false);
|
||||
pauseMenu.SetActive(false);
|
||||
Time.timeScale = _prevTimeScale;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
41
Assets/Scripts/Other/GoTextFadeHelper.cs
Normal file
41
Assets/Scripts/Other/GoTextFadeHelper.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GoTextFadeHelper : MonoBehaviour
|
||||
{
|
||||
private bool _nowActive = false;
|
||||
public float fadeTime;
|
||||
private TimerHelper _fadeTimer;
|
||||
|
||||
public AudioSource sfxAudioSource;
|
||||
public AudioClip startAudioClip;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_fadeTimer = new TimerHelper(fadeTime, false);
|
||||
}
|
||||
|
||||
public void StartFade()
|
||||
{
|
||||
_nowActive = true;
|
||||
if (sfxAudioSource != null && startAudioClip != null)
|
||||
{
|
||||
sfxAudioSource.clip = startAudioClip;
|
||||
sfxAudioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_nowActive)
|
||||
{
|
||||
if (_fadeTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3de6b36e04a5c3449c7104442440712
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: e655029d7496d024fb4dae98d2b6dce5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -44,6 +44,7 @@ public class MainMenuEngine : MonoBehaviour
|
||||
_meshRenderer = hudGO.GetComponent<MeshRenderer>();
|
||||
_defaultEmissionColor = _meshRenderer.materials[0].GetColor("_EmissionColor");
|
||||
|
||||
_lastControlSelected = EventSystem.current.firstSelectedGameObject;
|
||||
versionText.text = versionText.text.Replace("{versionNo}", GameManager.Instance.CurrentVersion);
|
||||
}
|
||||
|
||||
@ -127,11 +128,13 @@ public class MainMenuEngine : MonoBehaviour
|
||||
_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;
|
||||
float horzIn = Input.GetAxis("Horizontal");
|
||||
float vertIn = Input.GetAxis("Vertical");
|
||||
float horzLRot = -horzIn * joystickJiggleSpeed;
|
||||
float vertLRot = -45.0f + -vertIn * joystickJiggleSpeed;
|
||||
joystickGO.transform.eulerAngles = new Vector3(vertLRot, 0.0f, horzLRot);
|
||||
|
||||
if (horzLRot != 0)
|
||||
if (horzIn != 0 || vertIn != 0)
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject == null)
|
||||
{
|
||||
|
@ -1,64 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -5,24 +5,19 @@ using UnityEngine;
|
||||
public class ParticalCleanUp : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private float tik;
|
||||
private float end = 2;
|
||||
private TimerHelper _removeTimer;
|
||||
|
||||
void Start()
|
||||
{
|
||||
tik = 0;
|
||||
_removeTimer = new TimerHelper(2.0f, false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(tik >= end)
|
||||
if(_removeTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
tik += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
@ -41,6 +41,7 @@ public class RulesMenuEngine : MonoBehaviour
|
||||
currentBGMManager.StartAudioQueueAndPlay(0);
|
||||
}
|
||||
|
||||
_lastControlSelected = EventSystem.current.firstSelectedGameObject;
|
||||
_startPosition = playerCameraGO.transform.position;
|
||||
_cutsceneEnded = false;
|
||||
}
|
||||
@ -148,6 +149,21 @@ public class RulesMenuEngine : MonoBehaviour
|
||||
//playerTrailsGO.SetActive(true);
|
||||
playerCameraGO.transform.position = playerCameraGO.transform.forward * 0.05f * Time.deltaTime;
|
||||
}
|
||||
|
||||
|
||||
float horzIn = Input.GetAxis("Horizontal");
|
||||
float vertIn = Input.GetAxis("Vertical");
|
||||
|
||||
if (horzIn != 0 || vertIn != 0)
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject == null)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_lastControlSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastControlSelected = EventSystem.current.currentSelectedGameObject;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
33
Assets/Scripts/Other/StaticImageAnimationHelper.cs
Normal file
33
Assets/Scripts/Other/StaticImageAnimationHelper.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class StaticImageAnimationHelper : MonoBehaviour
|
||||
{
|
||||
public Image uiImageHolder;
|
||||
public List<Sprite> sprites = new List<Sprite>();
|
||||
public float frameTime;
|
||||
|
||||
private int _currentFrame;
|
||||
private TimerHelper _frameTimer;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_currentFrame = 0;
|
||||
_frameTimer = new TimerHelper(frameTime);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (uiImageHolder != null)
|
||||
{
|
||||
if (_frameTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
uiImageHolder.sprite = sprites[_frameTimer.TimesRun % sprites.Count];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5678218a3034524ca1d3eb11b13ae1c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 93d29a2b1c6f99543b13f87c781b32fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Assets/Scripts/Other/TargetBillboardHelper.cs
Normal file
21
Assets/Scripts/Other/TargetBillboardHelper.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TargetBillboardHelper : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Camera.main != null)
|
||||
{
|
||||
gameObject.transform.rotation = Camera.main.transform.rotation;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 742ed625e6d4d46439f31a3dd0b6f94c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: c9fa54d5230d8194097ff53035347f62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/Other/TrailsHelper.cs
Normal file
18
Assets/Scripts/Other/TrailsHelper.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TrailsHelper : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
gameObject.transform.position += gameObject.transform.forward * 10.0f * Time.deltaTime;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/TrailsHelper.cs.meta
Normal file
11
Assets/Scripts/Other/TrailsHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e6b861c09631ab4ab5711aa1b3de80e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
104
Assets/Scripts/Other/WinEngine.cs
Normal file
104
Assets/Scripts/Other/WinEngine.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class WinEngine : MonoBehaviour
|
||||
{
|
||||
public TMPro.TextMeshProUGUI scoreText;
|
||||
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
|
||||
private GameObject _lastControlSelected;
|
||||
|
||||
public GameObject shipGO;
|
||||
public float flightSpeed;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GameManager.Instance.currentGameState = GameState.WINMENU;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
scoreText.text = scoreText.text.Replace("{SCORE}", GameManager.Instance.CurrentScore.ToString().PadLeft(10, '0'));
|
||||
_lastControlSelected = EventSystem.current.firstSelectedGameObject;
|
||||
}
|
||||
|
||||
public void PlayMenuClick()
|
||||
{
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
}
|
||||
|
||||
public void MainMenuNav()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
SceneManager.LoadSceneAsync("MainMenu");
|
||||
}
|
||||
|
||||
public void GameMenuNav()
|
||||
{
|
||||
// Play the menu click sound if the audio manager is present
|
||||
if (currentMenuAudioManager)
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
SceneManager.LoadSceneAsync("Game");
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (shipGO != null)
|
||||
{
|
||||
shipGO.transform.position += (shipGO.transform.forward * flightSpeed * Time.deltaTime);
|
||||
shipGO.transform.Rotate(Vector3.up, flightSpeed * Time.deltaTime * 0.5f);
|
||||
}
|
||||
|
||||
float horzIn = Input.GetAxis("Horizontal");
|
||||
float vertIn = Input.GetAxis("Vertical");
|
||||
|
||||
if (horzIn != 0 || vertIn != 0)
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject == null)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_lastControlSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastControlSelected = EventSystem.current.currentSelectedGameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/WinEngine.cs.meta
Normal file
11
Assets/Scripts/Other/WinEngine.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5a82754d46144d459297d06b756809b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,68 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7e2c85678107d943bcdd2c894626dba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
60
Assets/Scripts/PowerUps/AttachablePowerUpEffect.cs
Normal file
60
Assets/Scripts/PowerUps/AttachablePowerUpEffect.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AttachablePowerUpEffect : PowerUpEffect
|
||||
{
|
||||
public string uiReadyText;
|
||||
[TextArea]
|
||||
public string uiDescText;
|
||||
|
||||
public AudioClip onUseSFX;
|
||||
public AudioClip onAltSFX;
|
||||
|
||||
public float abilityCooldown;
|
||||
protected bool _abilityCooldown;
|
||||
protected TimerHelper _abilityCooldownTimer;
|
||||
|
||||
public bool CooldownStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return _abilityCooldown;
|
||||
}
|
||||
}
|
||||
|
||||
public float CooldownTimePercent
|
||||
{
|
||||
get
|
||||
{
|
||||
return _abilityCooldownTimer.Position;
|
||||
}
|
||||
}
|
||||
|
||||
public float CooldownTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _abilityCooldownTimer.CurrentTick;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool OnUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool OnAltUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual T GetStatChangesValue<T>(string statName, T currentValue)
|
||||
{
|
||||
switch(statName)
|
||||
{
|
||||
default:
|
||||
return currentValue;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/AttachablePowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/AttachablePowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2d66670f3ff6264c8f188a9ed6812a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
207
Assets/Scripts/PowerUps/ChaseAttachedPowerUpEffect.cs
Normal file
207
Assets/Scripts/PowerUps/ChaseAttachedPowerUpEffect.cs
Normal file
@ -0,0 +1,207 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
public class ChaseAttachedPowerUpEffect : AttachablePowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
private Rigidbody _playerRigidBody;
|
||||
|
||||
public float chargeForce;
|
||||
public float targetRange;
|
||||
public GameObject selectorGO;
|
||||
|
||||
private GameObject _currentTarget;
|
||||
|
||||
public float scanCooldown;
|
||||
private bool _scanCooldown;
|
||||
private TimerHelper _scanTimer;
|
||||
|
||||
private Queue<GameObject> _scannedObjects = new Queue<GameObject>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
_playerRigidBody = _player.GetComponent<Rigidbody>();
|
||||
_abilityCooldown = false;
|
||||
_abilityCooldownTimer = new TimerHelper(abilityCooldown, false);
|
||||
_scanCooldown = false;
|
||||
_scanTimer = new TimerHelper(scanCooldown, false);
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
PlayerColliderManager playerCM = _player.GetComponent<PlayerColliderManager>();
|
||||
if (playerCM != null)
|
||||
{
|
||||
playerCM.SetImmune(2.0f);
|
||||
}
|
||||
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Vector3 directionToTarget = _currentTarget.transform.position - _player.transform.position;
|
||||
_playerRigidBody.AddForce(directionToTarget.normalized * chargeForce, ForceMode.VelocityChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerRigidBody.AddForce(_player.transform.forward * chargeForce, ForceMode.VelocityChange);
|
||||
}
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("PowerUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onUseSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onUseSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnAltUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
if (!_scanCooldown)
|
||||
{
|
||||
bool result = false;
|
||||
Queue<GameObject> currentScan = new Queue<GameObject>();
|
||||
RaycastHit[] raycastHits = Physics.SphereCastAll(_player.transform.position, 30.0f, _player.transform.forward, targetRange, LayerMask.GetMask("Enemies"));
|
||||
if (raycastHits.Length > 0)
|
||||
{
|
||||
foreach (RaycastHit currentHit in raycastHits)
|
||||
{
|
||||
GameObject currentGO = currentHit.transform.gameObject;
|
||||
if (currentGO.tag != "Asteroid")
|
||||
{
|
||||
if (!currentScan.Contains(currentGO))
|
||||
{
|
||||
currentScan.Enqueue(currentGO);
|
||||
if (!_scannedObjects.Contains(currentGO))
|
||||
{
|
||||
_scannedObjects.Enqueue(currentGO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_scannedObjects = new Queue<GameObject>(_scannedObjects.Where(s => currentScan.Any(c => c == s)));
|
||||
|
||||
if (_scannedObjects.Count > 0)
|
||||
{
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Transform lastTargetGO = _currentTarget.transform.Find("ShipModel/Target");
|
||||
if (lastTargetGO != null)
|
||||
{
|
||||
Destroy(lastTargetGO.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
_currentTarget = _scannedObjects.Dequeue();
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Transform shipModel = _currentTarget.transform.Find("ShipModel");
|
||||
if (shipModel != null)
|
||||
{
|
||||
GameObject newTarget = Instantiate(selectorGO, shipModel);
|
||||
newTarget.name = "Target";
|
||||
}
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Transform lastTargetGO = _currentTarget.transform.Find("ShipModel/Target");
|
||||
if (lastTargetGO != null)
|
||||
{
|
||||
Destroy(lastTargetGO.gameObject);
|
||||
}
|
||||
}
|
||||
_currentTarget = null;
|
||||
}
|
||||
|
||||
if (onAltSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onAltSFX);
|
||||
}
|
||||
|
||||
_scanTimer.RestartTimer();
|
||||
_scanCooldown = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
Transform lastTargetGO = _currentTarget.transform.Find("ShipModel/Target");
|
||||
if (lastTargetGO != null)
|
||||
{
|
||||
Destroy(lastTargetGO.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_abilityCooldown)
|
||||
{
|
||||
if (_abilityCooldownTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_abilityCooldown = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_scanCooldown)
|
||||
{
|
||||
if (_scanTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_scanCooldown = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
uiReadyText = "Target Locked!";
|
||||
}
|
||||
else
|
||||
{
|
||||
uiReadyText = "Charge Ready";
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/ChaseAttachedPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/ChaseAttachedPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76658df4e112a4242933ce765ec32517
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
Assets/Scripts/PowerUps/ChasePowerUpEffect.cs
Normal file
39
Assets/Scripts/PowerUps/ChasePowerUpEffect.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChasePowerUpEffect : PowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
public GameObject coredVersionGO;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_currentGameEngine = FindObjectOfType<GameEngine>();
|
||||
_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);
|
||||
AttachablePowerUpEffect newDropEffect = newSpecialCore.GetComponent<ChaseAttachedPowerUpEffect>();
|
||||
_playerObjectShared.AttachPickUp(newDropEffect);
|
||||
|
||||
if (_currentGameEngine != null)
|
||||
{
|
||||
_currentGameEngine.QueueDialog(dialogIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/ChasePowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/ChasePowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0acb9ef365b6ca64f9de242050419158
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
94
Assets/Scripts/PowerUps/DropAttachedPowerUpEffect.cs
Normal file
94
Assets/Scripts/PowerUps/DropAttachedPowerUpEffect.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DropAttachedPowerUpEffect : AttachablePowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
private PlayerColliderManager _playerColliderManager;
|
||||
private Rigidbody _playerRigidBody;
|
||||
|
||||
public float dropPowerForce;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
_playerRigidBody = _player.GetComponent<Rigidbody>();
|
||||
_playerColliderManager = _player.GetComponent<PlayerColliderManager>();
|
||||
_abilityCooldown = false;
|
||||
_abilityCooldownTimer = new TimerHelper(abilityCooldown, false);
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
_playerRigidBody.AddForce(-_player.transform.up * dropPowerForce, ForceMode.VelocityChange);
|
||||
_playerColliderManager.SetDeadly();
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("PowerUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onUseSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onUseSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnAltUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
_playerRigidBody.AddForce(_player.transform.up * dropPowerForce, ForceMode.VelocityChange);
|
||||
_playerColliderManager.SetDeadly();
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("AltUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onAltSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onAltSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_abilityCooldown)
|
||||
{
|
||||
if (_abilityCooldownTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_abilityCooldown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/DropAttachedPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/DropAttachedPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 454df0da5160bf04ba9d3c2b668abb15
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
Assets/Scripts/PowerUps/DropPowerUpEffect.cs
Normal file
39
Assets/Scripts/PowerUps/DropPowerUpEffect.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DropPowerUpEffect : PowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
public GameObject coredVersionGO;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_currentGameEngine = FindObjectOfType<GameEngine>();
|
||||
_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);
|
||||
AttachablePowerUpEffect newDropEffect = newSpecialCore.GetComponent<DropAttachedPowerUpEffect>();
|
||||
_playerObjectShared.AttachPickUp(newDropEffect);
|
||||
|
||||
if (_currentGameEngine != null)
|
||||
{
|
||||
_currentGameEngine.QueueDialog(dialogIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
}
|
11
Assets/Scripts/PowerUps/DropPowerUpEffect.cs.meta
Normal file
11
Assets/Scripts/PowerUps/DropPowerUpEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23358c3666402094fb34adca754e8461
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
147
Assets/Scripts/PowerUps/MagnetAttachedPowerUpEffect.cs
Normal file
147
Assets/Scripts/PowerUps/MagnetAttachedPowerUpEffect.cs
Normal file
@ -0,0 +1,147 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MagnetAttachedPowerUpEffect : AttachablePowerUpEffect
|
||||
{
|
||||
private GameObject _player;
|
||||
private PlayerObjectShared _playerObjectShared;
|
||||
|
||||
public float magnetPowerForce;
|
||||
public float magnetPowerRange;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
_abilityCooldown = false;
|
||||
_abilityCooldownTimer = new TimerHelper(abilityCooldown, false);
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
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.normalized * magnetPowerForce, ForceMode.VelocityChange);
|
||||
}
|
||||
if (currentObject.tag == "Enemy")
|
||||
{
|
||||
EnemyColliderManager enemyColliderManager = currentObject.GetComponent<EnemyColliderManager>();
|
||||
enemyColliderManager.MagnetizeEnemy();
|
||||
}
|
||||
else if (currentObject.tag == "Mine")
|
||||
{
|
||||
MineColliderManager mineCM = currentObject.GetComponent<MineColliderManager>();
|
||||
if (mineCM != null)
|
||||
{
|
||||
mineCM.magnetizeMine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("PowerUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onUseSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onUseSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnAltUseEffect()
|
||||
{
|
||||
if (!_abilityCooldown)
|
||||
{
|
||||
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.normalized * magnetPowerForce, ForceMode.VelocityChange);
|
||||
}
|
||||
if (currentObject.tag == "Enemy")
|
||||
{
|
||||
EnemyColliderManager enemyColliderManager = currentObject.GetComponent<EnemyColliderManager>();
|
||||
enemyColliderManager.MagnetizeEnemy();
|
||||
}
|
||||
else if (currentObject.tag == "Mine")
|
||||
{
|
||||
MineColliderManager mineCM = currentObject.GetComponent<MineColliderManager>();
|
||||
if (mineCM != null)
|
||||
{
|
||||
mineCM.magnetizeMine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform particleEffect = powerUpModel.transform.Find("AltUsed");
|
||||
if (particleEffect != null)
|
||||
{
|
||||
ParticleSystem particleSys = particleEffect.gameObject.GetComponent<ParticleSystem>();
|
||||
particleSys.Play();
|
||||
}
|
||||
|
||||
if (onAltSFX != null)
|
||||
{
|
||||
_playerObjectShared.PlaySFX(onAltSFX);
|
||||
}
|
||||
|
||||
_abilityCooldown = true;
|
||||
_abilityCooldownTimer.RestartTimer();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_abilityCooldown)
|
||||
{
|
||||
if (_abilityCooldownTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_abilityCooldown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
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,6 +11,7 @@ public class MagnetPowerUpEffect : PowerUpEffect
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_currentGameEngine = FindObjectOfType<GameEngine>();
|
||||
_player = GameEngine.mainPlayer;
|
||||
_playerObjectShared = _player.GetComponent<PlayerObjectShared>();
|
||||
}
|
||||
@ -23,26 +24,16 @@ public class MagnetPowerUpEffect : PowerUpEffect
|
||||
Destroy(coreHolder.GetChild(i).gameObject);
|
||||
}
|
||||
GameObject newSpecialCore = Instantiate(coredVersionGO, coreHolder);
|
||||
PowerUpEffect newMagnetEffect = newSpecialCore.GetComponent<MagnetEmbedPowerUpEffect>();
|
||||
AttachablePowerUpEffect newMagnetEffect = newSpecialCore.GetComponent<MagnetAttachedPowerUpEffect>();
|
||||
_playerObjectShared.AttachPickUp(newMagnetEffect);
|
||||
|
||||
if (_currentGameEngine != null)
|
||||
{
|
||||
_currentGameEngine.QueueDialog(dialogIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override float CooldownStatus()
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public override bool PowerUpReady()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,12 @@ using UnityEngine;
|
||||
public class PowerUpEffect : MonoBehaviour
|
||||
{
|
||||
public string powerUpName;
|
||||
public string powerUpDesc;
|
||||
public string powerUpDesc;
|
||||
public GameObject powerUpModel;
|
||||
|
||||
protected GameEngine _currentGameEngine;
|
||||
public int dialogIndex;
|
||||
|
||||
public virtual void OnPickUp()
|
||||
{
|
||||
ApplyEffect();
|
||||
@ -16,20 +19,4 @@ public class PowerUpEffect : MonoBehaviour
|
||||
public virtual void ApplyEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool OnUseEffect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual float CooldownStatus()
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public virtual bool PowerUpReady()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class AsteroidHoverMovement : HoverMovement
|
||||
/// Processes the inputs needed to move the gameObject, the turn direction, thrust direction and any residual thrust calculations so that we dont just stop in place.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if the movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -154,10 +154,11 @@ public class AsteroidHoverMovement : HoverMovement
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
//ProcessPostMovement();
|
||||
ProcessPostMovement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,16 +13,24 @@ public class BackgroundMusicManager : MonoBehaviour
|
||||
// List of Audio clips for the background music
|
||||
public List<AudioClip> musicLibrary = new List<AudioClip>();
|
||||
|
||||
[SerializeField]
|
||||
private List<int> _loopQueue = new List<int>();
|
||||
|
||||
private AudioSource _audioSource;
|
||||
private AudioClip _currentAudioClip;
|
||||
private bool _pauseAudio = true;
|
||||
public static bool pauseAudio = true;
|
||||
public static bool stopAudio = false;
|
||||
private TimerHelper _audioTimer;
|
||||
private bool _forceChange;
|
||||
private int _currentLoopIndex;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
// Get the current audio source on this GO
|
||||
_audioSource = gameObject.GetComponent<AudioSource>();
|
||||
_audioSource = gameObject.GetComponent<AudioSource>();
|
||||
_forceChange = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -33,10 +41,25 @@ public class BackgroundMusicManager : MonoBehaviour
|
||||
public void StartAudioQueue(int initialSong, bool playOnStart = true)
|
||||
{
|
||||
QueueNextAudio(initialSong);
|
||||
_pauseAudio = !playOnStart;
|
||||
pauseAudio = !playOnStart;
|
||||
_forceChange = true;
|
||||
PlayCurrentAudio();
|
||||
}
|
||||
|
||||
public void CreateLoopQueue(params int[] trackIDs)
|
||||
{
|
||||
_loopQueue.Clear();
|
||||
_loopQueue.AddRange(trackIDs);
|
||||
_currentLoopIndex = 0;
|
||||
}
|
||||
|
||||
public void QueueIntroThenLoopQueue(int initialSong, params int[] trackIDs)
|
||||
{
|
||||
_currentAudioClip = musicLibrary[initialSong];
|
||||
CreateLoopQueue(trackIDs);
|
||||
_currentLoopIndex = -1;
|
||||
}
|
||||
|
||||
public void StartAudioQueueAndPlay(int initialSong)
|
||||
{
|
||||
StartAudioQueue(initialSong, true);
|
||||
@ -54,46 +77,71 @@ public class BackgroundMusicManager : MonoBehaviour
|
||||
|
||||
// Stop the audio but keep scanning for changes
|
||||
public void StopAudioNow()
|
||||
{
|
||||
_audioSource.Stop();
|
||||
_pauseAudio = true;
|
||||
CancelInvoke("PlayCurrentAudio");
|
||||
Invoke("PlayCurrentAudio", 0.1f);
|
||||
{
|
||||
pauseAudio = true;
|
||||
}
|
||||
|
||||
// Stop the audio and instantly play the next track
|
||||
public void StopCurrentAudioAndPlay(int songIndex)
|
||||
{
|
||||
_audioSource.Stop();
|
||||
CancelInvoke("PlayCurrentAudio");
|
||||
{
|
||||
_forceChange = true;
|
||||
StartAudioQueueAndPlay(songIndex);
|
||||
}
|
||||
|
||||
// Stop the audio and the cancel the invoke
|
||||
public void StopCurrentAudioForGood()
|
||||
{
|
||||
_audioSource.Stop();
|
||||
CancelInvoke("PlayCurrentAudio");
|
||||
stopAudio = true;
|
||||
}
|
||||
|
||||
public void PlayCurrentAudio()
|
||||
{
|
||||
if (!_pauseAudio)
|
||||
{
|
||||
_audioSource.clip = _currentAudioClip;
|
||||
_audioSource.Play();
|
||||
Invoke("PlayCurrentAudio", _audioSource.clip.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
_audioSource.Stop();
|
||||
Invoke("PlayCurrentAudio", 0.1f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (!stopAudio)
|
||||
{
|
||||
if (!pauseAudio)
|
||||
{
|
||||
if (_forceChange || _audioTimer.HasTicked(Time.unscaledDeltaTime))
|
||||
{
|
||||
if (_loopQueue.Count > 0 )
|
||||
{
|
||||
// Let a song play before the loop starts
|
||||
if (_currentLoopIndex == -1)
|
||||
{
|
||||
_currentLoopIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentAudioClip = musicLibrary[_loopQueue[_currentLoopIndex]];
|
||||
if (_currentLoopIndex >= _loopQueue.Count - 1)
|
||||
{
|
||||
_currentLoopIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentLoopIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
_audioSource.clip = _currentAudioClip;
|
||||
_audioSource.Play();
|
||||
_audioTimer = new TimerHelper(_audioSource.clip.length, false);
|
||||
_forceChange = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_audioSource.Pause();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_audioSource.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,16 @@ public class BasicEnemySpawning : ObjectSpawning
|
||||
newSpawnMovement.startPositionVector = new Vector3(xPos, yPos, zPos);
|
||||
newSpawnMovement.ForceHeightAdjust(Random.Range(minSpawnHeight, maxSpawnHeight));
|
||||
}
|
||||
|
||||
if (Physics.CheckSphere(newSpawn.transform.position, 2.0f, LayerMask.NameToLayer("Player")))
|
||||
{
|
||||
xPos = Random.Range(-xSpawnRange, xSpawnRange);
|
||||
yPos = Random.Range(-ySpawnRange, ySpawnRange);
|
||||
zPos = Random.Range(-zSpawnRange, zSpawnRange);
|
||||
newSpawnMovement.startPositionVector = new Vector3(xPos, yPos, zPos);
|
||||
newSpawnMovement.ForceHeightAdjust(Random.Range(minSpawnHeight, maxSpawnHeight));
|
||||
}
|
||||
|
||||
// Set the spawned to this on the gameObject
|
||||
EnemyObjectShared newSpawnShared = newSpawn.GetComponent<EnemyObjectShared>();
|
||||
if (newSpawnShared)
|
||||
|
@ -38,10 +38,10 @@ public class BasicFollowEnemyHoverMovement : HoverMovement
|
||||
public float chargeCooldown;
|
||||
private bool _charged;
|
||||
private float _currentChargeCooldownTick;
|
||||
private RaycastHit _rayHitPosition;
|
||||
|
||||
private RaycastHit _rayHitPosition;
|
||||
|
||||
public override void DoAwakeTasks()
|
||||
|
||||
protected override void DoAwakeTasks()
|
||||
{
|
||||
base.DoAwakeTasks();
|
||||
}
|
||||
@ -175,7 +175,7 @@ public class BasicFollowEnemyHoverMovement : HoverMovement
|
||||
/// Anything in this method can be removed, as long as the _turnDirection and _thrustDirection are set then the parent script with handle the orbit and positioning.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if movement has been frozen
|
||||
if (!freezeMovement)
|
||||
|
@ -21,7 +21,7 @@ public class BlackHoleManager : MonoBehaviour
|
||||
public float initialBlackHoleRadius;
|
||||
public float blackHoleSizeIncrement;
|
||||
public float blackHoleSizeTime;
|
||||
public float gravityPullFoce;
|
||||
public float gravityPullForce;
|
||||
|
||||
public float currentBlackHoleRadius;
|
||||
|
||||
@ -30,7 +30,7 @@ public class BlackHoleManager : MonoBehaviour
|
||||
// Vars for dealing with the blackhole SFX
|
||||
private AudioSource _currentAudioSource;
|
||||
public AudioClip blackHoleAmbiantSFX;
|
||||
public int maxAudioSize = 10;
|
||||
public int maxAudioSize = 5;
|
||||
public bool playBlackHoleAmbiantNoise;
|
||||
|
||||
/// <summary>
|
||||
@ -129,7 +129,7 @@ public class BlackHoleManager : MonoBehaviour
|
||||
// Apply force to every blackhole force object in the list
|
||||
foreach (BlackHoleForce bhfObject in blackHoleForceObjects)
|
||||
{
|
||||
bhfObject.ApplyBlackHoleForce(gravityPullFoce * Time.fixedDeltaTime);
|
||||
bhfObject.ApplyBlackHoleForce(gravityPullForce * Time.fixedDeltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,22 +21,25 @@ public class BoundaryManager : MonoBehaviour
|
||||
|
||||
void OnCollisionStay(Collision collision)
|
||||
{
|
||||
DoCollision(collision.gameObject, collision);
|
||||
DoCollision(collision.gameObject, collision, false);
|
||||
}
|
||||
|
||||
void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
DoCollision(collision.gameObject, collision);
|
||||
DoCollision(collision.gameObject, collision, true);
|
||||
}
|
||||
|
||||
private void DoCollision(GameObject collidedObject, Collision collisionPoint)
|
||||
private void DoCollision(GameObject collidedObject, Collision collisionPoint, bool doHitEffect)
|
||||
{
|
||||
BoundaryCheck collidedBoundaryCheck = collidedObject.GetComponent<BoundaryCheck>();
|
||||
if (collidedBoundaryCheck)
|
||||
{
|
||||
GameObject newLight = Instantiate(hitLight);
|
||||
newLight.transform.position = collisionPoint.GetContact(0).point;
|
||||
newLight.SetActive(true);
|
||||
if (doHitEffect)
|
||||
{
|
||||
GameObject newLight = Instantiate(hitLight);
|
||||
newLight.transform.position = collisionPoint.GetContact(0).point;
|
||||
newLight.SetActive(true);
|
||||
}
|
||||
|
||||
collidedBoundaryCheck.DoBoundaryPushback(collisionPoint.GetContact(0).normal, pushbackForce);
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
@ -8,7 +6,9 @@ using UnityEngine;
|
||||
public class ColliderManager : MonoBehaviour
|
||||
{
|
||||
protected AudioSource _attachedAudioSource;
|
||||
|
||||
protected Rigidbody _attachedRigidbody;
|
||||
public GameObject shipModel;
|
||||
|
||||
/// <summary>
|
||||
/// An enum to pass which direction the collision happened.
|
||||
/// </summary>
|
||||
@ -23,9 +23,10 @@ public class ColliderManager : MonoBehaviour
|
||||
{
|
||||
// Get the objects audio source, if one is present
|
||||
_attachedAudioSource = gameObject.GetComponent<AudioSource>();
|
||||
_attachedRigidbody = gameObject.GetComponent<Rigidbody>();
|
||||
|
||||
// Do any tasks the child has to process
|
||||
DoAwakeTasks();
|
||||
DoAwakeTasks();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -62,7 +63,7 @@ public class ColliderManager : MonoBehaviour
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
{
|
||||
DoCollisionEnter(collision);
|
||||
}
|
||||
|
||||
@ -76,21 +77,25 @@ public class ColliderManager : MonoBehaviour
|
||||
// Get the collided objects collision manager, if they dont have one then we ignore it since we only want objects to interact when they have to.
|
||||
ColliderManager hitCM = collision.gameObject.GetComponent<ColliderManager>();
|
||||
if (hitCM != null)
|
||||
{
|
||||
// Get the vector where the collision happened, and check if it happened above or below.
|
||||
//Vector3 collisionHitCheckPosition = collision.gameObject.transform.position - gameObject.transform.position;
|
||||
float collisionHitDirection = Vector3.Dot(collision.GetContact(0).normal, collision.transform.up);
|
||||
|
||||
{
|
||||
CollisionDirection direction = CollisionDirection.None;
|
||||
if (collisionHitDirection < -0.1f)
|
||||
|
||||
if (_attachedRigidbody != null)
|
||||
{
|
||||
direction = CollisionDirection.Top;
|
||||
if (collision.contacts.Length > 0)
|
||||
{
|
||||
Vector3 collisionDirLocal = gameObject.transform.InverseTransformPoint(collision.gameObject.transform.position);
|
||||
if (collisionDirLocal.y > 0.5f)
|
||||
{
|
||||
direction = CollisionDirection.Top;
|
||||
}
|
||||
else if (collisionDirLocal.y < -0.5f)
|
||||
{
|
||||
direction = CollisionDirection.Bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (collisionHitDirection > 0.1f)
|
||||
{
|
||||
direction = CollisionDirection.Bottom;
|
||||
}
|
||||
|
||||
|
||||
// Once we know process the collision.
|
||||
ProcessCollision(direction, collision, wasChild);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class CoreHoverMovement : HoverMovement
|
||||
private float _rngHorz;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
@ -38,7 +38,7 @@ public class CoreHoverMovement : HoverMovement
|
||||
/// Calculates some RNG movement for the attached core.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
void DoRNG(float currentTimeStep)
|
||||
private void DoRNG(float currentTimeStep)
|
||||
{
|
||||
// Cores dont move at the moment but the movescript can be used above if they need to orbit around the blackhole
|
||||
_rngHorz = 0;
|
||||
@ -49,7 +49,7 @@ public class CoreHoverMovement : HoverMovement
|
||||
/// Processes the inputs needed to move the gameobject, the turn direction, thrust direction and any residual thrust calculations so that we dont just stop in place.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if the movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -148,12 +148,13 @@ public class CoreHoverMovement : HoverMovement
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
|
@ -27,7 +27,7 @@ public class CoreObjectShared : ObjectShared
|
||||
float distanceToPlayer = directionToPlayer.magnitude;
|
||||
if (distanceToPlayer <= _playerObjectShared.coreMagnetRange)
|
||||
{
|
||||
_objectRigidBody.AddForce(-directionToPlayer * distanceToPlayer * _playerObjectShared.coreMagnetForce * Time.fixedDeltaTime, ForceMode.VelocityChange);
|
||||
_objectRigidBody.AddForce(-directionToPlayer.normalized * distanceToPlayer * _playerObjectShared.coreMagnetForce * Time.fixedDeltaTime, ForceMode.VelocityChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using UnityEngine;
|
||||
public class EnemyColliderManager : ColliderManager
|
||||
{
|
||||
public GameObject shipCore;
|
||||
public GameObject shipModel;
|
||||
public float bounceForce;
|
||||
public float coreSpawnDelayTime;
|
||||
|
||||
@ -26,9 +25,30 @@ public class EnemyColliderManager : ColliderManager
|
||||
public List<GameObject> enemyLoot;
|
||||
public List<float> enemyLootChance;
|
||||
|
||||
public float magnetizedTime;
|
||||
private bool _magnetHit = false;
|
||||
private TimerHelper _magnetizeTime;
|
||||
|
||||
public bool Dying
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enemyDestroyed;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Magnetized
|
||||
{
|
||||
get
|
||||
{
|
||||
return _magnetHit;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_deathTimer = new TimerHelper(coreSpawnDelayTime, false);
|
||||
_deathTimer = new TimerHelper(coreSpawnDelayTime, false);
|
||||
_magnetizeTime = new TimerHelper(magnetizedTime, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -58,88 +78,106 @@ public class EnemyColliderManager : ColliderManager
|
||||
collisionGO = collision.gameObject;
|
||||
}
|
||||
|
||||
switch (direction)
|
||||
if (!Dying)
|
||||
{
|
||||
// We were hit from the top
|
||||
case CollisionDirection.Top:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Player":
|
||||
// We were killed by the player above
|
||||
DestoryEnemy(true);
|
||||
break;
|
||||
case "Enemy":
|
||||
// Bounce other enemies back
|
||||
BounceAway(collision.contacts[0].normal);
|
||||
break;
|
||||
case "Core":
|
||||
case "Dead":
|
||||
// Now handled by the layer NoCollide
|
||||
// Ignore the physics between this and the core or dead players
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
// We were hit from the bottom
|
||||
case CollisionDirection.Bottom:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Player":
|
||||
// Kill the player because we were on top
|
||||
PlayerColliderManager playerColliderManager = collisionGO.GetComponent<PlayerColliderManager>();
|
||||
if (playerColliderManager)
|
||||
{
|
||||
playerColliderManager.PlayerHit();
|
||||
}
|
||||
break;
|
||||
case "Enemy":
|
||||
// Bounce the enemy away
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
enemyColliderManager.BounceAway(-collision.contacts[0].normal);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
case "Dead":
|
||||
// Now handled by the layer NoCollide
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
// Hits coming from any direction
|
||||
default:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Mine":
|
||||
MineColliderManager mineColliderManager = collisionGO.GetComponent<MineColliderManager>();
|
||||
if (mineColliderManager)
|
||||
{
|
||||
mineColliderManager.HitMine();
|
||||
}
|
||||
break;
|
||||
case "Asteroid":
|
||||
AsteroidColliderManager asteroidColliderManager = collisionGO.GetComponent<AsteroidColliderManager>();
|
||||
if (asteroidColliderManager)
|
||||
{
|
||||
asteroidColliderManager.BounceAway(gameObject, -collision.contacts[0].normal);
|
||||
}
|
||||
break;
|
||||
case "Enemy":
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
enemyColliderManager.BounceAway(-collision.contacts[0].normal);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
case "Dead":
|
||||
// Handled by the layers now
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
// We were hit from the top
|
||||
case CollisionDirection.Top:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Player":
|
||||
// We were killed by the player above
|
||||
PlayerColliderManager playerColliderManager = collisionGO.GetComponent<PlayerColliderManager>();
|
||||
if (playerColliderManager)
|
||||
{
|
||||
if (!playerColliderManager.Dying)
|
||||
{
|
||||
DestoryEnemy(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Enemy":
|
||||
// Bounce other enemies back
|
||||
BounceAway(collision.contacts[0].normal);
|
||||
break;
|
||||
case "Core":
|
||||
case "Dead":
|
||||
// Now handled by the layer NoCollide
|
||||
// Ignore the physics between this and the core or dead players
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
// We were hit from the bottom
|
||||
case CollisionDirection.Bottom:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Player":
|
||||
// Kill the player because we were on top
|
||||
PlayerColliderManager playerColliderManager = collisionGO.GetComponent<PlayerColliderManager>();
|
||||
if (playerColliderManager)
|
||||
{
|
||||
if (playerColliderManager.Deadly)
|
||||
{
|
||||
DestoryEnemy(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerColliderManager.PlayerHit();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Enemy":
|
||||
// Bounce the enemy away
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
enemyColliderManager.BounceAway(-collision.contacts[0].normal);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
case "Dead":
|
||||
// Now handled by the layer NoCollide
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
// Hits coming from any direction
|
||||
default:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Mine":
|
||||
MineColliderManager mineColliderManager = collisionGO.GetComponent<MineColliderManager>();
|
||||
if (mineColliderManager)
|
||||
{
|
||||
mineColliderManager.HitMine();
|
||||
}
|
||||
break;
|
||||
case "Asteroid":
|
||||
AsteroidColliderManager asteroidColliderManager = collisionGO.GetComponent<AsteroidColliderManager>();
|
||||
if (asteroidColliderManager)
|
||||
{
|
||||
asteroidColliderManager.BounceAway(gameObject, -collision.contacts[0].normal);
|
||||
}
|
||||
break;
|
||||
case "Player":
|
||||
case "Enemy":
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
enemyColliderManager.BounceAway(-collision.contacts[0].normal);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
case "Dead":
|
||||
// Handled by the layers now
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -172,6 +210,14 @@ public class EnemyColliderManager : ColliderManager
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
public void MagnetizeEnemy()
|
||||
{
|
||||
if (!_magnetHit)
|
||||
{
|
||||
_magnetHit = true;
|
||||
_magnetizeTime.RestartTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnLoot()
|
||||
{
|
||||
@ -248,7 +294,14 @@ public class EnemyColliderManager : ColliderManager
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_magnetHit)
|
||||
{
|
||||
if (_magnetizeTime.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_magnetHit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -34,7 +34,7 @@ public class EnemyHoverMovement : HoverMovement
|
||||
private float _movementCurrentTick;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
@ -53,7 +53,7 @@ public class EnemyHoverMovement : HoverMovement
|
||||
/// Calculates some RNG movement for the attached Enemy.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
void DoRNG(float currentTimeStep)
|
||||
private void DoRNG(float currentTimeStep)
|
||||
{
|
||||
// Check if the movement tick has passed
|
||||
if (_movementCurrentTick >= movementTickMax)
|
||||
@ -104,7 +104,7 @@ public class EnemyHoverMovement : HoverMovement
|
||||
/// Anything in this method can be removed, as long as the _turnDirection and _thrustDirection are set then the parent script with handle the orbit and positioning.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if the movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -195,7 +195,7 @@ public class EnemyHoverMovement : HoverMovement
|
||||
/// <summary>
|
||||
/// Method for dealing with the jump physics, this should be in the fixed update since it uses rigidbody physics
|
||||
/// </summary>
|
||||
void ProcessJump()
|
||||
private void ProcessJump()
|
||||
{
|
||||
if (_isJumping)
|
||||
{
|
||||
@ -232,6 +232,7 @@ public class EnemyHoverMovement : HoverMovement
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
|
@ -1,320 +0,0 @@
|
||||
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;
|
||||
|
||||
[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;
|
||||
|
||||
[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()
|
||||
{
|
||||
// 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>
|
||||
/// Gets the current blackhole radius
|
||||
/// </summary>
|
||||
/// <returns>Current Blackhole size as a float</returns>
|
||||
public float GetCurrentBlackHoleRadius()
|
||||
{
|
||||
return _currentBlackHoleManager.currentBlackHoleRadius;
|
||||
}
|
||||
|
||||
private void UpdateLifeBar()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HealthPowerUpColliderManager : ColliderManager
|
||||
{
|
||||
public AudioClip tokenPickupSFX;
|
||||
private AudioSource _audioSource;
|
||||
|
||||
// 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 DoAwakeTasks()
|
||||
{
|
||||
GameObject playerGO = GameObject.Find("Player");
|
||||
_audioSource = playerGO.GetComponent<AudioSource>();
|
||||
base.DoAwakeTasks();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
_tokenCollected = true;
|
||||
if (_audioSource != null)
|
||||
{
|
||||
_audioSource.PlayOneShot(tokenPickupSFX);
|
||||
}
|
||||
GameManager.Instance.AddLife();
|
||||
|
||||
if (transform.childCount > 0)
|
||||
{
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
transform.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
Destroy(gameObject, 2.0f);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70fcf396118a0b94d89673a208f6ac2d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -26,6 +26,10 @@ public class HoverMovement : MonoBehaviour
|
||||
public float turnSmoothTime;
|
||||
public float maxThrust;
|
||||
|
||||
private float _workingTurnSpeed;
|
||||
private float _workingRollAngle;
|
||||
private float _workingMaxThrust;
|
||||
|
||||
protected int _turnDirection;
|
||||
protected float _smoothedTurnSpeed;
|
||||
protected float _smoothTurnV;
|
||||
@ -42,20 +46,25 @@ public class HoverMovement : MonoBehaviour
|
||||
public float immuneMinHeight;
|
||||
protected bool _immuneMinHit;
|
||||
|
||||
protected bool _noMovement;
|
||||
|
||||
protected GameEngine _currentGameEngine;
|
||||
protected Rigidbody _objectRigidbody;
|
||||
protected ObjectShared _currentObjectShared;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_currentGameEngine = FindObjectOfType<GameEngine>();
|
||||
_objectRigidbody = GetComponent<Rigidbody>();
|
||||
_currentObjectShared = GetComponent<ObjectShared>();
|
||||
_noMovement = false;
|
||||
DoAwakeTasks();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method for allowing a child script to execute code during the awake call
|
||||
/// </summary>
|
||||
public virtual void DoAwakeTasks()
|
||||
protected virtual void DoAwakeTasks()
|
||||
{
|
||||
}
|
||||
|
||||
@ -93,7 +102,7 @@ public class HoverMovement : MonoBehaviour
|
||||
/// <summary>
|
||||
/// Method for run start call jobs once the child has
|
||||
/// </summary>
|
||||
public void BaseOnStart()
|
||||
protected void BaseOnStart()
|
||||
{
|
||||
if (!_currentGameEngine)
|
||||
{
|
||||
@ -114,11 +123,18 @@ public class HoverMovement : MonoBehaviour
|
||||
return _currentHeight;
|
||||
}
|
||||
|
||||
protected virtual void ProcessWorkingStartValues(float currentTimeStep)
|
||||
{
|
||||
_workingTurnSpeed = turnSpeed;
|
||||
_workingRollAngle = rollAngle;
|
||||
_workingMaxThrust = maxThrust;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method for the child scripts to setup the variables needed for movement
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">Time scale used, depends if this is in fixedUpdate or update.</param>
|
||||
public virtual void ProcessPreMovement(float currentTimeStep)
|
||||
protected virtual void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
}
|
||||
|
||||
@ -126,7 +142,7 @@ public class HoverMovement : MonoBehaviour
|
||||
/// Method that processes the actual movement around the blackhole using some wizard math
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">Time step currently used</param>
|
||||
public virtual void ProcessCurrentMovement(float currentTimeStep)
|
||||
protected virtual void ProcessCurrentMovement(float currentTimeStep)
|
||||
{
|
||||
float heightDistance = (transform.position - _currentGameEngine.currentBlackHole.transform.position).magnitude;
|
||||
if (heightDistance >= _currentGameEngine.arenaSize)
|
||||
@ -152,21 +168,24 @@ public class HoverMovement : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
_smoothedTurnSpeed = Mathf.SmoothDamp(_smoothedTurnSpeed, _turnDirection * turnSpeed, ref _smoothTurnV, turnSmoothTime);
|
||||
_smoothedTurnSpeed = Mathf.SmoothDamp(_smoothedTurnSpeed, _turnDirection * _workingTurnSpeed, ref _smoothTurnV, turnSmoothTime);
|
||||
float turnAmount = _smoothedTurnSpeed * currentTimeStep;
|
||||
|
||||
transform.RotateAround(transform.position, transform.up, turnAmount);
|
||||
|
||||
_currentThrust = Mathf.Lerp(_currentThrust, maxThrust, 1 - Mathf.Pow(smoothThrusting, currentTimeStep));
|
||||
_currentThrust = Mathf.Lerp(_currentThrust, _workingMaxThrust, 1 - Mathf.Pow(smoothThrusting, currentTimeStep));
|
||||
float thrustSpeed = (Mathf.Cos(1 * Mathf.Deg2Rad) * _currentThrust) * _thrustDirection;
|
||||
|
||||
Vector3 movePos = transform.position + transform.forward * thrustSpeed * currentTimeStep;
|
||||
movePos = movePos.normalized * (_currentGameEngine.GetCurrentBlackHoleRadius() * _currentHeight);
|
||||
transform.position = movePos;
|
||||
|
||||
if (!_noMovement)
|
||||
{
|
||||
Vector3 movePos = transform.position + transform.forward * thrustSpeed * currentTimeStep;
|
||||
movePos = movePos.normalized * (_currentGameEngine.GetCurrentBlackHoleRadius() * _currentHeight);
|
||||
transform.position = movePos;
|
||||
}
|
||||
|
||||
ProcessRotation();
|
||||
|
||||
float targetRoll = _turnDirection * rollAngle;
|
||||
float targetRoll = _turnDirection * _workingRollAngle;
|
||||
_currentRollAngle = Mathf.SmoothDampAngle(_currentRollAngle, targetRoll, ref _smoothRollV, smoothRollTime);
|
||||
}
|
||||
|
||||
@ -182,14 +201,14 @@ public class HoverMovement : MonoBehaviour
|
||||
/// <summary>
|
||||
/// Method for processing the rotation of the model
|
||||
/// </summary>
|
||||
public virtual void ProcessRotation()
|
||||
protected virtual void ProcessRotation()
|
||||
{
|
||||
Vector3 gravityUp = transform.position.normalized;
|
||||
transform.rotation = Quaternion.FromToRotation(transform.up, gravityUp) * transform.rotation;
|
||||
transform.LookAt((transform.position + transform.forward * 10).normalized * (_currentGameEngine.GetCurrentBlackHoleRadius() * _currentHeight), gravityUp);
|
||||
}
|
||||
|
||||
public virtual void ProcessPostMovement()
|
||||
protected virtual void ProcessPostMovement()
|
||||
{
|
||||
if (objectModel != null)
|
||||
{
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MineColliderManager : ColliderManager
|
||||
@ -15,24 +13,128 @@ public class MineColliderManager : ColliderManager
|
||||
// Bool checks if the mine has been hit, this is because the ships are made of multiple collision boxes and would trigger more than once.
|
||||
private bool _mineHit = false;
|
||||
|
||||
public float magnetizedTime;
|
||||
private bool _magnetHit = false;
|
||||
private TimerHelper _magnetizeTime;
|
||||
public Material magnetizedMaterial;
|
||||
|
||||
public float spawnImmunityTime;
|
||||
private TimerHelper _immuneTimer;
|
||||
private bool _spawnImmune;
|
||||
|
||||
public bool Hit
|
||||
{
|
||||
get
|
||||
{
|
||||
return _mineHit;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_player = GameObject.Find("Player");
|
||||
_magnetizeTime = new TimerHelper(magnetizedTime, false);
|
||||
_spawnImmune = true;
|
||||
_immuneTimer = new TimerHelper(spawnImmunityTime, false);
|
||||
}
|
||||
|
||||
public override void ProcessCollision(CollisionDirection direction, Collision collision, bool wasChild)
|
||||
{
|
||||
{
|
||||
if (collision.gameObject.tag == "Enemy")
|
||||
{
|
||||
EnemyColliderManager enemyColliderManager = collision.gameObject.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager != null)
|
||||
{
|
||||
if (enemyColliderManager.Magnetized)
|
||||
{
|
||||
magnetizeMine();
|
||||
}
|
||||
}
|
||||
}
|
||||
HitMine();
|
||||
}
|
||||
|
||||
public void magnetizeMine()
|
||||
{
|
||||
if (!_magnetHit)
|
||||
{
|
||||
if (magnetizedMaterial != null)
|
||||
{
|
||||
Transform mineChild = gameObject.transform.Find("MineAlt");
|
||||
if (mineChild != null)
|
||||
{
|
||||
MeshRenderer mineModel = mineChild.gameObject.GetComponent<MeshRenderer>();
|
||||
if (mineModel != null)
|
||||
{
|
||||
Material[] materials = new Material[mineModel.materials.Length];
|
||||
mineModel.materials.CopyTo(materials, 0);
|
||||
materials[0] = magnetizedMaterial;
|
||||
mineModel.materials = materials;
|
||||
}
|
||||
}
|
||||
}
|
||||
explosionDistance *= 1.3f;
|
||||
_magnetHit = true;
|
||||
_magnetizeTime.RestartTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_magnetHit)
|
||||
{
|
||||
if (_magnetizeTime.HasTicked(Time.deltaTime))
|
||||
{
|
||||
HitMine();
|
||||
}
|
||||
}
|
||||
if (_spawnImmune)
|
||||
{
|
||||
if (_immuneTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_spawnImmune = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the mine exploding and destroy the mine object.
|
||||
/// </summary>
|
||||
public void HitMine()
|
||||
{
|
||||
// If the mine has been hit ignore it.
|
||||
if (!_mineHit)
|
||||
if (!_mineHit && !_spawnImmune)
|
||||
{
|
||||
if (_magnetHit)
|
||||
{
|
||||
Collider[] collidersInRange = Physics.OverlapSphere(gameObject.transform.position, explosionDistance);
|
||||
foreach (Collider currentCollider in collidersInRange)
|
||||
{
|
||||
Rigidbody colliderRB = currentCollider.attachedRigidbody;
|
||||
if (colliderRB != null)
|
||||
{
|
||||
GameObject colliderGO = currentCollider.attachedRigidbody.gameObject;
|
||||
if (colliderGO.CompareTag("Enemy"))
|
||||
{
|
||||
EnemyColliderManager currentColliderManager = colliderGO.GetComponent<EnemyColliderManager>();
|
||||
if (currentColliderManager != null)
|
||||
{
|
||||
currentColliderManager.DestoryEnemy(true);
|
||||
}
|
||||
|
||||
}
|
||||
else if (colliderGO.CompareTag("Mine"))
|
||||
{
|
||||
MineColliderManager currentMineCM = colliderGO.GetComponent<MineColliderManager>();
|
||||
if (currentMineCM != null && !currentMineCM.Hit)
|
||||
{
|
||||
currentMineCM.magnetizeMine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float playerDistance = (_player.transform.position - transform.position).magnitude;
|
||||
|
||||
_mineHit = true;
|
||||
@ -41,6 +143,8 @@ public class MineColliderManager : ColliderManager
|
||||
ParticleSystem boomboom2 = Instantiate(effectB);
|
||||
boomboom.transform.position = transform.position;
|
||||
boomboom2.transform.position = transform.position;
|
||||
boomboom.transform.localScale = boomboom.transform.localScale * explosionDistance;
|
||||
boomboom2.transform.localScale = boomboom2.transform.localScale * explosionDistance;
|
||||
if (playerDistance <= explosionDistance)
|
||||
{
|
||||
PlayerColliderManager playerColliderManager = _player.GetComponent<PlayerColliderManager>();
|
||||
@ -48,7 +152,7 @@ public class MineColliderManager : ColliderManager
|
||||
{
|
||||
playerColliderManager.PlayerHit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (transform.childCount > 0)
|
||||
{
|
||||
@ -57,7 +161,8 @@ public class MineColliderManager : ColliderManager
|
||||
transform.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gameObject.layer = LayerMask.NameToLayer("ExplodedMine");
|
||||
Destroy(gameObject, 2.0f);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class MineHoverMovement : HoverMovement
|
||||
private float _rngHorz;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
@ -35,7 +35,7 @@ public class MineHoverMovement : HoverMovement
|
||||
/// Calculates some RNG movement for the attached core.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
void DoRNG(float currentTimeStep)
|
||||
private void DoRNG(float currentTimeStep)
|
||||
{
|
||||
// Cores dont move at the moment but the movescript can be used above if they need to orbit around the blackhole
|
||||
_rngHorz = 0;
|
||||
@ -46,7 +46,7 @@ public class MineHoverMovement : HoverMovement
|
||||
/// Processes the inputs needed to move the gameobject, the turn direction, thrust direction and any residual thrust calculations so that we dont just stop in place.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if the movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -145,12 +145,13 @@ public class MineHoverMovement : HoverMovement
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
|
@ -14,7 +14,7 @@ public class PlayerBlackHoleForce : BlackHoleForce
|
||||
|
||||
public override void ApplyBlackHoleForce(float appliedForce)
|
||||
{
|
||||
if (!blackHolePullImmunue)
|
||||
if (!blackHolePullImmunue && !GameEngine.playerPaused)
|
||||
{
|
||||
_objectRigidBody.AddForce(-_objectRigidBody.transform.up * appliedForce);
|
||||
base.ApplyBlackHoleForce(appliedForce);
|
||||
|
@ -1,33 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerColliderManager : ColliderManager
|
||||
{
|
||||
// After death immunity variables
|
||||
public float immunityTimer;
|
||||
private float _immunityCurrentTick;
|
||||
private float _immunityCurrentTick;
|
||||
public float dyingTime;
|
||||
private TimerHelper _dyingTimer;
|
||||
private bool _dying = false;
|
||||
|
||||
private static PlayerColliderManager _instance;
|
||||
|
||||
public static PlayerColliderManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
set
|
||||
{
|
||||
Instance = value;
|
||||
}
|
||||
}
|
||||
public float deadlyTime;
|
||||
private TimerHelper _deadlyTimer;
|
||||
private bool _deadly = false;
|
||||
|
||||
public float flashTick;
|
||||
private float _currentFlashTick;
|
||||
private bool _flashed;
|
||||
|
||||
public GameObject mainMeshGO;
|
||||
|
||||
private MeshRenderer _currentMeshRenderer;
|
||||
public Color immunityColorFlash;
|
||||
private Color _originalColor;
|
||||
@ -35,7 +23,27 @@ public class PlayerColliderManager : ColliderManager
|
||||
public AudioClip shipDeathSFX;
|
||||
public AudioClip playerImmunitySFX;
|
||||
|
||||
private PlayerHoverMovement _currentMovement;
|
||||
private PlayerHoverMovement _currentMovement;
|
||||
|
||||
public ParticleSystem effectA;
|
||||
public ParticleSystem effectB;
|
||||
private TimerHelper _particleTimer;
|
||||
|
||||
public bool Dying
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dying;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Deadly
|
||||
{
|
||||
get
|
||||
{
|
||||
return _deadly;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to handle awake tasks for the player collider.
|
||||
@ -43,15 +51,14 @@ public class PlayerColliderManager : ColliderManager
|
||||
public override void DoAwakeTasks()
|
||||
{
|
||||
_currentMovement = gameObject.GetComponent<PlayerHoverMovement>();
|
||||
_currentMeshRenderer = mainMeshGO.GetComponent<MeshRenderer>();
|
||||
_currentMeshRenderer = shipModel.GetComponent<MeshRenderer>();
|
||||
_originalColor = _currentMeshRenderer.material.color;
|
||||
base.DoAwakeTasks();
|
||||
}
|
||||
|
||||
public void SetImmune(float length)
|
||||
{
|
||||
Debug.Log("I am immune");
|
||||
_immunityCurrentTick = length;
|
||||
_immunityCurrentTick += length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -67,6 +74,13 @@ public class PlayerColliderManager : ColliderManager
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_dyingTimer = new TimerHelper(dyingTime, false);
|
||||
_deadlyTimer = new TimerHelper(deadlyTime, false);
|
||||
_particleTimer = new TimerHelper(0.3f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method for killing the player without a collision, used for the debug console mainly
|
||||
/// </summary>
|
||||
@ -83,7 +97,7 @@ public class PlayerColliderManager : ColliderManager
|
||||
/// <param name="collision">Collision object holding the details on the collided object.</param>
|
||||
/// <param name="wasChild">Was the hit collider a child of this game object.</param>
|
||||
public override void ProcessCollision(CollisionDirection direction, Collision collision, bool wasChild)
|
||||
{
|
||||
{
|
||||
GameObject collisionGO;
|
||||
if (wasChild)
|
||||
{
|
||||
@ -94,85 +108,123 @@ public class PlayerColliderManager : ColliderManager
|
||||
collisionGO = collision.gameObject;
|
||||
}
|
||||
|
||||
switch(direction)
|
||||
if (!Dying)
|
||||
{
|
||||
case CollisionDirection.Top:
|
||||
switch(collisionGO.tag)
|
||||
{
|
||||
case "Mine":
|
||||
MineColliderManager mineColliderManager = collisionGO.GetComponent<MineColliderManager>();
|
||||
if (mineColliderManager)
|
||||
{
|
||||
mineColliderManager.HitMine();
|
||||
}
|
||||
break;
|
||||
case "Enemy":
|
||||
// Enemy hit players top.
|
||||
PlayerHit();
|
||||
break;
|
||||
case "Core":
|
||||
// Collected a core.
|
||||
PickUpCore(collisionGO);
|
||||
break;
|
||||
case "Dead":
|
||||
// Now handled by the layer NoCollide
|
||||
// Ignore dead enemies collision
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CollisionDirection.Bottom:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Mine":
|
||||
MineColliderManager mineColliderManager = collisionGO.GetComponent<MineColliderManager>();
|
||||
if (mineColliderManager)
|
||||
{
|
||||
mineColliderManager.HitMine();
|
||||
}
|
||||
break;
|
||||
case "Enemy":
|
||||
// Kill the collided enemy
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
enemyColliderManager.DestoryEnemy(true);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
// Pick up core
|
||||
PickUpCore(collisionGO);
|
||||
break;
|
||||
case "Dead":
|
||||
// Now handled by the layer NoCollide
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Mine":
|
||||
MineColliderManager mineColliderManager = collisionGO.GetComponent<MineColliderManager>();
|
||||
if (mineColliderManager)
|
||||
{
|
||||
mineColliderManager.HitMine();
|
||||
}
|
||||
break;
|
||||
case "Asteroid":
|
||||
// Player hit an asteroid from any direction, get bounced
|
||||
AsteroidColliderManager asteroidColliderManager = collisionGO.GetComponent<AsteroidColliderManager>();
|
||||
if (asteroidColliderManager)
|
||||
{
|
||||
asteroidColliderManager.BounceAway(gameObject, -collision.contacts[0].normal);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
PickUpCore(collisionGO);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case CollisionDirection.Top:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Mine":
|
||||
MineColliderManager mineColliderManager = collisionGO.GetComponent<MineColliderManager>();
|
||||
if (mineColliderManager)
|
||||
{
|
||||
mineColliderManager.HitMine();
|
||||
}
|
||||
break;
|
||||
case "Enemy":
|
||||
// Enemy hit players top.
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
if (!enemyColliderManager.Dying)
|
||||
{
|
||||
if (Deadly)
|
||||
{
|
||||
enemyColliderManager.DestoryEnemy(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerHit();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
// Collected a core.
|
||||
PickUpCore(collisionGO);
|
||||
break;
|
||||
case "Dead":
|
||||
// Now handled by the layer NoCollide
|
||||
// Ignore dead enemies collision
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CollisionDirection.Bottom:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Mine":
|
||||
MineColliderManager mineColliderManager = collisionGO.GetComponent<MineColliderManager>();
|
||||
if (mineColliderManager)
|
||||
{
|
||||
mineColliderManager.HitMine();
|
||||
}
|
||||
break;
|
||||
case "Enemy":
|
||||
// Kill the collided enemy
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
enemyColliderManager.DestoryEnemy(true);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
// Pick up core
|
||||
PickUpCore(collisionGO);
|
||||
break;
|
||||
case "Dead":
|
||||
// Now handled by the layer NoCollide
|
||||
//Physics.IgnoreCollision(collision.collider, gameObject.GetComponent<Collider>());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Enemy":
|
||||
EnemyColliderManager enemyColliderManager = collisionGO.GetComponent<EnemyColliderManager>();
|
||||
if (enemyColliderManager)
|
||||
{
|
||||
if (Deadly)
|
||||
{
|
||||
// Kill the collided enemy
|
||||
enemyColliderManager.DestoryEnemy(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
enemyColliderManager.BounceAway(-collision.contacts[0].normal);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Mine":
|
||||
MineColliderManager mineColliderManager = collisionGO.GetComponent<MineColliderManager>();
|
||||
if (mineColliderManager)
|
||||
{
|
||||
mineColliderManager.HitMine();
|
||||
}
|
||||
break;
|
||||
case "Asteroid":
|
||||
// Player hit an asteroid from any direction, get bounced
|
||||
AsteroidColliderManager asteroidColliderManager = collisionGO.GetComponent<AsteroidColliderManager>();
|
||||
if (asteroidColliderManager)
|
||||
{
|
||||
asteroidColliderManager.BounceAway(gameObject, -collision.contacts[0].normal);
|
||||
}
|
||||
break;
|
||||
case "Core":
|
||||
PickUpCore(collisionGO);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDeadly()
|
||||
{
|
||||
_deadly = true;
|
||||
_deadlyTimer.RestartTimer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -195,22 +247,20 @@ public class PlayerColliderManager : ColliderManager
|
||||
}
|
||||
// Remove a life from the game manager
|
||||
_dying = true;
|
||||
GameManager.Instance.LostLife();
|
||||
_currentMovement.ForceStartLocationReset();
|
||||
|
||||
//Check if its game over (moved to the game manager)
|
||||
if (GameManager.Instance.isGameOver)
|
||||
_dyingTimer.RestartTimer();
|
||||
Rigidbody currentRigidBody = gameObject.GetComponent<Rigidbody>();
|
||||
if (currentRigidBody != null)
|
||||
{
|
||||
//GameManager.Instance.DoGameOver();
|
||||
//gameObject.SetActive(false);
|
||||
currentRigidBody.velocity = Vector3.zero;
|
||||
}
|
||||
else
|
||||
GameEngine.playerPaused = true;
|
||||
if (shipModel != null)
|
||||
{
|
||||
SetImmune(immunityTimer);
|
||||
//_immunityCurrentTick = immunityTimer;
|
||||
_flashed = false;
|
||||
shipModel.SetActive(false);
|
||||
}
|
||||
}
|
||||
_particleTimer.RestartTimer();
|
||||
Time.timeScale = 0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -237,31 +287,107 @@ public class PlayerColliderManager : ColliderManager
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// If we are immune flash the player to show it.
|
||||
if (_immunityCurrentTick > 0.0f)
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
if (_currentFlashTick >= flashTick)
|
||||
if (Deadly)
|
||||
{
|
||||
FlashToggle();
|
||||
_currentFlashTick = 0.0f;
|
||||
if (_deadlyTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
_deadly = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Dying)
|
||||
{
|
||||
if (_dyingTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
GameManager.Instance.LostLife();
|
||||
if (GameManager.Instance.CurrentLives > -1)
|
||||
{
|
||||
_currentMovement.ForceStartLocationReset();
|
||||
_immunityCurrentTick = 0.0f;
|
||||
|
||||
SetImmune(immunityTimer);
|
||||
//_immunityCurrentTick = immunityTimer;
|
||||
_flashed = false;
|
||||
|
||||
if (shipModel != null)
|
||||
{
|
||||
shipModel.SetActive(true);
|
||||
}
|
||||
GameEngine.playerPaused = false;
|
||||
_dying = false;
|
||||
}
|
||||
Time.timeScale = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 = gameObject.transform.position + offsetDir;
|
||||
boomboom2.transform.position = gameObject.transform.position + offsetDir;
|
||||
if (_attachedAudioSource)
|
||||
{
|
||||
_attachedAudioSource.PlayOneShot(shipDeathSFX);
|
||||
}
|
||||
|
||||
if (!_particleTimer.Started)
|
||||
{
|
||||
_particleTimer.HasTicked(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we are immune flash the player to show it.
|
||||
if (_immunityCurrentTick > 0.0f)
|
||||
{
|
||||
if (_currentFlashTick >= flashTick)
|
||||
{
|
||||
FlashToggle();
|
||||
_currentFlashTick = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentFlashTick += Time.deltaTime;
|
||||
}
|
||||
|
||||
_immunityCurrentTick -= Time.deltaTime;
|
||||
if (_immunityCurrentTick < 0.0f)
|
||||
{
|
||||
_immunityCurrentTick = 0.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentFlashTick += Time.deltaTime;
|
||||
}
|
||||
|
||||
_immunityCurrentTick -= Time.deltaTime;
|
||||
if (_immunityCurrentTick < 0.0f)
|
||||
{
|
||||
_immunityCurrentTick = 0.0f;
|
||||
FlashToggle(true);
|
||||
_flashed = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_immunityCurrentTick = 0.0f;
|
||||
_dying = false;
|
||||
FlashToggle(true);
|
||||
_flashed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
@ -30,8 +28,8 @@ public class PlayerHoverMovement : HoverMovement
|
||||
public float boostModifier;
|
||||
public float maxBoostTime;
|
||||
public float boostCooldown;
|
||||
private float _currentBoostTick;
|
||||
private float _currentBoostCooldownTick;
|
||||
private TimerHelper _currentBoostTimer;
|
||||
private TimerHelper _currentBoostCooldownTimer;
|
||||
private bool _isBoosting;
|
||||
private bool _boostingCoolingDown;
|
||||
|
||||
@ -49,6 +47,8 @@ public class PlayerHoverMovement : HoverMovement
|
||||
private Gradient _defaultTrailGradient;
|
||||
private float _defaultTrailMultiplier;
|
||||
|
||||
public bool playerDying;
|
||||
|
||||
public bool BoostReady
|
||||
{
|
||||
get
|
||||
@ -66,6 +66,14 @@ public class PlayerHoverMovement : HoverMovement
|
||||
}
|
||||
}
|
||||
|
||||
public float BoostCooldownPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return _currentBoostCooldownTimer.Position;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method for toggling the boost trail particle effects for the player
|
||||
/// </summary>
|
||||
@ -88,14 +96,14 @@ public class PlayerHoverMovement : HoverMovement
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
_currentJumpTime = 0.0f;
|
||||
|
||||
_currentBoostTick = 0.0f;
|
||||
_currentBoostCooldownTick = 0.0f;
|
||||
_currentBoostTimer = new TimerHelper(maxBoostTime, false);
|
||||
_currentBoostCooldownTimer = new TimerHelper(boostCooldown, false);
|
||||
_isBoosting = false;
|
||||
_boostingCoolingDown = false;
|
||||
|
||||
@ -107,7 +115,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
/// <summary>
|
||||
/// Method for doing tasks that need doing during the AWake call, since an inherited script can only have 1 awake shared between everything
|
||||
/// </summary>
|
||||
public override void DoAwakeTasks()
|
||||
protected override void DoAwakeTasks()
|
||||
{
|
||||
// Get all the child trails
|
||||
_playerTrails = GetComponentsInChildren<TrailRenderer>();
|
||||
@ -125,7 +133,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
/// Processes the inputs needed to move the gameObject, the turn direction, thrust direction and any residual thrust calculations so that we dont just stop in place.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Get the Horz and Vert axis from the controls
|
||||
float horzInput = Input.GetAxis("Horizontal");
|
||||
@ -146,7 +154,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
}
|
||||
|
||||
// Check if the vert is pushed forwards or back, pos = forward, neg = back
|
||||
if (vertInput > 0)
|
||||
if (vertInput > 0 || _isBoosting)
|
||||
{
|
||||
// Start boosting forward and adding residual thrust
|
||||
_thrusting = true;
|
||||
@ -243,32 +251,24 @@ public class PlayerHoverMovement : HoverMovement
|
||||
// If boosting check if we have boosted for long enough
|
||||
if (_isBoosting)
|
||||
{
|
||||
if (_currentBoostTick >= maxBoostTime)
|
||||
if (_currentBoostTimer.HasTicked(currentTimeStep))
|
||||
{
|
||||
_isBoosting = false;
|
||||
_currentBoostTick = 0.0f;
|
||||
_currentBoostTimer.RestartTimer();
|
||||
_boostingCoolingDown = true;
|
||||
ToggleBoostEffects();
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentBoostTick += currentTimeStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce the boost cooldown timer when on cooldown
|
||||
if (_boostingCoolingDown)
|
||||
{
|
||||
if (_currentBoostCooldownTick >= boostCooldown)
|
||||
if (_currentBoostCooldownTimer.HasTicked(currentTimeStep))
|
||||
{
|
||||
_currentBoostCooldownTick = 0.0f;
|
||||
_currentBoostCooldownTimer.RestartTimer();
|
||||
_boostingCoolingDown = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentBoostCooldownTick += currentTimeStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -293,7 +293,7 @@ public class PlayerHoverMovement : HoverMovement
|
||||
/// <summary>
|
||||
/// Method for dealing with the jump physics, this should be in the fixed update since it uses rigidbody physics
|
||||
/// </summary>
|
||||
void ProcessJump()
|
||||
private void ProcessJump()
|
||||
{
|
||||
// If the player is jumping add the jump force
|
||||
if (_isJumping)
|
||||
@ -314,23 +314,24 @@ public class PlayerHoverMovement : HoverMovement
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
if (!GameEngine.isPaused && !GameEngine.playerPaused)
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
if (!GameEngine.isPaused && !GameEngine.playerPaused)
|
||||
{
|
||||
testHeight = _currentHeight;
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
ProcessPostMovement();
|
||||
|
@ -19,20 +19,33 @@ public class PlayerObjectShared : ObjectShared
|
||||
public AudioClip badPowerUp;
|
||||
|
||||
[SerializeField]
|
||||
private PowerUpEffect _currentPowerUpEffect;
|
||||
private AttachablePowerUpEffect _currentPowerUpEffect;
|
||||
|
||||
public AttachablePowerUpEffect currentAbility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _currentPowerUpEffect;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_currentAudioSource = gameObject.GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
public bool AttachPickUp(PowerUpEffect newEffect)
|
||||
public bool AttachPickUp(AttachablePowerUpEffect newEffect)
|
||||
{
|
||||
_currentPowerUpEffect = newEffect;
|
||||
_currentPowerUpEffect.ApplyEffect();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void PlaySFX(AudioClip clipToPlay)
|
||||
{
|
||||
_currentAudioSource.PlayOneShot(clipToPlay);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetButtonDown("Fire2"))
|
||||
@ -56,6 +69,28 @@ public class PlayerObjectShared : ObjectShared
|
||||
_currentAudioSource.PlayOneShot(badPowerUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Input.GetButtonDown("Fire3"))
|
||||
{
|
||||
if (_currentPowerUpEffect != null)
|
||||
{
|
||||
if (!_currentPowerUpEffect.OnAltUseEffect())
|
||||
{
|
||||
if (_currentAudioSource != null)
|
||||
{
|
||||
Debug.Log("Used by failed");
|
||||
_currentAudioSource.PlayOneShot(badPowerUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentAudioSource != null)
|
||||
{
|
||||
Debug.Log("None Exist failed");
|
||||
_currentAudioSource.PlayOneShot(badPowerUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class PowerUpHoverMovement : HoverMovement
|
||||
private float _rngHorz;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
_residualThrust = 0.0f;
|
||||
_residualThrustCurrentTime = 0.0f;
|
||||
@ -35,7 +35,7 @@ public class PowerUpHoverMovement : HoverMovement
|
||||
/// Calculates some RNG movement for the attached core.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
void DoRNG(float currentTimeStep)
|
||||
private void DoRNG(float currentTimeStep)
|
||||
{
|
||||
// Cores dont move at the moment but the movescript can be used above if they need to orbit around the blackhole
|
||||
_rngHorz = 0;
|
||||
@ -46,7 +46,7 @@ public class PowerUpHoverMovement : HoverMovement
|
||||
/// Processes the inputs needed to move the gameobject, the turn direction, thrust direction and any residual thrust calculations so that we dont just stop in place.
|
||||
/// </summary>
|
||||
/// <param name="currentTimeStep">The time unit currently used, typically deltatime or deltafixed time depending on if its the fixed update or not.</param>
|
||||
public override void ProcessPreMovement(float currentTimeStep)
|
||||
protected override void ProcessPreMovement(float currentTimeStep)
|
||||
{
|
||||
// Check if the movement has been frozen
|
||||
if (!freezeMovement)
|
||||
@ -145,12 +145,13 @@ public class PowerUpHoverMovement : HoverMovement
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
if (objectIsActive)
|
||||
{
|
||||
ProcessWorkingStartValues(Time.deltaTime);
|
||||
DoRNG(Time.deltaTime);
|
||||
ProcessPreMovement(Time.deltaTime);
|
||||
ProcessCurrentMovement(Time.deltaTime);
|
||||
|
@ -42,7 +42,7 @@ public class PowerUpObjectShared : ObjectShared
|
||||
float distanceToPlayer = directionToPlayer.magnitude;
|
||||
if (distanceToPlayer <= _playerObjectShared.coreMagnetRange)
|
||||
{
|
||||
_objectRigidBody.AddForce(-directionToPlayer * distanceToPlayer * _playerObjectShared.coreMagnetForce * Time.fixedDeltaTime, ForceMode.VelocityChange);
|
||||
_objectRigidBody.AddForce(-directionToPlayer.normalized * distanceToPlayer * _playerObjectShared.coreMagnetForce * Time.fixedDeltaTime, ForceMode.VelocityChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShieldPowerUpColliderManager : ColliderManager
|
||||
{
|
||||
public float immunityLength;
|
||||
public AudioClip tokenPickupSFX;
|
||||
private AudioSource _audioSource;
|
||||
private GameObject _player;
|
||||
|
||||
// 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 DoAwakeTasks()
|
||||
{
|
||||
_player = GameObject.Find("Player");
|
||||
_audioSource = _player.GetComponent<AudioSource>();
|
||||
base.DoAwakeTasks();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
_tokenCollected = true;
|
||||
if (_audioSource != null)
|
||||
{
|
||||
_audioSource.PlayOneShot(tokenPickupSFX);
|
||||
}
|
||||
if (_player != null)
|
||||
{
|
||||
PlayerColliderManager currentPCM = _player.GetComponent<PlayerColliderManager>();
|
||||
if (currentPCM != null)
|
||||
{
|
||||
currentPCM.SetImmune(immunityLength);
|
||||
}
|
||||
}
|
||||
|
||||
if (transform.childCount > 0)
|
||||
{
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
transform.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
Destroy(gameObject, 2.0f);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1982a3849dc22fd4da0403f6e1d8f80f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user