超大量的更新 修复很多问题,gameplay特效初步
This commit is contained in:
@@ -105,8 +105,8 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
StartCoroutine(AnimateSlots());
|
||||
StartCoroutine(AnimateSmallCards());
|
||||
|
||||
// skills flash after bottom panel enters
|
||||
float delay = panelEnterTime + panelStagger + 0.05f;
|
||||
// Defer skills flash to avoid stacking with slot enter animation work.
|
||||
float delay = panelEnterTime + panelStagger + EstimateSlotEnterWindow() + 0.05f;
|
||||
DOVirtual.DelayedCall(delay, () => PlaySkillsFlashInternal(null)).SetUpdate(useUnscaled);
|
||||
}
|
||||
|
||||
@@ -167,9 +167,15 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
|
||||
IEnumerator AnimateSlots()
|
||||
{
|
||||
// Some slots can be instantiated/enabled a couple frames after the panel is shown.
|
||||
// Wait a bit for the full slot set so we don't miss animating the last one.
|
||||
int expectedCount = cachedTeam != null && cachedTeam.Length > 0 ? cachedTeam.Length : 5;
|
||||
if (newTeamSelector.Instance != null && newTeamSelector.Instance.slotCount > 0)
|
||||
expectedCount = newTeamSelector.Instance.slotCount;
|
||||
|
||||
List<RectTransform> slotRects = GetSlotRects();
|
||||
int tries = 0;
|
||||
while ((slotRects == null || slotRects.Count == 0) && tries < 10)
|
||||
while ((slotRects == null || slotRects.Count < expectedCount) && tries < 20)
|
||||
{
|
||||
tries++;
|
||||
yield return null;
|
||||
@@ -182,22 +188,26 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
if (leftSlotsContainer != null)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(leftSlotsContainer);
|
||||
|
||||
slotRects.Sort((a, b) => a.position.y.CompareTo(b.position.y));
|
||||
slotRects.Sort((a, b) => a.GetSiblingIndex().CompareTo(b.GetSiblingIndex()));
|
||||
|
||||
if (layoutEnabled) layout.enabled = false;
|
||||
|
||||
var basePosBySlot = new Dictionary<RectTransform, Vector2>(slotRects.Count);
|
||||
for (int i = 0; i < slotRects.Count; i++)
|
||||
{
|
||||
RectTransform rt = slotRects[i];
|
||||
if (rt == null) continue;
|
||||
Vector2 basePos = rt.anchoredPosition;
|
||||
basePosBySlot[rt] = basePos;
|
||||
rt.DOKill();
|
||||
rt.anchoredPosition = basePos + new Vector2(0f, -slotEnterOffset);
|
||||
rt.DOAnchorPos(basePos, slotEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(i * slotStagger)
|
||||
.SetUpdate(useUnscaled)
|
||||
.SetLink(rt.gameObject, LinkBehaviour.KillOnDisable);
|
||||
// If a slot gets disabled/enabled during layout/UI updates, don't kill the tween
|
||||
// (killing it can leave the slot stuck at the start offset).
|
||||
.SetLink(rt.gameObject, LinkBehaviour.PauseOnDisablePlayOnEnable);
|
||||
}
|
||||
|
||||
float total = slotEnterTime + slotStagger * Mathf.Max(0, slotRects.Count - 1);
|
||||
@@ -208,6 +218,22 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Failsafe: if any slot tween was interrupted (e.g. killed by disable), snap it back.
|
||||
foreach (var kvp in basePosBySlot)
|
||||
{
|
||||
RectTransform rt = kvp.Key;
|
||||
if (rt == null) continue;
|
||||
Vector2 basePos = kvp.Value;
|
||||
if (Vector2.Distance(rt.anchoredPosition, basePos) > 0.5f)
|
||||
{
|
||||
rt.DOKill();
|
||||
rt.DOAnchorPos(basePos, 0.12f)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetUpdate(useUnscaled)
|
||||
.SetLink(rt.gameObject, LinkBehaviour.PauseOnDisablePlayOnEnable);
|
||||
}
|
||||
}
|
||||
|
||||
if (layoutEnabled) layout.enabled = true;
|
||||
if (leftSlotsContainer != null)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(leftSlotsContainer);
|
||||
@@ -217,8 +243,8 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
{
|
||||
if (smallCardsContainer == null)
|
||||
EnsureRefs();
|
||||
// wait for top panel to slide in
|
||||
float t = panelEnterTime + 0.02f;
|
||||
// Start a bit later to avoid overlapping slot enter bursts.
|
||||
float t = panelEnterTime + Mathf.Min(0.2f, EstimateSlotEnterWindow() * 0.4f);
|
||||
while (t > 0f)
|
||||
{
|
||||
t -= useUnscaled ? Time.unscaledDeltaTime : Time.deltaTime;
|
||||
@@ -481,6 +507,14 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
Graphic g = rt.GetComponent<Graphic>();
|
||||
if (g != null) g.raycastTarget = true;
|
||||
}
|
||||
|
||||
float EstimateSlotEnterWindow()
|
||||
{
|
||||
int count = 5;
|
||||
if (newTeamSelector.Instance != null && newTeamSelector.Instance.slotCount > 0)
|
||||
count = newTeamSelector.Instance.slotCount;
|
||||
return slotEnterTime + Mathf.Max(0, count - 1) * slotStagger;
|
||||
}
|
||||
}
|
||||
|
||||
static class TeamSelectorAnimBootstrap
|
||||
|
||||
Reference in New Issue
Block a user