Demonic.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. using Spine.Unity;
  2. using Spine;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using Sirenix.OdinInspector;
  7. public class Demonic : MoveCharacter
  8. {
  9. [FoldoutGroup("组件")] [DisplayOnly]public SearchState searchState;
  10. [Header("友方单位属性")]
  11. public SoldierType soldierType; //当前士兵属于什么兵种
  12. public PlayerController player; //召唤师
  13. public int playerID;
  14. public int id;
  15. public float costMp = 10;
  16. public bool isBack = false; //往反方向走
  17. public int baseSortingOrder;
  18. public float runSpeed;
  19. public float summonTime;
  20. private bool isFreeze; //冻结rb
  21. [Header("锁魂塔")]
  22. public bool isReturnSoulTower;
  23. public Vector3 origSoulPos;
  24. public bool isRecorded;
  25. [Header("攻击")]
  26. [SerializeField]
  27. private int curAttackID;
  28. private AttackController.AttackMethod[] am;
  29. private int len;
  30. private float pastAttackTime;
  31. private bool isConAttack; //连续攻击,不切idle动画
  32. [Header("八卦")]
  33. public float adsorbSpeed; //八卦吸附的速度
  34. [HideInInspector] public Vector3 adsorbTarget; //八卦胖子吸附时目标位置的X
  35. private float adsorbTime; //八卦吸附中的时间
  36. public GameObject effectPrefab; //八卦卦象效果
  37. [Header("掉落魂")]
  38. public int dropSoulMax = 3;
  39. public int dropSoulMin = 1;
  40. public float dropSoulAngle = 60f;
  41. private void Start()
  42. {
  43. am = attackController.attackMethod;
  44. len = am.Length;
  45. }
  46. private void OnDisable()
  47. {
  48. PlayersInput.instance[playerID].OnDemonicRecycle(this);
  49. curAttackID = 0;
  50. }
  51. public override void FixedUpdate()
  52. {
  53. OnSearchState();
  54. OnState();
  55. }
  56. public bool SearchTarget()
  57. {
  58. targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly,attackController.curAttackMethod.searchMode);
  59. if (targetCharacter != null)
  60. {
  61. return true;
  62. }
  63. else
  64. {
  65. return false;
  66. }
  67. }
  68. public void ChangeSearchState(SearchState newState)
  69. {
  70. switch (searchState)
  71. {
  72. case SearchState.NoTarget:
  73. break;
  74. case SearchState.InSearchScope:
  75. break;
  76. case SearchState.InAttackScope:
  77. break;
  78. default:
  79. break;
  80. }
  81. searchState = newState;
  82. switch (searchState)
  83. {
  84. case SearchState.NoTarget:
  85. targetCharacter = null;
  86. break;
  87. case SearchState.InSearchScope:
  88. break;
  89. case SearchState.InAttackScope:
  90. break;
  91. default:
  92. break;
  93. }
  94. }
  95. public void OnSearchState()
  96. {
  97. switch (searchState)
  98. {
  99. case SearchState.NoTarget:
  100. if (SearchTarget())
  101. {
  102. ChangeSearchState(SearchState.InSearchScope);
  103. break;
  104. }
  105. //向玩家基地移动
  106. break;
  107. case SearchState.InSearchScope:
  108. if (!SearchTarget())
  109. {
  110. targetCharacter = null;
  111. ChangeSearchState(SearchState.NoTarget);
  112. break;
  113. }
  114. attackDis = attackController.attackDistance + targetCharacter.beHitDistance;
  115. if (targetCharacter != null && Mathf.Abs(targetCharacter.transform.position.x - transform.position.x) <= attackDis)
  116. {
  117. ChangeSearchState(SearchState.InAttackScope);
  118. break;
  119. }
  120. break;
  121. case SearchState.InAttackScope:
  122. if (targetCharacter != null)
  123. {
  124. //判断是否在射程夹角内
  125. AttackController.AttackMethod am = attackController.curAttackMethod;
  126. if (am.attackType == AttackController.AttackType.Shoot && am.id != 0)
  127. {
  128. Vector3 dir = targetCharacter.beSearchTrigger.transform.position - transform.position;
  129. float angle = Vector3.Angle(dir, Vector3.left * bodyTrans.localScale.x);
  130. if ((dir.y > 0 && angle > am.maxUpAngle) || (dir.y < 0 && angle > am.maxDownAngle))
  131. {
  132. ChangeSearchState(SearchState.NoTarget);
  133. break;
  134. }
  135. }
  136. attackDis = attackController.attackDistance + targetCharacter.beHitDistance;
  137. if (!targetCharacter.gameObject.activeInHierarchy || targetCharacter.isDie
  138. || Mathf.Abs(targetCharacter.transform.position.x - transform.position.x) > attackDis)
  139. {
  140. ChangeSearchState(SearchState.NoTarget);
  141. }
  142. }
  143. else
  144. {
  145. ChangeSearchState(SearchState.NoTarget);
  146. }
  147. break;
  148. default:
  149. break;
  150. }
  151. }
  152. public override Vector3 GetMoveDir()
  153. {
  154. Vector3 moveDir = Vector3.zero;
  155. switch (searchState)
  156. {
  157. case SearchState.NoTarget:
  158. if (TowerMap.enemyTowers.Count == 0)
  159. {
  160. moveDir = Vector3.left;
  161. break;
  162. }
  163. float minDistance = Mathf.Infinity;
  164. int id = -1;
  165. for (int i = 0; i < TowerMap.enemyTowers.Count; i++)
  166. {
  167. EnemyTower enemyTower = TowerMap.enemyTowers[i].GetComponent<EnemyTower>();
  168. if (transform.position.y >
  169. enemyTower.transform.position.y + enemyTower.height)
  170. {
  171. continue;
  172. }
  173. float distance = Vector3.Distance(transform.position,
  174. TowerMap.enemyTowers[i].transform.position);
  175. if (distance < minDistance)
  176. {
  177. minDistance = distance;
  178. id = i;
  179. }
  180. }
  181. if (id == -1)
  182. {
  183. moveDir = Vector3.left;
  184. break;
  185. }
  186. if (bodyTrans.position.x > TowerMap.enemyTowers[id].transform.position.x)
  187. {
  188. moveDir = Vector3.left;
  189. }
  190. else
  191. {
  192. moveDir = Vector3.right;
  193. }
  194. break;
  195. case SearchState.InSearchScope:
  196. if (targetCharacter)
  197. {
  198. if (targetCharacter.transform.position.x - transform.position.x < 0)
  199. {
  200. moveDir = Vector3.left;
  201. }
  202. else
  203. {
  204. moveDir = Vector3.right;
  205. }
  206. }
  207. else
  208. {
  209. moveDir = Vector3.zero;
  210. }
  211. break;
  212. case SearchState.InAttackScope:
  213. if (targetCharacter)
  214. {
  215. if (targetCharacter.transform.position.x - transform.position.x < 0)
  216. {
  217. moveDir = Vector3.left;
  218. }
  219. else
  220. {
  221. moveDir = Vector3.right;
  222. }
  223. }
  224. else
  225. {
  226. moveDir = Vector3.zero;
  227. }
  228. break;
  229. default:
  230. break;
  231. }
  232. if (!isBack)
  233. {
  234. return moveDir;
  235. }
  236. return -moveDir;
  237. }
  238. public bool GetAttack()
  239. {
  240. if (searchState == SearchState.InAttackScope)
  241. {
  242. return true;
  243. }
  244. return false;
  245. }
  246. public override void OnState()
  247. {
  248. base.OnState();
  249. if (state == CharacterState.None)
  250. {
  251. return;
  252. }
  253. //hurtKeepTime -= Time.deltaTime;
  254. dieKeepTime -= Time.deltaTime;
  255. invincibleTime -= Time.deltaTime;
  256. pastAttackTime += Time.deltaTime;
  257. Vector3 leftDir = GetMoveDir();
  258. bool isAttack = GetAttack();
  259. Vector3 velocity = rb.velocity;
  260. Quaternion targetQt = Quaternion.Euler(Vector3.zero);
  261. switch (state)
  262. {
  263. case CharacterState.Idle:
  264. if (isAdjustHeight == 1)
  265. {
  266. ChangeState(CharacterState.Rise);
  267. break;
  268. }
  269. if (isAttack)
  270. {
  271. if (pastAttackTime >= attackController.attackInterval)
  272. {
  273. Attack_march();
  274. }
  275. }
  276. else
  277. {
  278. if (!foot.TrigGround && !canFly)
  279. {
  280. if (rb.velocity.y > 0)
  281. {
  282. ChangeState(CharacterState.Rise);
  283. break;
  284. }
  285. else
  286. {
  287. ChangeState(CharacterState.Fall);
  288. break;
  289. }
  290. }
  291. if (leftDir.x > 0.3f || leftDir.x < -0.3f)
  292. {
  293. ChangeState(CharacterState.Run);
  294. break;
  295. }
  296. velocity.x = velocityAddition;
  297. velocity.y = 0;
  298. if (!foot.haveGravity)
  299. {
  300. transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
  301. targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
  302. }
  303. if (RotLerpTime < 1)
  304. {
  305. RotLerpTime += RotLerpSpeed * Time.deltaTime;
  306. transform.rotation = Quaternion.Lerp(transform.rotation, targetQt, RotLerpTime);
  307. }
  308. else
  309. {
  310. transform.rotation = targetQt;
  311. }
  312. rb.velocity = velocity;
  313. }
  314. break;
  315. case CharacterState.Run:
  316. if (isAttack)
  317. {
  318. if (pastAttackTime >= attackController.attackInterval)
  319. {
  320. Attack_march();
  321. }
  322. else
  323. {
  324. ChangeState(CharacterState.Idle);
  325. }
  326. }
  327. else
  328. {
  329. if (!foot.TrigGround && !canFly)
  330. {
  331. if (rb.velocity.y > 0)
  332. {
  333. ChangeState(CharacterState.Rise);
  334. break;
  335. }
  336. else
  337. {
  338. ChangeState(CharacterState.Fall);
  339. break;
  340. }
  341. }
  342. if (leftDir.x < 0.3f && leftDir.x > -0.3f)
  343. {
  344. ChangeState(CharacterState.Idle);
  345. break;
  346. }
  347. if (leftDir.x > 0.3f)
  348. {
  349. velocity.x = moveSpeed + velocityAddition;
  350. if (bodyTrans.localScale.x > 0)
  351. {
  352. Turn();
  353. }
  354. }
  355. else if (leftDir.x < -0.3f)
  356. {
  357. velocity.x = -moveSpeed + velocityAddition;
  358. if (bodyTrans.localScale.x < 0)
  359. {
  360. Turn();
  361. }
  362. }
  363. velocity.y = 0;
  364. if (!foot.haveGravity)
  365. {
  366. transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
  367. targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
  368. }
  369. if (RotLerpTime < 1)
  370. {
  371. RotLerpTime += RotLerpSpeed * Time.deltaTime;
  372. transform.rotation = Quaternion.Lerp(transform.rotation, targetQt, RotLerpTime);
  373. }
  374. else
  375. {
  376. transform.rotation = targetQt;
  377. }
  378. rb.velocity = velocity;
  379. AdjustHeight();
  380. }
  381. break;
  382. case CharacterState.Rush:
  383. if (isAttack)
  384. {
  385. if (pastAttackTime >= attackController.attackInterval)
  386. {
  387. Attack_march();
  388. }
  389. else
  390. {
  391. ChangeState(CharacterState.Idle);
  392. }
  393. }
  394. else
  395. {
  396. if (!foot.TrigGround && !canFly)
  397. {
  398. if (rb.velocity.y > 0)
  399. {
  400. ChangeState(CharacterState.Rise);
  401. break;
  402. }
  403. else
  404. {
  405. ChangeState(CharacterState.Fall);
  406. break;
  407. }
  408. }
  409. if (leftDir.x < 0.3f && leftDir.x > -0.3f)
  410. {
  411. ChangeState(CharacterState.Idle);
  412. break;
  413. }
  414. if (leftDir.x > 0.3f)
  415. {
  416. //rb.velocity += Vector3.right * moveAcc * Time.deltaTime;
  417. rb.velocity = Vector3.right * runSpeed;
  418. //if (rb.velocity.x > maxMoveSpeed)
  419. //{
  420. // rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
  421. //}
  422. if (bodyTrans.localScale.x > 0)
  423. {
  424. Turn();
  425. }
  426. }
  427. else if (leftDir.x < -0.3f)
  428. {
  429. //rb.velocity -= Vector3.right * moveAcc * Time.deltaTime;
  430. rb.velocity = Vector3.left * runSpeed;
  431. //if (rb.velocity.x < -maxMoveSpeed)
  432. //{
  433. // rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
  434. //}
  435. if (bodyTrans.localScale.x < 0)
  436. {
  437. Turn();
  438. }
  439. }
  440. }
  441. break;
  442. case CharacterState.Rise:
  443. if (isAdjustHeight == 1)
  444. {
  445. AdjustHeight();
  446. }
  447. else if(isAdjustHeight == 2)
  448. {
  449. ChangeState(CharacterState.Idle);
  450. isAdjustHeight = 0;
  451. }
  452. else
  453. {
  454. if (rb.velocity.y <= 0)
  455. {
  456. ChangeState(CharacterState.Fall);
  457. break;
  458. }
  459. rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
  460. }
  461. break;
  462. case CharacterState.Fall:
  463. if (foot.TrigGround || canFly)
  464. {
  465. ChangeState(CharacterState.Idle);
  466. break;
  467. }
  468. velocity.y += extraFallGravity * Time.deltaTime;
  469. if (leftDir.x > 0.3f)
  470. {
  471. velocity.x = moveSpeed;
  472. if (bodyTrans.localScale.x > 0)
  473. {
  474. Turn();
  475. }
  476. }
  477. else if (leftDir.x < -0.3f)
  478. {
  479. velocity.x = -moveSpeed;
  480. if (bodyTrans.localScale.x < 0)
  481. {
  482. Turn();
  483. }
  484. }
  485. rb.velocity = velocity;
  486. break;
  487. case CharacterState.Attack:
  488. attackController.JudgeTriggerOnOff();
  489. if (attackController.attackTime <= 0)
  490. {
  491. if (isInSoulTower)
  492. {
  493. ChangeState(CharacterState.LockSoul);
  494. }
  495. else
  496. {
  497. isAttack = GetAttack();
  498. if (isAttack)
  499. {
  500. isConAttack = true;
  501. }
  502. ChangeState(CharacterState.Idle);
  503. }
  504. break;
  505. }
  506. if (!foot.haveGravity)
  507. {
  508. targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
  509. }
  510. if (RotLerpTime < 1)
  511. {
  512. RotLerpTime += RotLerpSpeed * Time.deltaTime;
  513. transform.rotation = Quaternion.Lerp(transform.rotation, targetQt, RotLerpTime);
  514. }
  515. else
  516. {
  517. transform.rotation = targetQt;
  518. }
  519. rb.velocity = new Vector3(velocityAddition, rb.velocity.y, rb.velocity.z);
  520. break;
  521. case CharacterState.Die:
  522. if (dieKeepTime <= 0)
  523. {
  524. gameObject.SetActive(false);
  525. break;
  526. }
  527. break;
  528. case CharacterState.LockSoul:
  529. if (!isReturnSoulTower)
  530. {
  531. if (targetCharacter != null && targetCharacter.gameObject.layer == 8 && targetCharacter.isInSoulTower)
  532. {
  533. ChangeState(CharacterState.Idle);
  534. }
  535. else
  536. {
  537. isReturnSoulTower = true;
  538. }
  539. }
  540. else
  541. {
  542. if (transform.position.x - origSoulPos.x >= 0.2f)
  543. {
  544. rb.velocity = Vector3.right * (-moveSpeed + velocityAddition);
  545. if (bodyTrans.localScale.x < 0)
  546. {
  547. Turn();
  548. }
  549. }
  550. else if (origSoulPos.x - transform.position.x >= 0.2f)
  551. {
  552. rb.velocity = Vector3.right * (moveSpeed + velocityAddition);
  553. if (bodyTrans.localScale.x > 0)
  554. {
  555. Turn();
  556. }
  557. }
  558. else
  559. {
  560. ani.Play("idle", 0, 0);
  561. rb.velocity = Vector3.zero;
  562. transform.position = origSoulPos;
  563. isReturnSoulTower = false;
  564. targetCharacter = null;
  565. FaceToEneTower();
  566. }
  567. //锁魂塔内使魔返回原地过程中扫描到敌人时,停止返回并索敌攻击
  568. if (targetCharacter != null && targetCharacter.gameObject.layer == 8 && targetCharacter.isInSoulTower)
  569. {
  570. ChangeState(CharacterState.Idle);
  571. }
  572. }
  573. break;
  574. case CharacterState.HitStun:
  575. hitFeedbackSystem.HitStunUpdate();
  576. break;
  577. case CharacterState.SpecialStatus_Float:
  578. attributeStatus.SpecialStateEffect(SpecialState.FloatState);
  579. break;
  580. case CharacterState.SpecialStatus_BlowUp:
  581. attributeStatus.SpecialStateEffect(SpecialState.BlownUp);
  582. break;
  583. case CharacterState.SpecialStatus_ShotDown:
  584. attributeStatus.SpecialStateEffect(SpecialState.ShotDown);
  585. break;
  586. case CharacterState.SpecialStatus_Weak:
  587. attributeStatus.SpecialStateEffect(SpecialState.Weak);
  588. break;
  589. default:
  590. break;
  591. }
  592. }
  593. private void FaceToEneTower()
  594. {
  595. float dis = 1000000;
  596. GameObject to = null;
  597. foreach (GameObject g in TowerMap.enemyTowers)
  598. {
  599. float k = Vector3.Distance(g.transform.position, transform.position);
  600. if (k < dis)
  601. {
  602. dis = k;
  603. to = g;
  604. }
  605. }
  606. if (to != null && to.transform.position.x < transform.position.x)
  607. {
  608. if (bodyTrans.localScale.x < 0)
  609. {
  610. Turn();
  611. }
  612. }
  613. else
  614. {
  615. if (bodyTrans.localScale.x > 0)
  616. {
  617. Turn();
  618. }
  619. }
  620. }
  621. public override void ChangeState(CharacterState newState)
  622. {
  623. if (state == newState)
  624. {
  625. return;
  626. }
  627. switch (state)
  628. {
  629. case CharacterState.Idle:
  630. //transform.rotation = Quaternion.Euler(Vector3.zero);
  631. break;
  632. case CharacterState.Run:
  633. //transform.rotation = Quaternion.Euler(Vector3.zero);
  634. rb.velocity = Vector3.zero;
  635. break;
  636. case CharacterState.Rush:
  637. rb.velocity = Vector3.zero;
  638. break;
  639. case CharacterState.Rise:
  640. if (!canFly)
  641. {
  642. bodyCollider.SetActive(true);
  643. }
  644. break;
  645. case CharacterState.Fall:
  646. rb.velocity = Vector3.zero;
  647. break;
  648. case CharacterState.Attack:
  649. if (isFreeze)
  650. {
  651. rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
  652. }
  653. attackController.ChooseAttack(curAttackID);
  654. attackController.isAttackTriggerOn = false;
  655. attackController.attackTrigger.gameObject.SetActive(false);
  656. break;
  657. case CharacterState.Die:
  658. isDie = false;
  659. break;
  660. case CharacterState.LockSoul:
  661. //isReturnSoulTower = true;
  662. break;
  663. default:
  664. break;
  665. }
  666. state = newState;
  667. switch (newState)
  668. {
  669. case CharacterState.Idle:
  670. if (!isConAttack)
  671. {
  672. ani.Play("idle", 0, 0);
  673. }
  674. rb.velocity = Vector3.zero;
  675. isConAttack = false;
  676. //animalAni.SetInteger("state", (int)PlayerState.Idle);
  677. break;
  678. case CharacterState.Run:
  679. ani.Play("walk", 0, 0);
  680. //animalAni.SetInteger("state", (int)PlayerState.Walk);
  681. break;
  682. case CharacterState.Rush:
  683. ani.Play("rush", 0, 0);
  684. break;
  685. case CharacterState.Fall:
  686. ani.Play("fall", 0, 0);
  687. //animalAni.SetInteger("state", (int)PlayerState.Fall);
  688. break;
  689. case CharacterState.Attack:
  690. break;
  691. case CharacterState.Die:
  692. ani.Play("die", 0, 0);
  693. isDie = true;
  694. dieKeepTime = totalDieKeepTime;
  695. break;
  696. case CharacterState.LockSoul:
  697. rb.velocity = Vector3.zero;
  698. ani.Play("walk", 0, 0);
  699. //FaceToEneTower();
  700. break;
  701. default:
  702. break;
  703. }
  704. }
  705. public void Attack_summon()
  706. {
  707. if (needToAdjustFlyHeight && canFly)
  708. {
  709. flyHeight = Random.Range(minFlyHeight, maxFlyHeight);
  710. isAdjustHeight = 1;
  711. }
  712. if (!canFly)
  713. {
  714. rb.constraints = RigidbodyConstraints.FreezeAll;
  715. isFreeze = true;
  716. }
  717. attackController.Attack_summon();
  718. Vector3 moveDir;
  719. if (PlayersInput.instance[playerID].bodyTrans.localScale.x > 0)
  720. {
  721. moveDir = Vector3.left;
  722. }
  723. else
  724. {
  725. moveDir = Vector3.right;
  726. }
  727. if (moveDir.x > 0.3f)
  728. {
  729. if (bodyTrans.localScale.x > 0)
  730. {
  731. Turn();
  732. }
  733. }
  734. else if (moveDir.x < -0.3f)
  735. {
  736. if (bodyTrans.localScale.x < 0)
  737. {
  738. Turn();
  739. }
  740. }
  741. invincibleTime = totalAttack_summonTime;
  742. attackTarget = targetCharacter;
  743. curAttackID = 1;
  744. }
  745. public virtual void Attack_march()
  746. {
  747. attackController.Attack_march(curAttackID);
  748. if (curAttackID + 1 < len)
  749. {
  750. curAttackID += 1;
  751. }
  752. else if (am[0].id == 0)
  753. {
  754. curAttackID = 1;
  755. }
  756. else
  757. {
  758. curAttackID = 0;
  759. }
  760. attackTarget = targetCharacter;
  761. pastAttackTime = 0;
  762. }
  763. public void DropSouls()
  764. {
  765. int dropSoulNum = Random.Range(dropSoulMin, dropSoulMax + 1);
  766. if (dropSoulNum > 1)
  767. {
  768. for (int i = 0; i < dropSoulNum; i++)
  769. {
  770. float angleInterval = dropSoulAngle / (float)(dropSoulNum - 1);
  771. float angle = 90 + ((float)i - (float)(dropSoulNum - 1) / 2) * angleInterval;
  772. angle = angle / 180 * Mathf.PI;
  773. GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
  774. Vector3 dir = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0);
  775. Soul soul = soulObj.GetComponent<Soul>();
  776. soul.Burst(dir * soulStartSpeed);
  777. }
  778. }
  779. else
  780. {
  781. GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
  782. Vector3 dir = Vector3.up;
  783. Soul soul = soulObj.GetComponent<Soul>();
  784. soul.Burst(dir * soulStartSpeed);
  785. }
  786. }
  787. }