Cleaned option flow
This commit is contained in:
parent
9a4eaea61d
commit
9451309526
File diff suppressed because it is too large
Load Diff
@ -224,6 +224,17 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 1214567908930553594, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||
m_PrefabInstance: {fileID: 1942557562}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &775644865 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 1599369357879094150, guid: f7f5d2b1228d13f4d9015073aced3e81, type: 3}
|
||||
m_PrefabInstance: {fileID: 647315810}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &836972483 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 344214379, guid: e1dac4f28fe75a547b919b7aa8240fed, type: 3}
|
||||
@ -494,6 +505,42 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 742651633273559791, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 742651633273559791, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 742651633273559791, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
value:
|
||||
objectReference: {fileID: 171858601}
|
||||
- target: {fileID: 742651633273559791, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 742651633273559791, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: ToGameplayFlowState
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 742651633273559791, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||
value: GameFlowManager, Assembly-CSharp
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 742651633273559791, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
value: UnityEngine.Object, UnityEngine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1568061621804763920, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: gameTimer
|
||||
value:
|
||||
objectReference: {fileID: 836972483}
|
||||
- target: {fileID: 1568061621804763920, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: eventSystem
|
||||
value:
|
||||
objectReference: {fileID: 775644865}
|
||||
- target: {fileID: 4394421820928219480, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: MainMenu
|
||||
@ -598,6 +645,10 @@ PrefabInstance:
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Target
|
||||
value:
|
||||
objectReference: {fileID: 30189384}
|
||||
- target: {fileID: 4394421821813469848, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4394421821813469848, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: ToStartFlowState
|
||||
|
||||
@ -102,6 +102,11 @@ public class GameFlowManager : MonoBehaviour {
|
||||
/// </summary>
|
||||
public void ToStartFlowState() => SwitchState(new StartFlowState(this));
|
||||
|
||||
/// <summary>
|
||||
/// For calling from main menu button
|
||||
/// </summary>
|
||||
public void ToGameplayFlowState() => SwitchState(new GameplayFlowState(this));
|
||||
|
||||
#region Inputs
|
||||
|
||||
public void OnStart(InputAction.CallbackContext ctx) {
|
||||
|
||||
@ -61,6 +61,7 @@ public class GameTimer : MonoBehaviour {
|
||||
|
||||
public void ResetHighScore() {
|
||||
PlayerPrefs.DeleteKey(HIGH_SCORE_KEY);
|
||||
highScore = 0f;
|
||||
highScore = timer;
|
||||
UpdateLabel();
|
||||
}
|
||||
}
|
||||
@ -1,23 +1,35 @@
|
||||
using System;
|
||||
using NaughtyAttributes;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class MainMenuManager : MonoBehaviour {
|
||||
public enum MenuMode {
|
||||
MainMenu,
|
||||
PauseMenu,
|
||||
Options,
|
||||
}
|
||||
|
||||
[SerializeField] [Required]
|
||||
TMP_Text titleLabel;
|
||||
[SerializeField] string[] titleOptions;
|
||||
[SerializeField] [Required]
|
||||
Button startButton;
|
||||
Transform startMenuParent;
|
||||
[SerializeField] [Required]
|
||||
Transform pauseParent;
|
||||
[SerializeField] [Required]
|
||||
Transform optionsParent;
|
||||
[SerializeField] [Required]
|
||||
GameTimer gameTimer;
|
||||
[SerializeField] [Required]
|
||||
EventSystem eventSystem;
|
||||
MenuMode mode;
|
||||
MenuMode? preOptionsMode;
|
||||
|
||||
void Awake() => mode = MenuMode.MainMenu;
|
||||
void Awake() => SetMenuMode(MenuMode.MainMenu);
|
||||
|
||||
void Start() {
|
||||
if (titleOptions.Length == 0) {
|
||||
@ -32,18 +44,43 @@ public class MainMenuManager : MonoBehaviour {
|
||||
}
|
||||
|
||||
public void SetMenuMode(MenuMode mode) {
|
||||
this.mode = mode;
|
||||
//meh
|
||||
titleLabel.gameObject.SetActive(mode == MenuMode.MainMenu);
|
||||
startMenuParent.gameObject.SetActive(mode == MenuMode.MainMenu);
|
||||
pauseParent.gameObject.SetActive(mode == MenuMode.PauseMenu);
|
||||
optionsParent.gameObject.SetActive(mode == MenuMode.Options);
|
||||
if (mode == MenuMode.Options) {
|
||||
if (this.mode != MenuMode.Options)
|
||||
preOptionsMode = this.mode;
|
||||
} else {
|
||||
preOptionsMode = null;
|
||||
}
|
||||
|
||||
bool mainMenu = mode == MenuMode.MainMenu;
|
||||
startButton.gameObject.SetActive(mainMenu);
|
||||
titleLabel.gameObject.SetActive(mainMenu);
|
||||
this.mode = mode;
|
||||
ResetMenuState();
|
||||
}
|
||||
|
||||
public void SetOptions() => SetMenuMode(MenuMode.Options);
|
||||
|
||||
public void ExitOptions() {
|
||||
if (preOptionsMode != null)
|
||||
SetMenuMode(preOptionsMode.Value);
|
||||
}
|
||||
|
||||
public void ResetMenuState() {
|
||||
//TODO Reset selected button
|
||||
GameObject selected = mode switch {
|
||||
MenuMode.MainMenu => startMenuParent.GetChild(0).gameObject,
|
||||
MenuMode.PauseMenu => pauseParent.GetChild(0).gameObject,
|
||||
MenuMode.Options => optionsParent.GetChild(0).gameObject,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null)
|
||||
};
|
||||
eventSystem.firstSelectedGameObject = selected;
|
||||
eventSystem.SetSelectedGameObject(selected);
|
||||
}
|
||||
|
||||
public void GoToScene(int sceneNb) => SceneManager.LoadScene(sceneNb);
|
||||
|
||||
public void QuitGame() => Application.Quit(0);
|
||||
|
||||
public void ResetHighScore() => gameTimer.ResetHighScore();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user