Aetheria/Assets/Scripts/MainMenu.cs
Reinier Vens e6181c11dc Main Menu
Added Main Menu scene
Tweaked world map to incorporate secondary colors in zone icons + glowing links
Entity Serialization is now generic
Zone Serialization now includes entities
Fixed bug where wormhole traversal would unbind from player entity
Game Manager no longer spawns entities (loadout file format changed)
Wrote extension to randomly select weighted items from collections (for generating enemies)
2021-03-13 03:23:58 +00:00

46 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class MainMenu : MonoBehaviour
{
public TextMeshProUGUI Title;
public Prototype ButtonPrototype;
private List<Prototype> _contents = new List<Prototype>();
void Start()
{
ShowMain();
}
private void ShowMain()
{
Title.text = "aetheria\n<smallcaps><size=50%>terminus";
Clear();
AddButton("Continue", null);
AddButton("New Game", null);
AddButton("Load Game", null);
AddButton("Settings", null);
AddButton("Quit", Application.Quit);
}
private void Clear()
{
foreach(var item in _contents)
item.ReturnToPool();
_contents.Clear();
}
private void AddButton(string label, Action onPress)
{
var button = ButtonPrototype.Instantiate<Button>();
button.GetComponent<TextMeshProUGUI>().text = label;
button.onClick.RemoveAllListeners();
button.onClick.AddListener(() => onPress?.Invoke());
_contents.Add(button.GetComponent<Prototype>());
}
}