From c1aef9f6a93dce205fe658923b08d6d21868a785 Mon Sep 17 00:00:00 2001 From: GL <2365963573@qq.com> Date: Tue, 17 Dec 2024 18:07:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Role/Attack.cs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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() {