sm
This commit is contained in:
parent
8873ff3378
commit
fc5f538527
39
Role/Role.cs
39
Role/Role.cs
@ -629,27 +629,36 @@ public class Role : Fun
|
||||
|
||||
|
||||
|
||||
public void ApplyPoisonDamage(float poisonDuration, float poisonInterval, float poisonDamage,Role AttackRole)
|
||||
public void ApplyPoisonDamage(float poisonDuration, float poisonInterval, float poisonDamage, Role AttackRole)
|
||||
{
|
||||
// 使用异步方法时要确保调用时使用 await,或者启动异步任务
|
||||
ApplyPoisonCoroutine(poisonDuration, poisonInterval, poisonDamage, AttackRole);
|
||||
}
|
||||
|
||||
private async Task ApplyPoisonCoroutine(float poisonDuration, float poisonInterval, float poisonDamage, Role AttackRole)
|
||||
{
|
||||
// 记录开始时间
|
||||
float elapsedTime = 0f;
|
||||
FlashRedEffect(2, poisonDuration);
|
||||
// 使用 DOTween 执行一个持续 `poisonDuration` 的计时器
|
||||
DOTween.To(() => elapsedTime, x => elapsedTime = x, poisonDuration, poisonDuration)
|
||||
.OnUpdate(() =>
|
||||
{
|
||||
if (elapsedTime % poisonInterval < 0.1f) // 修改为更精确的触发条件
|
||||
|
||||
// 通过一个时间间隔来每隔一段时间触发伤害
|
||||
while (elapsedTime < poisonDuration)
|
||||
{
|
||||
this.bloodLoss(new object[] { this, poisonDamage, DamageType.magicDamage, AttackRange });
|
||||
UnityEngine.Debug.Log($"中毒伤害: {poisonDamage}, 当前血量: {hp}/{maxHp}");
|
||||
}
|
||||
})
|
||||
.OnKill(() =>
|
||||
{
|
||||
UnityEngine.Debug.Log("中毒效果结束");
|
||||
});
|
||||
// 等待下一个伤害时间点
|
||||
await Task.Delay((int)(poisonInterval * 1000)); // 乘以1000转换为毫秒
|
||||
|
||||
// 每隔 poisonInterval 执行一次伤害
|
||||
this.bloodLoss(new object[] { this, poisonDamage, DamageType.magicDamage, AttackRole });
|
||||
//Hp -= poisonDamage;
|
||||
|
||||
UnityEngine.Debug.Log($"中毒伤害: {poisonDamage}, 当前血量: {hp}/{maxHp}");
|
||||
|
||||
elapsedTime += poisonInterval;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.Log("中毒效果结束");
|
||||
}
|
||||
|
||||
|
||||
public float WuxingDamage(enemy Target)//五行属性伤害计算 返回倍率减伤或增加伤害
|
||||
{
|
||||
// 克制关系表(使用二维数组或字典表示)
|
||||
|
Loading…
Reference in New Issue
Block a user