修改
This commit is contained in:
parent
2e5e8ae1d1
commit
c1aef9f6a9
@ -22,6 +22,10 @@ public class Attack : MonoBehaviour
|
|||||||
|
|
||||||
[Header("角色动画控制器")] public Animator animator;
|
[Header("角色动画控制器")] public Animator animator;
|
||||||
[Header("火焰动画控制器")] public Animator fireAni;
|
[Header("火焰动画控制器")] public Animator fireAni;
|
||||||
|
|
||||||
|
[Header("子弹起始点")] public Transform BulletStartPos;
|
||||||
|
|
||||||
|
public Vector2 direction;
|
||||||
public float AttackScope
|
public float AttackScope
|
||||||
{
|
{
|
||||||
[DebuggerStepThrough]
|
[DebuggerStepThrough]
|
||||||
@ -60,8 +64,13 @@ public class Attack : MonoBehaviour
|
|||||||
role.animationHighlight = 1;
|
role.animationHighlight = 1;
|
||||||
if (animator!=null)
|
if (animator!=null)
|
||||||
{
|
{
|
||||||
|
if (bulletPrefab.GetComponent<Bullet>().myBulletType != BulletType.Spraying)
|
||||||
|
{
|
||||||
|
direction = (targetRole.transform.position - transform.position).normalized;
|
||||||
|
}
|
||||||
animator.SetInteger("State", 1);
|
animator.SetInteger("State", 1);
|
||||||
lastAttackTime = Time.time; // 更新上次攻击时间
|
lastAttackTime = Time.time; // 更新上次攻击时间
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -135,6 +144,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()
|
public void Fireattack()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user