Updated Unity Version
Added graphics options and rendering quality level settings Added new movement patterns to the dumb enemy AI Added chance for Coward Enemies to drop a random Added method to correctly reset the game variables on death and win screens Updated the UI to work on different resolutions without breaking Moved Sprites into a sprites folder Fixed issue where score would overflow the int because the multiplier was too high Fixed issue where new lives gained from the score breakpoints were not being calculated correctly Fixed issue where clicking off a menu element then trying to control the menu with the controller did not correctly reselect a menu item Fixed issue where enemies colliding with the outer boundary too much would break the sfx and music (i assume from a buffering issue)
This commit is contained in:
25
Assets/Scripts/AI/CommanderHoverMovement.cs
Normal file
25
Assets/Scripts/AI/CommanderHoverMovement.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CommanderHoverMovement : HoverMovement
|
||||
{
|
||||
protected List<HoverMovement> _enemyParty;
|
||||
public int partySize;
|
||||
public float partyScanSize;
|
||||
public float commandingRange;
|
||||
|
||||
protected List<EnemyTypeName> _canPartyTypes;
|
||||
|
||||
protected void ScanForParty(float currentTimestamp)
|
||||
{
|
||||
if (_canPartyTypes.Count > 0)
|
||||
{
|
||||
if (_canPartyTypes.Count < partySize)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/AI/CommanderHoverMovement.cs.meta
Normal file
11
Assets/Scripts/AI/CommanderHoverMovement.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3c5534733cf278478e336141c3e3f6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,13 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CowardEnemyHoverMovement : HoverMovement
|
||||
public class CowardEnemyHoverMovement : CommanderHoverMovement
|
||||
{
|
||||
public GameObject minePrefab;
|
||||
public float mineSpawnChance;
|
||||
public int mineSpawnChance;
|
||||
public float mineSpawnCooldown;
|
||||
private float _mineSpawnTick;
|
||||
private TimerHelper _mineSpawnTick;
|
||||
private bool _canSpawnMine;
|
||||
|
||||
public float mineDropTime;
|
||||
public float mineDropCooldown;
|
||||
private TimerHelper _mineDropTimer;
|
||||
private TimerHelper _mineDropCooldownTimer;
|
||||
private TimerHelper _canMineDropRoll;
|
||||
private bool _mineDropReady;
|
||||
private bool _mineDropping;
|
||||
|
||||
// Game object to track the player GO
|
||||
private GameObject _player;
|
||||
private GameObject _blackHole;
|
||||
@ -33,7 +42,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
private float _aiVert;
|
||||
private float _aiHorz;
|
||||
private bool _aiJump;
|
||||
|
||||
|
||||
public float cowerDistance;
|
||||
public float emergencyBoostSpeed;
|
||||
public float emergencyBoostCooldownSpeed;
|
||||
@ -41,11 +50,11 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
public float emergencyBoostCooldown;
|
||||
private bool _emergencyBoosting;
|
||||
private bool _emergencyBoosted;
|
||||
private float _currentEmergencyBoostingTick;
|
||||
private float _currentEmergencyBoosterCooldownTick;
|
||||
private TimerHelper _currentEmergencyBoostingTick;
|
||||
private TimerHelper _currentEmergencyBoosterCooldownTick;
|
||||
|
||||
private float _currentHoldHeight;
|
||||
private float _heightChangeTick;
|
||||
private TimerHelper _heightChangeTick;
|
||||
public float heightChangeInterval;
|
||||
|
||||
protected override void DoAwakeTasks()
|
||||
@ -72,9 +81,21 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
|
||||
_emergencyBoosting = false;
|
||||
_emergencyBoosted = false;
|
||||
_currentEmergencyBoosterCooldownTick = 0.0f;
|
||||
_currentHoldHeight = GetCurrentHeight();
|
||||
_heightChangeTick = 0.0f;
|
||||
_currentEmergencyBoostingTick = new TimerHelper(emergencyBoostTime, false);
|
||||
_currentEmergencyBoosterCooldownTick = new TimerHelper(emergencyBoostCooldown, false);
|
||||
_heightChangeTick = new TimerHelper(heightChangeInterval, false);
|
||||
_mineSpawnTick = new TimerHelper(mineSpawnCooldown, false);
|
||||
|
||||
_mineDropReady = false;
|
||||
_mineDropping = false;
|
||||
_mineDropTimer = new TimerHelper(mineDropTime, false);
|
||||
_mineDropCooldownTimer = new TimerHelper(mineDropCooldown, false);
|
||||
|
||||
_canPartyTypes = new List<EnemyTypeName>();
|
||||
_canPartyTypes.Add(EnemyTypeName.ENEMYDUMB);
|
||||
|
||||
_enemyParty = new List<HoverMovement>();
|
||||
|
||||
BaseOnStart();
|
||||
// Custom start stuff can go here
|
||||
@ -102,13 +123,13 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
|
||||
// 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);
|
||||
Vector3 myLocation = Vector3.ProjectOnPlane(transform.position, Vector3.forward);
|
||||
Vector3 direction = playerLocation - myLocation;
|
||||
Vector3 direction = playerLocation - myLocation;
|
||||
|
||||
float facingPlayer = Vector3.Dot(playerDirection.normalized, transform.forward);
|
||||
|
||||
|
||||
// Added a check to see if the difference is big enough to warrant a turn otherwise they just get stuck turning forever
|
||||
float playerHeight = _player.GetComponent<PlayerHoverMovement>().GetCurrentHeight();
|
||||
|
||||
@ -122,9 +143,9 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
// Try to boost away
|
||||
_emergencyBoosting = true;
|
||||
_canSpawnMine = false;
|
||||
_mineSpawnTick = 0.0f;
|
||||
_mineSpawnTick.RestartTimer();
|
||||
// Force a height change for fun
|
||||
_heightChangeTick = heightChangeInterval;
|
||||
_heightChangeTick.HasTicked(heightChangeInterval);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +161,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
if (aboveCheck.rigidbody != null)
|
||||
{
|
||||
if ((GetCurrentHeight() < playerHeight))
|
||||
{
|
||||
{
|
||||
_objectRigidbody.velocity = Vector3.zero;
|
||||
_aiJump = false;
|
||||
}
|
||||
@ -163,8 +184,30 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
if (minePrefab != null)
|
||||
{
|
||||
if (_canSpawnMine && _emergencyBoosting)
|
||||
{
|
||||
DoAMineSpawn();
|
||||
{
|
||||
DoAMineSpawn();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_emergencyBoosted)
|
||||
{
|
||||
if (_mineDropReady)
|
||||
{
|
||||
int dropChance = Random.Range(0, 100);
|
||||
if (dropChance <= mineSpawnChance)
|
||||
{
|
||||
_mineDropping = true;
|
||||
}
|
||||
_mineDropReady = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_canSpawnMine && _mineDropping)
|
||||
{
|
||||
DoAMineSpawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -280,7 +323,7 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
// Check if the jump button
|
||||
if (_aiJump && !_isJumping)
|
||||
{
|
||||
_isJumping = true;
|
||||
_isJumping = true;
|
||||
}
|
||||
|
||||
// Run any base class stuff
|
||||
@ -315,51 +358,53 @@ public class CowardEnemyHoverMovement : HoverMovement
|
||||
{
|
||||
if (_emergencyBoosting)
|
||||
{
|
||||
if (_currentEmergencyBoostingTick >= emergencyBoostTime)
|
||||
if (_currentEmergencyBoostingTick.HasTicked(currentTimeStep))
|
||||
{
|
||||
_emergencyBoosted = true;
|
||||
_emergencyBoosting = false;
|
||||
_currentEmergencyBoostingTick = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentEmergencyBoostingTick += currentTimeStep;
|
||||
_currentEmergencyBoostingTick.RestartTimer();
|
||||
}
|
||||
}
|
||||
|
||||
if (_emergencyBoosted)
|
||||
{
|
||||
if (_currentEmergencyBoosterCooldownTick >= emergencyBoostCooldown)
|
||||
if (_currentEmergencyBoosterCooldownTick.HasTicked(currentTimeStep))
|
||||
{
|
||||
_emergencyBoosted = false;
|
||||
_currentEmergencyBoosterCooldownTick = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentEmergencyBoosterCooldownTick += currentTimeStep;
|
||||
_currentEmergencyBoosterCooldownTick.RestartTimer();
|
||||
}
|
||||
}
|
||||
|
||||
if (_heightChangeTick >= heightChangeInterval)
|
||||
if (_heightChangeTick.HasTicked(currentTimeStep))
|
||||
{
|
||||
_currentHoldHeight = Random.Range(startHeight, startHeight + 5.0f);
|
||||
_heightChangeTick = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_heightChangeTick += currentTimeStep;
|
||||
_currentHoldHeight = Random.Range(startHeight - 2.0f, startHeight + 3.0f);
|
||||
_heightChangeTick.RestartTimer();
|
||||
}
|
||||
|
||||
if (!_canSpawnMine)
|
||||
{
|
||||
if (_mineSpawnTick >= mineSpawnCooldown)
|
||||
if (_mineSpawnTick.HasTicked(currentTimeStep))
|
||||
{
|
||||
_mineSpawnTick = 0.0f;
|
||||
_mineSpawnTick.RestartTimer();
|
||||
_canSpawnMine = true;
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
if (_mineDropping)
|
||||
{
|
||||
if (_mineDropTimer.HasTicked(currentTimeStep))
|
||||
{
|
||||
_mineSpawnTick += currentTimeStep;
|
||||
_mineDropTimer.RestartTimer();
|
||||
_mineDropping = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_mineDropReady && !_mineDropping)
|
||||
{
|
||||
if (_mineDropCooldownTimer.HasTicked(currentTimeStep))
|
||||
{
|
||||
_mineDropCooldownTimer.RestartTimer();
|
||||
_mineDropReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,19 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
private bool _aiJump;
|
||||
|
||||
public float maxRNGThrust;
|
||||
public float movementDecayRate;
|
||||
public float movementTickMax;
|
||||
private float _movementCurrentTick;
|
||||
public float movementDecayRate;
|
||||
private List<TimerHelper> _movementMoveTimers = new List<TimerHelper>();
|
||||
public float patternChangeInterval;
|
||||
private TimerHelper _movementPatternTimer;
|
||||
|
||||
private float _currentHoldHeight;
|
||||
private float _heightChangeTick;
|
||||
public float heightChangeInterval;
|
||||
|
||||
private int _currentPattern;
|
||||
private int _nextThrustDir;
|
||||
private int _nextTurnDir;
|
||||
|
||||
protected override void DoAwakeTasks()
|
||||
{
|
||||
base.DoAwakeTasks();
|
||||
@ -64,6 +69,10 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
_currentHoldHeight = GetCurrentHeight();
|
||||
_heightChangeTick = 0.0f;
|
||||
|
||||
_movementPatternTimer = new TimerHelper(patternChangeInterval, false);
|
||||
_movementPatternTimer.HasTicked(patternChangeInterval + 100.0f);
|
||||
_currentPattern = Random.Range(0, 4);
|
||||
|
||||
BaseOnStart();
|
||||
// Custom start stuff can go here
|
||||
}
|
||||
@ -97,35 +106,126 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
float playerHeight = _player.GetComponent<PlayerHoverMovement>().GetCurrentHeight();
|
||||
|
||||
_aiVert = 1;
|
||||
if (_movementCurrentTick >= movementTickMax)
|
||||
if (_movementPatternTimer.HasTicked(currentTimeStep))
|
||||
{
|
||||
// Pick a random horz value
|
||||
if (_aiHorz == 0)
|
||||
_currentPattern = Random.Range(0, 4);
|
||||
_movementMoveTimers.Clear();
|
||||
|
||||
switch (_currentPattern)
|
||||
{
|
||||
_aiHorz = Random.Range(0, maxRNGThrust);
|
||||
default:
|
||||
case 0:
|
||||
int dirRandom = Random.Range(0, 2);
|
||||
if (dirRandom == 0)
|
||||
{
|
||||
_nextTurnDir = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_nextTurnDir = 1;
|
||||
}
|
||||
_movementMoveTimers.Add(new TimerHelper(30.0f, false));
|
||||
_movementMoveTimers.Add(new TimerHelper(3.0f, false));
|
||||
break;
|
||||
case 1:
|
||||
_movementMoveTimers.Add(new TimerHelper(10.0f));
|
||||
break;
|
||||
case 2:
|
||||
int zigRandom = Random.Range(0, 2);
|
||||
if (zigRandom == 0)
|
||||
{
|
||||
_nextTurnDir = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_nextTurnDir = 1;
|
||||
}
|
||||
_movementMoveTimers.Add(new TimerHelper(3.0f, false));
|
||||
break;
|
||||
case 3:
|
||||
_movementMoveTimers.Add(new TimerHelper(15.0f, false));
|
||||
break;
|
||||
}
|
||||
|
||||
// Pick a random vert value
|
||||
if (_aiVert == 0)
|
||||
{
|
||||
_aiVert = Random.Range(0, maxRNGThrust);
|
||||
}
|
||||
|
||||
_movementCurrentTick = 0.0f;
|
||||
_movementPatternTimer.RestartTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset the variables to stop it turning/moving
|
||||
if (_aiHorz > 0)
|
||||
switch (_currentPattern)
|
||||
{
|
||||
_aiHorz = Mathf.Clamp(_aiHorz - movementDecayRate, 0, maxRNGThrust); ;
|
||||
}
|
||||
if (_aiVert > 0)
|
||||
{
|
||||
_aiVert = Mathf.Clamp(_aiVert - movementDecayRate, 0, maxRNGThrust);
|
||||
}
|
||||
default:
|
||||
case 0:
|
||||
_aiVert = 1.0f;
|
||||
if (_movementMoveTimers[0].HasTicked(currentTimeStep))
|
||||
{
|
||||
if (_movementMoveTimers[1].HasTicked(currentTimeStep))
|
||||
{
|
||||
int dirRandom = Random.Range(0, 2);
|
||||
if (dirRandom == 0)
|
||||
{
|
||||
_nextTurnDir = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_nextTurnDir = 1;
|
||||
}
|
||||
|
||||
_movementCurrentTick += currentTimeStep;
|
||||
_movementMoveTimers[0].RestartTimer();
|
||||
_movementMoveTimers[1].RestartTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
_aiHorz = _nextTurnDir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_aiHorz = 0.0f;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_aiVert = 1.0f;
|
||||
if (_movementMoveTimers[0].HasTicked(currentTimeStep))
|
||||
{
|
||||
int dirTimesRan = _movementMoveTimers[0].TimesRun % 2;
|
||||
if (dirTimesRan == 0)
|
||||
{
|
||||
_aiHorz = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_aiHorz = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
_aiVert = 1.0f;
|
||||
if (_movementMoveTimers[0].HasTicked(currentTimeStep))
|
||||
{
|
||||
_nextTurnDir *= -1;
|
||||
|
||||
_movementMoveTimers[0].RestartTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
_aiHorz = _nextTurnDir;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (_movementMoveTimers[0].HasTicked(currentTimeStep))
|
||||
{
|
||||
_nextThrustDir = Random.Range(0, 2);
|
||||
_nextTurnDir = Random.Range(-1, 2);
|
||||
|
||||
_movementMoveTimers[0].RestartTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
_aiVert = _nextThrustDir;
|
||||
_aiHorz = _nextTurnDir;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_currentHoldHeight >= GetCurrentHeight())
|
||||
@ -188,7 +288,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
if (vertInput > 0)
|
||||
{
|
||||
_thrusting = true;
|
||||
_thrustDirection = 1;
|
||||
_thrustDirection = 1.0f * _aiVert;
|
||||
if (_residualThrust < residualThrustMax)
|
||||
{
|
||||
_residualThrust += residualThrustStep * currentTimeStep;
|
||||
@ -208,7 +308,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
else
|
||||
{
|
||||
_thrusting = true;
|
||||
_thrustDirection = -1;
|
||||
_thrustDirection = -1.0f * _aiVert;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -224,7 +324,7 @@ public class DumbEnemyHoverMovement : HoverMovement
|
||||
else
|
||||
{
|
||||
_thrusting = false;
|
||||
_thrustDirection = 0;
|
||||
_thrustDirection = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class DeadEngine : MonoBehaviour
|
||||
_defaultEmissionColor = _meshRenderer.materials[0].GetColor("_EmissionColor");
|
||||
_lastControlSelected = EventSystem.current.firstSelectedGameObject;
|
||||
|
||||
scoreText.text = scoreText.text.Replace("{SCORE}", GameManager.Instance.CurrentScore.ToString().PadLeft(10, '0'));
|
||||
scoreText.text = scoreText.text.Replace("{SCORE}", GameManager.Instance.CurrentScore.ToString().PadLeft(9, '0'));
|
||||
}
|
||||
|
||||
public void PlayMenuClick()
|
||||
@ -70,6 +70,7 @@ public class DeadEngine : MonoBehaviour
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
GameManager.Instance.ResetStats();
|
||||
SceneManager.LoadSceneAsync("Game");
|
||||
}
|
||||
|
||||
|
73
Assets/Scripts/Other/DropDownScrollbarHelper.cs
Normal file
73
Assets/Scripts/Other/DropDownScrollbarHelper.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
public class DropDownScrollbarHelper : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
RectTransform scrollRectTransform;
|
||||
RectTransform contentPanel;
|
||||
RectTransform selectedRectTransform;
|
||||
GameObject lastSelected;
|
||||
|
||||
Vector2 targetPos;
|
||||
|
||||
void Start()
|
||||
{
|
||||
scrollRectTransform = GetComponent<RectTransform>();
|
||||
|
||||
if (contentPanel == null)
|
||||
contentPanel = GetComponent<ScrollRect>().content;
|
||||
|
||||
targetPos = contentPanel.anchoredPosition;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!_mouseHover)
|
||||
Autoscroll();
|
||||
}
|
||||
|
||||
|
||||
public void Autoscroll()
|
||||
{
|
||||
if (contentPanel == null)
|
||||
contentPanel = GetComponent<ScrollRect>().content;
|
||||
|
||||
GameObject selected = EventSystem.current.currentSelectedGameObject;
|
||||
|
||||
if (selected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (selected.transform.parent != contentPanel.transform)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (selected == lastSelected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
selectedRectTransform = (RectTransform)selected.transform;
|
||||
targetPos.x = contentPanel.anchoredPosition.x;
|
||||
targetPos.y = -(selectedRectTransform.localPosition.y) - (selectedRectTransform.rect.height / 2);
|
||||
targetPos.y = Mathf.Clamp(targetPos.y, 0, contentPanel.sizeDelta.y - scrollRectTransform.sizeDelta.y);
|
||||
|
||||
contentPanel.anchoredPosition = targetPos;
|
||||
lastSelected = selected;
|
||||
}
|
||||
|
||||
bool _mouseHover;
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
_mouseHover = true;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
_mouseHover = false;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Other/DropDownScrollbarHelper.cs.meta
Normal file
11
Assets/Scripts/Other/DropDownScrollbarHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99396d0b10d909c48a842775cb13ae0d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -116,6 +116,7 @@ public class GameEngine : MonoBehaviour
|
||||
_playerJumped = false;
|
||||
_playerJumpFlash = new TimerHelper(0.5f);
|
||||
_winCinematicDone = false;
|
||||
_lastControlSelected = EventSystem.current.firstSelectedGameObject;
|
||||
|
||||
for (int i = 0; i < dialogGOList.Count; i++)
|
||||
{
|
||||
@ -206,12 +207,12 @@ public class GameEngine : MonoBehaviour
|
||||
{
|
||||
if (scoreText != null)
|
||||
{
|
||||
scoreText.GetComponent<TMPro.TextMeshProUGUI>().text = GameManager.Instance.CurrentScore.ToString().PadLeft(10, '0');
|
||||
scoreText.GetComponent<TMPro.TextMeshProUGUI>().text = GameManager.Instance.CurrentScore.ToString().PadLeft(9, '0');
|
||||
}
|
||||
int newLifeCheck = Mathf.FloorToInt(GameManager.Instance.CurrentScore / _scorePerLifeUp.Value);
|
||||
if (_lastScoreCheck.Value < newLifeCheck && !_gameOverHit)
|
||||
{
|
||||
GameManager.Instance.AddLife(_lastScoreCheck.Value - newLifeCheck);
|
||||
GameManager.Instance.AddLife(newLifeCheck - _lastScoreCheck.Value);
|
||||
_lastScoreCheck.Value = newLifeCheck;
|
||||
if (lifeUpSFX != null)
|
||||
{
|
||||
@ -423,17 +424,15 @@ public class GameEngine : MonoBehaviour
|
||||
|
||||
if (isPaused)
|
||||
{
|
||||
float horzLRot = Input.GetAxis("Horizontal") + Input.GetAxis("Vertical");
|
||||
if (horzLRot != 0)
|
||||
float horzIn = Input.GetAxisRaw("Horizontal");
|
||||
float vertIn = Input.GetAxisRaw("Vertical");
|
||||
|
||||
if (horzIn != 0 || vertIn != 0)
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject == null)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_lastControlSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastControlSelected = EventSystem.current.currentSelectedGameObject;
|
||||
}
|
||||
EventSystem.current.SetSelectedGameObject(pauseMenuFirstItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,10 +499,11 @@ public class GameEngine : MonoBehaviour
|
||||
public void CalcFinalScore(bool wonGame)
|
||||
{
|
||||
int workingScore = GameManager.Instance.CurrentScore;
|
||||
workingScore += 100000 * GameManager.Instance.CurrentLevel;
|
||||
workingScore += 10000 * GameManager.Instance.CurrentLevel;
|
||||
if (wonGame)
|
||||
{
|
||||
workingScore *= Mathf.FloorToInt(_bonusTimeLimit.Position * 10.0f);
|
||||
workingScore += 1000 * GameManager.Instance.CurrentLives;
|
||||
workingScore += 5000 * Mathf.FloorToInt(_bonusTimeLimit.Position * 100.0f);
|
||||
}
|
||||
GameManager.Instance.SetScore(workingScore);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class MainMenuEngine : MonoBehaviour
|
||||
{
|
||||
@ -13,6 +14,11 @@ public class MainMenuEngine : MonoBehaviour
|
||||
public GameObject yolkBGO;
|
||||
public TMPro.TextMeshProUGUI versionText;
|
||||
|
||||
public TMPro.TMP_Dropdown qualityDropdown;
|
||||
public TMPro.TMP_Dropdown resolutionDropdown;
|
||||
public TMPro.TMP_Dropdown fullscreenDropdown;
|
||||
public List<RenderPipelineAsset> renderPipelines = new List<RenderPipelineAsset>();
|
||||
|
||||
public BackgroundMusicManager currentBGMManager;
|
||||
public MenuAudioManager currentMenuAudioManager;
|
||||
|
||||
@ -63,6 +69,126 @@ public class MainMenuEngine : MonoBehaviour
|
||||
masterVolSliderGo.GetComponent<Slider>().value = currentMasterVol;
|
||||
musicVolSliderGo.GetComponent<Slider>().value = currentMusicVol;
|
||||
SFXVolSliderGo.GetComponent<Slider>().value = currentSFXVol;
|
||||
|
||||
qualityDropdown.value = QualitySettings.GetQualityLevel();
|
||||
|
||||
int selectedResolution = 0;
|
||||
string resolutionString = Screen.width.ToString() + " X " + Screen.height.ToString();
|
||||
switch(resolutionString)
|
||||
{
|
||||
case "1280 X 720":
|
||||
selectedResolution = 1;
|
||||
break;
|
||||
case "1280 X 800":
|
||||
selectedResolution = 2;
|
||||
break;
|
||||
case "1366 X 768":
|
||||
selectedResolution = 3;
|
||||
break;
|
||||
case "1440 X 900":
|
||||
selectedResolution = 4;
|
||||
break;
|
||||
case "1680 X 1050":
|
||||
selectedResolution = 5;
|
||||
break;
|
||||
case "1920 X 1080":
|
||||
selectedResolution = 6;
|
||||
break;
|
||||
case "2560 X 1440":
|
||||
selectedResolution = 7;
|
||||
break;
|
||||
case "3840 X 2160":
|
||||
selectedResolution = 8;
|
||||
break;
|
||||
default:
|
||||
selectedResolution = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
resolutionDropdown.value = selectedResolution;
|
||||
|
||||
int fullscreenModeId = 0;
|
||||
switch (Screen.fullScreenMode)
|
||||
{
|
||||
case FullScreenMode.ExclusiveFullScreen:
|
||||
fullscreenModeId = 0;
|
||||
break;
|
||||
case FullScreenMode.Windowed:
|
||||
fullscreenModeId = 2;
|
||||
break;
|
||||
default:
|
||||
case FullScreenMode.FullScreenWindow:
|
||||
fullscreenModeId = 1;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
fullscreenDropdown.value = fullscreenModeId;
|
||||
}
|
||||
|
||||
public void SaveOptionChanges()
|
||||
{
|
||||
QualitySettings.SetQualityLevel(qualityDropdown.value);
|
||||
QualitySettings.renderPipeline = renderPipelines[qualityDropdown.value];
|
||||
|
||||
int resolutionWidth = Screen.width;
|
||||
int resolutionHeight = Screen.height;
|
||||
switch(resolutionDropdown.value)
|
||||
{
|
||||
case 1:
|
||||
resolutionWidth = 1280;
|
||||
resolutionHeight = 720;
|
||||
break;
|
||||
case 2:
|
||||
resolutionWidth = 1280;
|
||||
resolutionHeight = 800;
|
||||
break;
|
||||
case 3:
|
||||
resolutionWidth = 1366;
|
||||
resolutionHeight = 768;
|
||||
break;
|
||||
case 4:
|
||||
resolutionWidth = 1440;
|
||||
resolutionHeight = 900;
|
||||
break;
|
||||
case 5:
|
||||
resolutionWidth = 1680;
|
||||
resolutionHeight = 1050;
|
||||
break;
|
||||
case 6:
|
||||
resolutionWidth = 1920;
|
||||
resolutionHeight = 1080;
|
||||
break;
|
||||
case 7:
|
||||
resolutionWidth = 2560;
|
||||
resolutionHeight = 1440;
|
||||
break;
|
||||
case 8:
|
||||
resolutionWidth = 3840;
|
||||
resolutionHeight = 2160;
|
||||
break;
|
||||
default:
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
|
||||
FullScreenMode newFullScreenMode = Screen.fullScreenMode;
|
||||
switch(fullscreenDropdown.value)
|
||||
{
|
||||
case 0:
|
||||
newFullScreenMode = FullScreenMode.ExclusiveFullScreen;
|
||||
break;
|
||||
case 2:
|
||||
newFullScreenMode = FullScreenMode.Windowed;
|
||||
break;
|
||||
default:
|
||||
case 1:
|
||||
newFullScreenMode = FullScreenMode.FullScreenWindow;
|
||||
break;
|
||||
}
|
||||
|
||||
Screen.SetResolution(resolutionWidth, resolutionHeight, newFullScreenMode);
|
||||
}
|
||||
|
||||
public void PlayMenuClick()
|
||||
|
@ -58,6 +58,7 @@ public class RulesMenuEngine : MonoBehaviour
|
||||
|
||||
public void ChangeScene()
|
||||
{
|
||||
GameManager.Instance.ResetStats();
|
||||
SceneManager.LoadSceneAsync("Game");
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class WinEngine : MonoBehaviour
|
||||
currentBGMManager.StartAudioQueueAndPlay(0);
|
||||
}
|
||||
|
||||
scoreText.text = scoreText.text.Replace("{SCORE}", GameManager.Instance.CurrentScore.ToString().PadLeft(10, '0'));
|
||||
scoreText.text = scoreText.text.Replace("{SCORE}", GameManager.Instance.CurrentScore.ToString().PadLeft(9, '0'));
|
||||
_lastControlSelected = EventSystem.current.firstSelectedGameObject;
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ public class WinEngine : MonoBehaviour
|
||||
{
|
||||
currentMenuAudioManager.PlayMenuClick();
|
||||
}
|
||||
GameManager.Instance.ResetStats();
|
||||
SceneManager.LoadSceneAsync("Game");
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,21 @@ using UnityEngine;
|
||||
|
||||
public class BoundaryLightManager : MonoBehaviour
|
||||
{
|
||||
public AudioClip bounceSFX;
|
||||
public Light currentLight;
|
||||
public float startIntensity;
|
||||
public float lightLifeTime;
|
||||
private TimerHelper _lightTimer;
|
||||
public bool doSFX = false;
|
||||
|
||||
private float _currentTick;
|
||||
private AudioSource _currentAudioSource;
|
||||
private TimerHelper _lightTimer;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
currentLight.intensity = startIntensity;
|
||||
_lightTimer = new TimerHelper(lightLifeTime, false);
|
||||
_currentAudioSource = gameObject.GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@ -23,6 +26,14 @@ public class BoundaryLightManager : MonoBehaviour
|
||||
{
|
||||
if (!GameEngine.isPaused)
|
||||
{
|
||||
if (doSFX)
|
||||
{
|
||||
if (_currentAudioSource != null)
|
||||
{
|
||||
_currentAudioSource.PlayOneShot(bounceSFX);
|
||||
doSFX = false;
|
||||
}
|
||||
}
|
||||
currentLight.intensity = startIntensity - Mathf.Lerp(0, startIntensity, _lightTimer.Position);
|
||||
if (_lightTimer.HasTicked(Time.deltaTime))
|
||||
{
|
||||
|
@ -37,6 +37,14 @@ public class BoundaryManager : MonoBehaviour
|
||||
if (doHitEffect)
|
||||
{
|
||||
GameObject newLight = Instantiate(hitLight);
|
||||
if (collidedObject.tag == "Player")
|
||||
{
|
||||
BoundaryLightManager newLightBM = newLight.GetComponent<BoundaryLightManager>();
|
||||
if (newLightBM != null)
|
||||
{
|
||||
newLightBM.doSFX = true;
|
||||
}
|
||||
}
|
||||
newLight.transform.position = collisionPoint.GetContact(0).point;
|
||||
newLight.SetActive(true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user