攻击属性计算

This commit is contained in:
GL 2024-12-29 17:29:36 +08:00
parent bf88fb96a3
commit 44483bcb6a

View File

@ -1,22 +1,23 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using DG.Tweening; using DG.Tweening;
using TMPro;
public enum Camp public enum Camp
{/// <summary> {/// <summary>
/// 玩家 /// 玩家
/// </summary> /// </summary>
Player, Player,
/// <summary> /// <summary>
/// 怪物 /// 怪物
/// </summary> /// </summary>
Enemy, Enemy,
/// <summary> /// <summary>
/// 中立 /// 中立
/// </summary> /// </summary>
Neutral Neutral
} }
@ -29,6 +30,7 @@ public enum CharacterFlags
land = 1 << 1, land = 1 << 1,
big = 1 << 2, big = 1 << 2,
min = 1 << 3, min = 1 << 3,
FlyBig=fly|big, FlyBig=fly|big,
FlyMin=fly|min, FlyMin=fly|min,
LandBig = land | big, LandBig = land | big,
@ -36,38 +38,38 @@ public enum CharacterFlags
} }
/// <summary> /// <summary>
/// 角色基类,玩家处理事件 /// 角色基类,玩家处理事件
/// </summary> /// </summary>
[ExecuteInEditMode] [ExecuteInEditMode]
public class Role : Fun public class Role : Fun
{ {
[Header("Id")] public string id; [Header("Id")] public string id;
[Header("名称")] public string Name; [Header("名称")] public string Name;
[Header("阵营")] public Camp camp ; [Header("阵营")] public Camp camp ;
[Header("血量")] public float hp = 100f;//血量 [Header("血量")] public float hp = 100f;//血量
private float maxHp; private float maxHp;
[Header(("死亡动画编号"))] public int dieIndex=-1; [Header(("死亡动画编号"))] public int dieIndex=-1;
[Header("hp填充直接扣")] public Image Hpfiil; [Header("hp填充直接扣")] public Image Hpfiil;
[Header("hp填充慢慢扣")] public Image HpfiilYello; [Header("hp填充慢慢扣")] public Image HpfiilYello;
[Header("扣血填充")] public GameObject HpTextPrefab; [Header("扣血填充")] public GameObject HpTextPrefab;
[Header("自己的画布")]public Canvas _Canvas; [Header("自己的画布")]public Canvas _Canvas;
[Header("自己的图片")] public SpriteRenderer spriteRenderers; // 存储所有的SpriteRenderer组件 [Header("自己的图片")] public SpriteRenderer spriteRenderers; // 存储所有的SpriteRenderer组件
[Header("被打的方向")] public int HurtDirectin; [Header("被打的方向")] public int HurtDirectin;
public string Quality;//品质 public string Quality;//品质
public string Elements;//属性 public string Elements;//属性
public string Info;//详情 public string Info;//详情
public string SkillId;//技能 public string SkillId;//技能
public string AttackType;//攻击类型 public string AttackType;//攻击类型
public string AttackActionType;//攻击作用类型 public string AttackActionType;//攻击作用类型
public float AttackRange;//攻击范围 public float AttackRange;//攻击范围
public float AttackCD;//攻击CD public float AttackCD;//攻击CD
public float CritRate;//暴击率 public float CritRate;//暴击率
public float CriticalHitRateBonus;//暴击加成 public float CriticalHitRateBonus;//暴击加成
[Header("击杀数量")] public int killNum; [Header("击杀数量")] public int killNum;
public float Hp public float Hp
{ {
@ -81,35 +83,44 @@ public class Role : Fun
hp = value; hp = value;
// 更新血条显示 // 更新血条显示
if (Hpfiil != null) if (Hpfiil != null)
{ {
Hpfiil.fillAmount = hp / maxHp; Hpfiil.fillAmount = hp / maxHp;
// 使用 DOTween 动画平滑过渡血条填充 // 使用 DOTween 动画平滑过渡血条填充
DOTween.To(() => HpfiilYello.fillAmount, x => HpfiilYello.fillAmount = x, hp / maxHp, 0.8f) // 0.5f 为过渡时间 DOTween.To(() => HpfiilYello.fillAmount, x => HpfiilYello.fillAmount = x, hp / maxHp, 0.8f) // 0.5f 为过渡时间
.SetEase(Ease.InOutQuad); // 使用缓动效果,使血条变化更加平滑 .SetEase(Ease.InOutQuad); // 使用缓动效果,使血条变化更加平滑
} }
// 更新血量文本效果 // 更新血量文本效果
if (HpTextPrefab != null && hp < maxHp) if (HpTextPrefab != null && hp < maxHp)
{ {
hit(); hit();
Navigation.StopPathDoTween(0.2f); // 停止任何进行中的 DoTween 动画0.2s为示例值 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(); if (isGoodDamege)
go.GetComponent<Text>().text = (temp - hp).ToString("F0"); // 显示伤害值 {
go.GetComponent<SnowHpControl>().CreateText(true);
isGoodDamege = false;
}
else
{
go.GetComponent<SnowHpControl>().CreateText();
}
go.GetComponent<Text>().text = (temp - hp).ToString("F0"); // 显示伤害值
} }
// 判断角色是否死亡 // 判断角色是否死亡
if (hp <= 0) if (hp <= 0)
{ {
die(); // 执行死亡处理 die(); // 执行死亡处理
} }
} }
} }
[Header("掉落")] public int gold = 6; [Header("掉落")] public int gold = 6;
public int Gold public int Gold
{ {
[DebuggerStepThrough] [DebuggerStepThrough]
@ -117,47 +128,48 @@ public class Role : Fun
[DebuggerStepThrough] [DebuggerStepThrough]
set => gold = value; set => gold = value;
} }
[Header("攻击力")] private float attack = 10f; [Header("攻击力")] private float attack = 10f;
[Header("攻击力上限")] public float MaxAttack = 10f; [Header("攻击力上限")] public float MaxAttack = 10f;
[Header("攻击力下限")] public float MinAttack = 10f; [Header("攻击力下限")] public float MinAttack = 10f;
public bool isGoodDamege=false;//是否暴击
public float Attack public float Attack
{ {
get => attack; get => attack;
set => attack = value; set => attack = value;
} }
[Header("等级")] private int level = 1; [Header("等级")] private int level = 1;
public int Level public int Level
{ {
[DebuggerStepThrough] get => level; [DebuggerStepThrough] get => level;
[DebuggerStepThrough] set => level = value; [DebuggerStepThrough] set => level = value;
} }
[Header("物理护甲")] public int physicalArmor = 10;//物理护甲 [Header("物理护甲")] public int physicalArmor = 10;//物理护甲
[Header("魔法护甲")] public int magicArmor = 5;//魔法护甲 [Header("魔法护甲")] public int magicArmor = 5;//魔法护甲
[Header("导航组件")] public SimplePathfindingDoTween Navigation; [Header("导航组件")] public SimplePathfindingDoTween Navigation;
[System.Serializable ] [System.Serializable ]
public class AnimationList//动画list public class AnimationList//动画list
{ {
//[Header("动画是否循环")] public bool isloop = false; //[Header("动画是否循环")] public bool isloop = false;
[Header("动画图片")] public List<Sprite> value; // 字典的值 [Header("动画图片")] public List<Sprite> value; // 字典的值
[Header("角色动画帧数间隔(毫秒)")] public int CharacterAnimationFrameInterval = 50; [Header("角色动画帧数间隔(毫秒)")] public int CharacterAnimationFrameInterval = 50;
} }
[Header("角色动画")] public List<AnimationList> AnimationTree = new List<AnimationList>(); [Header("角色动画")] public List<AnimationList> AnimationTree = new List<AnimationList>();
[Header("角色动画播放")] public int animationHighlight = 0; [Header("角色动画播放")] public int animationHighlight = 0;
[Header("角色精灵位置")] public SpriteRenderer spriteRenderer; [Header("角色精灵位置")] public SpriteRenderer spriteRenderer;
[Header("角色Image位置")] public Image image; [Header("角色Image位置")] public Image image;
public delegate void AnimationItem(int AnimationItem); public delegate void AnimationItem(int AnimationItem);
public event AnimationItem OnAnimationStart; public event AnimationItem OnAnimationStart;
public event AnimationItem OnAnimationIng; public event AnimationItem OnAnimationIng;
public event AnimationItem OnAnimationEnd; public event AnimationItem OnAnimationEnd;
[Header("动画是否正常播放")] public bool isAnimationPlay = false;//动画是否正常播放 [Header("动画是否正常播放")] public bool isAnimationPlay = false;//动画是否正常播放
[Header("碰撞体")]public Collider2D mycollider; [Header("碰撞体")]public Collider2D mycollider;
[Header("攻击脚本")] public Attack attackClass; [Header("攻击脚本")] public Attack attackClass;
[Header("当前播放图片序列")] public int CurrentIndex; [Header("当前播放图片序列")] public int CurrentIndex;
public int hitIndex = 2;//受击动画索引 public int hitIndex = 2;//受击动画索引
public int normalIndex = 0;//移动动画索引 public int normalIndex = 0;//移动动画索引
public bool isHit=false;// public bool isHit=false;//
public List<BUff> buffList = new List<BUff>(); public List<BUff> buffList = new List<BUff>();
@ -171,12 +183,12 @@ public class Role : Fun
public SkillUp mySkillUp; public SkillUp mySkillUp;
/// <summary> /// <summary>
/// 储存buff /// 储存buff
/// </summary> /// </summary>
public List<Action<Role>> storageBuff = new List<Action<Role>>(); public List<Action<Role>> storageBuff = new List<Action<Role>>();
/// <summary> /// <summary>
/// 使用buff /// 使用buff
/// </summary> /// </summary>
public List<Action<Role>> PlayerBuff=new List<Action<Role>>(); public List<Action<Role>> PlayerBuff=new List<Action<Role>>();
@ -189,7 +201,7 @@ public class Role : Fun
maxHp = hp; maxHp = hp;
SetSelfInfo(); SetSelfInfo();
//SetAttackRange();//设置攻击范围 //SetAttackRange();//设置攻击范围
if (Application.isPlaying) if (Application.isPlaying)
{ {
if (attackClass) if (attackClass)
@ -205,32 +217,32 @@ public class Role : Fun
/// <summary> /// <summary>
/// 添加Buff /// 添加Buff
/// </summary> /// </summary>
/// <param name="buffAction"></param> /// <param name="buffAction"></param>
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);
UnityEngine.Debug.LogError(this.name + "添加buff到"+ buffs); UnityEngine.Debug.LogError(this.name + "添加buff到"+ buffs);
} }
/// <summary> /// <summary>
/// 执行所有当前 Buff /// 执行所有当前 Buff
/// </summary> /// </summary>
public void ApplyBuffs() public void ApplyBuffs()
{ {
foreach (var buff in PlayerBuff) foreach (var buff in PlayerBuff)
{ {
UnityEngine.Debug.LogError(this.name + "进入执行buff判断"); UnityEngine.Debug.LogError(this.name + "进入执行buff判断");
buff.Invoke(this); // 将自己作为目标传递 buff.Invoke(this); // 将自己作为目标传递
} }
// 清空 Buff 列表,假设 Buff 是一次性的 // 清空 Buff 列表,假设 Buff 是一次性的
PlayerBuff.Clear(); PlayerBuff.Clear();
} }
/// <summary> /// <summary>
/// 角色动画更新 /// 角色动画更新
/// </summary> /// </summary>
public async void updateAnimation() public async void updateAnimation()
{ {
@ -289,7 +301,7 @@ public class Role : Fun
{ {
SpawnPool.intance.DeadNumber += 1; SpawnPool.intance.DeadNumber += 1;
Destroy(gameObject); Destroy(gameObject);
// SpawnPool.intance.ReturnEnemyToPool(this.gameObject); // 回收当前敌人到池中 // SpawnPool.intance.ReturnEnemyToPool(this.gameObject); // 回收当前敌人到池中
// ResetAllStatus(); // ResetAllStatus();
} }
@ -303,7 +315,7 @@ public class Role : Fun
/// <summary> /// <summary>
/// 角色死亡 /// 角色死亡
/// </summary> /// </summary>
public virtual void die() public virtual void die()
{ {
@ -324,7 +336,7 @@ public class Role : Fun
} }
/// <summary> /// <summary>
/// 角色受到攻击 /// 角色受到攻击
/// </summary> /// </summary>
public virtual void hit() public virtual void hit()
{ {
@ -336,16 +348,16 @@ public class Role : Fun
} }
/// <summary> /// <summary>
/// 角色减速 /// 角色减速
/// </summary> /// </summary>
public void SlowDown(float num) public void SlowDown(float num)
{ {
Navigation.speedFactor *= num; Navigation.speedFactor *= num;
} }
/// <summary> /// <summary>
/// 单位更新buff /// 单位更新buff
/// </summary> /// </summary>
async void UpdateBuff()//单位buff更新 async void UpdateBuff()//单位buff更新
{ {
while (true) while (true)
{ {
@ -370,83 +382,83 @@ public class Role : Fun
{ {
buffList.Remove(item); buffList.Remove(item);
} }
await Task.Delay(100);//buff检测最小时间0.1秒执行一次 await Task.Delay(100);//buff检测最小时间0.1秒执行一次
} }
} }
/// <summary> /// <summary>
/// 重置角色所有状态 /// 重置角色所有状态
/// </summary> /// </summary>
public void ResetAllStatus() public void ResetAllStatus()
{ {
IsDead = false; IsDead = false;
// 重置血量 // 重置血量
Hp = 100f; Hp = 100f;
// 重置攻击力 // 重置攻击力
Attack = 10f; Attack = 10f;
// 重置护甲 // 重置护甲
physicalArmor = 10; physicalArmor = 10;
magicArmor = 5; magicArmor = 5;
// 重置等级 // 重置等级
Level = 1; Level = 1;
// 重置金币 // 重置金币
Gold = 10; Gold = 10;
// 清空 Buff 列表 // 清空 Buff 列表
buffList.Clear(); buffList.Clear();
// 如果有导航组件,停止当前的导航行为 // 如果有导航组件,停止当前的导航行为
if (Navigation != null) if (Navigation != null)
{ {
//Navigation.Stop(); // 假设你有 Stop 方法来停止导航 //Navigation.Stop(); // 假设你有 Stop 方法来停止导航
} }
// 重置角色动画 // 重置角色动画
animationHighlight = 0; animationHighlight = 0;
isAnimationPlay = false; isAnimationPlay = false;
// 重置碰撞体(根据需求是否需要调整) // 重置碰撞体(根据需求是否需要调整)
if (mycollider != null) if (mycollider != null)
{ {
mycollider.enabled = true; // 启用碰撞体 mycollider.enabled = true; // 启用碰撞体
} }
// 如果有其他需要重置的状态,可以在这里添加 // 如果有其他需要重置的状态,可以在这里添加
} }
public void FlashRedEffect(int color = 0, float time = 0.2f)//0、1 红、蓝 public void FlashRedEffect(int color = 0, float time = 0.2f)//0、1 红、蓝
{ {
// 如果spriteRenderer存在 // 如果spriteRenderer存在
if (spriteRenderer != null) if (spriteRenderer != null)
{ {
// 创建一个Sequence来确保动画按顺序执行 // 创建一个Sequence来确保动画按顺序执行
Sequence sequence = DOTween.Sequence(); Sequence sequence = DOTween.Sequence();
// 颜色变化 // 颜色变化
if (color == 0) if (color == 0)
{ {
// 变为红色并恢复白色 // 变为红色并恢复白色
sequence.Append(spriteRenderer.DOColor(UnityEngine.Color.red, 0.2f)) sequence.Append(spriteRenderer.DOColor(UnityEngine.Color.red, 0.2f))
.Append(spriteRenderer.DOColor(UnityEngine.Color.white, time)); .Append(spriteRenderer.DOColor(UnityEngine.Color.white, time));
} }
else if (color == 1) else if (color == 1)
{ {
// 更冷的深蓝色 // 更冷的深蓝色
UnityEngine.Color frostBlueWithAlpha = new UnityEngine.Color(0.2f, 0.5f, 1f); ; // 冰冻蓝色 UnityEngine.Color frostBlueWithAlpha = new UnityEngine.Color(0.2f, 0.5f, 1f); ; // 冰冻蓝色
// 变为蓝色并恢复白色 // 变为蓝色并恢复白色
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));
} }
// 开始执行Sequence // 开始执行Sequence
sequence.Play(); sequence.Play();
} }
} }
@ -454,13 +466,13 @@ public class Role : Fun
public void StopDoTween(float stopTime) public void StopDoTween(float stopTime)
{ {
// 暂停当前的动画 // 暂停当前的动画
transform.DOPause(); transform.DOPause();
// 插入一个自定义的延迟(僵直时间) // 插入一个自定义的延迟(僵直时间)
DOTween.To(() => 0f, x => { }, 0f, stopTime).OnKill(() => DOTween.To(() => 0f, x => { }, 0f, stopTime).OnKill(() =>
{ {
// 在延迟结束后恢复动画 // 在延迟结束后恢复动画
transform.DOPlay(); transform.DOPlay();
}); });
} }
@ -470,7 +482,7 @@ public class Role : Fun
if (camp==Camp.Player) if (camp==Camp.Player)
{ {
// Debug.Log("攻击力赋值==============================" + MengyaoInfo.Instance.m_Mengyao.Count); // Debug.Log("攻击力赋值==============================" + MengyaoInfo.Instance.m_Mengyao.Count);
foreach (Character character in MengyaoInfo.Instance.m_Mengyao) foreach (Character character in MengyaoInfo.Instance.m_Mengyao)
{ {
if (id ==character.Id) if (id ==character.Id)
@ -480,68 +492,82 @@ public class Role : Fun
MaxAttack = int.Parse(character.MaxAttack); MaxAttack = int.Parse(character.MaxAttack);
AttackCD = float.Parse(character.AttackCD); AttackCD = float.Parse(character.AttackCD);
CritRate = float.Parse(character.CritRate); CritRate = float.Parse(character.CritRate);
Quality=character.Quality;//品质 Quality=character.Quality;//品质
Elements=character.Elements;//属性 Elements=character.Elements;//属性
Info=character.Info;//详情 Info=character.Info;//详情
SkillId=character.SkillId;//技能 SkillId=character.SkillId;//技能
AttackType=character.AttackType;//攻击类型 AttackType=character.AttackType;//攻击类型
AttackActionType=character.AttackActionType;//攻击作用类型 AttackActionType=character.AttackActionType;//攻击作用类型
CriticalHitRateBonus = float.Parse(character.CriticalHitRateBonus); CriticalHitRateBonus = float.Parse(character.CriticalHitRateBonus);
AttackRange = float.Parse(character.AttackRange); AttackRange = float.Parse(character.AttackRange);
//Debug.Log("攻击力赋值++++++++++++++++++++++++++++++"); //Debug.Log("攻击力赋值++++++++++++++++++++++++++++++");
} }
} }
} }
} }
/// <summary> /// <summary>
/// 计算伤害 /// 计算伤害
/// </summary> /// </summary>
/// <param name="self">造成者</param> /// <param name="self">造成者</param>
/// <param name="Target">目标</param> /// <param name="Target">目标</param>
/// <returns></returns> /// <returns></returns>
public float DamageCreate(Role Target)//伤害生成 /// 萌妖每次攻击对敌人造成伤害=a*(1+g+d+e)*(1-b/100)*c*(1+h)
//暴击情况下萌妖每次攻击对敌人造成伤害=a* (1+g+d+e)*(1-b/100)*c* (1+h)*(2+f)
public float DamageCreate(Role Target)//伤害生成
{ {
// 生成普通伤害 // 生成普通伤害
float hurt = UnityEngine.Random.Range(MinAttack, MaxAttack); float hurt = UnityEngine.Random.Range(MinAttack, MaxAttack);
// 判断是否暴击 // 判断是否暴击
float critChance = UnityEngine.Random.Range(0f, 1f); // 生成一个0到1之间的随机数 float critChance = UnityEngine.Random.Range(0f, 1f); // 生成一个0到1之间的随机数
//敌人防御力
float TargetDefense = Target.gameObject.GetComponent<enemy>().Defense;
if (critChance < CritRate*(1+mySkillUp.CriticalRate)) // 如果暴击发生
if (critChance < CritRate*(1+mySkillUp.CriticalRate)) // 如果暴击发生
{ {
// 计算暴击伤害(普通伤害乘以暴击加成) // 计算暴击伤害(普通伤害乘以暴击加成)
hurt *= (1 + CriticalHitRateBonus*(1+ mySkillUp.CriticalDamage)); hurt *= (2 + CriticalHitRateBonus*(1+ mySkillUp.CriticalDamage));
//Debug.Log("暴击发生!伤害增加:" + num); isGoodDamege = true;
UnityEngine.Debug.Log("暴击发生!伤害增加");
} }
hurt *= (1 + mySkillUp.DamageUp); hurt *= (1 + mySkillUp.DamageUp);
// Debug.LogError("伤害加成:"+ mySkillUp.DamageUp); // Debug.LogError("伤害加成:"+ mySkillUp.DamageUp);
if (Target.hasfalg(CharacterFlags.big)) // 如果是大型敌人 if (Target.hasfalg(CharacterFlags.big)) // 如果是大型敌人
{ {
hurt*=(1+mySkillUp.DamageOfBig); hurt*=(1+mySkillUp.DamageOfBig);
//Debug.LogError("大型敌人加成"); //Debug.LogError("大型敌人加成");
} }
if (Target.hasfalg(CharacterFlags.min)) // 如果是小型敌人 if (Target.hasfalg(CharacterFlags.min)) // 如果是小型敌人
{ {
hurt *= (1 + mySkillUp.DamageOfMin); hurt *= (1 + mySkillUp.DamageOfMin);
//Debug.LogError("小型敌人加成"); //Debug.LogError("小型敌人加成");
} }
if (Target.hasfalg(CharacterFlags.fly)) // 如果是飞行敌人 if (Target.hasfalg(CharacterFlags.fly)) // 如果是飞行敌人
{ {
hurt *= (1 + mySkillUp.DamageOfSky); hurt *= (1 + mySkillUp.DamageOfSky);
//Debug.LogError("飞行敌人加成"); //Debug.LogError("飞行敌人加成");
} }
if (Target.hasfalg(CharacterFlags.land)) // 如果是地面敌人 if (Target.hasfalg(CharacterFlags.land)) // 如果是地面敌人
{ {
hurt *= (1 + mySkillUp.DamageOfland); hurt *= (1 + mySkillUp.DamageOfland);
//Debug.LogError("地面敌人加成"); //Debug.LogError("地面敌人加成");
} }
if (hurt * (1 - TargetDefense / 100) < 1)
{
hurt = 1;
}
else
{
hurt *=(1- TargetDefense/100) ;
}
hurt *= (1 + WuxingDamage(Target.gameObject.GetComponent<enemy>()));//计算五行属性伤害
if (GetComponent<enemy>()) if (GetComponent<enemy>())
{ {
GetComponent<enemy>().HarmNumber += Mathf.Round(hurt); GetComponent<enemy>().HarmNumber += Mathf.Round(hurt);
@ -554,6 +580,29 @@ public class Role : Fun
} }
public float WuxingDamage(enemy Target)//五行属性伤害计算 返回倍率减伤或增加伤害
{
// 克制关系表(使用二维数组或字典表示)
// 行:敌人属性,列:萌妖属性
// 正数表示加成负数表示减成0表示无影响
float[,] attributeRelations = new float[5, 5]
{
// 金 木 水 火 土
{ 0f, 0.5f, 0f, -0.25f, 0f }, // 金
{ -0.25f, 0f, 0f, 0f, 0.5f }, // 木
{ 0f, 0f, 0f, 0.5f, -0.25f }, // 水
{ 0.5f, 0f, -0.25f, 0f, 0f }, // 火
{ 0f, -0.25f, 0.5f, 0f, 0f } // 土
};
// 获取克制关系
float relation = attributeRelations[ (int)GetComponent<enemy>().elementType,(int)Target.elementType];
// 如果是正数,表示加成,增加伤害
// 如果是负数,表示减成,减少伤害
UnityEngine.Debug.Log("属性关系:"+"萌妖"+ GetComponent<enemy>().elementType+"::"+"敌人"+ Target.elementType+"伤害加成"+relation);
return relation;
}
} }