This commit is contained in:
GL 2024-12-17 18:07:43 +08:00
parent 2e5e8ae1d1
commit c1aef9f6a9

View File

@ -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<Bullet>().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<Bullet>().role = role;
BulletGamobj.GetComponent<Bullet>().attackObj = this;
BulletGamobj.transform.up = direction;
BulletGamobj.transform.position = transform.position;
bulltes.Add(BulletGamobj);
}
}
public void Fireattack()
{