Game Loop V1

Controls don't deactivate yet
This commit is contained in:
TheDaringDan 2022-05-14 16:04:31 -04:00
parent 6a11cfef7f
commit 09c6fc05d9
9 changed files with 7131 additions and 1 deletions

5866
Assets/Scenes/DanTest.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e54128340e19f0d42accf44efa9ed8d7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,29 @@
using UnityEngine;
public class DimensionController : MonoBehaviour
{
[SerializeField] private int dimensionId;
[SerializeField] private int maxHp;
private float _hp;
private void Start()
{
_hp = maxHp;
}
private void OnTriggerEnter(Collider other)
{
var enemy = other.GetComponent<Enemy>();
if (ReferenceEquals(enemy, null)) return;
// Update HP (temp for now)
_hp -= 1;
// Destroy projectile
Destroy(other.gameObject);
// Check loss condition
if (_hp <= 0) GameManager.Instance.TriggerGameOver(dimensionId);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5dfc667192d2c2641bbd86b84f6dea74
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,44 @@
using UnityEngine;
public class GameManager : MonoBehaviour
{
private ConjureCreativeJam20 _controls;
private GameState _state;
public static GameManager Instance { get; private set; }
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
}
else
{
Instance = this;
_controls = new ConjureCreativeJam20();
_state = GameState.InGame;
}
}
public void TriggerGameOver(int dimensionID)
{
if (_state == GameState.Loss) return;
// Stop controls
_controls.Player.Disable();
_controls.UI.Enable();
// Show Game Over Message
Debug.Log("Game Over: Dimension " + dimensionID + " has been destroyed");
// Show Options (Return to Menu / Retry)
_state = GameState.Loss;
}
}
public enum GameState
{
InGame,
Loss
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cbbe9406db76ed447bdc7c36883ee139
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5b95153e0aacd4642bfff2a40912b435
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -8,7 +8,7 @@ ScriptedImporter:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
generateWrapperCode: 0
generateWrapperCode: 1
wrapperCodePath:
wrapperClassName:
wrapperCodeNamespace: