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:
commit
ecb1c9edea
1455 changed files with 933295 additions and 0 deletions
93
Assets/Scripts/Leaderboard.cs
Normal file
93
Assets/Scripts/Leaderboard.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Leaderboard : MonoBehaviour
|
||||
{
|
||||
[Header("━━━ UI SLOTS (10 satır) ━━━━━━━━━━━━━━━")]
|
||||
public TMP_Text[] rows;
|
||||
|
||||
[Header("━━━ BUTONLAR ━━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public Button mainMenuButton;
|
||||
|
||||
[Header("━━━ MOD SKOR KEYLERİ ━━━━━━━━━━━━━━━━━━")]
|
||||
public string[] modScoreKeys; // Inspector'dan 12 key gir
|
||||
|
||||
// ─── Sabitler ────────────────────────────────
|
||||
private readonly string[] botNames =
|
||||
{
|
||||
"ShadowWolf", "CrystalMind", "NightHunter",
|
||||
"BlueVortex", "IronSoul", "PixelGhost",
|
||||
"SilverClaw", "MegaCore", "NeonBlade", "DarkNova"
|
||||
};
|
||||
|
||||
class LBEntry
|
||||
{
|
||||
public string name;
|
||||
public int score;
|
||||
public LBEntry(string n, int s) { name = n; score = s; }
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
void Start()
|
||||
{
|
||||
GenerateLeaderboard();
|
||||
|
||||
if (mainMenuButton != null)
|
||||
mainMenuButton.onClick.AddListener(() =>
|
||||
SceneManager.LoadScene("Anamen"));
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
void GenerateLeaderboard()
|
||||
{
|
||||
List<LBEntry> list = new List<LBEntry>();
|
||||
|
||||
// ─── Bot skorları ─────────────────────────
|
||||
int botLimit = Mathf.Min(rows.Length - 1, botNames.Length);
|
||||
for (int i = 0; i < botLimit; i++)
|
||||
list.Add(new LBEntry(botNames[i], Random.Range(3000, 12000)));
|
||||
|
||||
// ─── Tüm modların toplamı ─────────────────
|
||||
int totalScore = 0;
|
||||
if (modScoreKeys != null)
|
||||
{
|
||||
foreach (string key in modScoreKeys)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
totalScore += PlayerPrefs.GetInt(key + "_High", 0);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Yüksek skor güncelle ─────────────────
|
||||
int savedTotal = PlayerPrefs.GetInt("TotalHighScore", 0);
|
||||
if (totalScore > savedTotal)
|
||||
{
|
||||
savedTotal = totalScore;
|
||||
PlayerPrefs.SetInt("TotalHighScore", savedTotal);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
list.Add(new LBEntry("YOU", savedTotal));
|
||||
|
||||
// ─── Sırala ───────────────────────────────
|
||||
list.Sort((a, b) => b.score.CompareTo(a.score));
|
||||
|
||||
// ─── Ekrana yaz ───────────────────────────
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
{
|
||||
if (i < list.Count)
|
||||
{
|
||||
rows[i].text = list[i].name == "YOU"
|
||||
? $"<color=#00FF00>{i + 1}. {list[i].name} - {list[i].score}</color>"
|
||||
: $"{i + 1}. {list[i].name} - {list[i].score}";
|
||||
}
|
||||
else
|
||||
{
|
||||
rows[i].text = $"{i + 1}. ---";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue