hold音符补丁 备份

This commit is contained in:
FloatGaming
2026-03-03 14:07:39 +08:00
parent b8704629a3
commit 9011fa022e
36 changed files with 2721 additions and 256 deletions
+75 -17
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -153,6 +153,22 @@ public class AllyCombatant : MonoBehaviour, ICombatant
public AppliedEffect(EffectType t, float a) { effectType = t; amount = a; }
}
private List<(iNumberPrefabController.InstantNumberType type, int val)> _queuedPopups = new List<(iNumberPrefabController.InstantNumberType, int)>();
public void QueueDamagePopup(iNumberPrefabController.InstantNumberType type, int val)
{
_queuedPopups.Add((type, val));
}
public void TriggerQueuedPopups()
{
foreach (var p in _queuedPopups)
{
iNumberPrefabController.SpawnForAllyStatic(slotIndex, p.type, p.val);
}
_queuedPopups.Clear();
}
private void Awake()
{
// ensure GameObject name matches pattern so EffectSystem can find it
@@ -236,10 +252,9 @@ public class AllyCombatant : MonoBehaviour, ICombatant
if (allowOverwriteFromSO)
InitializeStatsFromData();
// Documentation text normalized.
// Documentation text normalized.
isDead = false;
currentHP = Mathf.Max(1, maxHP);
// Initialize status
isDead = (maxHP <= 0);
currentHP = maxHP;
currentMana = 0;
UpdateUIImmediate();
@@ -271,7 +286,8 @@ public class AllyCombatant : MonoBehaviour, ICombatant
if (allowOverwriteFromSO)
{
InitializeStatsFromData();
currentHP = Mathf.Max(1, maxHP);
currentHP = maxHP;
isDead = (maxHP <= 0);
UpdateUIImmediate();
}
@@ -1132,6 +1148,11 @@ public class AllyCombatant : MonoBehaviour, ICombatant
// Public setters that update UI and optionally animate fade bars
public void SetCurrentHP(int hp, bool animateFade = true)
{
SetCurrentHP(hp, animateFade, false);
}
public void SetCurrentHP(int hp, bool animateFade, bool skipPopup)
{
if (isDead) return; // dead characters cannot change HP
int old = currentHP;
@@ -1141,7 +1162,7 @@ public class AllyCombatant : MonoBehaviour, ICombatant
// Trigger HP changed events
int delta = currentHP - old;
if (delta != 0)
if (delta != 0 && !skipPopup)
{
if (iNumberPrefabController.Instance != null)
{
@@ -1180,16 +1201,26 @@ public class AllyCombatant : MonoBehaviour, ICombatant
// Internal HP modifier that does NOT apply heal multipliers (used by ReceiveHeal to avoid double rounding).
private void ModifyHPRaw(int delta, bool animateFade = true)
{
ModifyHPRaw(delta, animateFade, false);
}
private void ModifyHPRaw(int delta, bool animateFade, bool skipPopup)
{
if (isDead && delta > 0)
{
// cannot heal a dead unit
return;
}
SetCurrentHP(currentHP + delta, animateFade);
SetCurrentHP(currentHP + delta, animateFade, skipPopup);
}
public void ModifyHP(int delta, bool animateFade = true)
{
ModifyHP(delta, animateFade, false);
}
public void ModifyHP(int delta, bool animateFade, bool skipPopup)
{
if (isDead && delta > 0)
{
@@ -1207,7 +1238,7 @@ public class AllyCombatant : MonoBehaviour, ICombatant
delta = Mathf.CeilToInt(delta * mult);
}
}
ModifyHPRaw(delta, animateFade);
ModifyHPRaw(delta, animateFade, skipPopup);
}
public void SetMaxHP(int newMax, bool keepCurrentRatio = true)
@@ -1528,12 +1559,12 @@ public class AllyCombatant : MonoBehaviour, ICombatant
fadeManaImage.fillAmount = targetFill;
}
public void ReceiveDamage(float amount, GameObject source)
public void ReceiveDamage(float amount, GameObject source, bool deferPopup = false)
{
ReceiveDamageInternal(amount, source, true);
ReceiveDamageInternal(amount, source, true, deferPopup);
}
private void ReceiveDamageInternal(float amount, GameObject source, bool allowRedirect)
private void ReceiveDamageInternal(float amount, GameObject source, bool allowRedirect, bool deferPopup)
{
if (IsDead) return; // dead characters cannot be hit
if (allowRedirect && TryGetGlobalRedirectTargetForReceiverDamage(this, out var redirector))
@@ -1541,7 +1572,7 @@ public class AllyCombatant : MonoBehaviour, ICombatant
ConsumeGlobalRedirect(redirector);
if (redirector != null && redirector != this)
{
redirector.ReceiveDamageInternal(amount, source, false);
redirector.ReceiveDamageInternal(amount, source, false, deferPopup);
return;
}
// If redirector is self or invalid, consume redirect and continue to take damage normally.
@@ -1555,22 +1586,49 @@ public class AllyCombatant : MonoBehaviour, ICombatant
if (adj != null && adj != this)
{
ConsumeSelfDamageRedirectToAdjacent();
adj.ReceiveDamageInternal(amount, source, false);
adj.ReceiveDamageInternal(amount, source, false, deferPopup);
return;
}
}
int oldHP = currentHP;
float effective = amount * (1f - damageResistance);
int delta = Mathf.CeilToInt(effective);
ModifyHP(-delta, true);
ModifyHP(-delta, true, true);
int actual = oldHP - currentHP;
if (actual != 0)
{
if (deferPopup)
{
QueueDamagePopup(iNumberPrefabController.InstantNumberType.Damage, -actual);
}
else
{
iNumberPrefabController.SpawnForAllyStatic(slotIndex, iNumberPrefabController.InstantNumberType.Damage, -actual);
}
}
}
public void ReceiveHeal(float amount, GameObject source)
public void ReceiveHeal(float amount, GameObject source, bool deferPopup = false)
{
if (IsDead) return; // dead characters cannot be healed
int oldHP = currentHP;
float mult = GetTotalHealReceivedMultiplier();
int delta = Mathf.CeilToInt(amount * mult);
ModifyHPRaw(delta, true);
ModifyHP(delta, true, true);
int actual = currentHP - oldHP;
if (actual != 0)
{
if (deferPopup)
{
QueueDamagePopup(iNumberPrefabController.InstantNumberType.Heal, actual);
}
else
{
iNumberPrefabController.SpawnForAllyStatic(slotIndex, iNumberPrefabController.InstantNumberType.Heal, actual);
}
}
}
public void ApplyBuff(Buff buff, GameObject source)
+2 -2
View File
@@ -52,8 +52,8 @@ public enum EffectType
public interface ICombatant
{
void ReceiveDamage(float amount, GameObject source);
void ReceiveHeal(float amount, GameObject source);
void ReceiveDamage(float amount, GameObject source, bool deferPopup = false);
void ReceiveHeal(float amount, GameObject source, bool deferPopup = false);
void ApplyBuff(Buff buff, GameObject source);
void RemoveBuff(string buffId);
}
+28 -141
View File
@@ -23,7 +23,6 @@ public class EffectSystem : MonoBehaviour
private readonly List<GameObject> _cachedEnemies = new List<GameObject>(8);
private readonly HashSet<int> _awaitingHitFxTargets = new HashSet<int>();
private readonly Dictionary<int, int> _pendingDamagePopupByTargetId = new Dictionary<int, int>(64);
private void Awake()
{
@@ -322,12 +321,6 @@ public class EffectSystem : MonoBehaviour
{
int before = ally.currentScore;
ally.AddScoreDirect(Mathf.CeilToInt(amount));
int delta = ally.currentScore - before;
if (delta != 0)
{
var type = delta > 0 ? iNumberPrefabController.InstantNumberType.IscorePlus : iNumberPrefabController.InstantNumberType.IscoreMinus;
iNumberPrefabController.SpawnForAllyStatic(ally.slotIndex, type, delta);
}
}
else
{
@@ -372,7 +365,7 @@ public class EffectSystem : MonoBehaviour
if (duration <= 0f)
{
enemy.SetMaxHP(enemy.maxHP + delta, false);
if (delta > 0) enemy.currentHP = Mathf.Clamp(enemy.currentHP + delta, 0, enemy.maxHP);
if (delta > 0) enemy.ModifyHP(delta);
iBudeffPrefabController.Instance?.RefreshEnemyNow(enemy);
iBudeffPrefabController.Instance?.RegisterEnemyTimedEffect(enemy, PlayerBudeffIconType.ot_maxHP_up, delta, 0f);
}
@@ -1083,18 +1076,8 @@ public class EffectSystem : MonoBehaviour
var comp = target.GetComponent<ICombatant>();
if (comp != null)
{
int beforeHP = 0;
if (targetAlly != null) beforeHP = targetAlly.currentHP;
else if (targetEnemy != null) beforeHP = targetEnemy.currentHP;
comp.ReceiveDamage(amount, source);
int afterHP = 0;
if (targetAlly != null) afterHP = targetAlly.currentHP;
else if (targetEnemy != null) afterHP = targetEnemy.currentHP;
int actualDelta = beforeHP - afterHP;
if (actualDelta != 0) QueueOrSpawnDamagePopup(target, targetAlly, targetEnemy, actualDelta);
// Use deferPopup: true for synchronization with hit fx
comp.ReceiveDamage(amount, source, true);
// Record stats if source is an ally
if (source != null && target.GetComponent<EnemyCombatant>() != null)
@@ -1124,26 +1107,8 @@ public class EffectSystem : MonoBehaviour
var comp = target.GetComponent<ICombatant>();
if (comp != null)
{
var targetAlly = target.GetComponent<AllyCombatant>();
var targetEnemy = target.GetComponent<EnemyCombatant>();
int beforeHP = 0;
if (targetAlly != null) beforeHP = targetAlly.currentHP;
else if (targetEnemy != null) beforeHP = targetEnemy.currentHP;
comp.ReceiveHeal(amount, source);
int afterHP = 0;
if (targetAlly != null) afterHP = targetAlly.currentHP;
else if (targetEnemy != null) afterHP = targetEnemy.currentHP;
int actualDelta = afterHP - beforeHP;
if (actualDelta != 0)
{
if (targetAlly != null)
iNumberPrefabController.SpawnForAllyStatic(targetAlly.slotIndex, iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
else if (targetEnemy != null)
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
}
// Use deferPopup: false for heals (usually immediate)
comp.ReceiveHeal(amount, source, false);
// Record stats if source is an ally
if (source != null)
@@ -1208,7 +1173,9 @@ public class EffectSystem : MonoBehaviour
}
}
comp.ReceiveDamage(totalAmount, source);
comp.ReceiveDamage(totalAmount, source, false);
// No need to call TriggerQueuedPopups manually as deferPopup is false
if (source != null && targetEnemy != null)
{
var ally = source.GetComponent<AllyCombatant>();
@@ -1255,19 +1222,9 @@ public class EffectSystem : MonoBehaviour
}
}
int beforeHP = 0;
if (targetAlly != null) beforeHP = targetAlly.currentHP;
else if (targetEnemy != null) beforeHP = targetEnemy.currentHP;
comp.ReceiveDamage(perTick, source);
int afterHP = 0;
if (targetAlly != null) afterHP = targetAlly.currentHP;
else if (targetEnemy != null) afterHP = targetEnemy.currentHP;
int actualDelta = beforeHP - afterHP;
if (actualDelta != 0) QueueOrSpawnDamagePopup(target, targetAlly, targetEnemy, actualDelta);
comp.ReceiveDamage(perTick, source, false);
// No need to call TriggerQueuedPopups manually as deferPopup is false
if (source != null && targetEnemy != null)
{
var ally = source.GetComponent<AllyCombatant>();
@@ -1306,21 +1263,9 @@ public class EffectSystem : MonoBehaviour
if (targetAlly != null) beforeHP = targetAlly.currentHP;
else if (targetEnemy != null) beforeHP = targetEnemy.currentHP;
comp.ReceiveHeal(totalAmount, source);
int afterHP = 0;
if (targetAlly != null) afterHP = targetAlly.currentHP;
else if (targetEnemy != null) afterHP = targetEnemy.currentHP;
int actualDelta = afterHP - beforeHP;
if (actualDelta != 0)
{
if (targetAlly != null)
iNumberPrefabController.SpawnForAllyStatic(targetAlly.slotIndex, iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
else if (targetEnemy != null)
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
}
comp.ReceiveHeal(totalAmount, source, false);
// No need to call TriggerQueuedPopups manually as deferPopup is false
// Record stats
if (source != null)
{
@@ -1339,25 +1284,9 @@ public class EffectSystem : MonoBehaviour
{
if (target == null) yield break;
int beforeHP = 0;
if (targetAllyHot != null) beforeHP = targetAllyHot.currentHP;
else if (targetEnemyHot != null) beforeHP = targetEnemyHot.currentHP;
comp.ReceiveHeal(perTick, source);
int afterHP = 0;
if (targetAllyHot != null) afterHP = targetAllyHot.currentHP;
else if (targetEnemyHot != null) afterHP = targetEnemyHot.currentHP;
int actualDelta = afterHP - beforeHP;
if (actualDelta != 0)
{
if (targetAllyHot != null)
iNumberPrefabController.SpawnForAllyStatic(targetAllyHot.slotIndex, iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
else if (targetEnemyHot != null)
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
}
comp.ReceiveHeal(perTick, source, false);
// No need to call TriggerQueuedPopups manually as deferPopup is false
// Record stats
if (source != null)
{
@@ -1382,47 +1311,19 @@ public class EffectSystem : MonoBehaviour
int id = target.GetInstanceID();
if (_awaitingHitFxTargets.Contains(id)) _awaitingHitFxTargets.Remove(id);
if (!_pendingDamagePopupByTargetId.TryGetValue(id, out var signedValue) || signedValue == 0) return;
_pendingDamagePopupByTargetId.Remove(id);
var ally = target.GetComponent<AllyCombatant>();
if (ally != null)
// Trigger any queued damage/heal popups now that the hit FX is playing
var enemy = target.GetComponent<EnemyCombatant>();
if (enemy != null)
{
iNumberPrefabController.SpawnForAllyStatic(ally.slotIndex, iNumberPrefabController.InstantNumberType.Damage, signedValue);
return;
enemy.TriggerQueuedPopups();
}
if (target.GetComponent<EnemyCombatant>() != null)
else
{
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Damage, signedValue);
}
}
private void QueueOrSpawnDamagePopup(GameObject target, AllyCombatant targetAlly, EnemyCombatant targetEnemy, int actualDelta)
{
if (target == null) return;
if (actualDelta == 0) return;
int id = target.GetInstanceID();
int signedValue = -Mathf.Abs(actualDelta);
if (_awaitingHitFxTargets.Contains(id))
{
if (_pendingDamagePopupByTargetId.TryGetValue(id, out var prev))
_pendingDamagePopupByTargetId[id] = prev + signedValue;
else
_pendingDamagePopupByTargetId[id] = signedValue;
return;
}
if (targetAlly != null)
{
iNumberPrefabController.SpawnForAllyStatic(targetAlly.slotIndex, iNumberPrefabController.InstantNumberType.Damage, signedValue);
return;
}
if (targetEnemy != null)
{
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Damage, signedValue);
var ally = target.GetComponent<AllyCombatant>();
if (ally != null)
{
ally.TriggerQueuedPopups();
}
}
}
@@ -1443,14 +1344,7 @@ public class EffectSystem : MonoBehaviour
// immediate add totalAmount to mana if ally present
if (ally != null)
{
int before = ally.currentMana;
ally.ModifyMana(Mathf.CeilToInt(totalAmount), true, true);
int delta = ally.currentMana - before;
if (delta != 0)
{
var type = delta > 0 ? iNumberPrefabController.InstantNumberType.ManaPlus : iNumberPrefabController.InstantNumberType.ManaMinus;
iNumberPrefabController.SpawnForAllyStatic(ally.slotIndex, type, delta);
}
// Record stats
if (totalAmount > 0f && source != null)
{
@@ -1469,14 +1363,7 @@ public class EffectSystem : MonoBehaviour
if (target == null) yield break;
if (ally != null)
{
int before = ally.currentMana;
ally.ModifyMana(Mathf.CeilToInt(perTick), true, true);
int delta = ally.currentMana - before;
if (delta != 0)
{
var type = delta > 0 ? iNumberPrefabController.InstantNumberType.ManaPlus : iNumberPrefabController.InstantNumberType.ManaMinus;
iNumberPrefabController.SpawnForAllyStatic(ally.slotIndex, type, delta);
}
// Record stats
if (perTick > 0f && source != null)
{
@@ -1641,7 +1528,7 @@ public class EffectSystem : MonoBehaviour
{
if (enemy == null) yield break;
enemy.SetMaxHP(Mathf.Max(1, enemy.maxHP + delta), false);
if (delta > 0) enemy.currentHP = Mathf.Clamp(enemy.currentHP + delta, 0, enemy.maxHP);
if (delta > 0) enemy.ModifyHP(delta);
iBudeffPrefabController.Instance?.RefreshEnemyNow(enemy);
yield return new WaitForSeconds(duration);
if (enemy == null) yield break;
+71 -6
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -133,7 +133,7 @@ public class EnemyCombatant : MonoBehaviour, ICombatant
}
}
public void ReceiveDamage(float amount, GameObject source)
public void ReceiveDamage(float amount, GameObject source, bool deferPopup = false)
{
if (isDead) return;
@@ -144,9 +144,23 @@ public class EnemyCombatant : MonoBehaviour, ICombatant
}
_lastAttacker = source;
int before = currentHP;
float effective = amount * (1f - damageResistance);
int delta = Mathf.CeilToInt(effective);
currentHP = Mathf.Clamp(currentHP - delta, 0, maxHP);
ModifyHP(-delta, true);
int actual = before - currentHP;
if (actual != 0)
{
if (deferPopup)
{
QueueDamagePopup(iNumberPrefabController.InstantNumberType.Damage, -actual);
}
else
{
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Damage, -actual);
}
}
// grant mana based on sourceData setting
if (sourceData != null && sourceData.manaGainOnDamagePercent > 0f && maxMana > 0)
@@ -162,12 +176,25 @@ public class EnemyCombatant : MonoBehaviour, ICombatant
}
}
public void ReceiveHeal(float amount, GameObject source)
public void ReceiveHeal(float amount, GameObject source, bool deferPopup = false)
{
if (isDead) return;
int before = currentHP;
float mult = GetTotalHealReceivedMultiplier();
int delta = Mathf.CeilToInt(amount * mult);
currentHP = Mathf.Clamp(currentHP + delta, 0, maxHP);
ModifyHP(delta, true);
int actual = currentHP - before;
if (actual != 0)
{
if (deferPopup)
{
QueueDamagePopup(iNumberPrefabController.InstantNumberType.Heal, actual);
}
else
{
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Heal, actual);
}
}
}
public void ApplyBuff(Buff buff, GameObject source)
@@ -255,10 +282,38 @@ public class EnemyCombatant : MonoBehaviour, ICombatant
RecalculateAttackFromBuffs();
}
private List<(iNumberPrefabController.InstantNumberType type, int val)> _queuedPopups = new List<(iNumberPrefabController.InstantNumberType, int)>();
public void QueueDamagePopup(iNumberPrefabController.InstantNumberType type, int val)
{
_queuedPopups.Add((type, val));
}
public void TriggerQueuedPopups()
{
foreach (var p in _queuedPopups)
{
iNumberPrefabController.SpawnForEnemyStatic(p.type, p.val);
}
_queuedPopups.Clear();
}
public void ModifyHP(int delta)
{
ModifyHP(delta, false);
}
public void ModifyHP(int delta, bool skipPopup)
{
if (isDead && delta > 0) return;
int before = currentHP;
currentHP = Mathf.Clamp(currentHP + delta, 0, maxHP);
int actual = currentHP - before;
if (actual != 0 && !skipPopup)
{
var type = actual > 0 ? iNumberPrefabController.InstantNumberType.Heal : iNumberPrefabController.InstantNumberType.Damage;
iNumberPrefabController.SpawnForEnemyStatic(type, actual);
}
if (currentHP <= 0) Die();
}
@@ -267,6 +322,16 @@ public class EnemyCombatant : MonoBehaviour, ICombatant
if (maxMana <= 0) return;
int old = currentMana;
currentMana = Mathf.Clamp(currentMana + delta, 0, maxMana);
int actual = currentMana - old;
if (actual != 0)
{
if (iNumberPrefabController.Instance != null)
{
var type = actual > 0 ? iNumberPrefabController.InstantNumberType.ManaPlus : iNumberPrefabController.InstantNumberType.ManaMinus;
iNumberPrefabController.SpawnForEnemyStatic(type, actual);
}
}
// If mana reached full, trigger primary skill and reset mana
if (currentMana >= maxMana && maxMana > 0 && Application.isPlaying)
@@ -283,7 +348,7 @@ public class EnemyCombatant : MonoBehaviour, ICombatant
}
// reset mana after casting
currentMana = 0;
ModifyMana(-currentMana, false);
}
}
+10 -2
View File
@@ -380,8 +380,8 @@ public class ScoreManager : MonoBehaviour
if (idolScoreSums[trackIndex] > int.MaxValue - 1) idolScoreSums[trackIndex] = int.MaxValue - 1;
int idolActualDelta = idolScoreSums[trackIndex] - idolBefore;
// Only spawn popup if it is skill-related
if (isSkillRelated && idolActualDelta != 0)
// Spawn floating number popup for idol score change
if (idolActualDelta != 0)
{
var type = idolActualDelta > 0 ? iNumberPrefabController.InstantNumberType.IscorePlus : iNumberPrefabController.InstantNumberType.IscoreMinus;
iNumberPrefabController.SpawnForAllyStatic(trackIndex, type, idolActualDelta);
@@ -458,9 +458,17 @@ public class ScoreManager : MonoBehaviour
if (trackIndex < 0 || trackIndex >= idolScoreSums.Length) return;
if (idolDelta == 0) return;
int idolBefore = idolScoreSums[trackIndex];
idolScoreSums[trackIndex] += idolDelta;
if (idolScoreSums[trackIndex] < 0) idolScoreSums[trackIndex] = 0;
if (idolScoreSums[trackIndex] > int.MaxValue - 1) idolScoreSums[trackIndex] = int.MaxValue - 1;
int actual = idolScoreSums[trackIndex] - idolBefore;
if (actual != 0)
{
var type = actual > 0 ? iNumberPrefabController.InstantNumberType.IscorePlus : iNumberPrefabController.InstantNumberType.IscoreMinus;
iNumberPrefabController.SpawnForAllyStatic(trackIndex, type, actual);
}
red_idolScore_sum = idolScoreSums[0];
green_idolScore_sum = idolScoreSums[1];
+3 -9
View File
@@ -1,14 +1,8 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Documentation text normalized.
/// Documentation text normalized.
/// Documentation text normalized.
/// Documentation text normalized.
///
/// Documentation text normalized.
/// SkillBuilder.Instance.ExecuteSkill("Fireball", EffectType.DamageSingleEnemy, 120f, Selector.CurrentEnemies, caster, target);
/// Documentation text normalized.
/// </summary>
@@ -1003,7 +997,7 @@ public class SkillBuilder : MonoBehaviour
else
{
enemy.SetMaxHP(Mathf.Max(1, enemy.maxHP + hpDelta), false);
if (hpDelta > 0) enemy.currentHP = Mathf.Clamp(enemy.currentHP + hpDelta, 0, enemy.maxHP);
if (hpDelta > 0) enemy.ModifyHP(hpDelta);
}
int newHP = ally != null ? ally.maxHP : enemy.maxHP;
CheckLimitAndWarnInt(targetName, "最大生命值", oldHP, newHP, hpDelta);
@@ -1595,7 +1589,7 @@ ResolvedGroup:
{
int d = Mathf.CeilToInt(amountTotal);
enemy.SetMaxHP(enemy.maxHP + d, false);
if (d > 0) enemy.currentHP = Mathf.Clamp(enemy.currentHP + d, 0, enemy.maxHP);
if (d > 0) enemy.ModifyHP(d);
iBudeffPrefabController.Instance?.RegisterEnemyTimedEffect(enemy, PlayerBudeffIconType.ot_maxHP_up, d, 0f);
}
break;
+77 -17
View File
@@ -60,6 +60,11 @@ public class HoldNote : BaseNote
[Range(1f, 2f)]
public float holdWindowMultiplier = 1.3f;
[Header("Custom Animation")]
public GameObject holdAnimationPrefab;
private GameObject activeHoldAnimationInstance;
private Coroutine delayedHoldAnimationCoroutine;
public float visualSpeedMultiplier = 1f; // injected from NoteSpawner to adapt windows when visual speed changes
// track when the hold actually started (real-time) so we can compute held fraction
@@ -317,6 +322,58 @@ public class HoldNote : BaseNote
}
}
private void StartHoldEffects()
{
StopHoldEffects(); // cleanup any existing
if (gameObject.activeInHierarchy)
{
delayedHoldAnimationCoroutine = StartCoroutine(DelayedStartHoldEffects());
}
}
private void StopHoldEffects()
{
if (delayedHoldAnimationCoroutine != null)
{
StopCoroutine(delayedHoldAnimationCoroutine);
delayedHoldAnimationCoroutine = null;
}
if (activeHoldAnimationInstance != null)
{
Destroy(activeHoldAnimationInstance);
activeHoldAnimationInstance = null;
}
AnimationController.Global?.StopHoldParticles();
}
private IEnumerator DelayedStartHoldEffects()
{
yield return new WaitForSeconds(0.1f);
// Start standard particles
AnimationController.Global?.StartHoldParticles(noteColor);
// Instantiate custom prefab if assigned
if (holdAnimationPrefab != null)
{
// find spawn position: prefer the track effect position if available from AnimationController
Vector3 spawnPos = transform.position;
var ac = AnimationController.Global;
if (ac != null)
{
// Logic to find slot position (simplified: use ac's position or the note's)
// In AnimationController.PlayDestroyAnimation, it uses redEffect.transform.position etc.
// We don't have direct access to those private fields, but we can assume
// the note is at the judge line when this starts.
}
activeHoldAnimationInstance = Instantiate(holdAnimationPrefab, spawnPos, Quaternion.identity);
// Optionally parent to the note or track
// activeHoldAnimationInstance.transform.SetParent(this.transform, false);
}
}
private IEnumerator DelayedDisableAnimation(GameObject animationObject, float delay)
{
// No-op: we used to disable the shared AnimationController here which stopped coroutines.
@@ -440,7 +497,7 @@ public class HoldNote : BaseNote
if (!isHoldActive && jm != null && jm.IsStartJudged(noteID) && !jm.HasNoteReleased(noteID) && keyHeld)
{
isHoldActive = true;
AnimationController.Global?.StartHoldParticles(noteColor);
StartHoldEffects();
if (debugEnabled) Debug.Log($"[HoldNote] Start particles started for {noteID} color={noteColor} at time={now:F3}");
}
@@ -474,7 +531,7 @@ public class HoldNote : BaseNote
if (isHoldActive && keyUp)
{
isHoldActive = false;
AnimationController.Global?.StopHoldParticles();
StopHoldEffects();
if (debugEnabled) Debug.Log($"[HoldNote] KeyUp {keyToPress} detected. NoteID: {noteID}, Segment: {segment}, Type: {type}");
if (!hasReleased)
@@ -649,7 +706,7 @@ public class HoldNote : BaseNote
JudgeManager.Instance.RegisterStartJudged(noteID, true);
isHoldActive = true;
PlayHitAnimation();
AnimationController.Global?.StartHoldParticles(noteColor);
StartHoldEffects();
holdStartTime = pressTime;
HoldNoteJudgePool.RegisterStart(noteID, pressTime, hitTime, scheduledEndTime, noteColor, trackIndex, (object)noteData);
@@ -695,17 +752,17 @@ public class HoldNote : BaseNote
// Autoplay must ignore physical input to guarantee Perfect at scheduledEndTime.
if (!GameConfig.autoPlayEnabled && Input.GetKey(keyToPress) && JudgeManager.Instance.IsStartJudged(noteID) && !isJudged)
{
if (JudgeManager.IsDebugEnabled) Debug.Log($"[HoldNote] End entered while key still held: {noteColor}, calculating result immediately");
if (JudgeManager.IsDebugEnabled) Debug.Log($"[HoldNote] End entered while key still held: {noteColor}, forcing Perfect");
// Record release time as current time (player is still holding)
releaseTime = Time.time;
hasReleased = true;
JudgeManager.Instance?.RegisterNoteReleased(noteID, true);
// Evaluate and judge the hold end
EvaluateHoldEnd(releaseTime, false);
// Evaluate and judge the hold end - force Perfect since we reached the end while holding
EvaluateHoldEnd(releaseTime, false, true);
isJudged = true;
// Terminate input - mark key as released
isHoldActive = false;
AnimationController.Global?.StopHoldParticles();
StopHoldEffects();
return;
}
@@ -875,7 +932,7 @@ public class HoldNote : BaseNote
JudgeManager.Instance.RegisterStartJudged(noteID, true);
isHoldActive = true;
PlayHitAnimation();
AnimationController.Global?.StartHoldParticles(noteColor);
StartHoldEffects();
// record when the hold started so we can compute held fraction later
holdStartTime = pressTime;
@@ -891,7 +948,7 @@ public class HoldNote : BaseNote
JudgeManager.Instance.RegisterStartJudged(noteID, true);
isHoldActive = true;
PlayHitAnimation();
AnimationController.Global?.StartHoldParticles(noteColor);
StartHoldEffects();
holdStartTime = pressTime;
@@ -905,7 +962,7 @@ public class HoldNote : BaseNote
JudgeManager.Instance.RegisterStartJudged(noteID, true);
isHoldActive = true;
PlayHitAnimation();
AnimationController.Global?.StartHoldParticles(noteColor);
StartHoldEffects();
holdStartTime = pressTime;
@@ -986,7 +1043,7 @@ public class HoldNote : BaseNote
}
// central evaluation for hold end, given an actual releaseTime (real-time) or forceMiss
private void EvaluateHoldEnd(float actualReleaseTime, bool forceMiss)
private void EvaluateHoldEnd(float actualReleaseTime, bool forceMiss, bool forcePerfect = false)
{
if (isJudged) return; // already evaluated
@@ -1001,7 +1058,7 @@ public class HoldNote : BaseNote
hasReleased = true;
JudgeManager.Instance.RegisterNoteReleased(noteID, true);
if (JudgeManager.IsDebugEnabled) Debug.Log($"[HoldNote] EvaluateHoldEnd: noteID={noteID} releaseTime={releaseTime:F3} scheduledEnd={scheduledEndTime:F3} forceMiss={forceMiss}");
if (JudgeManager.IsDebugEnabled) Debug.Log($"[HoldNote] EvaluateHoldEnd: noteID={noteID} releaseTime={releaseTime:F3} scheduledEnd={scheduledEndTime:F3} forceMiss={forceMiss} forcePerfect={forcePerfect}");
string result;
@@ -1028,13 +1085,13 @@ public class HoldNote : BaseNote
float playerHeld = Mathf.Clamp(releaseTime - info.pressTime, 0f, info.length);
float frac = info.length <= 0f ? 0f : (playerHeld / info.length);
if (frac > 0.8f)
if (forcePerfect || frac > 0.7f)
{
result = "Perfect";
ScoreManager.Instance.countPerfect += 1;
if (trackIndex >= 0 && trackIndex < 5) ScoreManager.Instance.trackPerfectCounts[trackIndex]++;
}
else if (frac > 0.5f)
else if (frac > 0.4f)
{
result = "Great";
ScoreManager.Instance.countGreat += 1;
@@ -1069,13 +1126,13 @@ public class HoldNote : BaseNote
float held = Mathf.Clamp(actualReleaseTime - hitTime, 0f, holdRequired);
float frac = holdRequired <= 0f ? 0f : (held / holdRequired);
if (frac > 0.8f)
if (forcePerfect || frac > 0.7f)
{
result = "Perfect";
ScoreManager.Instance.countPerfect += 1;
if (trackIndex >= 0 && trackIndex < 5) ScoreManager.Instance.trackPerfectCounts[trackIndex]++;
}
else if (frac > 0.5f)
else if (frac > 0.4f)
{
result = "Great";
ScoreManager.Instance.countGreat += 1;
@@ -1193,7 +1250,7 @@ public class HoldNote : BaseNote
if (JudgeManager.IsDebugEnabled) Debug.Log($"[HoldNote] Hold end NotifyNoteHit called: TrackIndex={TrackIndex} trackIndexField={trackIndex} result={result} triggeredHold={triggeredHold} triggeredTap={triggeredTap}");
}
AnimationController.Global?.StopHoldParticles();
StopHoldEffects();
// Release the track lock immediately after end evaluation so the next hold can start on time
ReleaseTrackJudgeLockSafe();
@@ -1315,6 +1372,9 @@ public class HoldNote : BaseNote
// Restore materials before returning to pool/reusing
RestoreOriginalMaterials();
// Stop any active hold animations or delayed starts
StopHoldEffects();
hasReleased = false;
segment = NoteSegment.None;
keyToPress = KeyCode.None;
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 088ed1ed6b6731f43ad3166781e3e931, type: 3}
m_Name: NoteJudgeConfig
m_EditorClassIdentifier:
perfectRange: 0.15
greatRange: 0.2
goodRange: 0.25
missRange: 0.3
perfectRange: 0.05
greatRange: 0.1
goodRange: 0.15
missRange: 0.2
+3
View File
@@ -55,6 +55,9 @@ public class Note : BaseNote
private static int ComputePmDeltaFromJudge(string judgeResult, AllyCombatant ally)
{
// If current character slot has no ally or is dead, then this corresponding track will also not get idol score
if (ally == null || ally.IsDead) return 0;
int baseScore = 0;
var bmm = ally != null ? ally.bmm : null;
@@ -27,6 +27,12 @@ public class NoteSpawner : MonoBehaviour
[Tooltip("Global additional realtime offset (seconds) added to hit times for all notes. Use to test input latency or adjust judgement timing. Default 0. Can be negative to make notes arrive earlier.")]
public float globalHitDelay = 0f;
[Header("Sync Note Detection")]
[Tooltip("Whether to spawn a special prefab for notes that appear within 0.05s of each other.")]
public bool enableSyncNotePrefab = false;
[Tooltip("The prefab to instantiate under the note when a sync is detected.")]
public GameObject syncNotePrefab;
// Documentation text normalized.
[Tooltip("Multiplier applied to visual fall speed. Changing this will automatically adjust spawn timing so notes still arrive at their original beat times.")]
[Range(0.5f, 2f)]
@@ -131,6 +137,10 @@ public class NoteSpawner : MonoBehaviour
spawnOffset = savedDelay + static_value_add_to_spawnoffset;
if (JudgeManager.IsDebugEnabled) Debug.Log($"[NoteSpawner] Applied spawnOffset={spawnOffset} (Saved={savedDelay} + Static={static_value_add_to_spawnoffset})");
// 读取 PlayerPrefs 中的同步音符开关状态
enableSyncNotePrefab = PlayerPrefs.GetInt("EnableSyncNotePrefab", 1) == 1;
if (JudgeManager.IsDebugEnabled) Debug.Log($"[NoteSpawner] Applied enableSyncNotePrefab={enableSyncNotePrefab}");
// restore animations active state on Start
if (animations != null)
{
@@ -254,6 +264,27 @@ public class NoteSpawner : MonoBehaviour
NoteData note = beatmap.notes[i];
// Check if this is a sync note (within 0.05s of any other note)
bool isSync = false;
if (enableSyncNotePrefab)
{
// Check previous notes (optimized assuming sorted beatmap)
for (int j = i - 1; j >= 0; j--)
{
if (Mathf.Abs(note.time - beatmap.notes[j].time) <= 0.05f) { isSync = true; break; }
if (note.time - beatmap.notes[j].time > 0.05f) break;
}
if (!isSync)
{
// Check next notes (optimized assuming sorted beatmap)
for (int j = i + 1; j < beatmap.notes.Length; j++)
{
if (Mathf.Abs(note.time - beatmap.notes[j].time) <= 0.05f) { isSync = true; break; }
if (beatmap.notes[j].time - note.time > 0.05f) break;
}
}
}
float travelTime = GetLaneTravelTimeSeconds(laneTravelTimes, note.trackIndex);
float spawnTime = note.time - travelTime;
float delay = spawnTime - (Time.time - startTime) + spawnOffset;
@@ -272,12 +303,12 @@ public class NoteSpawner : MonoBehaviour
if (note.type == "hold")
{
// create the hold note once and record its id mapping
int hid = SpawnHoldNote(note, sm, travelTime, noteSpeed, segmentInterval);
int hid = SpawnHoldNote(note, sm, travelTime, noteSpeed, segmentInterval, isSync);
noteIndexToHoldId[i] = hid;
}
else
{
SpawnNote(note, sm, travelTime, noteSpeed);
SpawnNote(note, sm, travelTime, noteSpeed, isSync);
}
}
@@ -299,7 +330,7 @@ public class NoteSpawner : MonoBehaviour
return key;
}
public void SpawnNote(NoteData noteData, float sm, float travelTime, float noteSpeed)
public void SpawnNote(NoteData noteData, float sm, float travelTime, float noteSpeed, bool isSync = false)
{
if (noteData.trackIndex < 0 || noteData.trackIndex >= spawnPoints.Length)
{
@@ -321,6 +352,23 @@ public class NoteSpawner : MonoBehaviour
return;
}
if (enableSyncNotePrefab && syncNotePrefab != null)
{
// Clean up any existing sync prefab from previous use in pool
foreach (Transform child in note.transform)
{
if (child.name.StartsWith(syncNotePrefab.name))
{
Destroy(child.gameObject);
}
}
if (isSync)
{
Instantiate(syncNotePrefab, note.transform);
}
}
Transform spawnPoint = spawnPoints[noteData.trackIndex];
// Calculate hit time (realtime when note should be judged)
@@ -354,7 +402,7 @@ public class NoteSpawner : MonoBehaviour
}
// Modified: return generated holdNoteId so callers can map notes to ids
public int SpawnHoldNote(NoteData noteData, float sm, float travelTime, float noteSpeed, float segmentInterval)
public int SpawnHoldNote(NoteData noteData, float sm, float travelTime, float noteSpeed, float segmentInterval, bool isSync = false)
{
if (noteData.trackIndex < 0 || noteData.trackIndex >= spawnPoints.Length)
{
@@ -398,6 +446,23 @@ public class NoteSpawner : MonoBehaviour
return -1;
}
if (enableSyncNotePrefab && syncNotePrefab != null)
{
// Clean up any existing sync prefab from previous use in pool
foreach (Transform child in startObj.transform)
{
if (child.name.StartsWith(syncNotePrefab.name))
{
Destroy(child.gameObject);
}
}
if (isSync)
{
Instantiate(syncNotePrefab, startObj.transform);
}
}
// Hold segments use absolute positioning; spawn at the lane origin.
startObj.transform.position = spawnPoint.position;
startObj.transform.rotation = Quaternion.identity;
@@ -1228,11 +1228,11 @@ public class settlementController : MonoBehaviour
if (sm != null)
{
scores[0] = sm.red_pmScore_sum;
scores[1] = sm.green_pmScore_sum;
scores[2] = sm.yellow_pmScore_sum;
scores[3] = sm.purple_pmScore_sum;
scores[4] = sm.blue_pmScore_sum;
scores[0] = sm.red_idolScore_sum;
scores[1] = sm.green_idolScore_sum;
scores[2] = sm.yellow_idolScore_sum;
scores[3] = sm.purple_idolScore_sum;
scores[4] = sm.blue_idolScore_sum;
}
else
{
@@ -1262,9 +1262,13 @@ public class settlementController : MonoBehaviour
if (topIndex < 0 || max <= 0)
{
Debug.Log("[SettlementController] No top scorer found or scores are all zero");
// hide image
mvp_hero_hd_image.sprite = null;
mvp_hero_hd_image.color = new Color(mvp_hero_hd_image.color.r, mvp_hero_hd_image.color.g, mvp_hero_hd_image.color.b, 0f);
// hide image and mvp object
if (mvp_object != null) mvp_object.SetActive(false);
if (mvp_hero_hd_image != null)
{
mvp_hero_hd_image.sprite = null;
mvp_hero_hd_image.color = new Color(mvp_hero_hd_image.color.r, mvp_hero_hd_image.color.g, mvp_hero_hd_image.color.b, 0f);
}
return;
}
@@ -1297,6 +1301,8 @@ public class settlementController : MonoBehaviour
}
// final fallback: try direct Resources lookup by scanning all and picking first non-null for slot
// REMOVED: This fallback causes a default character to appear when no hero is selected.
/*
if (heroSO == null)
{
if (_cachedAllyHeroSOs == null || _cachedAllyHeroSOs.Length == 0)
@@ -1309,6 +1315,7 @@ public class settlementController : MonoBehaviour
heroSO = _cachedAllyHeroSOs[0] as AllyHero_SO;
}
}
*/
if (heroSO != null)
{
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using Spine;
using Spine.Unity;
using SmoothShakeFree;
+47
View File
@@ -0,0 +1,47 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class gameSettings : MonoBehaviour
{
public Toggle multiNoteNoticeToggle;
public Text multiNoteNoticeText; // Using Legacy Text object
private const string PrefKey_EnableSyncNotePrefab = "EnableSyncNotePrefab";
void Start()
{
if (multiNoteNoticeToggle != null)
{
// Initialize toggle state from PlayerPrefs, default to 1 (true)
bool isEnabled = PlayerPrefs.GetInt(PrefKey_EnableSyncNotePrefab, 1) == 1;
multiNoteNoticeToggle.isOn = isEnabled;
// Initialize text based on current toggle value
UpdateText(isEnabled);
// Add listener to save value and update text when changed
multiNoteNoticeToggle.onValueChanged.AddListener((isOn) =>
{
PlayerPrefs.SetInt(PrefKey_EnableSyncNotePrefab, isOn ? 1 : 0);
PlayerPrefs.Save();
UpdateText(isOn);
});
}
}
private void UpdateText(bool isOn)
{
if (multiNoteNoticeText != null)
{
multiNoteNoticeText.text = isOn ? "已启用多押指示器" : "已禁用多押指示器";
}
// Also update the Toggle's own label text if it exists (usually a child object)
Text toggleLabel = multiNoteNoticeToggle.GetComponentInChildren<Text>();
if (toggleLabel != null)
{
toggleLabel.text = isOn ? "启用" : "禁用";
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 689de294fb913594ab2f3185279f7093