Start and safe zone prompts
This commit is contained in:
parent
231070af77
commit
eaef42e6a8
@ -4,107 +4,115 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
//Could be a singleton
|
||||
public class GameFlowManager : MonoBehaviour {
|
||||
/// <summary>
|
||||
/// True if time is frozen (Start, Pause Menu, Dead)
|
||||
/// </summary>
|
||||
/// <remarks>Could be renamed appropriately</remarks>
|
||||
[field: SerializeField]
|
||||
public bool Paused { get; private set; } = true;
|
||||
public BaseState CurrentState { get; private set; } = null!;
|
||||
bool lastStartButton;
|
||||
bool lastAcceptButton;
|
||||
/// <summary>
|
||||
/// True if time is frozen (Start, Pause Menu, Dead)
|
||||
/// </summary>
|
||||
/// <remarks>Could be renamed appropriately</remarks>
|
||||
[field: SerializeField]
|
||||
public bool Paused { get; private set; } = true;
|
||||
public BaseState CurrentState { get; private set; } = null!;
|
||||
bool lastStartButton;
|
||||
bool lastAcceptButton;
|
||||
[SerializeField] GameObject startPrompt;
|
||||
|
||||
#region Unity Messages
|
||||
void Awake() => CurrentState = new StartFlowState(this);
|
||||
#region Unity Messages
|
||||
void Awake() {
|
||||
CurrentState = new StartFlowState(this);
|
||||
if (startPrompt != null) {
|
||||
startPrompt.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Start() => CurrentState.EnterState();
|
||||
#endregion
|
||||
void Start() => CurrentState.EnterState();
|
||||
#endregion
|
||||
|
||||
void SetPause(bool value) {
|
||||
Debug.Log($"Setting pause to {value}");
|
||||
Paused = value;
|
||||
Time.timeScale = value ? 0f : 1f;
|
||||
}
|
||||
void SetPause(bool value) {
|
||||
Debug.Log($"Setting pause to {value}");
|
||||
Paused = value;
|
||||
Time.timeScale = value ? 0f : 1f;
|
||||
}
|
||||
|
||||
public void GameOver() => SwitchState(new DeadFlowState(this));
|
||||
public void GameOver() => SwitchState(new DeadFlowState(this));
|
||||
|
||||
#region Inputs
|
||||
public void OnStart(InputAction.CallbackContext ctx) {
|
||||
if (!ctx.WasPressedThisFrame(ref lastStartButton))
|
||||
return;
|
||||
#region Inputs
|
||||
public void OnStart(InputAction.CallbackContext ctx) {
|
||||
if (!ctx.WasPressedThisFrame(ref lastStartButton))
|
||||
return;
|
||||
|
||||
if (CurrentState is StartFlowState)
|
||||
SwitchState(new GameplayFlowState(this));
|
||||
}
|
||||
if (CurrentState is StartFlowState) {
|
||||
startPrompt.SetActive(false);
|
||||
SwitchState(new GameplayFlowState(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAccept(InputAction.CallbackContext ctx) {
|
||||
if (!ctx.WasPressedThisFrame(ref lastAcceptButton))
|
||||
return;
|
||||
public void OnAccept(InputAction.CallbackContext ctx) {
|
||||
if (!ctx.WasPressedThisFrame(ref lastAcceptButton))
|
||||
return;
|
||||
|
||||
if (CurrentState is DeadFlowState deadState)
|
||||
deadState.ReloadGame();
|
||||
}
|
||||
#endregion
|
||||
if (CurrentState is DeadFlowState deadState)
|
||||
deadState.ReloadGame();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region States
|
||||
void SwitchState(BaseState newState) {
|
||||
CurrentState.LeaveState();
|
||||
CurrentState = newState;
|
||||
newState.EnterState();
|
||||
}
|
||||
#region States
|
||||
void SwitchState(BaseState newState) {
|
||||
CurrentState.LeaveState();
|
||||
CurrentState = newState;
|
||||
newState.EnterState();
|
||||
}
|
||||
|
||||
abstract class GameFlowState : BaseState {
|
||||
readonly protected GameFlowManager gameFlowManager;
|
||||
abstract class GameFlowState : BaseState {
|
||||
readonly protected GameFlowManager gameFlowManager;
|
||||
|
||||
protected GameFlowState(GameFlowManager gameFlowManager) {
|
||||
this.gameFlowManager = gameFlowManager;
|
||||
}
|
||||
}
|
||||
protected GameFlowState(GameFlowManager gameFlowManager) {
|
||||
this.gameFlowManager = gameFlowManager;
|
||||
}
|
||||
}
|
||||
|
||||
class StartFlowState : GameFlowState {
|
||||
public StartFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) {}
|
||||
class StartFlowState : GameFlowState {
|
||||
public StartFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) { }
|
||||
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
|
||||
Debug.Log("Press Start to start...!");
|
||||
gameFlowManager.SetPause(true);
|
||||
}
|
||||
Debug.Log("Press Start to start...!");
|
||||
gameFlowManager.SetPause(true);
|
||||
}
|
||||
|
||||
public override void LeaveState() {
|
||||
Debug.Log("Let the games begin!!");
|
||||
}
|
||||
}
|
||||
class GameplayFlowState : GameFlowState {
|
||||
public GameplayFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) {}
|
||||
public override void LeaveState() {
|
||||
Debug.Log("Let the games begin!!");
|
||||
}
|
||||
}
|
||||
class GameplayFlowState : GameFlowState {
|
||||
public GameplayFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) { }
|
||||
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
gameFlowManager.SetPause(false);
|
||||
}
|
||||
}
|
||||
class PauseMenuFlowState : GameFlowState {
|
||||
public PauseMenuFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) {}
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
gameFlowManager.SetPause(false);
|
||||
}
|
||||
}
|
||||
class PauseMenuFlowState : GameFlowState {
|
||||
public PauseMenuFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) { }
|
||||
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
gameFlowManager.SetPause(true);
|
||||
}
|
||||
}
|
||||
class DeadFlowState : GameFlowState {
|
||||
public DeadFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) {}
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
gameFlowManager.SetPause(true);
|
||||
}
|
||||
}
|
||||
class DeadFlowState : GameFlowState {
|
||||
public DeadFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) { }
|
||||
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
|
||||
Debug.Log("You died!\nPress Accept to restart!");
|
||||
gameFlowManager.SetPause(true);
|
||||
}
|
||||
Debug.Log("You died!\nPress Accept to restart!");
|
||||
gameFlowManager.SetPause(true);
|
||||
}
|
||||
|
||||
public void ReloadGame() {
|
||||
Debug.Log("Reloading scene...");
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
public void ReloadGame() {
|
||||
Debug.Log("Reloading scene...");
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@ -1,5 +1,156 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &763564871199756608
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7304592252411488326}
|
||||
m_Layer: 5
|
||||
m_Name: Safe Zone Prompt
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!224 &7304592252411488326
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 763564871199756608}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 6820018694670671316}
|
||||
m_Father: {fileID: 1878107874060227351}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &939250288673996249
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6820018694670671316}
|
||||
- component: {fileID: 2559709786450296225}
|
||||
- component: {fileID: 6319861665145814892}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &6820018694670671316
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 939250288673996249}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7304592252411488326}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0}
|
||||
m_AnchorMax: {x: 0.5, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 500, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!222 &2559709786450296225
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 939250288673996249}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &6319861665145814892
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 939250288673996249}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 30
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 3
|
||||
m_MaxSize: 50
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 'A : Safe zone'
|
||||
--- !u!1 &1844274959428875625
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6917216836479509094}
|
||||
m_Layer: 5
|
||||
m_Name: Start Prompt
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!224 &6917216836479509094
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1844274959428875625}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 408737556976395859}
|
||||
m_Father: {fileID: 1878107874060227351}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &1878107873570787823
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -124,11 +275,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 81a29b049c6380f4abb3c18ed121efcd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
minionTypes:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
minionIconPrefab: {fileID: 1979632678310270257, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3}
|
||||
--- !u!114 &1878107873739935075
|
||||
MonoBehaviour:
|
||||
@ -188,6 +334,8 @@ RectTransform:
|
||||
m_Children:
|
||||
- {fileID: 1878107874314509258}
|
||||
- {fileID: 1878107873739935084}
|
||||
- {fileID: 6917216836479509094}
|
||||
- {fileID: 7304592252411488326}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -434,3 +582,82 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &2910275079998420734
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 408737556976395859}
|
||||
- component: {fileID: 5431213429284538757}
|
||||
- component: {fileID: 7753986740047806469}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &408737556976395859
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2910275079998420734}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6917216836479509094}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 500, y: 300}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &5431213429284538757
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2910275079998420734}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &7753986740047806469
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2910275079998420734}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 50
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 5
|
||||
m_MaxSize: 50
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: PRESS START TO START
|
||||
|
||||
@ -287,6 +287,12 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
<Paused>k__BackingField: 1
|
||||
startPrompt: {fileID: 1551362088}
|
||||
--- !u!1 &1408196689 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 763564871199756608, guid: e1dac4f28fe75a547b919b7aa8240fed, type: 3}
|
||||
m_PrefabInstance: {fileID: 1551362086}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1464970062 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 1878107874314509256, guid: e1dac4f28fe75a547b919b7aa8240fed, type: 3}
|
||||
@ -414,6 +420,11 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 81a29b049c6380f4abb3c18ed121efcd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1551362088 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 1844274959428875625, guid: e1dac4f28fe75a547b919b7aa8240fed, type: 3}
|
||||
m_PrefabInstance: {fileID: 1551362086}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1557338110 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 3328484984159178892, guid: f7f5d2b1228d13f4d9015073aced3e81, type: 3}
|
||||
@ -574,6 +585,10 @@ PrefabInstance:
|
||||
propertyPath: m_ActionEvents.Array.data[16].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
value: UnityEngine.Object, UnityEngine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1214567908930553592, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||
propertyPath: safeZonePrompt
|
||||
value:
|
||||
objectReference: {fileID: 1408196689}
|
||||
- target: {fileID: 1214567908930553592, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||
propertyPath: gameFlowManager
|
||||
value:
|
||||
|
||||
@ -13,6 +13,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
|
||||
[field: Required]
|
||||
Rigidbody2D rb = null!;
|
||||
[SerializeField] GameObject safeZonePrompt;
|
||||
|
||||
Vector2 moveDirection;
|
||||
BaseState currentState = null!;
|
||||
@ -25,6 +26,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
void Awake() {
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
currentState = new ImmobileMovementState(this);
|
||||
safeZonePrompt.SetActive(false);
|
||||
}
|
||||
|
||||
void Start() => currentState.EnterState();
|
||||
@ -41,6 +43,12 @@ public class PlayerMovement : MonoBehaviour {
|
||||
if (gameFlowManager.Paused)
|
||||
return;
|
||||
|
||||
if (safeZone != null && safeZone.IsInSafeZone) {
|
||||
safeZonePrompt.SetActive(false);
|
||||
} else {
|
||||
safeZonePrompt.SetActive(true);
|
||||
}
|
||||
|
||||
if (currentState.FixedUpdateState() is {} newState)
|
||||
SwitchState(newState);
|
||||
}
|
||||
|
||||
@ -5,6 +5,9 @@ EditorBuildSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Scenes:
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/Main Menu.unity
|
||||
guid: 68bb79cf26688ab46a0c4c582d1cb315
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/SampleScene.unity
|
||||
guid: 2cda990e2423bbf4892e6590ba056729
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user