Enemy_Leafghost.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. public class Enemy_Leafghost : Enemy
  6. {
  7. [Space(30)]
  8. [Title("ÁŤť¨šÖ")]
  9. public GameObject lutos; //şÉť¨
  10. private Animator lutosAni;
  11. public Transform pos2;
  12. public Transform shootPos;
  13. private bool hasUp;
  14. public LeafGhost_UpDown ud;
  15. public override void Init()
  16. {
  17. base.Init();
  18. hasUp = false;
  19. pastAttackTime = attackController.attackInterval;
  20. lutosAni = lutos.GetComponent<Animator>();
  21. ani.Play("dive", 0, 0);
  22. ud.owner = this;
  23. ud.targetPosition = pos2;
  24. PolliwogShot ps = attackController.attackMethod_march[0].skill.GetComponent<PolliwogShot>();
  25. ps.owner = this;
  26. ps.pos = shootPos;
  27. }
  28. public override Vector3 GetMoveDir()
  29. {
  30. return Vector3.zero;
  31. }
  32. public override void ChangeState(CharacterState newState)
  33. {
  34. if (state == newState)
  35. {
  36. return;
  37. }
  38. switch (state)
  39. {
  40. case CharacterState.Attack:
  41. attackController.isAttackTriggerOn = false;
  42. attackController.curAttackMethod.attackTrigger.gameObject.SetActive(false);
  43. pastAttackTime = 0;
  44. break;
  45. case CharacterState.Die:
  46. isDie = false;
  47. break;
  48. }
  49. state = newState;
  50. switch (newState)
  51. {
  52. case CharacterState.Idle:
  53. if (!hasUp)
  54. {
  55. ani.Play("idle2", 0, 0);
  56. }
  57. break;
  58. case CharacterState.Die:
  59. ani.Play("die", 0, 0);
  60. isDie = true;
  61. dieKeepTime = totalDieKeepTime;
  62. DropSouls();
  63. break;
  64. }
  65. }
  66. public override void OnState()
  67. {
  68. if (state == CharacterState.None)
  69. {
  70. return;
  71. }
  72. dieKeepTime -= Time.deltaTime;
  73. pastAttackTime += Time.deltaTime;
  74. bool isAttack = GetAttack();
  75. switch (state)
  76. {
  77. case CharacterState.Idle:
  78. if (!hasUp)
  79. {
  80. if (isAttack)
  81. {
  82. ud.Attack();
  83. ChangeState(CharacterState.Attack);
  84. lutosAni.Play("attack", 0, 0);
  85. hasUp = true;
  86. }
  87. }
  88. else
  89. {
  90. if (pastAttackTime >= attackController.attackInterval)
  91. {
  92. Attack_march();
  93. }
  94. }
  95. break;
  96. case CharacterState.Attack:
  97. attackController.JudgeTriggerOnOff();
  98. if (attackController.attackTime <= 0)
  99. {
  100. isAttack = GetAttack();
  101. if (isAttack)
  102. {
  103. isConAttack = true;
  104. }
  105. ChangeState(CharacterState.Idle);
  106. break;
  107. }
  108. break;
  109. case CharacterState.Die:
  110. if (dieKeepTime <= 0)
  111. {
  112. if (killer != null && killer.GetComponent<Demonic>())
  113. {
  114. SoldierType st = killer.GetComponent<Demonic>().soldierType;
  115. SoldierEXP.expInstance.AddEXP(st, (int)(exp * LevelSelect.EXPRatio + 0.5f));
  116. }
  117. if (dieEffect)
  118. {
  119. PoolManager.Instantiate(dieEffect, transform.position);
  120. }
  121. gameObject.SetActive(false);
  122. break;
  123. }
  124. break;
  125. case CharacterState.HitStun:
  126. hitFeedbackSystem.HitStunUpdate();
  127. break;
  128. }
  129. }
  130. }