Chess-II-Counterattack/Assets/Scripts/GameOverCanvas.cs
Gerard Gascón 78b901484a init
2025-04-24 17:43:50 +02:00

54 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class GameOverCanvas : MonoBehaviour{
[SerializeField] TextMeshProUGUI newRecordText;
[Space]
public int movementsDone;
[SerializeField] TextMeshProUGUI movementDonePoints;
[Space]
public int enemiesKilled;
[SerializeField] TextMeshProUGUI enemiesKilledPoints;
[Space]
[SerializeField] int totalPoints;
[SerializeField] TextMeshProUGUI totalPointsPoints;
// Start is called before the first frame update
void Start(){
totalPoints = (movementsDone / 3) * enemiesKilled;
totalPointsPoints.text = totalPoints.ToString();
movementDonePoints.text = movementsDone.ToString();
enemiesKilledPoints.text = enemiesKilled.ToString();
if (PlayerPrefs.HasKey("MaxScore")){
if(PlayerPrefs.GetInt("MaxScore") < totalPoints){
newRecordText.enabled = true;
PlayerPrefs.SetInt("MaxScore", totalPoints);
}else{
newRecordText.enabled = false;
}
}else{
newRecordText.enabled = true;
PlayerPrefs.SetInt("MaxScore", totalPoints);
}
}
public void Menu(){
SceneLoader.instance.LoadScene(0, SceneLoader.DifficultySelected.Easy);
}
public void Retry(){
CanvasManager canvas = FindObjectOfType<CanvasManager>();
if(canvas.difficulty == CanvasManager.CanvasDifficulty.Easy){
SceneLoader.instance.LoadScene(1, SceneLoader.DifficultySelected.Easy);
}else{
SceneLoader.instance.LoadScene(1, SceneLoader.DifficultySelected.Hard);
}
}
}