61 lines
1.1 KiB
C#
61 lines
1.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class GameController : MonoBehaviour
|
|
{
|
|
public static int playerScore = 0;
|
|
public static int botScore = 0;
|
|
|
|
public Text playerScoreText;
|
|
public Text botScoreText;
|
|
|
|
private string lastHitter;
|
|
|
|
void Start()
|
|
{
|
|
UpdateScoreUI();
|
|
}
|
|
|
|
public void UpdateScoreUI()
|
|
{
|
|
playerScoreText.text = playerScore.ToString();
|
|
botScoreText.text = botScore.ToString();
|
|
}
|
|
|
|
public void AddScore(string hitter, int points)
|
|
{
|
|
if (hitter == "Player")
|
|
{
|
|
playerScore += points;
|
|
}
|
|
else if (hitter == "Bot")
|
|
{
|
|
botScore += points;
|
|
}
|
|
|
|
UpdateScoreUI();
|
|
}
|
|
|
|
public void SetLastHitter(string hitter)
|
|
{
|
|
lastHitter = hitter;
|
|
}
|
|
|
|
public bool LastHitterEquals(string hitter)
|
|
{
|
|
return lastHitter == hitter;
|
|
}
|
|
|
|
public void ResetBall(Bola bola)
|
|
{
|
|
bola.ResetBola();
|
|
}
|
|
|
|
public void ResetScores()
|
|
{
|
|
playerScore = 0;
|
|
botScore = 0;
|
|
UpdateScoreUI();
|
|
}
|
|
}
|