hold音符补丁 备份

This commit is contained in:
2026-03-03 14:07:39 +08:00
parent b8704629a3
commit 9011fa022e
36 changed files with 2721 additions and 256 deletions
+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);
}
}