This commit is contained in:
GL 2024-12-24 10:30:02 +08:00
parent eac4427f5e
commit 4b6941d72b
3 changed files with 24 additions and 21 deletions

View File

@ -4,7 +4,7 @@ using System.Threading.Tasks;
using Unity.VisualScripting; using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
using System.Linq;
public enum BulletType public enum BulletType
{ {
@ -124,6 +124,10 @@ public class Bullet : MonoBehaviour
{ {
if(Crole.camp!= role.camp) if(Crole.camp!= role.camp)
{ {
Crole.PlayerBuff = role.storageBuff.ToList();
Crole.ApplyBuffs();
Debug.Log(this.role.gameObject.name+"进行攻击计算"); Debug.Log(this.role.gameObject.name+"进行攻击计算");
int direction=0; int direction=0;
if (collision.transform.position.x>transform.position.x)//子弹打到敌人左边,飘字显示到右边 if (collision.transform.position.x>transform.position.x)//子弹打到敌人左边,飘字显示到右边

View File

@ -84,20 +84,7 @@ public class Fun : Base
} }
/// <summary>
/// 火焰伤害后眩晕效果
/// </summary>
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.");
}
}
/// <summary> /// <summary>
/// 创建一个减速(眩晕) Buff /// 创建一个减速(眩晕) Buff
@ -106,14 +93,21 @@ public class Fun : Base
/// <param name="probability">触发概率0到1之间</param> /// <param name="probability">触发概率0到1之间</param>
public Action<Role> CreateDecelerationBuff(float duration, float probability) public Action<Role> CreateDecelerationBuff(float duration, float probability)
{ {
Debug.Log("!!!!!!!!!!!!!!!!!!!!!!!!!!");
return (Role targetRole) => return (Role targetRole) =>
{ {
Debug.Log("@@@@@@@@@@@@@@@@@@@@@@@@");
float temp = UnityEngine.Random.Range(0f, 1f); float temp = UnityEngine.Random.Range(0f, 1f);
Debug.LogWarning("temp="+temp);
Debug.LogWarning("duration="+duration);
Debug.LogWarning("probability=" + probability);
if (temp <= probability) if (temp <= probability)
{ {
// 执行眩晕效果 // 执行眩晕效果
targetRole.Navigation.StopPathDoTween(duration); targetRole.Navigation.StopPathDoTween(duration);
Debug.Log($"Applied Deceleration for {duration} seconds to {targetRole.name}."); Debug.LogWarning(targetRole.name + "执行眩晕效果");
Debug.LogWarning($"Applied Deceleration for {duration} seconds to {targetRole.name}.");
} }
else else
{ {

View File

@ -83,7 +83,8 @@ public class Role : Fun
if (HpTextPrefab != null && hp < maxHp) if (HpTextPrefab != null && hp < maxHp)
{ {
hit(); hit();
Navigation.StopPathDoTween(0.2f); // 停止任何进行中的 DoTween 动画0.2s为示例值 Debug.LogError("僵直效果,被注释了");
//Navigation.StopPathDoTween(0.2f); // 停止任何进行中的 DoTween 动画0.2s为示例值
GameObject go = GameObject.Instantiate(HpTextPrefab, _Canvas.transform); GameObject go = GameObject.Instantiate(HpTextPrefab, _Canvas.transform);
go.GetComponent<SnowHpControl>().direction = HurtDirectin; go.GetComponent<SnowHpControl>().direction = HurtDirectin;
go.GetComponent<SnowHpControl>().CreateText(); go.GetComponent<SnowHpControl>().CreateText();
@ -180,7 +181,9 @@ public class Role : Fun
tag = Enum.GetName(typeof(Camp), camp); tag = Enum.GetName(typeof(Camp), camp);
updateAnimation(); updateAnimation();
//ApplyBuffs();
//AddBuff(storageBuff,this.CreateDecelerationBuff(10f,1f));
} }
@ -191,6 +194,7 @@ public class Role : Fun
public void AddBuff(List<Action<Role>> buffs, Action<Role> buffAction) public void AddBuff(List<Action<Role>> buffs, Action<Role> buffAction)
{ {
buffs.Add(buffAction); buffs.Add(buffAction);
Debug.LogError(this.name + "添加buff到"+ buffs);
} }
/// <summary> /// <summary>
@ -200,11 +204,12 @@ public class Role : Fun
{ {
foreach (var buff in PlayerBuff) foreach (var buff in PlayerBuff)
{ {
Debug.LogError(this.name + "执行buff");
buff.Invoke(this); // 将自己作为目标传递 buff.Invoke(this); // 将自己作为目标传递
} }
// 清空 Buff 列表,假设 Buff 是一次性的 // 清空 Buff 列表,假设 Buff 是一次性的
PlayerBuff.Clear(); //PlayerBuff.Clear();
} }
/// <summary> /// <summary>