initial commit

This commit is contained in:
2026-05-16 16:12:06 +08:00
parent a7e4ebd4f8
commit f432cfa92f
1008 changed files with 409466 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Platformer.UI
{
/// <summary>
/// A simple controller for switching between UI panels.
/// </summary>
public class MainUIController : MonoBehaviour
{
public GameObject[] panels;
public void SetActivePanel(int index)
{
for (var i = 0; i < panels.Length; i++)
{
var active = i == index;
var g = panels[i];
if (g.activeSelf != active) g.SetActive(active);
}
}
void OnEnable()
{
SetActivePanel(0);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 75fa2f9ea4cb54f34aaac731aabe3733
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+73
View File
@@ -0,0 +1,73 @@
using Platformer.Mechanics;
using Platformer.UI;
using UnityEngine;
namespace Platformer.UI
{
/// <summary>
/// The MetaGameController is responsible for switching control between the high level
/// contexts of the application, eg the Main Menu and Gameplay systems.
/// </summary>
public class MetaGameController : MonoBehaviour
{
/// <summary>
/// The main UI object which used for the menu.
/// </summary>
public MainUIController mainMenu;
/// <summary>
/// A list of canvas objects which are used during gameplay (when the main ui is turned off)
/// </summary>
public Canvas[] gamePlayCanvasii;
/// <summary>
/// The game controller.
/// </summary>
public GameController gameController;
bool showMainCanvas = false;
void OnEnable()
{
_ToggleMainMenu(showMainCanvas);
}
/// <summary>
/// Turn the main menu on or off.
/// </summary>
/// <param name="show"></param>
public void ToggleMainMenu(bool show)
{
if (this.showMainCanvas != show)
{
_ToggleMainMenu(show);
}
}
void _ToggleMainMenu(bool show)
{
if (show)
{
Time.timeScale = 0;
mainMenu.gameObject.SetActive(true);
foreach (var i in gamePlayCanvasii) i.gameObject.SetActive(false);
}
else
{
Time.timeScale = 1;
mainMenu.gameObject.SetActive(false);
foreach (var i in gamePlayCanvasii) i.gameObject.SetActive(true);
}
this.showMainCanvas = show;
}
void Update()
{
if (Input.GetButtonDown("Menu"))
{
ToggleMainMenu(show: !showMainCanvas);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 86f4a4ae3a36547dd915a91ceebed970
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: