first commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TerritoryUI : MonoBehaviour
|
||||
{
|
||||
public Text playerPointsText;
|
||||
public Text enemyPointsText;
|
||||
public Text zoneStatusText;
|
||||
public GameObject winPanel;
|
||||
public Text winText;
|
||||
|
||||
private readonly StringBuilder zoneStatusBuilder = new StringBuilder();
|
||||
|
||||
public void UpdateZoneStatus(CaptureZone[] zones)
|
||||
{
|
||||
if (zoneStatusText == null || zones == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
zoneStatusBuilder.Length = 0;
|
||||
for (int i = 0; i < zones.Length; i++)
|
||||
{
|
||||
CaptureZone zone = zones[i];
|
||||
if (zone == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int percent = Mathf.RoundToInt(zone.GetProgress() * 100f);
|
||||
zoneStatusBuilder.Append(zone.zoneName)
|
||||
.Append(": ")
|
||||
.Append(zone.GetOwner())
|
||||
.Append(", ")
|
||||
.Append(percent)
|
||||
.Append('%');
|
||||
|
||||
if (i < zones.Length - 1)
|
||||
{
|
||||
zoneStatusBuilder.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
zoneStatusText.text = zoneStatusBuilder.ToString();
|
||||
}
|
||||
|
||||
public void ShowGameOver(string message)
|
||||
{
|
||||
if (winPanel != null)
|
||||
{
|
||||
winPanel.SetActive(true);
|
||||
}
|
||||
|
||||
if (winText != null)
|
||||
{
|
||||
winText.text = message;
|
||||
}
|
||||
}
|
||||
|
||||
public void HideGameOver()
|
||||
{
|
||||
if (winPanel != null)
|
||||
{
|
||||
winPanel.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetScore(int playerScore, int enemyScore)
|
||||
{
|
||||
if (playerPointsText != null)
|
||||
{
|
||||
playerPointsText.text = "Player Points: " + playerScore;
|
||||
}
|
||||
|
||||
if (enemyPointsText != null)
|
||||
{
|
||||
enemyPointsText.text = "Enemy Points: " + enemyScore;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user