game(ui): interim overlay uxmls and skeleton scripts

This commit is contained in:
Mark Joshwel 2024-08-11 07:20:58 +08:00
parent fa3eebba97
commit 92aa45646c
15 changed files with 300 additions and 0 deletions

View file

@ -0,0 +1,22 @@
/*
* author: mark joshwel
* date: 11/8/2024
* description: TODO
*/
/// <summary>
/// TODO
/// </summary>
public class OverlayCompleteUnderTimeMenu : CommonMenu
{
/// <summary>
/// function to associate a display state with the menu,
/// and subscribe button events to their respective functions
/// </summary>
public override void OnEnable()
{
// set the associated state and call the base OnEnable
associatedState = GameManager.DisplayState.OverlayCompleteUnderTimeMenu;
base.OnEnable();
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d90104adf847428596a24cd16d00676e
timeCreated: 1723322846

View file

@ -0,0 +1,22 @@
/*
* author: mark joshwel
* date: 11/8/2024
* description: TODO
*/
/// <summary>
/// TODO
/// </summary>
public class OverlayFailedOverTimeMenu : CommonMenu
{
/// <summary>
/// function to associate a display state with the menu,
/// and subscribe button events to their respective functions
/// </summary>
public override void OnEnable()
{
// set the associated state and call the base OnEnable
associatedState = GameManager.DisplayState.OverlayFailedOverTimeMenu;
base.OnEnable();
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9dda88a82bad4822922db26f7f9f4266
timeCreated: 1723322994

View file

@ -0,0 +1,22 @@
/*
* author: mark joshwel
* date: 11/8/2024
* description: TODO
*/
/// <summary>
/// TODO
/// </summary>
public class OverlayPauseMenu : CommonMenu
{
/// <summary>
/// function to associate a display state with the menu,
/// and subscribe button events to their respective functions
/// </summary>
public override void OnEnable()
{
// set the associated state and call the base OnEnable
associatedState = GameManager.DisplayState.OverlayPauseMenu;
base.OnEnable();
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 06af012c6fb2403484f6b955d96c91db
timeCreated: 1723323029

View file

@ -0,0 +1,86 @@
/*
* author: mark joshwel
* date: 11/8/2024
* description: script for handling main menu button functions
*/
using UnityEngine;
using UnityEngine.UIElements;
/// <summary>
/// class managing the main menu and button function invocations
/// </summary>
public class ScreenMainMenu : CommonMenu
{
/// <summary>
/// button to quit game
/// </summary>
public Button ButtonExit;
/// <summary>
/// button to show the options menu
/// </summary>
public Button ButtonOptions;
/// <summary>
/// button to play game
/// </summary>
public Button ButtonPlay;
/// <summary>
/// function to associate a display state with the menu,
/// and subscribe button events to their respective functions
/// </summary>
public override void OnEnable()
{
// set the associated state and call the base OnEnable
associatedState = GameManager.DisplayState.ScreenMainMenu;
base.OnEnable();
// get the start button from the ui root and subscribe appropriate functions
ButtonPlay = UI.Q<Button>("ButtonPlay");
ButtonPlay.clicked += PlayClick;
ButtonPlay.clicked += OptionStartGame;
// get the options button from the ui root and subscribe appropriate functions
ButtonOptions = UI.Q<Button>("ButtonOptions");
ButtonOptions.clicked += PlayClick;
ButtonOptions.clicked += OptionShowOptions;
// get the quit button from the ui root and subscribe appropriate functions
ButtonExit = UI.Q<Button>("ButtonExit");
ButtonExit.clicked += PlayClick;
ButtonExit.clicked += OptionQuitGame;
}
/// <summary>
/// handles start button press,
/// signals the game manager appropriately
/// </summary>
private void OptionStartGame()
{
// start game
Game.NewGame();
}
/// <summary>
/// handles options button press,
/// signals the game manager appropriately
/// </summary>
private void OptionShowOptions()
{
// show the option menu
Game.SetDisplayState(GameManager.DisplayState.ScreenOptionsMenu);
}
/// <summary>
/// handles quit button press,
/// signals the game manager appropriately
/// </summary>
private void OptionQuitGame()
{
// quit game
Debug.Log("MainMenu.OptionQuitGame: exiting");
Game.Quit();
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f7d3d52857e7418c805c0237b4c86485
timeCreated: 1723321636

View file

@ -0,0 +1,90 @@
/*
* author: mark joshwel
* date: 11/8/2024
* description: option menu script for handling credits menu button functions
*/
using UnityEngine.UIElements;
/// <summary>
/// class managing the credits menu and button function invocations
/// </summary>
public class ScreenOptionsMenu : CommonMenu
{
/// <summary>
/// button to return to the main menu
/// </summary>
public Button ButtonReturn;
/// <summary>
/// slider for music volume
/// </summary>
public Slider SliderAudioMusic;
/// <summary>
/// slider for sfx volume
/// </summary>
public Slider SliderAudioSfx;
/// <summary>
/// function to associate a display state with the menu,
/// and subscribe button events to their respective functions
/// </summary>
public override void OnEnable()
{
// set the associated state and call the base OnEnable
associatedState = GameManager.DisplayState.ScreenOptionsMenu;
base.OnEnable();
// get the start button from the ui root and subscribe appropriate functions
ButtonReturn = UI.Q<Button>("ButtonReturn");
ButtonReturn.clicked += PlayClick;
ButtonReturn.clicked += OptionReturnToMainMenu;
// get the music slider from the ui root
SliderAudioMusic = UI.Q<Slider>("Music");
// TODO: and set the initial value to the current music volume
// SliderAudioMusic.value = Audio.GetMusicVolume() * 100;
// and subscribe appropriate functions
SliderAudioMusic.RegisterCallback<ChangeEvent<float>>(OptionSetMusicVolume);
// get the sfx slider from the ui root
SliderAudioSfx = UI.Q<Slider>("SFX");
// TODO: and set the initial value to the current sfx volume
// SliderAudioSfx.value = Audio.GetSfxVolume() * 100;
// and subscribe appropriate functions
SliderAudioSfx.RegisterCallback<ChangeEvent<float>>(OptionSetSfxVolume);
}
/// <summary>
/// handles return to the main menu button press,
/// signals the game manager appropriately
/// </summary>
private void OptionReturnToMainMenu()
{
// return to the main menu
Game.SetDisplayState(GameManager.DisplayState.ScreenMainMenu);
}
/// <summary>
/// handle music volume slider change,
/// sets the music channel volume in the audio manager appropriately
/// </summary>
/// <param name="evt"></param>
private void OptionSetMusicVolume(ChangeEvent<float> evt)
{
// TODO: slider is from 0 to 100, convert to 0 to 1, and set
// Audio.SetMusicVolume(evt.newValue / 100);
}
/// <summary>
/// handle sfx volume slider change,
/// sets the sfx channel volume in the audio manager appropriately
/// </summary>
/// <param name="evt"></param>
private void OptionSetSfxVolume(ChangeEvent<float> evt)
{
// TODO: slider is from 0 to 100, convert to 0 to 1, and set
// Audio.SetSfxVolume(evt.newValue / 100);
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 81b14085a75c30f4fb71c2f8c4429547
timeCreated: 1723321636

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 83ed4fb68c1cfd744b89eff5a83a6c2b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="Root" style="flex-grow: 1; justify-content: space-around; align-items: center;">
<ui:VisualElement name="VertHolder" style="flex-grow: 1; justify-content: flex-start; align-items: center; align-self: auto; margin-top: 2%;">
<ui:Label tabindex="-1" parse-escape-sequences="true" display-tooltip-when-elided="true" text="00:53.47" name="Stopwatch" style="color: rgb(255, 255, 255); -unity-text-align: upper-center; white-space: normal; -unity-font: url(&quot;project://database/Assets/UI%20Toolkit/RLFonts/Fervojo/Fervojo-Bold.otf?fileID=12800000&amp;guid=505dfbc18d2d4604db47ff55755f9dc8&amp;type=3#Fervojo-Bold&quot;); -unity-font-definition: url(&quot;project://database/Assets/UI%20Toolkit/RLFonts/Fervojo/Fervojo-Bold%20SDF.asset?fileID=11400000&amp;guid=1abb65c0bf74b1649863fc75b2b83ac1&amp;type=2#Fervojo-Bold SDF&quot;); font-size: 32px; margin-bottom: 0; padding-bottom: 0;" />
<ui:Label tabindex="-1" parse-escape-sequences="true" display-tooltip-when-elided="true" text="00:53.47" name="Score" style="color: rgb(255, 255, 255); -unity-text-align: upper-center; white-space: normal; -unity-font: url(&quot;project://database/Assets/UI%20Toolkit/RLFonts/Fervojo/Fervojo-Bold.otf?fileID=12800000&amp;guid=505dfbc18d2d4604db47ff55755f9dc8&amp;type=3#Fervojo-Bold&quot;); -unity-font-definition: url(&quot;project://database/Assets/UI%20Toolkit/RLFonts/Fervojo/Fervojo-Bold%20SDF.asset?fileID=11400000&amp;guid=1abb65c0bf74b1649863fc75b2b83ac1&amp;type=2#Fervojo-Bold SDF&quot;); font-size: 14px; margin-top: 0; padding-top: 0;" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 61a631e3bab018249a7b4e91108bfde2
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

View file

@ -0,0 +1,7 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="Root" style="flex-grow: 1; justify-content: space-around; align-items: center;">
<ui:VisualElement name="VertHolder" style="flex-grow: 1; justify-content: center; margin-top: 25%;">
<ui:Label tabindex="-1" parse-escape-sequences="true" display-tooltip-when-elided="true" text="Press E to Interact" name="PromptLabel" style="background-color: rgba(0, 0, 0, 0.33); color: rgb(255, 255, 255); -unity-text-align: upper-center; padding-right: 8px; padding-left: 8px; padding-top: 8px; padding-bottom: 8px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; white-space: normal; -unity-font: url(&quot;project://database/Assets/UI%20Toolkit/RLFonts/Fervojo/Fervojo-Medium.otf?fileID=12800000&amp;guid=9439a6fdc5392c6479cda7dd72a8f3f7&amp;type=3#Fervojo-Medium&quot;); -unity-font-definition: url(&quot;project://database/Assets/UI%20Toolkit/RLFonts/Fervojo/Fervojo-Medium%20SDF.asset?fileID=11400000&amp;guid=45943718062c86e448361bd7f6506932&amp;type=2#Fervojo-Medium SDF&quot;);" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 5ecae982f651ff6438bbaa95ba0362e1
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}