Claymore.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. using System;
  2. using Core;
  3. using ExtensionMethods;
  4. using LitJson;
  5. using UnityEngine;
  6. public class Claymore : BaseBehaviour
  7. {
  8. public bool aitAtkReset
  9. {
  10. get
  11. {
  12. return !base.IsInvoking("AttackReset");
  13. }
  14. }
  15. private float maxChargeTime
  16. {
  17. get
  18. {
  19. return this.pAttr.maxChargeTime;
  20. }
  21. }
  22. public bool canChargeAttack
  23. {
  24. get
  25. {
  26. return this.chargeTime >= 2.5f;
  27. }
  28. }
  29. private void Start()
  30. {
  31. this.execute = new PlayerExecuteTools();
  32. this.pAttr = R.Player.Attribute;
  33. this.listener = base.GetComponent<PlayerAnimEventListener>();
  34. this.player = base.GetComponent<PlayerAction>();
  35. this.comboConfig = JsonMapper.ToObject(this.weaponConfigure.text);
  36. this.AirAttackReset();
  37. }
  38. private void Update()
  39. {
  40. this.UpdateCharge();
  41. }
  42. public void HandleAttack(bool cirt)
  43. {
  44. JsonData jsonData = this.comboConfig["normalAttack"];
  45. if (this.player.stateMachine.currentState.IsInArray(PlayerAction.AttackSta))
  46. {
  47. this.continueAttack = true;
  48. this.cirtAttack = cirt;
  49. }
  50. else
  51. {
  52. if (cirt)
  53. {
  54. this.player.ChangeState(jsonData[9.ToString()].Get<string>("anim", null), 1f);
  55. this.attackID = 9;
  56. }
  57. else
  58. {
  59. this.player.ChangeState(jsonData[1.ToString()].Get<string>("anim", null), 1f);
  60. this.attackID = 1;
  61. }
  62. this.continueAttack = false;
  63. this.cirtAttack = false;
  64. }
  65. }
  66. public void CirtAttackHold()
  67. {
  68. JsonData jsonData = this.comboConfig["normalAttack"];
  69. this.player.ChangeState(jsonData[12.ToString()].Get<string>("anim", null), 1f);
  70. this.attackID = 12;
  71. }
  72. private void PlayNextAttackAnim(bool cirt)
  73. {
  74. this.canChangeAtkAnim = false;
  75. this.continueAttack = false;
  76. this.player.TurnRound(this.player.tempDir);
  77. JsonData jsonData = this.comboConfig["normalAttack"];
  78. string key = (!cirt) ? "nextID" : "nextCirtID";
  79. int nextID = jsonData[this.attackID.ToString()].Get<int>(key, 0);
  80. if (!cirt && this.attackID == 4)
  81. {
  82. nextID = this.ComboCheck(nextID);
  83. }
  84. if (cirt)
  85. {
  86. nextID = this.CirtComboCheck(nextID);
  87. }
  88. if (!jsonData.Contains(nextID.ToString()))
  89. {
  90. this.continueAttack = false;
  91. this.canChangeAtkAnim = false;
  92. return;
  93. }
  94. JsonData jsonData2 = jsonData[nextID.ToString()];
  95. this.player.ChangeState(jsonData2.Get<string>("anim", null), 1f);
  96. this.attackID = nextID;
  97. }
  98. public void CanPlayNextAttack()
  99. {
  100. if (this.canChangeAtkAnim)
  101. {
  102. this.PlayNextAttackAnim(this.cirtAttack);
  103. return;
  104. }
  105. if (this.continueAttack)
  106. {
  107. this.PlayNextAttackAnim(this.cirtAttack);
  108. }
  109. else
  110. {
  111. this.canChangeAtkAnim = true;
  112. }
  113. }
  114. public void AttackFinish()
  115. {
  116. this.cirtAttack = false;
  117. this.continueAttack = false;
  118. this.canChangeAtkAnim = false;
  119. }
  120. private int CirtComboCheck(int nextID)
  121. {
  122. if (this.attackID == 1 && nextID == 15 && R.Player.Enhancement.UpperChop == 0)
  123. {
  124. return -1;
  125. }
  126. if (this.attackID == 2 && nextID == 5 && R.Player.Enhancement.Combo2 == 0)
  127. {
  128. return -1;
  129. }
  130. if (this.attackID == 3 && nextID == 19 && R.Player.Enhancement.AvatarAttack == 0)
  131. {
  132. return -1;
  133. }
  134. if (this.attackID == 4 && nextID == 18 && R.Player.Enhancement.Knockout == 0)
  135. {
  136. return -1;
  137. }
  138. return nextID;
  139. }
  140. private int ComboCheck(int nextID)
  141. {
  142. int attack = R.Player.Enhancement.Attack;
  143. if (attack == 2)
  144. {
  145. return 16;
  146. }
  147. if (attack != 3)
  148. {
  149. return nextID;
  150. }
  151. return 16;
  152. }
  153. public void HandleAirAttack(bool cirt)
  154. {
  155. JsonData jsonData = this.comboConfig["airAttack"];
  156. if (this.player.stateMachine.currentState.IsInArray(PlayerAction.AirAttackSta) && this.player.stateMachine.currentState != "AirAtkRoll")
  157. {
  158. this.continueAirAttack = true;
  159. this.cirtAttack = cirt;
  160. }
  161. else
  162. {
  163. if (cirt)
  164. {
  165. if (!this.airAttackReset)
  166. {
  167. return;
  168. }
  169. this.player.ChangeState(jsonData[4.ToString()].Get<string>("anim", null), 1f);
  170. this.airAttackReset = false;
  171. this.attackID = 4;
  172. }
  173. else
  174. {
  175. if (!this.airAttackReset)
  176. {
  177. return;
  178. }
  179. this.player.ChangeState(jsonData[1.ToString()].Get<string>("anim", null), 1f);
  180. this.airAttackReset = false;
  181. this.attackID = 1;
  182. }
  183. this.continueAirAttack = false;
  184. this.cirtAttack = false;
  185. }
  186. }
  187. public void AirCirtAttackHold()
  188. {
  189. JsonData jsonData = this.comboConfig["airAttack"];
  190. this.player.ChangeState(jsonData[10.ToString()].Get<string>("anim", null), 1f);
  191. this.attackID = 10;
  192. }
  193. private void PlayNextAirAttackAnim(bool cirt)
  194. {
  195. this.continueAirAttack = false;
  196. this.canChangeAirAtkAnim = false;
  197. R.Player.TimeController.SetSpeed(Vector2.zero);
  198. this.player.TurnRound(this.player.tempDir);
  199. JsonData jsonData = this.comboConfig["airAttack"];
  200. string key = (!cirt) ? "nextID" : "nextCirtID";
  201. int nextID = jsonData[this.attackID.ToString()].Get<int>(key, 0);
  202. if (cirt)
  203. {
  204. nextID = this.AirCirtComboCheck(nextID);
  205. }
  206. if (!jsonData.Contains(nextID.ToString()))
  207. {
  208. this.continueAirAttack = false;
  209. this.canChangeAirAtkAnim = false;
  210. return;
  211. }
  212. JsonData jsonData2 = jsonData[nextID.ToString()];
  213. this.player.ChangeState(jsonData2.Get<string>("anim", null), 1f);
  214. this.attackID = nextID;
  215. }
  216. public void CanPlayNextAirAttack()
  217. {
  218. if (this.pAttr.isOnGround)
  219. {
  220. this.AirAttackReset();
  221. this.player.ChangeState(PlayerAction.StateEnum.GetUp, 1f);
  222. return;
  223. }
  224. if (this.canChangeAirAtkAnim)
  225. {
  226. this.PlayNextAirAttackAnim(this.cirtAttack);
  227. return;
  228. }
  229. if (this.continueAirAttack)
  230. {
  231. this.PlayNextAirAttackAnim(this.cirtAttack);
  232. }
  233. else
  234. {
  235. this.canChangeAirAtkAnim = true;
  236. }
  237. }
  238. public void AirAttackFinish()
  239. {
  240. this.cirtAttack = false;
  241. this.continueAirAttack = false;
  242. this.canChangeAirAtkAnim = false;
  243. this.player.ChangeState(PlayerAction.StateEnum.Fall1, 1f);
  244. }
  245. public void AirAttackRecover()
  246. {
  247. this.cirtAttack = false;
  248. this.AirAttackReset();
  249. }
  250. private int AirCirtComboCheck(int nextID)
  251. {
  252. if (this.attackID == 1 && nextID == 13 && R.Player.Enhancement.AirCombo2 == 0)
  253. {
  254. return -1;
  255. }
  256. if (this.attackID == 2 && nextID == 11 && R.Player.Enhancement.AirAvatarAttack == 0)
  257. {
  258. return -1;
  259. }
  260. if (this.attackID == 3 && nextID == 7 && R.Player.Enhancement.AirCombo1 == 0)
  261. {
  262. return -1;
  263. }
  264. return nextID;
  265. }
  266. public void HandleUpRising()
  267. {
  268. this.listener.PhysicReset();
  269. this.AirAttackReset();
  270. PlayerAction.StateEnum sta = PlayerAction.StateEnum.UpRising;
  271. this.player.ChangeState(sta, 1f);
  272. }
  273. public void HandleHitGround()
  274. {
  275. this.player.ChangeState(PlayerAction.StateEnum.HitGround, 1f);
  276. }
  277. public void HandleExecute(bool inAir, EnemyAttribute eAttr)
  278. {
  279. if (eAttr.rankType == EnemyAttribute.RankType.Normal)
  280. {
  281. this.NormalEnemyExecute(inAir, eAttr);
  282. }
  283. else
  284. {
  285. this.listener.isFalling = false;
  286. this.listener.checkFallDown = false;
  287. this.listener.airAtkDown = false;
  288. this.listener.checkHitGround = false;
  289. this.listener.PhysicReset();
  290. base.transform.position = base.transform.position.SetY(eAttr.transform.position.y);
  291. this.execute.SpecicalEnemyQTE(eAttr.transform);
  292. }
  293. eAttr.GetComponent<EnemyBaseHurt>().QTECameraStart();
  294. this.listener.StopIEnumerator("FlashPositionSet");
  295. }
  296. private void NormalEnemyExecute(bool inAir, EnemyAttribute eAttr)
  297. {
  298. if (inAir)
  299. {
  300. PlayerAction.StateEnum sta = (UnityEngine.Random.Range(0, 2) != 0) ? PlayerAction.StateEnum.NewExecuteAir2_1 : PlayerAction.StateEnum.NewExecuteAir1_1;
  301. this.player.ChangeState(sta, 1f);
  302. }
  303. else
  304. {
  305. PlayerAction.StateEnum sta2 = (UnityEngine.Random.Range(0, 2) != 0) ? PlayerAction.StateEnum.NewExecute2_0 : PlayerAction.StateEnum.NewExecute1_1;
  306. if (!eAttr.accpectAirExecute)
  307. {
  308. sta2 = PlayerAction.StateEnum.NewExecute1_1;
  309. }
  310. this.player.ChangeState(sta2, 1f);
  311. if (eAttr.isOnGround)
  312. {
  313. eAttr.stiffTime = 1f;
  314. eAttr.GetComponent<EnemyBaseAction>().AnimReady();
  315. }
  316. }
  317. }
  318. private void UpdateCharge()
  319. {
  320. if (this.startCharge)
  321. {
  322. this.chargeTime = Mathf.Clamp(this.chargeTime + Time.deltaTime, 0f, this.maxChargeTime);
  323. bool flag = this.player.stateMachine.currentState == "AirCharging";
  324. if (this.lastFrameTime < 2.5f && this.chargeTime >= 2.5f)
  325. {
  326. Core.Input.Vibration.Vibrate(2);
  327. if (flag)
  328. {
  329. this.airRelease = 5f;
  330. this.listener.chargeAnim.ChargeOneOverAir();
  331. }
  332. else
  333. {
  334. this.listener.chargeAnim.ChargeOneOver();
  335. }
  336. }
  337. this.lastFrameTime = this.chargeTime;
  338. }
  339. if (this.airRelease > 0f)
  340. {
  341. this.airRelease = Mathf.Clamp(this.airRelease - Time.unscaledDeltaTime, 0f, float.MaxValue);
  342. if (Math.Abs(this.airRelease) < 1.401298E-45f)
  343. {
  344. this.ReleaseCharge(true);
  345. }
  346. }
  347. }
  348. public void StartCharge(bool inAir)
  349. {
  350. this.startCharge = true;
  351. this.listener.charge = false;
  352. this.player.ChangeState((!inAir) ? PlayerAction.StateEnum.Charge1Ready : PlayerAction.StateEnum.AirCharging, 1f);
  353. }
  354. public void ReleaseCharge(bool inAir)
  355. {
  356. this.startCharge = false;
  357. this.listener.charge = true;
  358. this.listener.ChargeEffectDisappear();
  359. PlayerAction.StateEnum sta = (!inAir) ? PlayerAction.StateEnum.Charge1End : PlayerAction.StateEnum.AirChargeEnd;
  360. this.player.ChangeState(sta, 1f);
  361. this.player.pab.charge.ChargeReset();
  362. this.chargeTime = 0f;
  363. this.airRelease = 0f;
  364. }
  365. public void ChargeCancel()
  366. {
  367. this.listener.ChargeEffectDisappear();
  368. this.startCharge = false;
  369. this.chargeTime = 0f;
  370. this.airRelease = 0f;
  371. }
  372. public void AddChargeLevel()
  373. {
  374. this.chargeTime = Mathf.Clamp(this.chargeTime + 1.5f, 0f, this.maxChargeTime);
  375. }
  376. public void HandleShadeAttack()
  377. {
  378. R.Player.TimeController.SetSpeed(Vector2.zero);
  379. R.Player.Rigidbody2D.gravityScale = 0f;
  380. this.listener.isFalling = false;
  381. this.listener.checkFallDown = false;
  382. this.listener.checkHitGround = false;
  383. this.player.ChangeState(PlayerAction.StateEnum.Disappear, 1f);
  384. Transform transform = R.Effect.Generate(191, null, base.transform.position, default(Vector3), default(Vector3), true);
  385. Vector3 localScale = transform.localScale;
  386. localScale.x *= (float)(-(float)this.pAttr.faceDir);
  387. transform.localScale = localScale;
  388. }
  389. public void HandleBladeStorm()
  390. {
  391. R.Player.TimeController.SetSpeed(Vector2.zero);
  392. this.player.ChangeState(PlayerAction.StateEnum.RollGround, 1f);
  393. }
  394. public void AirAttackReset()
  395. {
  396. if (!this.airAttackReset)
  397. {
  398. this.airAttackReset = true;
  399. }
  400. }
  401. private PlayerAttribute pAttr;
  402. private int attackID;
  403. private const int comboID = 1;
  404. private const int cirtComboID = 9;
  405. private const int cirtHoldComboID = 12;
  406. private const int airComboID = 1;
  407. private const int airCirtComboID = 4;
  408. private const int airCirtHoldComboID = 10;
  409. private bool continueAttack;
  410. private bool continueAirAttack;
  411. public bool cirtAttack;
  412. [SerializeField]
  413. private TextAsset weaponConfigure;
  414. private JsonData comboConfig;
  415. private PlayerAction player;
  416. private PlayerAnimEventListener listener;
  417. private bool airAttackReset;
  418. [HideInInspector]
  419. public bool canChangeAtkAnim;
  420. [HideInInspector]
  421. public bool canChangeAirAtkAnim;
  422. private float chargeTime;
  423. private bool startCharge;
  424. private float lastFrameTime;
  425. private float airRelease;
  426. private PlayerExecuteTools execute;
  427. }