This commit is contained in:
wulongxiao 2024-12-25 16:47:54 +08:00
parent bd0c31fcf2
commit 729442fafa
2 changed files with 58 additions and 55 deletions

View File

@ -119,73 +119,77 @@ public class Bullet : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision)
{
if (NumberOfBulletAttacks > 0)
Role Crole = collision.gameObject.GetComponent<Role>();
if (Crole)
{
NumberOfBulletAttacks -= 1;
//Debug.Log("进入检测范围");
Role Crole = collision.gameObject.GetComponent<Role>();
if (Crole)
if (Crole.camp != role.camp)
{
if (Crole.camp != role.camp)
if (NumberOfBulletAttacks < 0)
{
foreach (var buff in role.storageBuff)
return;
}
else
{
NumberOfBulletAttacks -= 1;
}
foreach (var buff in role.storageBuff)
{
if (!Crole.PlayerBuff.Contains(buff))
{
if (!Crole.PlayerBuff.Contains(buff))
{
Crole.PlayerBuff.Add(buff);
}
Crole.PlayerBuff.Add(buff);
}
}
Crole.ApplyBuffs();
Crole.ApplyBuffs();
Debug.Log(this.role.gameObject.name + "进行攻击计算");
int direction = 0;
if (collision.transform.position.x > transform.position.x) //子弹打到敌人左边,飘字显示到右边
Debug.Log(this.role.gameObject.name + "进行攻击计算");
int direction = 0;
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)
{
direction = 1;
attackObj.bulltes.Remove(this.gameObject);
Destroy(this.gameObject);
}
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role }, direction);
attackObj.bulltes.Remove(this.gameObject);
if (myBulletType != BulletType.Spraying)
else
{
IsMove = false; //停止移动
Collider2D.enabled = false; //关闭碰撞体
transform.position = collision.transform.position;
animator.SetTrigger("Boom");
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();
//Debug.Log("创建火焰");
}
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();
//Debug.Log("创建火焰");
}
}
}
if (bulletAttributes == BulletAttributes.Water) //ˮ
@ -202,13 +206,8 @@ public class Bullet : MonoBehaviour
}
}
}
}
else
{
}
}
private float lastDamageTime = 0f;
private void OnTriggerStay2D(Collider2D collision)

View File

@ -36,6 +36,10 @@ public enum CharacterFlags
land = 1 << 1,
big = 1 << 2,
min = 1 << 3,
FlyBig=fly|big,
FlyMin=fly|min,
LandBig = land | big,
LandMin = land | min,
}
/// <summary>