starOfWords/Assets/Scripts/3.0/Mod5/Mod5Resume.cs
portakal ecb1c9edea Initial commit: Star of Words Unity project
Snapshot of the existing Unity 6 language-learning word game before any
refactoring. Adds Unity .gitignore and .gitattributes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-05 15:31:20 +03:00

90 lines
2.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 keyi
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");
}
}