| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using Sirenix.OdinInspector;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ChainShoot : SpecialSkills
- {
- [LabelText("弓箭预制体")] public GameObject arrow;
- [LabelText("连击间隔")] public float attackInterval;
- [LabelText("连击次数")] public float attackNum;
- public int num;
- public float time;
- public bool startAttack;
- private Vector3 attackDir;
- public override void Attack()
- {
- base.Attack();
- time = 0;
- num = 0;
- startAttack = true;
- }
- public void Update()
- {
- if (startAttack)
- {
- time += Time.deltaTime;
- if(time > attackInterval)
- {
- 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;
- }
- }
- }
- }
- 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);
- }
- }
|