修子弹bug

This commit is contained in:
wulongxiao 2024-12-25 17:00:36 +08:00
parent 4eb6e3c01d
commit 6de0047de2

View File

@ -11,7 +11,6 @@ public enum BulletType
Bullet, Bullet,
Lightning, Lightning,
Spraying //Ô­µØÅçÉä Spraying //Ô­µØÅçÉä
} }
public enum BulletAttributes public enum BulletAttributes
{ {
@ -130,81 +129,88 @@ public class Bullet : MonoBehaviour
} }
else else
{ {
if (this.myBulletType== BulletType.Spraying)
{
NumberOfBulletAttacks += 1;
}
NumberOfBulletAttacks -= 1; NumberOfBulletAttacks -= 1;
}
foreach (var buff in role.storageBuff) foreach (var buff in role.storageBuff)
{
if (!Crole.PlayerBuff.Contains(buff))
{ {
Crole.PlayerBuff.Add(buff); if (!Crole.PlayerBuff.Contains(buff))
{
Crole.PlayerBuff.Add(buff);
}
} }
}
Crole.ApplyBuffs(); 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) //子弹打到敌人左边,飘字显示到右边
{
direction = 1;
}
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role }, direction);
attackObj.bulltes.Remove(this.gameObject);
if (myBulletType != BulletType.Spraying)
{
if (animator == null)
{ {
attackObj.bulltes.Remove(this.gameObject); direction = 1;
Destroy(this.gameObject);
} }
else Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role }, direction);
{ attackObj.bulltes.Remove(this.gameObject);
IsMove = false; //停止移动
Collider2D.enabled = false; //关闭碰撞体
transform.position = collision.transform.position;
animator.SetTrigger("Boom");
if (myBulletType != BulletType.Spraying)
{
if (animator == null)
{
attackObj.bulltes.Remove(this.gameObject);
Destroy(this.gameObject);
}
else
{
IsMove = false; //停止移动
Collider2D.enabled = false; //关闭碰撞体
transform.position = collision.transform.position;
animator.SetTrigger("Boom");
}
} }
}
if (bulletAttributes == BulletAttributes.Not) //无属性 if (bulletAttributes == BulletAttributes.Not) //无属性
{
Crole.FlashRedEffect();
}
if (bulletAttributes == BulletAttributes.Fire) //火
{
if (effectPres.Count == 1)
{ {
GameObject go = Instantiate(effectPres[0], collision.transform);
go.transform.position = new Vector2(collision.transform.position.x,
collision.transform.position.y + 0.2f);
go.GetComponent<Huo>().bullet = this;
Crole.FlashRedEffect(); Crole.FlashRedEffect();
//Debug.Log("创建火焰");
} }
} if (bulletAttributes == BulletAttributes.Fire) //火
if (bulletAttributes == BulletAttributes.Water) //水
{
if (effectPres.Count > 1)
{ {
GameObject go = Instantiate(effectPres[Random.Range(0, effectPres.Count - 1)],
collision.transform); if (effectPres.Count == 1)
go.transform.position = new Vector2(collision.transform.position.x, {
collision.transform.position.y - 0.2f); GameObject go = Instantiate(effectPres[0], collision.transform);
collision.transform.GetComponent<enemy>().SlowDown(0.2f, 3f); go.transform.position = new Vector2(collision.transform.position.x,
Crole.FlashRedEffect(1, 3f); collision.transform.position.y + 0.2f);
go.GetComponent<Huo>().bullet = this;
Crole.FlashRedEffect();
//Debug.Log("创建火焰");
}
} }
if (bulletAttributes == BulletAttributes.Water) //水
{
if (effectPres.Count > 1)
{
GameObject go = Instantiate(effectPres[Random.Range(0, effectPres.Count - 1)],
collision.transform);
go.transform.position = new Vector2(collision.transform.position.x,
collision.transform.position.y - 0.2f);
collision.transform.GetComponent<enemy>().SlowDown(0.2f, 3f);
Crole.FlashRedEffect(1, 3f);
}
}
} }
} }
} }