diff --git a/Role/Fun.cs b/Role/Fun.cs
index 7b57101..9b7cb57 100644
--- a/Role/Fun.cs
+++ b/Role/Fun.cs
@@ -148,4 +148,21 @@ public class Fun : Base
targetRole.SlowDown(slowFactor, duration);
};
}
+
+
+ ///
+ /// 中毒buff
+ ///
+ /// 持续时间
+ /// 间隔
+ /// 伤害
+ ///
+ public Action CreatePoisonBuff(float poisonDuration, float poisonInterval, float poisonDamage)
+ {
+ return (Role targetRole) =>
+ {
+ Debug.LogError(this.name + "中毒buff");
+ targetRole.ApplyPoisonDamage(poisonDuration, poisonInterval,poisonDamage);
+ };
+ }
}
diff --git a/Role/Role.cs b/Role/Role.cs
index 57d4e17..2f7818f 100644
--- a/Role/Role.cs
+++ b/Role/Role.cs
@@ -245,7 +245,11 @@ public class Role : Fun
buffs.Add(buffAction);
UnityEngine.Debug.LogError(this.name + "娣诲姞buff鍒"+ buffs);
}
-
+ public void RemoveBuff(List> buffs, Action buffAction)
+ {
+ buffs.Remove(buffAction);
+ UnityEngine.Debug.LogError(this.name + "绉婚櫎" + buffs);
+ }
///
/// 鎵ц鎵鏈夊綋鍓 Buff
///
@@ -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瀛樺湪
if (spriteRenderer != null)
@@ -485,7 +489,15 @@ public class Role : Fun
sequence.Append(spriteRenderer.DOColor(frostBlueWithAlpha, 0.2f))
.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));
+ }
// 寮濮嬫墽琛孲equence
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) // 鐢ㄤ竴涓皬鑼冨洿妫鏌ユ槸鍚﹀埌杈句簡浼ゅ瑙﹀彂鏃舵満
+ {
+ // 鎵i櫎琛閲
+ if (hp- poisonDamage >= 0)
+ {
+ hp -= poisonDamage;
+ UnityEngine.Debug.Log($"涓瘨浼ゅ: {poisonDamage}, 褰撳墠琛閲: {hp}/{maxHp}");
+
+
+ }
+ }
+ })
+ .OnKill(() =>
+ {
+ // 鍦 `poisonDuration` 缁撴潫鍚庡仠姝激瀹
+ UnityEngine.Debug.Log("涓瘨鏁堟灉缁撴潫");
+ });
+ }
+
+ public float WuxingDamage(enemy Target)//浜旇灞炴т激瀹宠绠 杩斿洖鍊嶇巼鍑忎激鎴栧鍔犱激瀹
{
// 鍏嬪埗鍏崇郴琛紙浣跨敤浜岀淮鏁扮粍鎴栧瓧鍏歌〃绀猴級
// 琛岋細鏁屼汉灞炴э紝鍒楋細钀屽灞炴