|
|
@@ -1,52 +1,57 @@
|
|
|
+using Sirenix.OdinInspector;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
|
|
|
public class ChainShoot : SpecialSkills
|
|
|
{
|
|
|
- [Header("弓箭预制体")]
|
|
|
- public GameObject arrow;
|
|
|
+ [LabelText("弓箭预制体")] public GameObject arrow;
|
|
|
+ [LabelText("连击间隔")] public float attackInterval;
|
|
|
+ [LabelText("连击次数")] public float attackNum;
|
|
|
|
|
|
- [Header("齐发参数")]
|
|
|
public int num;
|
|
|
- public float angle;
|
|
|
- public float arrivalAngle;
|
|
|
- public int damage;
|
|
|
- public bool tryy;
|
|
|
- public float gravity = 9.8f; // 重力加速度
|
|
|
- public float speed;
|
|
|
+ public float time;
|
|
|
+ public bool startAttack;
|
|
|
+
|
|
|
+ private Vector3 attackDir;
|
|
|
|
|
|
public override void Attack()
|
|
|
{
|
|
|
base.Attack();
|
|
|
- Shoot();
|
|
|
+ time = 0;
|
|
|
+ num = 0;
|
|
|
+ startAttack = true;
|
|
|
}
|
|
|
|
|
|
- public void Shoot()
|
|
|
+ public void Update()
|
|
|
{
|
|
|
- float angleInterval = num > 1 ? angle / (float)(num - 1) : 0f;
|
|
|
- for (int i = 0; i < num; i++)
|
|
|
+ if (startAttack)
|
|
|
{
|
|
|
- float ang;
|
|
|
- GameObject obj = PoolManager.Instantiate(arrow);
|
|
|
- MultiArrowController arrowController = obj.GetComponent<MultiArrowController>();
|
|
|
- if (arrowController == null)
|
|
|
- {
|
|
|
- arrowController = obj.AddComponent<MultiArrowController>();
|
|
|
- }
|
|
|
- if (owner.bodyTrans.localScale.x > 0)
|
|
|
- {
|
|
|
- ang = 180 - arrivalAngle - angle / 2 + i * angleInterval;
|
|
|
- }
|
|
|
- else
|
|
|
+ time += Time.deltaTime;
|
|
|
+ if(time > attackInterval)
|
|
|
{
|
|
|
- ang = arrivalAngle - angle / 2 + i * angleInterval;
|
|
|
+ time = 0;
|
|
|
+ if(owner.targetCharacter == null)
|
|
|
+ {
|
|
|
+ startAttack = false;
|
|
|
+ owner.ChangeState(CharacterState.Idle);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ attackDir = (owner.targetCharacter.beSearchTrigger.transform.position - transform.position).normalized;
|
|
|
+ Shoot();
|
|
|
+ num ++;
|
|
|
+ if(num >= attackNum)
|
|
|
+ {
|
|
|
+ startAttack = false;
|
|
|
+ }
|
|
|
}
|
|
|
- ang = ang / 180 * Mathf.PI;
|
|
|
- Vector3 dir = new Vector3(Mathf.Cos(ang), Mathf.Sin(ang), 0);
|
|
|
- arrowController.Initialize(gravity, speed);
|
|
|
- obj.GetComponent<Bullet>().BeShoot(owner, transform.position, dir, false);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void Shoot()
|
|
|
+ {
|
|
|
+ Bullet bullet = PoolManager.Instantiate(arrow).GetComponent<Bullet>();
|
|
|
+ AttackController.AttackMethod attackMethod = owner.attackController.attackMethod_march[0];
|
|
|
+ bullet.BeShoot(owner, transform.position, attackDir,true,target:owner.targetCharacter);
|
|
|
+ }
|
|
|
}
|