using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UIElements; using System.Linq; public class SmallBullet : Bullet { private void Update() { switch (this.bulletMoveType) { //更具子弹的移动方式来移动 case BulletMoveType.PeerToPeer: if (IsMove) { this.gameObject.transform.Translate(Vector3.up * Time.deltaTime * bulletData.BulletSpeed*8); timer += Time.deltaTime; if (timer > BulletDeadTimer) { attackObj.bulltes.Remove(this.gameObject); Debug.Log("对象已成功移除。当前列表数量:" + attackObj.bulltes.Count); Destroy(this.gameObject); } } break; case BulletMoveType.PointToDirection: break; case BulletMoveType.Scope: break; } } private void OnTriggerEnter2D(Collider2D collision) { Role Crole = collision.gameObject.GetComponent(); if (Crole&&Target!= collision.gameObject) { if (Crole.camp != role.camp) { foreach (var buff in role.storageBuff) { if (!Crole.PlayerBuff.Contains(buff)) { Crole.PlayerBuff.Add(buff); } } Crole.ApplyBuffs(); // Debug.Log(this.role.gameObject.name + "进行攻击计算"); int direction = 0; if (collision.transform.position.x > transform.position.x) //子弹打到敌人左边,飘字显示到右边 { direction = 1; } Crole.bloodLoss(new object[] { Crole, attackObj.SplitAttack, attackObj.damageTyp, role }, direction); Crole.FlashRedEffect(); role.GetComponent().HarmNumber += attackObj.SplitAttack; Debug.Log("分裂攻击伤害"+ attackObj.SplitAttack); if (myBulletType != BulletType.Spraying) { if (animator == null) { Destroy(this.gameObject); } else { IsMove = false; //停止移动 Collider2D.enabled = false; //关闭碰撞体 transform.position = collision.transform.position; animator.SetTrigger("Boom"); } } } } } private void OnTriggerStay2D(Collider2D collision) { } private void OnTriggerExit2D(Collider2D collision) { } }