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:
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);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3de6b36e04a5c3449c7104442440712
|
||||
guid: 19749c0a365e21341b18d997644d62b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
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: b5678218a3034524ca1d3eb11b13ae1c
|
||||
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: 742ed625e6d4d46439f31a3dd0b6f94c
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/TargetBillboardHelper.cs.meta
Normal file
11
Assets/Scripts/Other/TargetBillboardHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
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:
|
Reference in New Issue
Block a user