Razor UI component for the main menu. Renders three buttons (New Game, LeaderBoards, Exit) and chooses which scene to load based on ScoreManager numeric thresholds; also has properties for several SceneFile assets.
@using Sandbox;
@using Sandbox.UI;
@inherits PanelComponent
@namespace Sandbox
<root>
<h2>Main Menu</h2>
<div class="options">
<div class="button" onclick=@NewGame>
New Game
</div>
<div class="button" onclick=@HighScore>
LeaderBoards
</div>
<div class="button" onclick=@Exit>
Exit
</div>
</div>
</root>
@code
{
[Property] public SceneFile hatselection { get; set; }
[Property] public SceneFile hatselectionWST { get; set; }
[Property] public SceneFile hatselectionWS { get; set; }
[Property] public SceneFile hatselectionWT { get; set; }
[Property] public SceneFile hatselectionW { get; set; }
[Property] public SceneFile hatselectionST { get; set; }
[Property] public SceneFile hatselectionS { get; set; }
[Property] public SceneFile hatselectionT { get; set; }
[Property] public SceneFile LBSelect { get; set; }
void NewGame()
{
if (ScoreManager.HighScore > 3000 && ScoreManager.WMCount > 9 && ScoreManager.TofuCount > 9)
{
Scene.Load(hatselection);
}
if (ScoreManager.HighScore <= 3000 && ScoreManager.WMCount <= 9 && ScoreManager.TofuCount > 9)
{
Scene.Load(hatselectionWS);
}
if (ScoreManager.HighScore > 3000 && ScoreManager.WMCount <= 9 && ScoreManager.TofuCount <= 9)
{
Scene.Load(hatselectionWT);
}
if (ScoreManager.HighScore > 3000 && ScoreManager.WMCount <= 9 && ScoreManager.TofuCount > 9)
{
Scene.Load(hatselectionW);
}
if (ScoreManager.HighScore <= 3000 && ScoreManager.WMCount > 9 && ScoreManager.TofuCount <= 9)
{
Scene.Load(hatselectionST);
}
if (ScoreManager.HighScore <= 3000 && ScoreManager.WMCount > 9 && ScoreManager.TofuCount > 9)
{
Scene.Load(hatselectionS);
}
if (ScoreManager.HighScore > 3000 && ScoreManager.WMCount > 9 && ScoreManager.TofuCount <= 9)
{
Scene.Load(hatselectionT);
}
if (ScoreManager.HighScore <= 3000 && ScoreManager.WMCount <= 9 && ScoreManager.TofuCount <= 9)
{
Scene.Load(hatselectionWST);
}
}
void HighScore()
{
Scene.Load(LBSelect);
}
void Exit()
{
Game.Close();
}
/// <summary>
/// the hash determines if the system should be rebuilt. If it changes, it will be rebuilt
/// </summary>
}