Start of WiN/LOSE UI
finishing later today
This commit is contained in:
parent
e51417a4e5
commit
33d88bdfa7
8 changed files with 221 additions and 111 deletions
40
Assets/Scripts/GameUI.cs
Normal file
40
Assets/Scripts/GameUI.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] TextMeshProUGUI timer;
|
||||
public float time;
|
||||
public bool timerActive;
|
||||
|
||||
[SerializeField] TextMeshProUGUI units;
|
||||
private int enemiesLeft;
|
||||
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
time = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (timerActive)
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
}
|
||||
|
||||
TimeSpan displayedTime = TimeSpan.FromSeconds(time);
|
||||
|
||||
timer.text = displayedTime.Minutes.ToString() + displayedTime.Seconds.ToString();
|
||||
|
||||
|
||||
enemiesLeft = GlobalsVariable.AliveUnitsTeamA.Count;
|
||||
units.text = "Units Left: " + enemiesLeft.ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
2
Assets/Scripts/GameUI.cs.meta
Normal file
2
Assets/Scripts/GameUI.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24e4c78ff3d5523409c311e513ba6ce4
|
21
Assets/Scripts/LoseUI.cs
Normal file
21
Assets/Scripts/LoseUI.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class LoseUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameUI gameUI;
|
||||
|
||||
[SerializeField] TextMeshProUGUI time;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
time.text = gameUI.GetComponent<GameUI>().time.ToString();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
2
Assets/Scripts/LoseUI.cs.meta
Normal file
2
Assets/Scripts/LoseUI.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5393cb13d8a7330418334d35a76e6da1
|
|
@ -9,6 +9,12 @@ 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()
|
||||
{
|
||||
|
@ -48,4 +54,11 @@ public class GameManager : MonoBehaviourSingletonPersistent<GameManager>
|
|||
|
||||
}
|
||||
|
||||
public void Losing()
|
||||
{
|
||||
|
||||
LoseUI.SetActive(true);
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue