Enemy.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. using Spine.Unity;
  2. using Spine;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using Base.Common;
  7. using UnityEditor.SceneManagement;
  8. public enum TargetType
  9. {
  10. None = 0,
  11. Demonic = 1,
  12. Tower = 2,
  13. Player = 3,
  14. Enemy = 4,
  15. EnemyTower = 5,
  16. Boss = 6,
  17. Portal = 7,
  18. }
  19. public enum SearchState
  20. {
  21. NoTarget = 0, //搜索范围内没有目标
  22. InSearchScope = 1, //在搜索范围内发现目标,但不在攻击范围内
  23. InAttackScope = 2, //目标在攻击范围内
  24. }
  25. public class Enemy : MoveCharacter
  26. {
  27. [Header("敌方单位属性")]
  28. public int id;
  29. public int baseSortingOrder;
  30. int sortingOrder = 0;
  31. public bool isBack = false; //往反方向走
  32. public float flyHeight;
  33. public float flyUpSpeed = 10;
  34. public float jumpSpeed = 10;
  35. public float maxMoveSpeed, minMoveSpeed;
  36. public float runSpeed;
  37. [Header("击飞、屏幕反弹")]
  38. public bool isBeBlownUp; //被击飞
  39. public bool isBeReboundedX; //X方向被反弹
  40. public bool isBeReboundedY; //Y方向被反弹
  41. private bool hasBeReboundedX;
  42. private bool hasBeReboundedY;
  43. public float reboundXSpeed;
  44. public float reboundYSpeed;
  45. public int wallDamage;
  46. [Header("落地眩晕")]
  47. public bool willBeComa;
  48. public float willComaTime;
  49. public int comaDamage;
  50. [Header("敌方英灵")]
  51. public Spirits.SpiritType type;
  52. [Header("敌方单位组件")]
  53. public SearchState searchState;
  54. [Header("攻击")]
  55. public float attackDistance;
  56. public float maxAttackDis, minAttackDis;
  57. public bool needToChange;
  58. public float attackRatio;
  59. private int curAttackID;
  60. private AttackController.AttackMethod[] am;
  61. private int len;
  62. [Header("掉落魂")]
  63. public int dropSoulMax = 3;
  64. public int dropSoulMin = 1;
  65. public float dropSoulAngle = 60f;
  66. [Header("验证功能开关")]
  67. public bool upFirstAfterWeaknessOrNot; //虚弱结束后是否先升高
  68. private void Start()
  69. {
  70. if (needToChange)
  71. {
  72. attackDistance = Random.Range(minAttackDis, maxAttackDis);
  73. }
  74. am = attackController.attackMethod;
  75. len = am.Length;
  76. }
  77. private void OnEnable()
  78. {
  79. Init();
  80. }
  81. public void OnDisable()
  82. {
  83. EnemyCreater.instance.OnEnemyRecycle(this);
  84. }
  85. public override void Init()
  86. {
  87. base.Init();
  88. moveSpeed = Random.Range(minMoveSpeed, maxMoveSpeed);
  89. ChangeSearchState(SearchState.NoTarget);
  90. }
  91. public override void FixedUpdate()
  92. {
  93. OnSearchState();
  94. OnState();
  95. }
  96. public override Vector3 GetMoveDir()
  97. {
  98. Vector3 moveDir = Vector3.zero;
  99. if (canMove)
  100. {
  101. switch (searchState)
  102. {
  103. case SearchState.NoTarget:
  104. if (TowerMap.myTowers.Count == 0)
  105. {
  106. moveDir = Vector3.right;
  107. break;
  108. }
  109. float minDistance = Mathf.Infinity;
  110. int id = -1;
  111. for (int i = 0; i < TowerMap.myTowers.Count; i++)
  112. {
  113. Tower myTower = TowerMap.myTowers[i].GetComponent<Tower>();
  114. if (transform.position.y >
  115. myTower.transform.position.y + myTower.height)
  116. {
  117. continue;
  118. }
  119. float distance = Vector3.Distance(transform.position,
  120. TowerMap.myTowers[i].transform.position);
  121. if (distance < minDistance)
  122. {
  123. minDistance = distance;
  124. id = i;
  125. }
  126. }
  127. if (id == -1)
  128. {
  129. moveDir = Vector3.right;
  130. break;
  131. }
  132. if (bodyTrans.position.x > TowerMap.myTowers[id].transform.position.x)
  133. {
  134. moveDir = Vector3.left;
  135. }
  136. else
  137. {
  138. moveDir = Vector3.right;
  139. }
  140. break;
  141. case SearchState.InSearchScope:
  142. if (targetCharacter)
  143. {
  144. if (targetCharacter.transform.position.x - transform.position.x < 0)
  145. {
  146. moveDir = Vector3.left;
  147. }
  148. else
  149. {
  150. moveDir = Vector3.right;
  151. }
  152. }
  153. else
  154. {
  155. moveDir = Vector3.zero;
  156. }
  157. break;
  158. case SearchState.InAttackScope:
  159. if (targetCharacter)
  160. {
  161. if (targetCharacter.transform.position.x - transform.position.x < 0)
  162. {
  163. moveDir = Vector3.left;
  164. }
  165. else
  166. {
  167. moveDir = Vector3.right;
  168. }
  169. }
  170. else
  171. {
  172. moveDir = Vector3.zero;
  173. }
  174. break;
  175. default:
  176. break;
  177. }
  178. }
  179. if (!isBack)
  180. {
  181. return moveDir;
  182. }
  183. return -moveDir;
  184. }
  185. public bool GetAttack()
  186. {
  187. if (searchState == SearchState.InAttackScope)
  188. {
  189. return true;
  190. }
  191. return false;
  192. }
  193. public bool GetJump()
  194. {
  195. return false;
  196. }
  197. public bool AdjustHeight()
  198. {
  199. if (canFly)
  200. {
  201. if (transform.position.y - flyHeight > 0.1f)
  202. {
  203. Vector3 pos = transform.position;
  204. pos.y -= flyUpSpeed * Time.deltaTime;
  205. transform.position = pos;
  206. return false;
  207. }
  208. else if (transform.position.y - flyHeight < -0.1f)
  209. {
  210. Vector3 pos = transform.position;
  211. pos.y += flyUpSpeed * Time.deltaTime;
  212. transform.position = pos;
  213. return false;
  214. }
  215. }
  216. return true;
  217. }
  218. public override void OnState()
  219. {
  220. base.OnState();
  221. //hurtKeepTime -= Time.deltaTime;
  222. dieKeepTime -= Time.deltaTime;
  223. invincibleTime -= Time.deltaTime;
  224. weakTime -= Time.deltaTime;
  225. beRepelValue += Time.deltaTime;
  226. Vector3 leftDir = GetMoveDir();
  227. bool isAttack = GetAttack();
  228. switch (state)
  229. {
  230. case CharacterState.Idle:
  231. if (isAttack)
  232. {
  233. Attack_march();
  234. break;
  235. }
  236. if (!foot.TrigGround && !canFly)
  237. {
  238. if (rb.velocity.y > 0)
  239. {
  240. ChangeState(CharacterState.Rise);
  241. break;
  242. }
  243. else
  244. {
  245. ChangeState(CharacterState.Fall);
  246. break;
  247. }
  248. }
  249. if (leftDir.x > 0.3f || leftDir.x < -0.3f)
  250. {
  251. ChangeState(CharacterState.Run);
  252. break;
  253. }
  254. //rb.velocity = Vector3.zero;
  255. if (!upFirstAfterWeaknessOrNot)
  256. {
  257. if (canFly)
  258. {
  259. rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
  260. rb.useGravity = false;
  261. AdjustHeight();
  262. }
  263. }
  264. break;
  265. case CharacterState.Run:
  266. if (isAttack)
  267. {
  268. Attack_march();
  269. break;
  270. }
  271. if (!foot.TrigGround && !canFly)
  272. {
  273. if (rb.velocity.y > 0)
  274. {
  275. ChangeState(CharacterState.Rise);
  276. break;
  277. }
  278. else
  279. {
  280. ChangeState(CharacterState.Fall);
  281. break;
  282. }
  283. }
  284. if (leftDir.x < 0.3f && leftDir.x > -0.3f)
  285. {
  286. ChangeState(CharacterState.Idle);
  287. break;
  288. }
  289. if (leftDir.x > 0.3f)
  290. {
  291. rb.velocity = Vector3.right * moveSpeed;
  292. if (bodyTrans.localScale.x > 0)
  293. {
  294. Turn();
  295. }
  296. }
  297. else if (leftDir.x < -0.3f)
  298. {
  299. rb.velocity = Vector3.left * moveSpeed;
  300. if (bodyTrans.localScale.x < 0)
  301. {
  302. Turn();
  303. }
  304. }
  305. if (!upFirstAfterWeaknessOrNot)
  306. {
  307. if (canFly)
  308. {
  309. rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
  310. rb.useGravity = false;
  311. AdjustHeight();
  312. }
  313. }
  314. break;
  315. case CharacterState.Rush:
  316. if (isAttack)
  317. {
  318. Attack_march();
  319. break;
  320. }
  321. if (!foot.TrigGround && !canFly)
  322. {
  323. if (rb.velocity.y > 0)
  324. {
  325. ChangeState(CharacterState.Rise);
  326. break;
  327. }
  328. else
  329. {
  330. ChangeState(CharacterState.Fall);
  331. break;
  332. }
  333. }
  334. if (leftDir.x < 0.3f && leftDir.x > -0.3f)
  335. {
  336. ChangeState(CharacterState.Idle);
  337. break;
  338. }
  339. if (leftDir.x > 0.3f)
  340. {
  341. //rb.velocity += Vector3.right * moveAcc * Time.deltaTime;
  342. rb.velocity = Vector3.right * runSpeed;
  343. //if (rb.velocity.x > maxMoveSpeed)
  344. //{
  345. // rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
  346. //}
  347. if (bodyTrans.localScale.x > 0)
  348. {
  349. Turn();
  350. }
  351. }
  352. else if (leftDir.x < -0.3f)
  353. {
  354. //rb.velocity -= Vector3.right * moveAcc * Time.deltaTime;
  355. rb.velocity = Vector3.left * runSpeed;
  356. //if (rb.velocity.x < -maxMoveSpeed)
  357. //{
  358. // rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
  359. //}
  360. if (bodyTrans.localScale.x < 0)
  361. {
  362. Turn();
  363. }
  364. }
  365. //AdjustHeight();
  366. break;
  367. case CharacterState.Rise:
  368. if (rb.velocity.y <= 0)
  369. {
  370. ChangeState(CharacterState.Fall);
  371. break;
  372. }
  373. rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
  374. break;
  375. case CharacterState.Fall:
  376. if (foot.TrigGround || canFly)
  377. {
  378. if (willBeComa)
  379. {
  380. comaTime = willComaTime;
  381. ChangeState(CharacterState.Coma);
  382. }
  383. else
  384. {
  385. ChangeState(CharacterState.Idle);
  386. }
  387. break;
  388. }
  389. Vector3 velocity = rb.velocity;
  390. velocity.y += extraFallGravity * Time.deltaTime;
  391. if (leftDir.x > 0.3f)
  392. {
  393. velocity.x = moveSpeed;
  394. if (bodyTrans.localScale.x > 0)
  395. {
  396. Turn();
  397. }
  398. }
  399. else if (leftDir.x < -0.3f)
  400. {
  401. velocity.x = -moveSpeed;
  402. if (bodyTrans.localScale.x < 0)
  403. {
  404. Turn();
  405. }
  406. }
  407. rb.velocity = velocity;
  408. break;
  409. case CharacterState.Attack:
  410. attackController.attackTime -= Time.deltaTime;
  411. attackController.attackKeyCount += Time.deltaTime;
  412. if (!attackController.isAttackTriggerOn && attackController.attackKeyCount >=
  413. attackController.nextStartKeyTime && attackController.attackKeyCount <= attackController.nextEndKeyTime)
  414. {
  415. attackController.isAttackTriggerOn = true;
  416. attackController.attackTrigger.gameObject.SetActive(true);
  417. }
  418. else if (attackController.isAttackTriggerOn && attackController.attackKeyCount >= attackController.nextEndKeyTime)
  419. {
  420. attackController.isAttackTriggerOn = false;
  421. attackController.attackTrigger.gameObject.SetActive(false);
  422. attackController.SetNextKeyTimes();
  423. }
  424. if (attackController.attackTime <= 0)
  425. {
  426. ChangeState(CharacterState.Idle);
  427. break;
  428. }
  429. break;
  430. case CharacterState.Die:
  431. if (dieKeepTime <= 0)
  432. {
  433. gameObject.SetActive(false);
  434. break;
  435. }
  436. break;
  437. case CharacterState.Coma:
  438. pastComaTime += Time.deltaTime;
  439. if (pastComaTime >= comaTime)
  440. {
  441. ChangeState(CharacterState.Idle);
  442. }
  443. break;
  444. case CharacterState.SpecialStatus:
  445. attributeStatus.SpecialStateEffect();
  446. break;
  447. default:
  448. break;
  449. }
  450. }
  451. public override void ChangeState(CharacterState newState)
  452. {
  453. if (state == newState)
  454. {
  455. return;
  456. }
  457. switch (state)
  458. {
  459. case CharacterState.Idle:
  460. break;
  461. case CharacterState.Run:
  462. rb.velocity = Vector3.zero;
  463. break;
  464. case CharacterState.Rush:
  465. rb.velocity = Vector3.zero;
  466. break;
  467. case CharacterState.Rise:
  468. if (!canFly)
  469. {
  470. bodyCollider.SetActive(true);
  471. }
  472. break;
  473. case CharacterState.Fall:
  474. rb.velocity = Vector3.zero;
  475. break;
  476. //case CharacterState.Hurt:
  477. // break;
  478. case CharacterState.Attack:
  479. break;
  480. case CharacterState.Die:
  481. isDie = false;
  482. break;
  483. case CharacterState.Float:
  484. canMove = true;
  485. break;
  486. case CharacterState.Coma:
  487. ani.Play("idle", 0, 0);
  488. if (canFly)
  489. {
  490. rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
  491. rb.useGravity = false;
  492. }
  493. canMove = true;
  494. break;
  495. default:
  496. break;
  497. }
  498. CharacterState oldState = state;
  499. state = newState;
  500. switch (newState)
  501. {
  502. case CharacterState.Idle:
  503. ani.Play("idle", 0, 0);
  504. rb.velocity = Vector3.zero;
  505. //animalAni.SetInteger("state", (int)PlayerState.Idle);
  506. break;
  507. case CharacterState.Run:
  508. ani.Play("walk", 0, 0);
  509. //animalAni.SetInteger("state", (int)PlayerState.Walk);
  510. break;
  511. case CharacterState.Rush:
  512. ani.Play("rush", 0, 0);
  513. break;
  514. case CharacterState.Float:
  515. canMove = false;
  516. break;
  517. case CharacterState.Coma:
  518. if (willBeComa)
  519. {
  520. BeHit(comaDamage, Vector3.zero, false, 0);
  521. }
  522. //ani.Play("Coma", 0, 0);
  523. ani.Play("weak", 0, 0);
  524. rb.velocity = Vector3.zero;
  525. pastComaTime = 0;
  526. if (canFly)
  527. {
  528. rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
  529. rb.useGravity = true;
  530. }
  531. break;
  532. case CharacterState.Attack:
  533. break;
  534. case CharacterState.Die:
  535. ani.Play("die", 0, 0);
  536. isDie = true;
  537. dieKeepTime = totalDieKeepTime;
  538. DropSouls();
  539. break;
  540. default:
  541. break;
  542. }
  543. }
  544. public void DropSouls()
  545. {
  546. int dropSoulNum = Random.Range(dropSoulMin, dropSoulMax + 1);
  547. if (dropSoulNum > 1)
  548. {
  549. for (int i = 0; i < dropSoulNum; i++)
  550. {
  551. float angleInterval = dropSoulAngle / (float)(dropSoulNum - 1);
  552. float angle = 90 + ((float)i - (float)(dropSoulNum - 1) / 2) * angleInterval;
  553. angle = angle / 180 * Mathf.PI;
  554. GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
  555. Vector3 dir = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0);
  556. Soul soul = soulObj.GetComponent<Soul>();
  557. soul.Burst(dir * soulStartSpeed);
  558. soul.type = type;
  559. }
  560. }
  561. else
  562. {
  563. GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
  564. Vector3 dir = Vector3.up;
  565. Soul soul = soulObj.GetComponent<Soul>();
  566. soul.Burst(dir * soulStartSpeed);
  567. soul.type = type;
  568. }
  569. }
  570. public void Jump()
  571. {
  572. SetUpSpeed(jumpSpeed);
  573. ani.Play("jump", 0, 0);
  574. }
  575. public void SetUpSpeed(float speed)
  576. {
  577. ChangeState(CharacterState.Rise);
  578. Vector3 velocity = rb.velocity;
  579. Vector3 leftDir = GetMoveDir();
  580. if (leftDir.x > 0.3f)
  581. {
  582. if (bodyTrans.localScale.x > 0)
  583. {
  584. Turn();
  585. }
  586. }
  587. else if (leftDir.x < -0.3f)
  588. {
  589. if (bodyTrans.localScale.x < 0)
  590. {
  591. Turn();
  592. }
  593. }
  594. velocity.y = speed;
  595. rb.velocity = velocity;
  596. //animalAni.SetInteger("state", (int)PlayerState.Rise);
  597. }
  598. public void ChangeSearchState(SearchState newState)
  599. {
  600. switch (searchState)
  601. {
  602. case SearchState.NoTarget:
  603. break;
  604. case SearchState.InSearchScope:
  605. break;
  606. case SearchState.InAttackScope:
  607. break;
  608. default:
  609. break;
  610. }
  611. searchState = newState;
  612. switch (searchState)
  613. {
  614. case SearchState.NoTarget:
  615. Character character0 = PlayersInput.instance[0];
  616. if (character0 && character0.attackController.beTargetCharacter.Exists(t => t == this))
  617. {
  618. character0.attackController.beTargetCharacter.Remove(this);
  619. }
  620. targetCharacter = null;
  621. break;
  622. case SearchState.InSearchScope:
  623. break;
  624. case SearchState.InAttackScope:
  625. break;
  626. default:
  627. break;
  628. }
  629. }
  630. public bool SearchTarget()
  631. {
  632. targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
  633. if (targetCharacter != null)
  634. {
  635. Character character0 = PlayersInput.instance[0];
  636. Character character1 = PlayersInput.instance[1];
  637. if (targetCharacter == character0
  638. && !character0.attackController.beTargetCharacter.Exists(t => t == this))
  639. {
  640. character0.attackController.beTargetCharacter.Add(this);
  641. }
  642. if (targetCharacter == character1
  643. && !character1.attackController.beTargetCharacter.Exists(t => t == this))
  644. {
  645. character1.attackController.beTargetCharacter.Add(this);
  646. }
  647. return true;
  648. }
  649. else
  650. {
  651. return false;
  652. }
  653. }
  654. public void OnSearchState()
  655. {
  656. switch (searchState)
  657. {
  658. case SearchState.NoTarget:
  659. if (SearchTarget())
  660. {
  661. ChangeSearchState(SearchState.InSearchScope);
  662. break;
  663. }
  664. //向玩家基地移动
  665. break;
  666. case SearchState.InSearchScope:
  667. if (!SearchTarget())
  668. {
  669. targetCharacter = null;
  670. ChangeSearchState(SearchState.NoTarget);
  671. break;
  672. }
  673. if (targetCharacter != null && Mathf.Abs(targetCharacter.transform.position.x - transform.position.x) <= attackDistance)
  674. {
  675. ChangeSearchState(SearchState.InAttackScope);
  676. break;
  677. }
  678. break;
  679. case SearchState.InAttackScope:
  680. if (targetCharacter != null)
  681. {
  682. if (!targetCharacter.gameObject.activeInHierarchy || targetCharacter.isDie
  683. || Mathf.Abs(targetCharacter.transform.position.x - transform.position.x) > attackDistance)
  684. {
  685. ChangeSearchState(SearchState.NoTarget);
  686. }
  687. }
  688. else
  689. {
  690. ChangeSearchState(SearchState.NoTarget);
  691. }
  692. break;
  693. default:
  694. break;
  695. }
  696. }
  697. public void Attack_summon()
  698. {
  699. attackController.Attack_summon();
  700. attackTarget = targetCharacter;
  701. }
  702. public virtual void Attack_march()
  703. {
  704. attackController.Attack_march(curAttackID);
  705. if (curAttackID + 1 < len)
  706. {
  707. curAttackID += 1;
  708. }
  709. else if (am[0].id == 0)
  710. {
  711. curAttackID = 1;
  712. }
  713. else
  714. {
  715. curAttackID = 0;
  716. }
  717. attackTarget = targetCharacter;
  718. }
  719. public void ChosePlayer()
  720. {
  721. float distance0 = Mathf.Infinity;
  722. float distance1 = Mathf.Infinity;
  723. PlayerController player0 = PlayersInput.instance[0];
  724. PlayerController player1 = PlayersInput.instance[1];
  725. if (player0 != null && !player0.isRevive && !player0.isBaseBtnOut)
  726. {
  727. distance0 = Mathf.Abs(player0.transform.position.x
  728. - transform.position.x);
  729. }
  730. if (player1 != null && !player1.isRevive && !player1.isBaseBtnOut)
  731. {
  732. distance1 = Mathf.Abs(player1.transform.position.x
  733. - transform.position.x);
  734. }
  735. if (distance0 == Mathf.Infinity && distance1 == Mathf.Infinity)
  736. {
  737. targetCharacter = null;
  738. return;
  739. }
  740. if (distance0 <= distance1)
  741. {
  742. targetCharacter = player0;
  743. if (!player0.attackController.beTargetCharacter.Exists(t => t == this))
  744. {
  745. player0.attackController.beTargetCharacter.Add(this);
  746. }
  747. }
  748. else
  749. {
  750. targetCharacter = player1;
  751. if (!player1.attackController.beTargetCharacter.Exists(t => t == this))
  752. {
  753. player1.attackController.beTargetCharacter.Add(this);
  754. }
  755. }
  756. }
  757. }