改动与优化
This commit is contained in:
@@ -183,31 +183,46 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
}
|
||||
if (slotRects == null || slotRects.Count == 0) yield break;
|
||||
|
||||
LayoutGroup layout = leftSlotsContainer != null ? leftSlotsContainer.GetComponent<LayoutGroup>() : null;
|
||||
bool layoutEnabled = layout != null && layout.enabled;
|
||||
if (leftSlotsContainer != null)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(leftSlotsContainer);
|
||||
|
||||
slotRects.Sort((a, b) => a.GetSiblingIndex().CompareTo(b.GetSiblingIndex()));
|
||||
|
||||
if (layoutEnabled) layout.enabled = false;
|
||||
|
||||
var basePosBySlot = new Dictionary<RectTransform, Vector2>(slotRects.Count);
|
||||
var canMoveBySlot = new Dictionary<RectTransform, bool>(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;
|
||||
bool canMove = !UI_OrderedEntryAnimator.IsLayoutSensitive(rt);
|
||||
canMoveBySlot[rt] = canMove;
|
||||
rt.DOKill();
|
||||
rt.anchoredPosition = basePos + new Vector2(0f, -slotEnterOffset);
|
||||
rt.DOAnchorPos(basePos, slotEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(i * slotStagger)
|
||||
.SetUpdate(useUnscaled)
|
||||
// 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);
|
||||
|
||||
CanvasGroup cg = EnsureCanvasGroup(rt);
|
||||
if (cg != null)
|
||||
{
|
||||
cg.DOKill();
|
||||
cg.alpha = 0f;
|
||||
cg.DOFade(1f, slotEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(i * slotStagger)
|
||||
.SetUpdate(useUnscaled)
|
||||
.SetLink(rt.gameObject, LinkBehaviour.PauseOnDisablePlayOnEnable);
|
||||
}
|
||||
|
||||
if (canMove)
|
||||
{
|
||||
rt.anchoredPosition = basePos + new Vector2(0f, -slotEnterOffset);
|
||||
rt.DOAnchorPos(basePos, slotEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(i * slotStagger)
|
||||
.SetUpdate(useUnscaled)
|
||||
// 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);
|
||||
@@ -223,6 +238,7 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
{
|
||||
RectTransform rt = kvp.Key;
|
||||
if (rt == null) continue;
|
||||
if (!canMoveBySlot.TryGetValue(rt, out bool canMove) || !canMove) continue;
|
||||
Vector2 basePos = kvp.Value;
|
||||
if (Vector2.Distance(rt.anchoredPosition, basePos) > 0.5f)
|
||||
{
|
||||
@@ -234,7 +250,6 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
if (layoutEnabled) layout.enabled = true;
|
||||
if (leftSlotsContainer != null)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(leftSlotsContainer);
|
||||
}
|
||||
@@ -281,6 +296,20 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
void AnimatePanel(RectTransform panel, float offsetX, float delay)
|
||||
{
|
||||
if (panel == null) return;
|
||||
bool canMove = !UI_OrderedEntryAnimator.IsLayoutSensitive(panel);
|
||||
CanvasGroup cg = EnsureCanvasGroup(panel);
|
||||
if (cg != null)
|
||||
{
|
||||
cg.DOKill();
|
||||
cg.alpha = 0f;
|
||||
cg.DOFade(1f, panelEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(delay)
|
||||
.SetUpdate(useUnscaled)
|
||||
.SetLink(cg.gameObject, LinkBehaviour.KillOnDisable);
|
||||
}
|
||||
if (!canMove) return;
|
||||
|
||||
Vector2 basePos = panel.anchoredPosition;
|
||||
panel.DOKill();
|
||||
panel.anchoredPosition = basePos + new Vector2(offsetX, 0f);
|
||||
@@ -294,6 +323,19 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
void AnimateConfirm(RectTransform button)
|
||||
{
|
||||
if (button == null) return;
|
||||
bool canMove = !UI_OrderedEntryAnimator.IsLayoutSensitive(button);
|
||||
CanvasGroup cg = EnsureCanvasGroup(button);
|
||||
if (cg != null)
|
||||
{
|
||||
cg.DOKill();
|
||||
cg.alpha = 0f;
|
||||
cg.DOFade(1f, confirmEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetUpdate(useUnscaled)
|
||||
.SetLink(cg.gameObject, LinkBehaviour.KillOnDisable);
|
||||
}
|
||||
if (!canMove) return;
|
||||
|
||||
Vector2 basePos = button.anchoredPosition;
|
||||
button.DOKill();
|
||||
button.anchoredPosition = basePos + new Vector2(0f, -confirmEnterOffset);
|
||||
|
||||
@@ -115,6 +115,7 @@ public class newTeamSelector : MonoBehaviour
|
||||
var go = Instantiate(slotPrefab, container);
|
||||
go.transform.SetParent(container, false);
|
||||
go.name = $"heroSlot_{i}";
|
||||
UI_OrderedEntryAnimator.PlayFadeOnly(go, i, 0.16f, 0.012f, true);
|
||||
|
||||
var slotComp = go.GetComponent<slots_heroSlots>();
|
||||
if (slotComp == null)
|
||||
|
||||
@@ -103,8 +103,11 @@ public class loadSettlementTeamPrefab : MonoBehaviour
|
||||
var rectTransform = go.GetComponent<RectTransform>();
|
||||
if (rectTransform != null)
|
||||
{
|
||||
rectTransform.anchoredPosition = Vector2.zero;
|
||||
rectTransform.sizeDelta = Vector2.zero;
|
||||
if (!UI_OrderedEntryAnimator.IsLayoutSensitive(rectTransform))
|
||||
{
|
||||
rectTransform.anchoredPosition = Vector2.zero;
|
||||
rectTransform.sizeDelta = Vector2.zero;
|
||||
}
|
||||
spawnedCardRoots.Add(rectTransform);
|
||||
}
|
||||
|
||||
@@ -296,10 +299,15 @@ public class loadSettlementTeamPrefab : MonoBehaviour
|
||||
CanvasGroup group = GetOrAddCanvasGroup(rt.transform);
|
||||
if (group != null) group.alpha = 0f;
|
||||
|
||||
rt.anchoredPosition = new Vector2(basePos.x + offsetX, basePos.y);
|
||||
bool canMove = !UI_OrderedEntryAnimator.IsLayoutSensitive(rt);
|
||||
if (canMove)
|
||||
{
|
||||
rt.anchoredPosition = new Vector2(basePos.x + offsetX, basePos.y);
|
||||
}
|
||||
|
||||
float startAt = i * stagger; // top -> bottom (sibling order)
|
||||
allySlotEntrySequence.Insert(startAt, rt.DOAnchorPos(basePos, duration).SetEase(allySlotEntryEase).SetUpdate(allySlotEntryUseUnscaledTime));
|
||||
if (canMove)
|
||||
allySlotEntrySequence.Insert(startAt, rt.DOAnchorPos(basePos, duration).SetEase(allySlotEntryEase).SetUpdate(allySlotEntryUseUnscaledTime));
|
||||
if (group != null)
|
||||
allySlotEntrySequence.Insert(startAt, group.DOFade(1f, duration).SetEase(allySlotEntryEase).SetUpdate(allySlotEntryUseUnscaledTime));
|
||||
}
|
||||
@@ -336,7 +344,10 @@ public class loadSettlementTeamPrefab : MonoBehaviour
|
||||
if (rt == null) continue;
|
||||
|
||||
if (i < spawnedCardBasePositions.Count)
|
||||
rt.anchoredPosition = spawnedCardBasePositions[i];
|
||||
{
|
||||
if (!UI_OrderedEntryAnimator.IsLayoutSensitive(rt))
|
||||
rt.anchoredPosition = spawnedCardBasePositions[i];
|
||||
}
|
||||
SetCanvasAlpha(rt.transform, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,9 @@ public class teamSettingPanel : MonoBehaviour
|
||||
if (tcdi != null)
|
||||
{
|
||||
if (t.charcterImg != null) { t.charcterImg.sprite = tcdi.CharacterTeamSprite; t.charcterImg.color=new Color(t.charcterImg.color.r,t.charcterImg.color.g,t.charcterImg.color.b,1f); }
|
||||
if (t.levelIcon != null) { t.levelIcon.sprite = getLevelSprite(currentTeam[i].currentBoundaryLevel); t.levelIcon.color=new Color(t.levelIcon.color.r,t.levelIcon.color.g,t.levelIcon.color.b,1f); }
|
||||
string boundaryLevel = ResolveBoundaryLevel(t.characterID, currentTeam[i].currentBoundaryLevel);
|
||||
currentTeam[i].currentBoundaryLevel = boundaryLevel;
|
||||
if (t.levelIcon != null) { t.levelIcon.sprite = getLevelSprite(boundaryLevel); t.levelIcon.color=new Color(t.levelIcon.color.r,t.levelIcon.color.g,t.levelIcon.color.b,1f); }
|
||||
if (t.skillName != null) t.skillName.text = tcdi.CharacterSkillName ?? string.Empty;
|
||||
}
|
||||
else
|
||||
@@ -230,6 +232,7 @@ public class teamSettingPanel : MonoBehaviour
|
||||
teamManager.currentSelectedCharacterCard = null;
|
||||
List<CharacterView> currentTeam = teamManager.getCurrentSelectedTeam().teamIdList;
|
||||
List<CharacterView> selectAbleCharacters = teamManager.SelectableCharacterList;
|
||||
int visibleIndex = 0;
|
||||
foreach (CharacterView c in selectAbleCharacters) //id and level
|
||||
{
|
||||
if (!IsCharacterUnlocked(c != null ? c.characterId : 0))
|
||||
@@ -238,14 +241,16 @@ public class teamSettingPanel : MonoBehaviour
|
||||
}
|
||||
|
||||
GameObject characterObj = Instantiate(teamCharacterPrefab, teamCharacterViewContent.transform);
|
||||
UI_OrderedEntryAnimator.PlayFadeOnly(characterObj, visibleIndex, 0.16f, 0.012f, true);
|
||||
visibleIndex++;
|
||||
CharacterCardView ccv = characterObj.GetComponent<CharacterCardView>();
|
||||
TeamCharacterDataInfo tcdi = getCharacterViewInfo(c.characterId);
|
||||
if (ccv != null&& tcdi!=null)
|
||||
{
|
||||
ccv.characterID = tcdi.CharacterID;
|
||||
ccv.currentBoundaryLevel= c.currentBoundaryLevel;
|
||||
ccv.currentBoundaryLevel= ResolveBoundaryLevel(c.characterId, c.currentBoundaryLevel);
|
||||
ccv.characterImage.sprite =tcdi.CharacterCardSprite;
|
||||
ccv.levelIcon.sprite = getLevelSprite(c.currentBoundaryLevel);
|
||||
ccv.levelIcon.sprite = getLevelSprite(ccv.currentBoundaryLevel);
|
||||
ccv.occupationIcon.sprite = tcdi.CharacterRoleSprite;
|
||||
}
|
||||
|
||||
@@ -277,6 +282,26 @@ public class teamSettingPanel : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
private string ResolveBoundaryLevel(int characterID, string fallbackLevel)
|
||||
{
|
||||
if (characterID <= 0)
|
||||
{
|
||||
return fallbackLevel;
|
||||
}
|
||||
|
||||
AllyHero_SO[] heroes = RuntimeResourcesCache.LoadAllAllyHeroes();
|
||||
for (int i = 0; i < heroes.Length; i++)
|
||||
{
|
||||
AllyHero_SO hero = heroes[i];
|
||||
if (hero != null && hero.ally_heroID == characterID)
|
||||
{
|
||||
return AllyHeroLevelRuntimeResolver.GetDisplayRatingKey(hero);
|
||||
}
|
||||
}
|
||||
|
||||
return fallbackLevel;
|
||||
}
|
||||
|
||||
private bool checkExistenceStatus(List<CharacterView> currentTeam,int characterID)
|
||||
{
|
||||
foreach (CharacterView c in currentTeam)
|
||||
|
||||
Reference in New Issue
Block a user