90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
|
|
using TMPro;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.SceneManagement;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
|
|||
|
|
public class Mod5Resume : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
[Header("UI TEXTS (ONLY NUMBERS)")]
|
|||
|
|
public TMP_Text scoreText;
|
|||
|
|
public TMP_Text maxScoreText;
|
|||
|
|
public TMP_Text correctText;
|
|||
|
|
public TMP_Text wrongText;
|
|||
|
|
|
|||
|
|
[Header("BUTTONS")]
|
|||
|
|
public Button retryButton;
|
|||
|
|
public Button exitButton;
|
|||
|
|
|
|||
|
|
[Header("AUDIO")]
|
|||
|
|
public AudioSource sfx;
|
|||
|
|
public AudioClip clickSound;
|
|||
|
|
|
|||
|
|
// 🔥 Bu modun özel ana key’i
|
|||
|
|
private string modKey = "Mod5";
|
|||
|
|
|
|||
|
|
private int score;
|
|||
|
|
private int maxScore;
|
|||
|
|
private int correct;
|
|||
|
|
private int wrong;
|
|||
|
|
|
|||
|
|
void Start()
|
|||
|
|
{
|
|||
|
|
LoadResults();
|
|||
|
|
UpdateUI();
|
|||
|
|
|
|||
|
|
if (retryButton != null)
|
|||
|
|
retryButton.onClick.AddListener(() =>
|
|||
|
|
{
|
|||
|
|
PlaySFX();
|
|||
|
|
Retry();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (exitButton != null)
|
|||
|
|
exitButton.onClick.AddListener(() =>
|
|||
|
|
{
|
|||
|
|
PlaySFX();
|
|||
|
|
ExitToMenu();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ---------------------------------------------------------------
|
|||
|
|
void LoadResults()
|
|||
|
|
{
|
|||
|
|
score = PlayerPrefs.GetInt(modKey + "_LastScore", 0);
|
|||
|
|
maxScore = PlayerPrefs.GetInt(modKey + "_MaxScore", 0);
|
|||
|
|
correct = PlayerPrefs.GetInt(modKey + "_Correct", 0);
|
|||
|
|
wrong = PlayerPrefs.GetInt(modKey + "_Wrong", 0);
|
|||
|
|
|
|||
|
|
Debug.Log("MOD5 RESULT → " +
|
|||
|
|
$"Score:{score} | Max:{maxScore} | C:{correct} | W:{wrong}");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ---------------------------------------------------------------
|
|||
|
|
void UpdateUI()
|
|||
|
|
{
|
|||
|
|
if (scoreText != null) scoreText.text = score.ToString();
|
|||
|
|
if (maxScoreText != null) maxScoreText.text = maxScore.ToString();
|
|||
|
|
if (correctText != null) correctText.text = correct.ToString();
|
|||
|
|
if (wrongText != null) wrongText.text = wrong.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ---------------------------------------------------------------
|
|||
|
|
void PlaySFX()
|
|||
|
|
{
|
|||
|
|
if (sfx && clickSound)
|
|||
|
|
sfx.PlayOneShot(clickSound);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ---------------------------------------------------------------
|
|||
|
|
void Retry()
|
|||
|
|
{
|
|||
|
|
// 🔥 Mod 5'in oyun sahnesine geri dönüş
|
|||
|
|
SceneManager.LoadScene("Mod5");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ---------------------------------------------------------------
|
|||
|
|
void ExitToMenu()
|
|||
|
|
{
|
|||
|
|
SceneManager.LoadScene("Anamen");
|
|||
|
|
}
|
|||
|
|
}
|