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>
This commit is contained in:
portakal 2026-07-05 15:31:20 +03:00
commit ecb1c9edea
1455 changed files with 933295 additions and 0 deletions

View file

@ -0,0 +1,140 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class MainMenuController : MonoBehaviour
{
[Header("Buttons")]
[SerializeField] private Button btnPlay;
[SerializeField] private Button btnContinue;
[SerializeField] private Button btnWords;
[SerializeField] private Button btnLeaderboard;
[SerializeField] private Button btnExit;
[SerializeField] private Button btnSettings;
[Header("Audio")]
[SerializeField] private AudioSource musicSource;
[SerializeField] private AudioSource sfxSource;
[SerializeField] private AudioClip clickSound;
[SerializeField] private AudioClip menuMusic;
private bool hasSave = false;
private void Awake()
{
ValidateComponents();
}
private void Start()
{
DetectSaveFile();
ConfigureContinueButton();
PlayMenuMusic();
BindButtonEvents();
}
// ===============================
// BUTTON EVENTS
// ===============================
private void BindButtonEvents()
{
btnPlay.onClick.AddListener(() => { PlayClick(); StartNewGame(); });
btnContinue.onClick.AddListener(() => { PlayClick(); ContinueGame(); });
btnWords.onClick.AddListener(() => { PlayClick(); GoWords(); });
btnLeaderboard.onClick.AddListener(() => { PlayClick(); GoLeaderboard(); });
btnExit.onClick.AddListener(() => { PlayClick(); ExitGame(); });
btnSettings.onClick.AddListener(() => { PlayClick(); OpenSettings(); });
}
private void StartNewGame()
{
SceneManager.LoadScene("ModeSelect");
}
private void ContinueGame()
{
int lastLevel = PlayerPrefs.GetInt("LastPlayedLevel", 1);
SceneManager.LoadScene("GameScene_Level" + lastLevel);
}
private void GoWords()
{
SceneManager.LoadScene("WordsScene");
}
private void GoLeaderboard()
{
SceneManager.LoadScene("LeaderboardScene");
}
private void OpenSettings()
{
SceneManager.LoadScene("SettingsScene");
}
private void ExitGame()
{
PlayClick(); // click sesi varsa
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#elif UNITY_ANDROID
Application.Quit();
System.Diagnostics.Process.GetCurrentProcess().Kill();
#elif UNITY_IOS
Application.Quit();
#else
Application.Quit();
#endif
}
// ===============================
// SAVE SYSTEM
// ===============================
private void DetectSaveFile()
{
hasSave = PlayerPrefs.HasKey("LastPlayedLevel");
}
private void ConfigureContinueButton()
{
if (!hasSave)
{
btnContinue.interactable = false;
var text = btnContinue.GetComponentInChildren<Text>();
if (text != null) text.color = new Color(1f, 1f, 1f, 0.4f);
}
else
{
btnContinue.interactable = true;
}
}
// ===============================
// AUDIO
// ===============================
private void PlayMenuMusic()
{
if (musicSource == null || menuMusic == null)
return;
musicSource.clip = menuMusic;
musicSource.loop = true;
if (!musicSource.isPlaying)
musicSource.Play();
}
private void PlayClick()
{
if (sfxSource != null && clickSound != null)
sfxSource.PlayOneShot(clickSound);
}
private void ValidateComponents()
{
if (btnSettings == null)
Debug.LogWarning("Btn_Settings atanmadı!");
}
}