Pull request #15: Jason
Merge in CEGJ/ludumdare50 from jason to dev * commit '2000f0859cab64285e9002fcd1dca94bc31fae44': Fullscreen mode dropdown Set window resizable Cleaned option flow Use new font on title Fixed buttons not choosable via controller Only randomize title if high score > 0
This commit is contained in:
commit
26336ce98b
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: a53670f9cd399ea4a8ae3ed81b923aa8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
stopped: 0
|
||||
--- !u!222 &344214378
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -88,8 +87,8 @@ MonoBehaviour:
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4291151301
|
||||
m_fontColor: {r: 0.7735849, g: 0.7735849, b: 0.7735849, a: 1}
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
|
||||
@ -157,6 +157,10 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 1599369357879094150, guid: f7f5d2b1228d13f4d9015073aced3e81, type: 3}
|
||||
propertyPath: m_FirstSelected
|
||||
value:
|
||||
objectReference: {fileID: 1492315807}
|
||||
- target: {fileID: 8365024801073869718, guid: f7f5d2b1228d13f4d9015073aced3e81, type: 3}
|
||||
propertyPath: m_Follow
|
||||
value:
|
||||
@ -220,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}
|
||||
@ -357,6 +372,11 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: aadb67b8f73573a44b31b015f38561ee, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1492315807 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4394421821813469862, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
m_PrefabInstance: {fileID: 1896701250}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &1551362086
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -485,6 +505,50 @@ 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: 2702070852302166608, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_text
|
||||
value: Windowed
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3281526541317417273, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4394421820928219480, guid: 7671830e57aa4bd4cab63b8399c6f825, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: MainMenu
|
||||
@ -589,6 +653,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) {
|
||||
|
||||
@ -25,12 +25,12 @@ public class GameTimer : MonoBehaviour {
|
||||
}
|
||||
|
||||
bool showHighScore;
|
||||
const string HighScoreKey = "High Score";
|
||||
public const string HIGH_SCORE_KEY = "High Score";
|
||||
|
||||
void Awake() {
|
||||
label = GetComponent<TMP_Text>();
|
||||
timer = 0f;
|
||||
highScore = PlayerPrefs.GetFloat(HighScoreKey);
|
||||
highScore = PlayerPrefs.GetFloat(HIGH_SCORE_KEY);
|
||||
Stopped = true;
|
||||
}
|
||||
|
||||
@ -55,12 +55,13 @@ public class GameTimer : MonoBehaviour {
|
||||
if (timer <= highScore)
|
||||
return;
|
||||
|
||||
PlayerPrefs.SetFloat(HighScoreKey, timer);
|
||||
PlayerPrefs.SetFloat(HIGH_SCORE_KEY, timer);
|
||||
highScore = timer;
|
||||
}
|
||||
|
||||
public void ResetHighScore() {
|
||||
PlayerPrefs.DeleteKey(HighScoreKey);
|
||||
highScore = 0f;
|
||||
PlayerPrefs.DeleteKey(HIGH_SCORE_KEY);
|
||||
highScore = timer;
|
||||
UpdateLabel();
|
||||
}
|
||||
}
|
||||
@ -1,41 +1,107 @@
|
||||
using System;
|
||||
using NaughtyAttributes;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
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]
|
||||
Text titleLable;
|
||||
[SerializeField] string[] titleOptions;
|
||||
[SerializeField] [Required]
|
||||
Button startButton;
|
||||
MenuMode mode;
|
||||
TMP_Text titleLabel;
|
||||
|
||||
void Awake() => mode = MenuMode.MainMenu;
|
||||
[SerializeField] string[] titleOptions;
|
||||
|
||||
[SerializeField] [Required]
|
||||
Transform startMenuParent;
|
||||
|
||||
[SerializeField] [Required]
|
||||
Transform pauseParent;
|
||||
|
||||
[SerializeField] [Required]
|
||||
Transform optionsParent;
|
||||
|
||||
[SerializeField] [Required]
|
||||
GameTimer gameTimer;
|
||||
|
||||
[SerializeField] [Required]
|
||||
EventSystem eventSystem;
|
||||
|
||||
[SerializeField] [Required]
|
||||
TMP_Dropdown displayModeDropdown;
|
||||
|
||||
MenuMode mode;
|
||||
MenuMode? preOptionsMode;
|
||||
|
||||
void Awake() => SetMenuMode(MenuMode.MainMenu);
|
||||
|
||||
void Start() {
|
||||
if (titleOptions.Length > 0)
|
||||
titleLable.text = titleOptions[Random.Range(0, titleOptions.Length)];
|
||||
if (titleOptions.Length == 0) {
|
||||
Debug.LogWarning("No titles listed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerPrefs.HasKey(GameTimer.HIGH_SCORE_KEY) && PlayerPrefs.GetFloat(GameTimer.HIGH_SCORE_KEY) > 0f)
|
||||
titleLabel.text = titleOptions[Random.Range(0, titleOptions.Length)];
|
||||
else
|
||||
titleLabel.text = titleOptions[0];
|
||||
}
|
||||
|
||||
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);
|
||||
titleLable.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();
|
||||
|
||||
public void DisplayModeChange() {
|
||||
Screen.fullScreenMode = displayModeDropdown.value switch {
|
||||
0 => FullScreenMode.Windowed,
|
||||
1 => FullScreenMode.ExclusiveFullScreen,
|
||||
2 => FullScreenMode.FullScreenWindow,
|
||||
_ => Screen.fullScreenMode
|
||||
};
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -88,7 +88,7 @@ PlayerSettings:
|
||||
bakeCollisionMeshes: 0
|
||||
forceSingleInstance: 0
|
||||
useFlipModelSwapchain: 1
|
||||
resizableWindow: 0
|
||||
resizableWindow: 1
|
||||
useMacAppStoreValidation: 0
|
||||
macAppStoreCategory: public.app-category.games
|
||||
gpuSkinning: 0
|
||||
@ -137,6 +137,7 @@ PlayerSettings:
|
||||
bundleVersion: 1.0
|
||||
preloadedAssets:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
m_HolographicPauseOnTrackingLoss: 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user