ProjetAMJV_CR/Assets/Scripts/Singletons/GameManager.cs
Kirabsol 33d88bdfa7 Start of WiN/LOSE UI
finishing later today
2025-01-28 13:20:29 +01:00

64 lines
1.4 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviourSingletonPersistent<GameManager>
{
[SerializeField] private List<string> levelNames;
int current_level = 0;
[SerializeField] GameObject GameUI;
[SerializeField] GameObject LoseUI;
[SerializeField] GameObject WinUI;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
// Delete, use only for Debug
if (Input.GetKeyDown(KeyCode.Space))
{
StartFightForAll();
}
}
public void StartFightForAll()
{
AbstractUnit[] units = FindObjectsByType<AbstractUnit>(FindObjectsSortMode.None);
foreach (var unit in units)
{
unit.StartFight();
}
}
public void GoNextLevel()
{
if (current_level < levelNames.Count)
{
current_level++;
SceneManager.LoadScene(levelNames[current_level]);
return;
}
throw new Exception("Bro there is no next level like stop pls");
}
public void Losing()
{
LoseUI.SetActive(true);
this.enabled = false;
}
}