Game Loop V1
Controls don't deactivate yet
This commit is contained in:
parent
6a11cfef7f
commit
09c6fc05d9
5866
Assets/Scenes/DanTest.unity
Normal file
5866
Assets/Scenes/DanTest.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/DanTest.unity.meta
Normal file
7
Assets/Scenes/DanTest.unity.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e54128340e19f0d42accf44efa9ed8d7
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
29
Assets/Scripts/DimensionController.cs
Normal file
29
Assets/Scripts/DimensionController.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/DimensionController.cs.meta
Normal file
11
Assets/Scripts/DimensionController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5dfc667192d2c2641bbd86b84f6dea74
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
44
Assets/Scripts/GameManager.cs
Normal file
44
Assets/Scripts/GameManager.cs
Normal 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
|
||||||
|
}
|
||||||
11
Assets/Scripts/GameManager.cs.meta
Normal file
11
Assets/Scripts/GameManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cbbe9406db76ed447bdc7c36883ee139
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
1151
Assets/Settings/ConjureCreativeJam20.cs
Normal file
1151
Assets/Settings/ConjureCreativeJam20.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/Settings/ConjureCreativeJam20.cs.meta
Normal file
11
Assets/Settings/ConjureCreativeJam20.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5b95153e0aacd4642bfff2a40912b435
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -8,7 +8,7 @@ ScriptedImporter:
|
|||||||
assetBundleName:
|
assetBundleName:
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||||
generateWrapperCode: 0
|
generateWrapperCode: 1
|
||||||
wrapperCodePath:
|
wrapperCodePath:
|
||||||
wrapperClassName:
|
wrapperClassName:
|
||||||
wrapperCodeNamespace:
|
wrapperCodeNamespace:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user