From 735255a588482967185c1d218c292c2d9239cfd8 Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Mon, 23 Dec 2024 22:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=A9=E6=99=95=E6=8A=80=E8=83=BD=E6=8A=80?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Role/Bullet.cs | 4 --- Role/Fun.cs | 68 ++++++++++++++++++++++++++++++++++++++------------ Role/Role.cs | 47 ++++++++++++++++++++++++++++++---- 3 files changed, 94 insertions(+), 25 deletions(-) diff --git a/Role/Bullet.cs b/Role/Bullet.cs index d5cf18a..5b394ad 100644 --- a/Role/Bullet.cs +++ b/Role/Bullet.cs @@ -236,10 +236,6 @@ public class Bullet : MonoBehaviour attackObj.bulltes.Remove(this.gameObject); Destroy(this.gameObject); } - - - - } } diff --git a/Role/Fun.cs b/Role/Fun.cs index bfeb3b1..a0c723c 100644 --- a/Role/Fun.cs +++ b/Role/Fun.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Reflection; using UnityEngine; +using Random = System.Random; public enum DamageType { @@ -29,24 +30,25 @@ public class BUff public Action Funaction;//调用的函数 public object[] value;//调用函数的值 + public BuffTypeState buffTypeState = 0; + + + public bool hasfalg(BuffTypeState fag) + { + return (buffTypeState & fag) == fag; + } + } +public enum BuffTypeState +{ + +} + + public class Fun : Base { - - /// - /// 中毒 //目标 // 自己 - /// - /// - public void poisoning(object[] objects) - { - Role targetAudience = (Role)objects[0]; - Role myPalye = (Role)objects[1]; - Debug.Log("触发中毒"); - Debug.Log(myPalye.name); - } - - + /// /// 扣血 传入参数 目标,伤害值,攻击类型,使用者,子弹射来的方向(0是右边,1是左边) /// @@ -57,8 +59,6 @@ public class Fun : Base float harm = (float)objects[1]; DamageType damageType = (DamageType)objects[2]; Role UserObj = (Role)objects[3]; - - float finalDamage = harm; switch (damageType) @@ -84,5 +84,41 @@ public class Fun : Base } + /// + /// 火焰伤害后眩晕效果 + /// + public void Deceleration(Role targetAudience, float DecelerationTimer, float probability) + { + // 随机决定是否触发眩晕效果 + float temp = UnityEngine.Random.Range(0, 1f); + if (temp <= probability) + { + // 执行眩晕效果 + targetAudience.Navigation.StopPathDoTween(DecelerationTimer); + Debug.Log($"Applied Deceleration for {DecelerationTimer} seconds."); + } + } + /// + /// 创建一个减速(眩晕) Buff + /// + /// 眩晕持续时间 + /// 触发概率(0到1之间) + public Action CreateDecelerationBuff(float duration, float probability) + { + return (Role targetRole) => + { + float temp = UnityEngine.Random.Range(0f, 1f); + if (temp <= probability) + { + // 执行眩晕效果 + targetRole.Navigation.StopPathDoTween(duration); + Debug.Log($"Applied Deceleration for {duration} seconds to {targetRole.name}."); + } + else + { + Debug.Log($"Deceleration Buff did not trigger on {targetRole.name}."); + } + }; + } } diff --git a/Role/Role.cs b/Role/Role.cs index 3c19107..a8c9b84 100644 --- a/Role/Role.cs +++ b/Role/Role.cs @@ -111,7 +111,8 @@ public class Role : Fun } [Header("物理护甲")] public int physicalArmor = 10;//物理护甲 [Header("魔法护甲")] public int magicArmor = 5;//魔法护甲 - public List buffList = new List(); + + [Header("导航组件")] public SimplePathfindingDoTween Navigation; [System.Serializable ] public class AnimationList//动画list @@ -137,6 +138,19 @@ public class Role : Fun public int normalIndex = 0;//移动动画索引 public bool isHit=false;// + public List buffList = new List(); + + + /// + /// 储存buff + /// + public List> storageBuff = new List>(); + + /// + /// 使用buff + /// + public List> PlayerBuff=new List>(); + public virtual async void Start() { maxHp = hp; @@ -149,13 +163,37 @@ public class Role : Fun attackClass.role = this; } UpdateBuff(); - //Navigation.MoveToNextWaypoint(gameObject); } tag = Enum.GetName(typeof(Camp), camp); updateAnimation(); - - //AttackScope=1f; + + //ApplyBuffs(); } + + + /// + /// 添加Buff + /// + /// + public void AddBuff(List> buffs, Action buffAction) + { + buffs.Add(buffAction); + } + + /// + /// 执行所有当前 Buff + /// + public void ApplyBuffs() + { + foreach (var buff in PlayerBuff) + { + buff.Invoke(this); // 将自己作为目标传递 + } + + // 清空 Buff 列表,假设 Buff 是一次性的 + PlayerBuff.Clear(); + } + /// /// 角色动画更新 /// @@ -177,7 +215,6 @@ public class Role : Fun { animationHighlight = 0; } - //EditorUtility.SetDirty(this); List LightSprite = AnimationTree[animationHighlight].value; if (LightSprite == null) {