hold音符补丁 备份
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user