This commit is contained in:
GL 2025-01-04 20:08:40 +08:00
parent 5632ff401d
commit 151503e59d
4 changed files with 38 additions and 9 deletions

View File

@ -42,7 +42,8 @@ public class Attack : MonoBehaviour
[Header("子弹分裂个数")] public int splitNum = 2;
[Header("分裂子弹伤害")] public float SplitAttack = 10;
[Header("子弹围绕范围")] public float RunRange = 3f;
[Header("是否造成额外伤害")] public bool haveAddDamage = false;
[Header("额外伤害类型")] public DamageType AdddamageType=DamageType.magicDamage;
public bool isAttack = true;
public bool flag = false;
[HideInInspector] public float timer = 0;
@ -446,6 +447,8 @@ public class Attack : MonoBehaviour
private int lastBulletNumber = 0; // 记录上一次的 BulletNumber
private float lastbulletLengthAdd = 0; // 记录上一次的 BulletNumber
public float bulletLengthAdd = 0f; // 子弹的长度属性
public void RunRangeattack() // 生成在周围
{
@ -456,10 +459,10 @@ public class Attack : MonoBehaviour
}
// 只有在 BulletNumber 变化时,才重新生成子弹
if (BulletNumber != lastBulletNumber)
if (BulletNumber != lastBulletNumber||lastbulletLengthAdd!=bulletLengthAdd) // 检查 BulletNumber 和 bulletLength 是否变化
{
// 销毁现有的所有子弹
if (bulltes.Count>0)
if (bulltes.Count > 0)
{
foreach (var bullet in bulltes)
{
@ -467,7 +470,6 @@ public class Attack : MonoBehaviour
}
bulltes.Clear(); // 清空子弹列表
}
// 计算子弹发射的圆周角度间隔
float angleStep = 360f / BulletNumber; // 计算每个子弹之间的角度间隔
@ -504,14 +506,24 @@ public class Attack : MonoBehaviour
// 设置子弹的朝向和位置
BulletGamobj.transform.up = scatterDirection; // 让子弹的"up"方向指向计算出的角度
BulletGamobj.transform.position = position; // 更新子弹的位置
if (lastbulletLengthAdd != bulletLengthAdd)
{
// 根据 bulletLength 设置子弹的长度
BulletGamobj.transform.localScale = new Vector3(BulletGamobj.transform.localScale.x + bulletLengthAdd, BulletGamobj.transform.localScale.y, BulletGamobj.transform.localScale.z);
}
}
// 更新记录的 BulletNumber
// 更新记录的 BulletNumber 和 bulletLength
lastBulletNumber = BulletNumber;
lastbulletLengthAdd = bulletLengthAdd;
}
}
}

View File

@ -55,7 +55,7 @@ public class Fun : Base
/// 扣血 传入参数 目标,伤害值,攻击类型,使用者子弹射来的方向0是右边1是左边
/// </summary>
/// <param name="objects"></param>
public void bloodLoss(object[] objects,int direction=1)//目标,伤害值,攻击类型,使用者,子弹射来的方向
public void bloodLoss(object[] objects,int direction=1)//目标,伤害值,攻击类型,使用者,子弹射来的方向
{
Role targetAudience = (Role)objects[0];
float harm = (float)objects[1];
@ -70,6 +70,8 @@ public class Fun : Base
break;
case DamageType.magicDamage://魔法伤害
finalDamage -= targetAudience.magicArmor;
targetAudience.isMoFa = true;
Debug.Log("魔法伤害");
break;
case DamageType.noAttributeDamage://无属性伤害
finalDamage -= 0;

View File

@ -71,7 +71,7 @@ public class Role : Fun
public float CritRate;//暴击率
public float CriticalHitRateBonus;//暴击加成
[Header("击杀数量")] public int killNum;
[Header("是不是魔法伤害")] public bool isMoFa=false;
public float Hp
{
get => hp;
@ -115,9 +115,20 @@ public class Role : Fun
{
go.GetComponent<SnowHpControl>().CreateText();
}
if (temp - hp>0)
{
go.GetComponent<Text>().text = (temp - hp).ToString("F0"); // 显示伤害值
if (isMoFa)
{
go.GetComponent<Text>().text = "<color=blue>" + (temp - hp).ToString("F0") + "</color>"; // 显示伤害值
isMoFa = false;
}
else
{
go.GetComponent<Text>().text = (temp - hp).ToString("F0"); // 显示伤害值
}
}
}

View File

@ -51,6 +51,10 @@ public class RunRangeBullet : Bullet
direction = 1;
}
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(Crole.GetComponent<Role>()), attackObj.damageTyp, role }, direction);
if (attackObj.haveAddDamage)
{
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(Crole.GetComponent<Role>())*0.3f, attackObj.AdddamageType, role }, direction);
}
Crole.FlashRedEffect();