diff --git a/Role/Attack.cs b/Role/Attack.cs index 25e7cf9..eb8f798 100644 --- a/Role/Attack.cs +++ b/Role/Attack.cs @@ -22,6 +22,10 @@ public class Attack : MonoBehaviour [Header("角色动画控制器")] public Animator animator; [Header("火焰动画控制器")] public Animator fireAni; + + [Header("子弹起始点")] public Transform BulletStartPos; + + public Vector2 direction; public float AttackScope { [DebuggerStepThrough] @@ -60,8 +64,13 @@ public class Attack : MonoBehaviour role.animationHighlight = 1; if (animator!=null) { + if (bulletPrefab.GetComponent().myBulletType != BulletType.Spraying) + { + direction = (targetRole.transform.position - transform.position).normalized; + } animator.SetInteger("State", 1); lastAttackTime = Time.time; // 更新上次攻击时间 + } else { @@ -134,6 +143,33 @@ public class Attack : MonoBehaviour } } + + + public void Pointattack() + { + + if (bulletPrefab == null) + { + Debug.LogError("子弹预制体为空"); + return; + } + + + + + for (int i = 0; i < bulletData.BulletScattering; i++) + { + // 改变子弹方向,根据角色自身的攻击范围来计算 + GameObject BulletGamobj = GameObject.Instantiate(bulletPrefab, this.transform.root); + BulletGamobj.GetComponent().role = role; + BulletGamobj.GetComponent().attackObj = this; + BulletGamobj.transform.up = direction; + BulletGamobj.transform.position = transform.position; + bulltes.Add(BulletGamobj); + } + + } + public void Fireattack() {