hhl
This commit is contained in:
parent
2cb47878a0
commit
37c9725786
@ -44,6 +44,7 @@ public class Attack : MonoBehaviour
|
|||||||
[Header("子弹围绕范围")] public float RunRange = 3f;
|
[Header("子弹围绕范围")] public float RunRange = 3f;
|
||||||
[Header("是否造成额外伤害")] public bool haveAddDamage = false;
|
[Header("是否造成额外伤害")] public bool haveAddDamage = false;
|
||||||
[Header("额外伤害类型")] public DamageType AdddamageType=DamageType.magicDamage;
|
[Header("额外伤害类型")] public DamageType AdddamageType=DamageType.magicDamage;
|
||||||
|
[Header("子弹爆炸范围")] public float BoomRange = 1;
|
||||||
public bool isAttack = true;
|
public bool isAttack = true;
|
||||||
public bool flag = false;
|
public bool flag = false;
|
||||||
[HideInInspector] public float timer = 0;
|
[HideInInspector] public float timer = 0;
|
||||||
|
@ -84,7 +84,7 @@ public class Bullet : MonoBehaviour
|
|||||||
[Header("销毁时间,默认是10f")] public float BulletDeadTimer = 10f;
|
[Header("销毁时间,默认是10f")] public float BulletDeadTimer = 10f;
|
||||||
[Header("子弹动画")] public Animator animator;
|
[Header("子弹动画")] public Animator animator;
|
||||||
[Header("子弹移动参数")] public bool IsMove = true;
|
[Header("子弹移动参数")] public bool IsMove = true;
|
||||||
[Header("×Óµ¯ÅöײÌå")] public Collider2D Collider2D;
|
[Header("子弹碰撞体")] public CircleCollider2D Collider2D;
|
||||||
[Header("子弹特效预制体")] public List<GameObject> effectPres = new List<GameObject>();
|
[Header("子弹特效预制体")] public List<GameObject> effectPres = new List<GameObject>();
|
||||||
private float timer = 0;
|
private float timer = 0;
|
||||||
[Header("子弹攻击数量")] public int NumberOfBulletAttacks = 1;
|
[Header("子弹攻击数量")] public int NumberOfBulletAttacks = 1;
|
||||||
@ -92,6 +92,7 @@ public class Bullet : MonoBehaviour
|
|||||||
[Header("子弹是否不锁定目标")] public bool noLockEnemy=false;
|
[Header("子弹是否不锁定目标")] public bool noLockEnemy=false;
|
||||||
[Header("子弹是否会分裂")] public bool Cansplit = false;
|
[Header("子弹是否会分裂")] public bool Cansplit = false;
|
||||||
[Header("分裂子弹的预制体")] public GameObject smallBulletPrefab;
|
[Header("分裂子弹的预制体")] public GameObject smallBulletPrefab;
|
||||||
|
[Header("子弹是否会爆炸")] public bool CanBoom = false;
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
switch (this.bulletMoveType)
|
switch (this.bulletMoveType)
|
||||||
@ -167,28 +168,43 @@ public class Bullet : MonoBehaviour
|
|||||||
{
|
{
|
||||||
direction = 1;
|
direction = 1;
|
||||||
}
|
}
|
||||||
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(Crole.GetComponent<Role>()), attackObj.damageTyp, role }, direction);
|
if (!CanBoom)//判断子弹是否会爆炸
|
||||||
attackObj.bulltes.Remove(this.gameObject);
|
|
||||||
|
|
||||||
if (myBulletType != BulletType.Spraying)
|
|
||||||
{
|
{
|
||||||
|
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(Crole.GetComponent<Role>()), attackObj.damageTyp, role }, direction);
|
||||||
|
attackObj.bulltes.Remove(this.gameObject);
|
||||||
if (animator == null)
|
if (myBulletType != BulletType.Spraying)
|
||||||
{
|
{
|
||||||
SplitBullet();
|
|
||||||
attackObj.bulltes.Remove(this.gameObject);
|
|
||||||
Destroy(this.gameObject);
|
if (animator == null)
|
||||||
|
{
|
||||||
|
SplitBullet();
|
||||||
|
attackObj.bulltes.Remove(this.gameObject);
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsMove = false; //停止移动
|
||||||
|
Collider2D.enabled = false; //关闭碰撞体
|
||||||
|
transform.position = collision.transform.position;
|
||||||
|
animator.SetTrigger("Boom");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (animator!=null)
|
||||||
{
|
{
|
||||||
IsMove = false; //停止移动
|
IsMove = false; //停止移动
|
||||||
Collider2D.enabled = false; //关闭碰撞体
|
Collider2D.enabled = false; //关闭碰撞体
|
||||||
transform.position = collision.transform.position;
|
transform.position = collision.transform.position;
|
||||||
animator.SetTrigger("Boom");
|
animator.SetTrigger("Boom");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (bulletAttributes == BulletAttributes.Not) //无属性
|
if (bulletAttributes == BulletAttributes.Not) //无属性
|
||||||
{
|
{
|
||||||
@ -319,4 +335,38 @@ public class Bullet : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void BulletBoom() // 子弹爆炸
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// 扩展碰撞体的大小,模拟爆炸范围
|
||||||
|
float explosionRadius = attackObj.BoomRange; // 设置爆炸的半径大小
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 检测爆炸范围内的敌人
|
||||||
|
Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(transform.position, explosionRadius);
|
||||||
|
|
||||||
|
foreach (var enemyCollider in hitEnemies)
|
||||||
|
{
|
||||||
|
Role enemyRole = enemyCollider.gameObject.GetComponent<Role>();
|
||||||
|
if (enemyRole != null && enemyRole.camp != role.camp) // 如果是敌人并且属于不同的阵营
|
||||||
|
{
|
||||||
|
// 计算伤害值,可以根据子弹的类型或其他参数来调整
|
||||||
|
float damage = role.DamageCreate(enemyRole);
|
||||||
|
|
||||||
|
// 扣血操作
|
||||||
|
enemyRole.bloodLoss(new object[] { enemyRole, damage, attackObj.damageTyp, role });
|
||||||
|
|
||||||
|
enemyRole.FlashRedEffect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 销毁当前子弹
|
||||||
|
attackObj.bulltes.Remove(this.gameObject);
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user