notebook实装功能,galgame继续,一些bug修复

This commit is contained in:
FloatGaming
2026-03-06 02:08:43 +08:00
parent 9011fa022e
commit 1f4077cf21
468 changed files with 50175 additions and 11402 deletions
@@ -5,6 +5,7 @@ using UnityEngine.Serialization;
using UnityEngine.SceneManagement;
using System.Collections;
using UnityEngine.Audio;
using DG.Tweening;
public class settlementController : MonoBehaviour
{
@@ -124,6 +125,10 @@ public class settlementController : MonoBehaviour
[SerializeField] private float introMoveDuration = 0.42f;
[SerializeField] private float introNumberDuration = 0.48f;
[SerializeField] private float introStepGap = 0.06f;
[SerializeField] private float introMvpEnterYOffset = 120f;
[SerializeField] private float introMvpEnterDuration = 0.42f;
[SerializeField] private Ease introMvpEnterEase = Ease.OutCubic;
[SerializeField] private bool introTweenUseUnscaledTime = true;
private int targetPmScore;
private int targetIdolScore;
@@ -139,6 +144,11 @@ public class settlementController : MonoBehaviour
private float targetGreatPercent;
private float targetGoodPercent;
private float targetMissPercent;
private Tween mvpEntryTween;
private bool skipIntroRequested;
private Transform cachedIntroMvpTransform;
private Vector3 cachedIntroMvpBaseLocalPos;
private bool hasCachedIntroMvpBaseLocalPos;
private void Awake()
{
@@ -175,6 +185,16 @@ public class settlementController : MonoBehaviour
}
}
private void Update()
{
if (settlementIntroCoroutine == null) return;
if (!enableDetailedSettlementIntro) return;
if (Input.GetMouseButtonDown(0))
{
SkipSettlementIntroAnimations();
}
}
private void OnDestroy()
{
if (replay_thisGame != null)
@@ -206,6 +226,12 @@ public class settlementController : MonoBehaviour
StopCoroutine(settlementIntroCoroutine);
settlementIntroCoroutine = null;
}
if (mvpEntryTween != null)
{
if (mvpEntryTween.active) mvpEntryTween.Kill(false);
mvpEntryTween = null;
}
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
@@ -420,8 +446,12 @@ public class settlementController : MonoBehaviour
private void StartSettlementIntro()
{
skipIntroRequested = false;
if (!enableDetailedSettlementIntro)
{
if (settlementTeamLoader != null)
settlementTeamLoader.ShowSpawnedCardsInstantly();
StartCanvasFadeIn();
return;
}
@@ -463,7 +493,16 @@ public class settlementController : MonoBehaviour
Transform heroDApicTr = FindDescendantByName(rightRoot != null ? rightRoot : settleRoot, "heroDApic");
Transform heroMaskTr = FindDescendantByName(heroDApicTr != null ? heroDApicTr : settleRoot, "MASK");
Transform lihuiTr = FindDescendantByName(heroMaskTr != null ? heroMaskTr : settleRoot, "lihui");
RectTransform teamDisplayingRt = FindRectByName(rightRoot != null ? rightRoot : settleRoot, "teamDisplaying");
Transform teamDisplayingTr = FindDescendantByName(rightRoot != null ? rightRoot : settleRoot, "teamDisplaying");
RectTransform teamDisplayingRt = teamDisplayingTr as RectTransform;
Transform mvpTr = (mvp_object != null) ? mvp_object.transform : FindDescendantByName(heroDApicTr != null ? heroDApicTr : settleRoot, "mvp");
bool hasAllyCardEntry = settlementTeamLoader != null && settlementTeamLoader.HasSpawnedCards();
bool shouldAnimateMvp = mvpTr != null && mvpTr.gameObject.activeInHierarchy;
Vector3 mvpBaseLocalPos = shouldAnimateMvp ? mvpTr.localPosition : Vector3.zero;
cachedIntroMvpTransform = mvpTr;
hasCachedIntroMvpBaseLocalPos = shouldAnimateMvp;
if (shouldAnimateMvp)
cachedIntroMvpBaseLocalPos = mvpBaseLocalPos;
Transform buttonsRoot = FindDescendantByName(rightRoot != null ? rightRoot : settleRoot, "buttons");
List<Transform> rightButtons = CollectDirectChildren(buttonsRoot);
@@ -496,7 +535,25 @@ public class settlementController : MonoBehaviour
if (rewardRt != null) { SetAnchoredY(rewardRt, -494.3f); SetCanvasAlpha(rewardRt, 0f); }
if (lihuiTr != null) SetCanvasAlpha(lihuiTr, 0f);
if (teamDisplayingRt != null) { SetAnchoredX(teamDisplayingRt, 2265f); SetCanvasAlpha(teamDisplayingRt, 0f); }
if (teamDisplayingRt != null)
{
if (hasAllyCardEntry)
{
SetAnchoredX(teamDisplayingRt, 1490.09f);
SetCanvasAlpha(teamDisplayingRt, 1f);
}
else
{
SetAnchoredX(teamDisplayingRt, 2265f);
SetCanvasAlpha(teamDisplayingRt, 0f);
}
}
if (shouldAnimateMvp)
{
SetCanvasAlpha(mvpTr, 0f);
mvpTr.localPosition = new Vector3(mvpBaseLocalPos.x, mvpBaseLocalPos.y + introMvpEnterYOffset, mvpBaseLocalPos.z);
}
for (int i = 0; i < rightButtons.Count; i++)
{
@@ -566,10 +623,20 @@ public class settlementController : MonoBehaviour
yield return StartCoroutine(PlayStatusGroupIn(goodGroup, goodHitCount_Text, targetGoodCount, goodHitPercent_Text, targetGoodPercent));
yield return StartCoroutine(PlayStatusGroupIn(missGroup, missHitCount_Text, targetMissCount, missHitPercent_Text, targetMissPercent));
// heroDApic/MASK/lihui flash + teamDisplaying move/fade in
// ally cards enter before MASK.
if (hasAllyCardEntry)
yield return StartCoroutine(settlementTeamLoader.PlayAllySlotEntryBeforeMask());
// heroDApic/MASK/lihui flash
if (lihuiTr != null)
yield return StartCoroutine(FlashInTransform(lihuiTr, introFlashCount, introFlashDuration));
if (teamDisplayingRt != null)
// MVP shows after MASK.
if (shouldAnimateMvp)
yield return StartCoroutine(AnimateMvpEntryAfterMask(mvpTr, mvpBaseLocalPos));
// Fallback for scenes still using container slide-in instead of per-slot tween.
if (!hasAllyCardEntry && teamDisplayingRt != null)
yield return StartCoroutine(AnimateAnchoredXAndFade(teamDisplayingRt, 2265f, 1490.09f, introMoveDuration, true));
// right/buttons: each button flashes in sequence
@@ -584,9 +651,125 @@ public class settlementController : MonoBehaviour
settlementCanvasGroup.alpha = 1f;
settlementCanvasGroup.interactable = true;
settlementCanvasGroup.blocksRaycasts = true;
hasCachedIntroMvpBaseLocalPos = false;
cachedIntroMvpTransform = null;
settlementIntroCoroutine = null;
}
private void SkipSettlementIntroAnimations()
{
if (skipIntroRequested) return;
skipIntroRequested = true;
if (settlementIntroCoroutine != null)
{
StopCoroutine(settlementIntroCoroutine);
settlementIntroCoroutine = null;
}
if (mvpEntryTween != null)
{
if (mvpEntryTween.active) mvpEntryTween.Kill(false);
mvpEntryTween = null;
}
if (settlementTeamLoader != null)
settlementTeamLoader.CompleteAllySlotEntryImmediately();
ApplySettlementIntroFinalState();
if (settlementCanvasGroup != null)
{
settlementCanvasGroup.alpha = 1f;
settlementCanvasGroup.interactable = true;
settlementCanvasGroup.blocksRaycasts = true;
}
hasCachedIntroMvpBaseLocalPos = false;
cachedIntroMvpTransform = null;
}
private void ApplySettlementIntroFinalState()
{
Transform settleRoot = settlementCanvasGroup != null ? settlementCanvasGroup.transform : transform;
Transform rightRoot = FindDescendantByName(settleRoot, "right");
Transform leftRoot = FindDescendantByName(settleRoot, "left");
Transform picsRoot = FindDescendantByName(leftRoot != null ? leftRoot : settleRoot, "pics");
RectTransform rightBottomRt = FindRectByName(rightRoot != null ? rightRoot : settleRoot, "right_bottom");
Transform quhuiImageTr = FindDescendantByName(picsRoot != null ? picsRoot : settleRoot, "quhuiImage");
RectTransform scoreBottomRt = FindRectByName(settleRoot, "score_bottom");
RectTransform shenstarsRt = FindRectByName(settleRoot, "shenstars");
RectTransform rewardRt = FindRectByName(settleRoot, "reward");
RectTransform teamDisplayingRt = FindRectByName(rightRoot != null ? rightRoot : settleRoot, "teamDisplaying");
Transform buttonsRoot = FindDescendantByName(rightRoot != null ? rightRoot : settleRoot, "buttons");
List<Transform> rightButtons = CollectDirectChildren(buttonsRoot);
Transform heroDApicTr = FindDescendantByName(rightRoot != null ? rightRoot : settleRoot, "heroDApic");
Transform heroMaskTr = FindDescendantByName(heroDApicTr != null ? heroDApicTr : settleRoot, "MASK");
Transform lihuiTr = FindDescendantByName(heroMaskTr != null ? heroMaskTr : settleRoot, "lihui");
Transform mvpTr = (mvp_object != null) ? mvp_object.transform : FindDescendantByName(heroDApicTr != null ? heroDApicTr : settleRoot, "mvp");
if (rightBottomRt != null) { SetAnchoredX(rightBottomRt, 1677.75f); SetCanvasAlpha(rightBottomRt, 1f); }
if (quhuiImageTr != null) SetCanvasAlpha(quhuiImageTr, 1f);
if (scoreBottomRt != null) { SetAnchoredX(scoreBottomRt, -432.4f); SetCanvasAlpha(scoreBottomRt, 1f); }
if (shenstarsRt != null) { SetAnchoredX(shenstarsRt, -437.5785f); SetCanvasAlpha(shenstarsRt, 1f); }
if (rewardRt != null) { SetAnchoredY(rewardRt, 0f); SetCanvasAlpha(rewardRt, 1f); }
if (lihuiTr != null) SetCanvasAlpha(lihuiTr, 1f);
if (teamDisplayingRt != null) { SetAnchoredX(teamDisplayingRt, 1490.09f); SetCanvasAlpha(teamDisplayingRt, 1f); }
for (int i = 0; i < rightButtons.Count; i++)
{
if (rightButtons[i] != null) SetCanvasAlpha(rightButtons[i], 1f);
}
Transform perfectGroup = FindGroupRoot(perfectHitCount_Text, perfectHitPercent_Text);
Transform greatGroup = FindGroupRoot(greatHitCount_Text, greatHitPercent_Text);
Transform goodGroup = FindGroupRoot(goodHitCount_Text, goodHitPercent_Text);
Transform missGroup = FindGroupRoot(missHitCount_Text, missHitPercent_Text);
if (perfectGroup != null) SetCanvasAlpha(perfectGroup, 1f);
if (greatGroup != null) SetCanvasAlpha(greatGroup, 1f);
if (goodGroup != null) SetCanvasAlpha(goodGroup, 1f);
if (missGroup != null) SetCanvasAlpha(missGroup, 1f);
int noteCountSum = Mathf.Max(1, targetPerfectCount + targetGreatCount + targetGoodCount + targetMissCount);
if (pmScoreSum_Text != null) { pmScoreSum_Text.text = targetPmScore.ToString(); SetCanvasAlpha(pmScoreSum_Text.transform, 1f); }
if (idolScoreSum_Text != null) { idolScoreSum_Text.text = targetIdolScore.ToString(); SetCanvasAlpha(idolScoreSum_Text.transform, 1f); }
if (accuracy_Text != null) { accuracy_Text.text = targetAccuracyPercent.ToString("F3") + "%"; SetCanvasAlpha(accuracy_Text.transform, 1f); }
if (finalScore_Text != null) { finalScore_Text.text = targetTotalScore.ToString(); SetCanvasAlpha(finalScore_Text.transform, 1f); }
if (thisLevel_currentPercentage_Text != null) { thisLevel_currentPercentage_Text.text = targetTotalPercent.ToString("F2") + "%"; SetCanvasAlpha(thisLevel_currentPercentage_Text.transform, 1f); }
if (perfectHitCount_Text != null) { perfectHitCount_Text.text = targetPerfectCount.ToString(); SetCanvasAlpha(perfectHitCount_Text.transform, 1f); }
if (greatHitCount_Text != null) { greatHitCount_Text.text = targetGreatCount.ToString(); SetCanvasAlpha(greatHitCount_Text.transform, 1f); }
if (goodHitCount_Text != null) { goodHitCount_Text.text = targetGoodCount.ToString(); SetCanvasAlpha(goodHitCount_Text.transform, 1f); }
if (missHitCount_Text != null) { missHitCount_Text.text = targetMissCount.ToString(); SetCanvasAlpha(missHitCount_Text.transform, 1f); }
if (perfectHitPercent_Text != null) { perfectHitPercent_Text.text = targetPerfectPercent.ToString("F1") + "%"; SetCanvasAlpha(perfectHitPercent_Text.transform, 1f); }
if (greatHitPercent_Text != null) { greatHitPercent_Text.text = targetGreatPercent.ToString("F1") + "%"; SetCanvasAlpha(greatHitPercent_Text.transform, 1f); }
if (goodHitPercent_Text != null) { goodHitPercent_Text.text = targetGoodPercent.ToString("F1") + "%"; SetCanvasAlpha(goodHitPercent_Text.transform, 1f); }
if (missHitPercent_Text != null) { missHitPercent_Text.text = targetMissPercent.ToString("F1") + "%"; SetCanvasAlpha(missHitPercent_Text.transform, 1f); }
if (thisLevel_progressBar_Image != null)
thisLevel_progressBar_Image.fillAmount = (float)targetTotalScore / Mathf.Max(1, _1000000);
if (perfect_barFill_Image != null) perfect_barFill_Image.fillAmount = (float)targetPerfectCount / noteCountSum;
if (great_barFill_Image != null) great_barFill_Image.fillAmount = (float)targetGreatCount / noteCountSum;
if (good_barFill_Image != null) good_barFill_Image.fillAmount = (float)targetGoodCount / noteCountSum;
if (miss_barFill_Image != null) miss_barFill_Image.fillAmount = (float)targetMissCount / noteCountSum;
if (mvpTr != null && mvpTr.gameObject.activeInHierarchy)
{
Vector3 targetPos;
if (hasCachedIntroMvpBaseLocalPos && cachedIntroMvpTransform == mvpTr)
targetPos = cachedIntroMvpBaseLocalPos;
else
targetPos = new Vector3(mvpTr.localPosition.x, mvpTr.localPosition.y - introMvpEnterYOffset, mvpTr.localPosition.z);
mvpTr.localPosition = targetPos;
SetCanvasAlpha(mvpTr, 1f);
}
}
/// <summary>
/// Documentation text normalized.
/// </summary>
@@ -823,6 +1006,32 @@ public class settlementController : MonoBehaviour
yield return WaitRealtime(introNumberDuration + 0.02f);
}
private IEnumerator AnimateMvpEntryAfterMask(Transform mvpTransform, Vector3 baseLocalPosition)
{
if (mvpTransform == null || !mvpTransform.gameObject.activeInHierarchy)
yield break;
if (mvpEntryTween != null)
{
if (mvpEntryTween.active) mvpEntryTween.Kill(false);
mvpEntryTween = null;
}
CanvasGroup group = GetOrAddCanvasGroup(mvpTransform);
if (group != null) group.alpha = 0f;
mvpTransform.localPosition = new Vector3(baseLocalPosition.x, baseLocalPosition.y + introMvpEnterYOffset, baseLocalPosition.z);
float duration = Mathf.Max(0.01f, introMvpEnterDuration);
Sequence seq = DOTween.Sequence().SetUpdate(introTweenUseUnscaledTime);
seq.Join(mvpTransform.DOLocalMoveY(baseLocalPosition.y, duration).SetEase(introMvpEnterEase).SetUpdate(introTweenUseUnscaledTime));
if (group != null)
seq.Join(group.DOFade(1f, duration).SetEase(introMvpEnterEase).SetUpdate(introTweenUseUnscaledTime));
mvpEntryTween = seq;
yield return seq.WaitForCompletion();
mvpEntryTween = null;
}
private IEnumerator AnimateIntText(Text target, int toValue, float duration)
{
if (target == null) yield break;
@@ -833,6 +1042,7 @@ public class settlementController : MonoBehaviour
while (elapsed < dur)
{
if (skipIntroRequested) break;
elapsed += Time.unscaledDeltaTime;
float t = EaseOutCubic(Mathf.Clamp01(elapsed / dur));
int value = Mathf.RoundToInt(Mathf.Lerp(0f, toValue, t));
@@ -853,6 +1063,7 @@ public class settlementController : MonoBehaviour
while (elapsed < dur)
{
if (skipIntroRequested) break;
elapsed += Time.unscaledDeltaTime;
float t = EaseOutCubic(Mathf.Clamp01(elapsed / dur));
float value = Mathf.Lerp(0f, toValue, t);
@@ -874,6 +1085,7 @@ public class settlementController : MonoBehaviour
float dur = Mathf.Max(0.01f, duration);
while (elapsed < dur)
{
if (skipIntroRequested) break;
elapsed += Time.unscaledDeltaTime;
float t = EaseOutCubic(Mathf.Clamp01(elapsed / dur));
SetAnchoredX(rt, Mathf.LerpUnclamped(fromX, toX, t));
@@ -896,6 +1108,7 @@ public class settlementController : MonoBehaviour
float dur = Mathf.Max(0.01f, duration);
while (elapsed < dur)
{
if (skipIntroRequested) break;
elapsed += Time.unscaledDeltaTime;
float t = EaseOutCubic(Mathf.Clamp01(elapsed / dur));
SetAnchoredY(rt, Mathf.LerpUnclamped(fromY, toY, t));
@@ -920,6 +1133,7 @@ public class settlementController : MonoBehaviour
float elapsed = 0f;
while (elapsed < total)
{
if (skipIntroRequested) break;
elapsed += Time.unscaledDeltaTime;
float p = Mathf.Clamp01(elapsed / total);
@@ -990,12 +1204,13 @@ public class settlementController : MonoBehaviour
return 1f - inv * inv * inv;
}
private static IEnumerator WaitRealtime(float duration)
private IEnumerator WaitRealtime(float duration)
{
float elapsed = 0f;
float dur = Mathf.Max(0f, duration);
while (elapsed < dur)
{
if (skipIntroRequested) yield break;
elapsed += Time.unscaledDeltaTime;
yield return null;
}
@@ -1347,4 +1562,3 @@ public class settlementController : MonoBehaviour
}
}
}