超大量的更新 修复很多问题,gameplay特效初步

This commit is contained in:
FloatGaming
2026-02-14 23:46:20 +08:00
parent ef8eb67259
commit 3a7a0b4669
360 changed files with 85670 additions and 4144 deletions
+69 -13
View File
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
@@ -7,13 +7,13 @@ public class newTeamSelector : MonoBehaviour
{
public static newTeamSelector Instance { get; private set; }
[Header("ȼͼƬCBAS")]
[Header("Inspector")]
public Sprite levelIcon_sprite_C;
public Sprite levelIcon_sprite_B;
public Sprite levelIcon_sprite_A;
public Sprite levelIcon_sprite_S;
[Header("ѡĶ")]
[Header("Inspector")]
public int selected_heroSlot01_heroID;
public int selected_heroSlot02_heroID;
public int selected_heroSlot03_heroID;
@@ -34,14 +34,20 @@ public class newTeamSelector : MonoBehaviour
[Tooltip("If true, create slots automatically on Start")]
public bool instantiateOnStart = true;
[Tooltip("Delay skill list rebuild until after slot enter animation to reduce hitching.")]
public float delayedSkillRefreshSeconds = 0.75f;
private readonly List<slots_heroSlots> createdSlots = new List<slots_heroSlots>();
private static AllyHero_SO[] cachedHeroes;
private static Dictionary<int, AllyHero_SO> cachedHeroesById;
private Coroutine refreshSkillsRoutine;
void Awake()
{
if (Instance == null)
{
Instance = this;
EnsureHeroCache();
}
else
{
@@ -53,11 +59,17 @@ public class newTeamSelector : MonoBehaviour
{
if (instantiateOnStart)
CreateSlots();
LoadSelectedHeroes();
StartCoroutine(LoadSelectedHeroesNextFrame());
}
void Update() { }
private IEnumerator LoadSelectedHeroesNextFrame()
{
yield return null;
LoadSelectedHeroes();
}
public void CreateSlots()
{
if (slotPrefab == null || container == null)
@@ -175,7 +187,7 @@ public class newTeamSelector : MonoBehaviour
PlayerPrefs.SetInt("selected_heroSlot05_heroID", selected_heroSlot05_heroID);
PlayerPrefs.Save();
Debug.Log("ѱ浱ǰPlayerPrefs");
Debug.Log("已保存当前英雄到 PlayerPrefs");
}
public void LoadSelectedHeroes()
@@ -205,14 +217,15 @@ public class newTeamSelector : MonoBehaviour
AllyHero_SO hero = FindHeroById(slot.heroSlot_heroID);
if (hero != null)
{
slot.SetSlot(slot.heroSlot_heroID, hero.ally_heroName, hero.ally_heroPoster);
// Delay expensive skill UI refresh to avoid slot-enter stutters.
slot.SetSlot(slot.heroSlot_heroID, hero.ally_heroName, hero.ally_heroPoster, false);
}
}
else
{
// Clear slot logic
slot.heroSlot_heroID = 0;
if (slot.heroSlot_heroName != null) slot.heroSlot_heroName.text = "";
if (slot.heroSlot_heroName != null) slot.heroSlot_heroName.text = "未选择";
if (slot.heroImage != null)
{
// revert to default sprite if provided, otherwise keep transparent
@@ -233,18 +246,61 @@ public class newTeamSelector : MonoBehaviour
slot.heroLevelImage.color = new Color(1f, 1f, 1f, 0f);
}
// Update skill list
slot.UpdateSkillList();
slot.UpdateSkillList(false);
}
}
if (refreshSkillsRoutine != null)
StopCoroutine(refreshSkillsRoutine);
refreshSkillsRoutine = StartCoroutine(RefreshSkillsGradually());
}
private IEnumerator RefreshSkillsGradually()
{
if (delayedSkillRefreshSeconds > 0f)
yield return new WaitForSecondsRealtime(delayedSkillRefreshSeconds);
else
yield return null;
for (int i = 0; i < createdSlots.Count; i++)
{
var slot = createdSlots[i];
if (slot == null) continue;
if (slot.heroSlot_heroID != 0)
{
slot.UpdateSkillList(false);
// Spread UI instantiation across frames to reduce hitch.
yield return null;
}
}
TeamSelectorAnimController.PlaySkillsFlash(null);
refreshSkillsRoutine = null;
}
private AllyHero_SO FindHeroById(int id)
{
var arr = Resources.LoadAll<AllyHero_SO>("");
foreach (var a in arr)
{
if (a != null && a.ally_heroID == id) return a;
}
EnsureHeroCache();
if (cachedHeroesById != null && cachedHeroesById.TryGetValue(id, out var hero))
return hero;
return null;
}
private static void EnsureHeroCache()
{
if (cachedHeroesById != null && cachedHeroesById.Count > 0)
return;
if (cachedHeroes == null || cachedHeroes.Length == 0)
cachedHeroes = Resources.LoadAll<AllyHero_SO>("");
cachedHeroesById = new Dictionary<int, AllyHero_SO>();
if (cachedHeroes == null) return;
for (int i = 0; i < cachedHeroes.Length; i++)
{
AllyHero_SO hero = cachedHeroes[i];
if (hero == null) continue;
cachedHeroesById[hero.ally_heroID] = hero;
}
}
}