From 1e14910b4dbc8af410380e609bcfc0010370c5e2 Mon Sep 17 00:00:00 2001 From: GL <2365963573@qq.com> Date: Tue, 7 Jan 2025 16:50:42 +0800 Subject: [PATCH] ssm --- Role/Fun.cs | 17 +++++++++++++++++ Role/Role.cs | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 3 deletions(-) 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)//浜旇灞炴т激瀹宠绠 杩斿洖鍊嶇巼鍑忎激鎴栧鍔犱激瀹 { // 鍏嬪埗鍏崇郴琛紙浣跨敤浜岀淮鏁扮粍鎴栧瓧鍏歌〃绀猴級 // 琛岋細鏁屼汉灞炴э紝鍒楋細钀屽灞炴