ssm
This commit is contained in:
parent
cbe42ad621
commit
1e14910b4d
17
Role/Fun.cs
17
Role/Fun.cs
@ -148,4 +148,21 @@ public class Fun : Base
|
|||||||
targetRole.SlowDown(slowFactor, duration);
|
targetRole.SlowDown(slowFactor, duration);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 中毒buff
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="poisonDuration">持续时间</param>
|
||||||
|
/// <param name="poisonInterval">间隔</param>
|
||||||
|
/// <param name="poisonInterval">伤害</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Action<Role> CreatePoisonBuff(float poisonDuration, float poisonInterval, float poisonDamage)
|
||||||
|
{
|
||||||
|
return (Role targetRole) =>
|
||||||
|
{
|
||||||
|
Debug.LogError(this.name + "中毒buff");
|
||||||
|
targetRole.ApplyPoisonDamage(poisonDuration, poisonInterval,poisonDamage);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
49
Role/Role.cs
49
Role/Role.cs
@ -245,7 +245,11 @@ public class Role : Fun
|
|||||||
buffs.Add(buffAction);
|
buffs.Add(buffAction);
|
||||||
UnityEngine.Debug.LogError(this.name + "添加buff到"+ buffs);
|
UnityEngine.Debug.LogError(this.name + "添加buff到"+ buffs);
|
||||||
}
|
}
|
||||||
|
public void RemoveBuff(List<Action<Role>> buffs, Action<Role> buffAction)
|
||||||
|
{
|
||||||
|
buffs.Remove(buffAction);
|
||||||
|
UnityEngine.Debug.LogError(this.name + "移除" + buffs);
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行所有当前 Buff
|
/// 执行所有当前 Buff
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -461,7 +465,7 @@ public class Role : Fun
|
|||||||
// 如果有其他需要重置的状态,可以在这里添加
|
// 如果有其他需要重置的状态,可以在这里添加
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FlashRedEffect(int color = 0, float time = 0.2f)//0、1 红、蓝
|
public void FlashRedEffect(int color = 0, float time = 0.2f)//0、1、2 红、蓝、紫
|
||||||
{
|
{
|
||||||
// 如果spriteRenderer存在
|
// 如果spriteRenderer存在
|
||||||
if (spriteRenderer != null)
|
if (spriteRenderer != null)
|
||||||
@ -485,7 +489,15 @@ public class Role : Fun
|
|||||||
sequence.Append(spriteRenderer.DOColor(frostBlueWithAlpha, 0.2f))
|
sequence.Append(spriteRenderer.DOColor(frostBlueWithAlpha, 0.2f))
|
||||||
.Append(spriteRenderer.DOColor(UnityEngine.Color.white, time));
|
.Append(spriteRenderer.DOColor(UnityEngine.Color.white, time));
|
||||||
}
|
}
|
||||||
|
else if (color == 2)
|
||||||
|
{
|
||||||
|
// 中毒的紫色
|
||||||
|
UnityEngine.Color poisonPurpleWithAlpha = new UnityEngine.Color(0.6f, 0.2f, 0.8f); // 紫色调,带有绿色的感觉
|
||||||
|
|
||||||
|
// 变为紫色并恢复白色
|
||||||
|
sequence.Append(spriteRenderer.DOColor(poisonPurpleWithAlpha, 0.2f))
|
||||||
|
.Append(spriteRenderer.DOColor(UnityEngine.Color.white, time));
|
||||||
|
}
|
||||||
// 开始执行Sequence
|
// 开始执行Sequence
|
||||||
sequence.Play();
|
sequence.Play();
|
||||||
}
|
}
|
||||||
@ -615,7 +627,38 @@ public class Role : Fun
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float WuxingDamage(enemy Target)//五行属性伤害计算 返回倍率减伤或增加伤害
|
|
||||||
|
|
||||||
|
public void ApplyPoisonDamage(float poisonDuration, float poisonInterval, float poisonDamage)
|
||||||
|
{
|
||||||
|
// 记录开始时间
|
||||||
|
float elapsedTime = 0f;
|
||||||
|
FlashRedEffect(2, poisonDuration);
|
||||||
|
// 使用 DOTween 执行一个持续 `poisonDuration` 的计时器
|
||||||
|
DOTween.To(() => elapsedTime, x => elapsedTime = x, poisonDuration, poisonDuration)
|
||||||
|
.OnUpdate(() =>
|
||||||
|
{
|
||||||
|
// 每隔 poisonInterval 触发一次伤害
|
||||||
|
if (elapsedTime % poisonInterval < 0.1f) // 用一个小范围检查是否到达了伤害触发时机
|
||||||
|
{
|
||||||
|
// 扣除血量
|
||||||
|
if (hp- poisonDamage >= 0)
|
||||||
|
{
|
||||||
|
hp -= poisonDamage;
|
||||||
|
UnityEngine.Debug.Log($"中毒伤害: {poisonDamage}, 当前血量: {hp}/{maxHp}");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.OnKill(() =>
|
||||||
|
{
|
||||||
|
// 在 `poisonDuration` 结束后停止伤害
|
||||||
|
UnityEngine.Debug.Log("中毒效果结束");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public float WuxingDamage(enemy Target)//五行属性伤害计算 返回倍率减伤或增加伤害
|
||||||
{
|
{
|
||||||
// 克制关系表(使用二维数组或字典表示)
|
// 克制关系表(使用二维数组或字典表示)
|
||||||
// 行:敌人属性,列:萌妖属性
|
// 行:敌人属性,列:萌妖属性
|
||||||
|
Loading…
Reference in New Issue
Block a user