Added Press Start to start (without prompt though)
This commit is contained in:
parent
027c287a43
commit
c6b9e5da93
@ -1,11 +1,91 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
//Could be a singleton
|
//Could be a singleton
|
||||||
public class GameFlowManager : MonoBehaviour {
|
public class GameFlowManager : MonoBehaviour {
|
||||||
[field: SerializeField] public bool Paused { get; private set; } = true;
|
[field: SerializeField]
|
||||||
|
public bool Paused { get; private set; } = true;
|
||||||
|
public BaseState CurrentState { get; private set; } = null!;
|
||||||
|
bool lastStartButton;
|
||||||
|
|
||||||
|
#region Unity Messages
|
||||||
|
void Awake() => CurrentState = new StartFlowState(this);
|
||||||
|
|
||||||
|
void Start() => CurrentState.EnterState();
|
||||||
|
#endregion
|
||||||
|
|
||||||
void SetPause(bool value) {
|
void SetPause(bool value) {
|
||||||
Paused = value;
|
Paused = value;
|
||||||
Time.timeScale = value ? 0f : 1f;
|
Time.timeScale = value ? 0f : 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Inputs
|
||||||
|
public void OnStart(InputAction.CallbackContext ctx) {
|
||||||
|
//feels pretty redundant ^^'
|
||||||
|
bool newValue = ctx.ReadValueAsButton();
|
||||||
|
bool wasJustPressed = !lastStartButton && newValue;
|
||||||
|
lastStartButton = newValue;
|
||||||
|
|
||||||
|
if (!wasJustPressed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (CurrentState is StartFlowState)
|
||||||
|
SwitchState(new GameplayFlowState(this));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region States
|
||||||
|
void SwitchState(BaseState newState) {
|
||||||
|
CurrentState.LeaveState();
|
||||||
|
CurrentState = newState;
|
||||||
|
newState.EnterState();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class GameFlowState : BaseState {
|
||||||
|
readonly protected GameFlowManager gameFlowManager;
|
||||||
|
|
||||||
|
protected GameFlowState(GameFlowManager gameFlowManager) {
|
||||||
|
this.gameFlowManager = gameFlowManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class StartFlowState : GameFlowState {
|
||||||
|
public StartFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) {}
|
||||||
|
|
||||||
|
public override void EnterState() {
|
||||||
|
base.EnterState();
|
||||||
|
|
||||||
|
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 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 63e66d66543b37e419694ac22a2941fd, type: 3}
|
m_Script: {fileID: 11500000, guid: 63e66d66543b37e419694ac22a2941fd, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
stats: {fileID: 11400000, guid: 188711c0b201b1a45ad601ee20233b20, type: 2}
|
<Stats>k__BackingField: {fileID: 11400000, guid: 188711c0b201b1a45ad601ee20233b20, type: 2}
|
||||||
moatCollider: {fileID: 9196727423716235687}
|
moatCollider: {fileID: 9196727423716235687}
|
||||||
--- !u!1 &9196727423754814335
|
--- !u!1 &9196727423754814335
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -1752,6 +1752,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 72794012913ccd840a73788b90573212, type: 3}
|
m_Script: {fileID: 11500000, guid: 72794012913ccd840a73788b90573212, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
gameFlowManager: {fileID: 0}
|
||||||
spawners:
|
spawners:
|
||||||
- {x: -10, y: 10, z: 0}
|
- {x: -10, y: 10, z: 0}
|
||||||
- {x: 10, y: 10, z: 0}
|
- {x: 10, y: 10, z: 0}
|
||||||
|
|||||||
@ -408,44 +408,80 @@ PrefabInstance:
|
|||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.size
|
propertyPath: m_ActionEvents.Array.size
|
||||||
value: 14
|
value: 15
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_ActionId
|
propertyPath: m_ActionEvents.Array.data[13].m_ActionId
|
||||||
value: d0405457-c534-4103-a0b6-cf113432b467
|
value: d0405457-c534-4103-a0b6-cf113432b467
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].m_ActionId
|
||||||
|
value: 01a06960-a379-49e3-9d58-9b7c8effcb3d
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_ActionName
|
propertyPath: m_ActionEvents.Array.data[13].m_ActionName
|
||||||
value: Player/SwitchMinion[/Keyboard/q,/Keyboard/e,/XInputControllerWindows/leftShoulder,/XInputControllerWindows/rightShoulder]
|
value: Player/SwitchMinion[/Keyboard/q,/Keyboard/e,/XInputControllerWindows/leftShoulder,/XInputControllerWindows/rightShoulder]
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].m_ActionName
|
||||||
|
value: Player/Start[/XInputControllerWindows/start,/Keyboard/enter]
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.size
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.size
|
||||||
value: 1
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.size
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 1551362087}
|
objectReference: {fileID: 1551362087}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1359990806}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
value: 2
|
value: 2
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
value: ChangeSelectedIcon
|
value: ChangeSelectedIcon
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
|
value: OnStart
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
value: MinionBar, Assembly-CSharp
|
value: MinionBar, Assembly-CSharp
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
|
value: GameFlowManager, Assembly-CSharp
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
value: UnityEngine.Object, UnityEngine
|
value: UnityEngine.Object, UnityEngine
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[14].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}
|
- target: {fileID: 1214567908930553592, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: gameFlowManager
|
propertyPath: gameFlowManager
|
||||||
value:
|
value:
|
||||||
|
|||||||
@ -167,7 +167,7 @@ public class PlayerMovement : MonoBehaviour {
|
|||||||
|
|
||||||
class EnterSafeZoneMovementState : JumpingMovementState {
|
class EnterSafeZoneMovementState : JumpingMovementState {
|
||||||
readonly SafeZone safeZone;
|
readonly SafeZone safeZone;
|
||||||
public EnterSafeZoneMovementState(PlayerMovement playerMovement, SafeZone safeZone) : base(playerMovement, safeZone.stats.JumpDuration, safeZone.transform.position) {
|
public EnterSafeZoneMovementState(PlayerMovement playerMovement, SafeZone safeZone) : base(playerMovement, safeZone.Stats.JumpDuration, safeZone.transform.position) {
|
||||||
this.safeZone = safeZone;
|
this.safeZone = safeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ public class PlayerMovement : MonoBehaviour {
|
|||||||
|
|
||||||
class ExitSafeZoneMovementState : JumpingMovementState {
|
class ExitSafeZoneMovementState : JumpingMovementState {
|
||||||
readonly SafeZone safeZone;
|
readonly SafeZone safeZone;
|
||||||
public ExitSafeZoneMovementState(PlayerMovement playerMovement, SafeZone safeZone, Vector2 direction) : base(playerMovement, safeZone.stats.JumpDuration, safeZone.GetOutsidePosition(direction)) {
|
public ExitSafeZoneMovementState(PlayerMovement playerMovement, SafeZone safeZone, Vector2 direction) : base(playerMovement, safeZone.Stats.JumpDuration, safeZone.GetOutsidePosition(direction)) {
|
||||||
this.safeZone = safeZone;
|
this.safeZone = safeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,15 @@
|
|||||||
"processors": "",
|
"processors": "",
|
||||||
"interactions": "",
|
"interactions": "",
|
||||||
"initialStateCheck": false
|
"initialStateCheck": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Start",
|
||||||
|
"type": "Button",
|
||||||
|
"id": "01a06960-a379-49e3-9d58-9b7c8effcb3d",
|
||||||
|
"expectedControlType": "Button",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bindings": [
|
"bindings": [
|
||||||
@ -284,6 +293,28 @@
|
|||||||
"action": "SwitchMinion",
|
"action": "SwitchMinion",
|
||||||
"isComposite": false,
|
"isComposite": false,
|
||||||
"isPartOfComposite": true
|
"isPartOfComposite": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "4715f838-717a-4f10-a668-05a6d761a7bc",
|
||||||
|
"path": "<Gamepad>/start",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "Gamepad",
|
||||||
|
"action": "Start",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "025fe243-6da7-4b27-9c02-f353d7a121df",
|
||||||
|
"path": "<Keyboard>/enter",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "Keyboard&Mouse",
|
||||||
|
"action": "Start",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user