修了不少东西

This commit is contained in:
FloatGaming
2026-07-16 23:04:59 +08:00
parent 29972d0705
commit 73fe474cc6
134 changed files with 7673 additions and 741 deletions
@@ -0,0 +1,51 @@
using UnityEngine;
public static class TeamSelectionDefaults
{
public const int SlotCount = 5;
private static readonly int[] DefaultHeroIds = { 30201, 30202, 30203, 30204, 30205 };
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Bootstrap()
{
EnsureDefaultTeamIfMissing();
}
public static void EnsureDefaultTeamIfMissing()
{
for (int slot = 1; slot <= SlotCount; slot++)
{
if (PlayerPrefs.HasKey(GetHeroSlotKey(slot)))
{
return;
}
}
for (int slot = 1; slot <= SlotCount; slot++)
{
PlayerPrefs.SetInt(GetHeroSlotKey(slot), GetDefaultHeroId(slot));
}
PlayerPrefs.SetInt("SelectedMainHeroID", DefaultHeroIds[0]);
PlayerPrefs.Save();
}
public static int ReadHeroId(int slot)
{
EnsureDefaultTeamIfMissing();
return Mathf.Max(0, PlayerPrefs.GetInt(GetHeroSlotKey(slot), GetDefaultHeroId(slot)));
}
public static int GetDefaultHeroId(int slot)
{
int index = Mathf.Clamp(slot - 1, 0, DefaultHeroIds.Length - 1);
return DefaultHeroIds[index];
}
private static string GetHeroSlotKey(int slot)
{
int safeSlot = Mathf.Clamp(slot, 1, SlotCount);
return $"selected_heroSlot0{safeSlot}_heroID";
}
}