Trans_Float.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Trans_Float : MonoBehaviour
  5. {
  6. public PlayerController controller;
  7. public Vector3 UIoffset; //UI调整值
  8. public float floatProbability; //漂浮概率
  9. public float gainAbilityProbability; //获得漂浮特性的概率
  10. public int abilityTimes; //攻击使漂浮的次数
  11. private void Start()
  12. {
  13. controller = GetComponentInParent<PlayerController>();
  14. controller.canArrowHitFloat = true;
  15. controller.probability = floatProbability;
  16. controller.gainAbilityProbability = gainAbilityProbability;
  17. controller.abilityTimes = abilityTimes;
  18. controller.canMove = true;
  19. }
  20. private void OnDisable()
  21. {
  22. controller.canArrowHitFloat = false;
  23. }
  24. private void DeMp(int deMP)
  25. {
  26. controller.mp -= deMP;
  27. controller.uiMp.Show(controller.mp, controller.totalMp);
  28. }
  29. /*
  30. private void Update()
  31. {
  32. //硬直
  33. if (!canAttack)
  34. {
  35. pastAttackTime += Time.deltaTime;
  36. if (pastAttackTime >= intervalTime)
  37. {
  38. canAttack = true;
  39. pastAttackTime = 0;
  40. controller.canMove = true;
  41. }
  42. }
  43. if (isCDJ)
  44. {
  45. pastCDJ += Time.deltaTime;
  46. if (pastCDJ >= CDJ)
  47. {
  48. isCDJ = false;
  49. pastCDJ = 0;
  50. }
  51. }
  52. if (isCDK)
  53. {
  54. pastCDK += Time.deltaTime;
  55. if (pastCDK >= CDK)
  56. {
  57. isCDK = false;
  58. pastCDK = 0;
  59. }
  60. }
  61. if (isCDL)
  62. {
  63. pastCDL += Time.deltaTime;
  64. if (pastCDL >= CDL)
  65. {
  66. isCDL = false;
  67. pastCDL = 0;
  68. }
  69. }
  70. //J
  71. if (!isCDJ && controller.isinputJ && canAttack)
  72. {
  73. if (controller.mp >= mpJ)
  74. {
  75. isCDJ = true;
  76. intervalTime = intervalTimeJ;
  77. ToInterval(mpJ);
  78. controller.isinputJ = false;
  79. //首次攻击触发漂浮
  80. if (isFirst)
  81. {
  82. if (!dem.attackToFloat)
  83. {
  84. isFirst = false;
  85. dem.attackToFloat = true;
  86. }
  87. }
  88. //攻击保底min~max次触发漂浮
  89. else
  90. {
  91. if (!dem.attackToFloat)
  92. {
  93. times += 1;
  94. if (times >= minTime || times == maxTime)
  95. {
  96. times = 0;
  97. dem.attackToFloat = true;
  98. }
  99. }
  100. }
  101. dem.Attack2();
  102. }
  103. else
  104. {
  105. Debug.Log("mp不足");
  106. }
  107. }
  108. //K
  109. if (!isCDK && controller.isinputK)
  110. {
  111. if (controller.mp >= mpK)
  112. {
  113. if (!once)
  114. {
  115. controller.canMove = false;
  116. controller.ChangeState(CharacterState.Idle);
  117. KContinueValue();
  118. once = true;
  119. isK = true;
  120. once = true;
  121. curlock.transform.position = transform.position;
  122. Vector3 orig = curlock.transform.localScale;
  123. curlock.transform.localScale = new Vector3(minRange, orig.y, orig.z);
  124. curlock.SetActive(true);
  125. }
  126. if (pastTime <= keepFloatTime)
  127. {
  128. pastTime += Time.deltaTime;
  129. isLosingMp += continueMp * Time.deltaTime;
  130. if (isLosingMp >= mpK)
  131. {
  132. DeMp(mpK);
  133. isLosingMp -= mpK;
  134. }
  135. if (curlock.transform.localScale.x < maxRange)
  136. {
  137. curlock.transform.localScale += new Vector3(continueRange * Time.deltaTime, 0, 0);
  138. }
  139. }
  140. }
  141. else
  142. {
  143. Debug.Log("mp不足");
  144. }
  145. }
  146. if(isK && !controller.isinputK)
  147. {
  148. isCDK = true;
  149. pastTime = 0;
  150. isK = false;
  151. intervalTime = intervalTimeK;
  152. ToInterval(0);
  153. once = false;
  154. curFe.transform.position = curlock.transform.position;
  155. Vector3 v = curFe.transform.localScale;
  156. curFe.transform.localScale = new Vector3(curlock.transform.localScale.x, v.y, v.z);
  157. curlock.SetActive(false);
  158. curFe.SetActive(true);
  159. }
  160. //L
  161. if (!isCDL && controller.isinputL)
  162. {
  163. if (controller.mp >= mpL)
  164. {
  165. isCDL = true;
  166. intervalTime = intervalTimeL;
  167. ToInterval(mpL);
  168. controller.isinputL = false;
  169. foreach (MoveCharacter f in FloatData.eneIsFloating)
  170. {
  171. if (f.isFloat)
  172. {
  173. f.dropDamage = LAttackDamage;
  174. f.FloatDrop();
  175. FloatData.Clear(1);
  176. }
  177. }
  178. }
  179. else
  180. {
  181. Debug.Log("mp不足");
  182. }
  183. }
  184. }
  185. */
  186. }