Fix winner detection
This commit is contained in:
parent
be419b5c78
commit
8ca5097604
@ -711,8 +711,8 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
distanceText: {fileID: 393375357}
|
||||
numberCoinsText: {fileID: 403573105}
|
||||
joueur1Text: {fileID: 1628274878}
|
||||
joueur2Text: {fileID: 1398225804}
|
||||
joueur1Text: {fileID: 0}
|
||||
joueur2Text: {fileID: 0}
|
||||
is1v1Mode: 1
|
||||
--- !u!1 &565350509
|
||||
GameObject:
|
||||
|
@ -8,57 +8,12 @@ public class UIManager : MonoBehaviour
|
||||
public TextMeshProUGUI distanceText;
|
||||
public TextMeshProUGUI numberCoinsText;
|
||||
|
||||
// Références pour le mode 1v1
|
||||
public TextMeshProUGUI joueur1Text;
|
||||
public TextMeshProUGUI joueur2Text;
|
||||
|
||||
// Variables pour distance et pièces
|
||||
private float distance = 0f;
|
||||
private int coins = 0;
|
||||
|
||||
// Variables pour le mode 1v1
|
||||
private int joueur1Score = 1;
|
||||
private int joueur2Score = 0;
|
||||
|
||||
// Mode de jeu
|
||||
public bool is1v1Mode = false;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!is1v1Mode)
|
||||
{
|
||||
distanceText.text = distance.ToString("F1", CultureInfo.InvariantCulture) + "M";
|
||||
numberCoinsText.text = coins.ToString();
|
||||
}
|
||||
else if (is1v1Mode)
|
||||
{
|
||||
distanceText.text = distance.ToString("F1", CultureInfo.InvariantCulture) + "M";
|
||||
numberCoinsText.text = coins.ToString();
|
||||
DisplayResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void DisplayResult()
|
||||
{
|
||||
if (is1v1Mode)
|
||||
{
|
||||
if (joueur1Score > joueur2Score)
|
||||
{
|
||||
joueur1Text.text ="Winner";
|
||||
joueur2Text.text ="Loser";
|
||||
}
|
||||
else if (joueur1Score < joueur2Score)
|
||||
{
|
||||
joueur1Text.text = "Loser";
|
||||
joueur2Text.text = "Winner";
|
||||
}
|
||||
else
|
||||
{
|
||||
joueur1Text.text = "Égalité";
|
||||
joueur2Text.text = "Égalité";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user