Made game able to be reloaded

This commit is contained in:
2026-01-19 21:04:58 +00:00
parent 6c3e7ca111
commit 59596fead8
6 changed files with 321 additions and 47 deletions

View File

@@ -1,6 +1,7 @@
using System;
using Ext.B83.Unity.Attributes;
using UnityEngine;
using UnityEngine.SceneManagement;
using Random = UnityEngine.Random;
namespace InterfaceOff
@@ -17,7 +18,7 @@ namespace InterfaceOff
{
[field: SerializeField] private GameObject SampleChild { get; set; }
[field: SerializeField] private Canvas GameCanvas { get; set; }
[field: SerializeField] private GameObject DeathInfo { get; set; }
[field: SerializeField] private SpawnableWindowType[] WindowTypes { get; set; }
private int TotalSpawnWeight { get; set; }
@@ -92,6 +93,7 @@ namespace InterfaceOff
private void FixedUpdate()
{
/* Spawns new windows whilst active */
if (AutoSpawn)
{
const int TICKS_PER_SECOND = 20;
@@ -106,17 +108,30 @@ namespace InterfaceOff
SpawnNewRandomWindow();
}
}
/* Else checks if it should reload the scene */
else if (Input.GetKey(KeyCode.Space))
{
int sceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(sceneIndex);
}
}
private void Update()
public void StartEndSequence()
{
if (!AutoSpawn)
/* Destroys all children and stops them from spawning */
AutoSpawn = false;
foreach (Transform child in GameCanvas.transform)
{
if (Input.GetKeyDown(KeyCode.Space))
WindowBase window = child.GetComponent<WindowBase>();
if (DebugUtils.IsNotNull(window))
{
SpawnNewRandomWindow();
window.DestroyWindow();
}
}
/* Makes the death text visible to the player */
DeathInfo.SetActive(true);
}
}
}