DahalFAnim.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. using System;
  2. using System.Collections;
  3. using DatabaseModel;
  4. using DG.Tweening;
  5. using GameWorld;
  6. using LitJson;
  7. using OnionSkin;
  8. using UnityEngine;
  9. public class DahalFAnim : BaseBehaviour
  10. {
  11. private PlayerManager player
  12. {
  13. get
  14. {
  15. return R.Player;
  16. }
  17. }
  18. private void Start()
  19. {
  20. this._eAction = base.GetComponent<DahalFAction>();
  21. this._eAttr = base.GetComponent<EnemyAttribute>();
  22. this._atk = base.GetComponentInChildren<EnemyAtk>();
  23. this._atkData = SingletonMono<EnemyDataPreload>.Instance.attack[EnemyType.达哈尔终极版];
  24. this._onion = base.GetComponent<OnionCreator>();
  25. this._baseHurt = base.GetComponent<EnemyBaseHurt>();
  26. }
  27. private void Update()
  28. {
  29. if (this._eAttr.isDead)
  30. {
  31. return;
  32. }
  33. this.UpdateFlyToFall();
  34. this.UpdateHitGround();
  35. this.UpdatePushDown();
  36. }
  37. private void UpdateFlyToFall()
  38. {
  39. if (this._eAttr.isFlyingUp)
  40. {
  41. bool flag = this.MaxFlyHeight > 0f && this._eAttr.height >= this.MaxFlyHeight;
  42. if (flag)
  43. {
  44. Vector2 currentSpeed = this._eAttr.timeController.GetCurrentSpeed();
  45. currentSpeed.y = 0f;
  46. this._eAttr.timeController.SetSpeed(currentSpeed);
  47. }
  48. if (this._eAttr.timeController.GetCurrentSpeed().y <= 0f)
  49. {
  50. this._eAttr.isFlyingUp = false;
  51. this._eAction.AnimChangeState("HitToFly3", 1f);
  52. }
  53. }
  54. }
  55. private void UpdateHitGround()
  56. {
  57. if (this._eAttr.checkHitGround && this._eAttr.isOnGround)
  58. {
  59. this._eAttr.checkHitGround = false;
  60. R.Effect.Generate(6, base.transform, default(Vector3), default(Vector3), default(Vector3), true);
  61. this._eAction.AnimChangeState("HitGround", 1f);
  62. }
  63. }
  64. private void UpdatePushDown()
  65. {
  66. if (this._pushDown && this._eAttr.isOnGround)
  67. {
  68. this._pushDown = false;
  69. this._eAttr.timeController.SetGravity(1f);
  70. Vector2 currentSpeed = this._eAttr.timeController.GetCurrentSpeed();
  71. currentSpeed.x = (float)(5 * this._eAttr.faceDir);
  72. this._eAttr.timeController.SetSpeed(currentSpeed);
  73. this._eAction.AnimChangeState(DahalFAction.StateEnum.AirPushEnd, 1f);
  74. }
  75. }
  76. public void ChangeState_Anim(DahalFAction.StateEnum sta)
  77. {
  78. this._eAction.AnimChangeState(sta, 1f);
  79. }
  80. public void HitGround()
  81. {
  82. this._eAttr.checkHitGround = true;
  83. this._pushDown = false;
  84. }
  85. public void FlyUp()
  86. {
  87. this._eAttr.isFlyingUp = true;
  88. this._pushDown = false;
  89. }
  90. public void GetUp()
  91. {
  92. this._eAttr.currentActionInterruptPoint = 0;
  93. this.BackToIdle();
  94. }
  95. public void Atk1Over(int move)
  96. {
  97. if (move != 1)
  98. {
  99. if (move != 2)
  100. {
  101. if (move == 3)
  102. {
  103. this.GravityScale(1f);
  104. this.ChangeState_Anim(DahalFAction.StateEnum.Atk1End1);
  105. }
  106. }
  107. else
  108. {
  109. this.ChangeState_Anim(DahalFAction.StateEnum.Atk1Move3);
  110. }
  111. }
  112. else
  113. {
  114. this.ChangeState_Anim(DahalFAction.StateEnum.Atk1Move2);
  115. }
  116. }
  117. public void StartPabody()
  118. {
  119. this._eAttr.paBody = true;
  120. }
  121. public void EndPabody()
  122. {
  123. this._eAttr.paBody = false;
  124. }
  125. public void SetAtkData()
  126. {
  127. this._atk.atkData = this._atkData[this._eAction.stateMachine.currentState];
  128. }
  129. public void SetAtkId()
  130. {
  131. this._atk.atkId = Incrementor.GetNextId();
  132. }
  133. public void GravityScale(float scale)
  134. {
  135. this._eAttr.timeController.SetGravity(scale);
  136. }
  137. public void Speed(string speed)
  138. {
  139. JsonData jsonData = JsonMapper.ToObject(speed);
  140. float num = jsonData.Get<float>("x", 0f);
  141. float y = jsonData.Get<float>("y", 0f);
  142. Vector2 speed2 = new Vector2(num * (float)this._eAttr.faceDir, y);
  143. this._eAttr.timeController.SetSpeed(speed2);
  144. }
  145. public void PushDown()
  146. {
  147. this._eAttr.isFlyingUp = false;
  148. this._eAttr.checkHitGround = false;
  149. this._pushDown = true;
  150. }
  151. public void PlaySound(int index)
  152. {
  153. R.Audio.PlayEffect(index, new Vector3?(base.transform.position));
  154. }
  155. public void PlayAtk2Sound()
  156. {
  157. R.Audio.PlayEffect(this.atk2Sound[UnityEngine.Random.Range(0, this.atk2Sound.Length)], new Vector3?(base.transform.position));
  158. }
  159. public void OpenOnion()
  160. {
  161. this._onion.Open(true, 0.7f, this.onionObj);
  162. }
  163. public void BackToIdle()
  164. {
  165. if (this._eAction.IsInWeakSta())
  166. {
  167. this._eAttr.enterWeakMod = false;
  168. this._eAction.AnimChangeState(DahalFAction.StateEnum.WeakMod, 1f);
  169. }
  170. else
  171. {
  172. this._eAction.AnimChangeState(DahalFAction.StateEnum.Idle, 1f);
  173. }
  174. }
  175. public IEnumerator WeakOver()
  176. {
  177. for (int i = 0; i < 96; i++)
  178. {
  179. if (this._eAction.stateMachine.currentState == "WeakMod" && !this._eAction.IsInWeakSta())
  180. {
  181. this._eAction.AnimChangeState(DahalFAction.StateEnum.Idle, 1f);
  182. }
  183. yield return new WaitForFixedUpdate();
  184. }
  185. yield break;
  186. }
  187. public void Shoot(int id = 0)
  188. {
  189. this.SparkL.GetComponent<SpriteRenderer>().enabled = true;
  190. this.SparkR.GetComponent<SpriteRenderer>().enabled = true;
  191. Vector2 from = (this.SparkL.position - this.SparkLGun.position).normalized;
  192. Vector2 from2 = (this.SparkR.position - this.SparkRGun.position).normalized;
  193. if (id == 1)
  194. {
  195. Transform transform = R.Effect.Generate(131, this.SparkL, new Vector3(0f, UnityEngine.Random.Range(-0.05f, 0.25f), 0f), default(Vector3), default(Vector3), true);
  196. Transform transform2 = R.Effect.Generate(131, this.SparkR, new Vector3(0f, UnityEngine.Random.Range(-0.05f, 0.25f), 0f), default(Vector3), default(Vector3), true);
  197. EnemyBulletLaucher component = transform.GetComponent<EnemyBulletLaucher>();
  198. component.SetVelocity(20f, Mathf.Sign(from.x) * Vector2.Angle(from, Vector2.up));
  199. component.damage = this._eAttr.atk;
  200. component.attacker = base.transform;
  201. component.SetAtkData(this._atkData[this._eAction.stateMachine.currentState]);
  202. EnemyBulletLaucher component2 = transform2.GetComponent<EnemyBulletLaucher>();
  203. component2.SetVelocity(20f, Mathf.Sign(from2.x) * Vector2.Angle(from2, Vector2.up));
  204. component2.damage = this._eAttr.atk;
  205. component2.attacker = base.transform;
  206. component2.SetAtkData(this._atkData[this._eAction.stateMachine.currentState]);
  207. }
  208. else
  209. {
  210. Transform transform3 = R.Effect.Generate(131, this.SparkL, new Vector3(0f, UnityEngine.Random.Range(-0.2f, 0.15f), 0f), default(Vector3), default(Vector3), true);
  211. Transform transform4 = R.Effect.Generate(131, this.SparkR, new Vector3(0f, UnityEngine.Random.Range(-0.2f, 0.15f), 0f), default(Vector3), default(Vector3), true);
  212. EnemyBulletLaucher component3 = transform3.GetComponent<EnemyBulletLaucher>();
  213. component3.SetVelocity(20f, Mathf.Sign(from.x) * Vector2.Angle(from, Vector2.up));
  214. component3.damage = this._eAttr.atk;
  215. component3.attacker = base.transform;
  216. component3.SetAtkData(this._atkData[this._eAction.stateMachine.currentState]);
  217. EnemyBulletLaucher component4 = transform4.GetComponent<EnemyBulletLaucher>();
  218. component4.SetVelocity(20f, Mathf.Sign(from2.x) * Vector2.Angle(from2, Vector2.up));
  219. component4.damage = this._eAttr.atk;
  220. component4.attacker = base.transform;
  221. component4.SetAtkData(this._atkData[this._eAction.stateMachine.currentState]);
  222. }
  223. base.Invoke("StopShoot", 0.28f);
  224. }
  225. public void StopShoot()
  226. {
  227. this.SparkL.GetComponent<SpriteRenderer>().enabled = false;
  228. this.SparkR.GetComponent<SpriteRenderer>().enabled = false;
  229. }
  230. public void RollOver()
  231. {
  232. base.GetComponent<AnimMoveController>().AnimMoveLoopReset();
  233. }
  234. public void ShowATK6FallSpark()
  235. {
  236. R.Effect.Generate(149, base.transform, new Vector3(0.35f, 0.05f, 0f), default(Vector3), default(Vector3), true);
  237. }
  238. public void ShowATK6Effect()
  239. {
  240. this.DahalAtk6Effect.rotation = Quaternion.Euler(0f, (float)((base.transform.localScale.x >= 0f) ? 0 : 180), 0f);
  241. this.DahalAtk6Effect.GetChild(0).localPosition = new Vector3((base.transform.localScale.x >= 0f) ? 0.45f : -0.45f, 0f, 0f);
  242. this.DahalAtk6Effect.gameObject.SetActive(true);
  243. }
  244. public void StopATK6Effect()
  245. {
  246. this.DahalAtk6Effect.gameObject.SetActive(false);
  247. }
  248. public void ShowChangeStateEffect(int id = 0)
  249. {
  250. if (id != 0)
  251. {
  252. return;
  253. }
  254. R.Effect.Generate(150, this.LBlade, Vector3.zero, new Vector3(0f, 0f, (float)((base.transform.localScale.x >= 0f) ? 0 : 90)), default(Vector3), true);
  255. R.Effect.Generate(150, this.RBlade, Vector3.zero, new Vector3(0f, 0f, (float)((base.transform.localScale.x >= 0f) ? 0 : 90)), default(Vector3), true);
  256. }
  257. public void DahalAngryEffect()
  258. {
  259. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(CameraEffectProxyPrefabData.GetPrefab(18));
  260. gameObject.transform.position = this._baseHurt.center.position;
  261. base.StartCoroutine(this.PlayDahalHaloEffect());
  262. }
  263. public IEnumerator PlayDahalHaloEffect()
  264. {
  265. for (int i = 0; i < 4; i++)
  266. {
  267. R.Effect.Generate(17, null, this._baseHurt.center.position, default(Vector3), default(Vector3), true);
  268. yield return new WaitForSeconds(0.1f);
  269. }
  270. yield break;
  271. }
  272. public void DestroySelf()
  273. {
  274. this.RealDestroy();
  275. }
  276. private void RealDestroy()
  277. {
  278. UnityEngine.Object.Destroy(base.gameObject);
  279. }
  280. public void QTEHurtPlayerApppear()
  281. {
  282. this.player.Transform.position = base.transform.position;
  283. this.player.Action.ChangeState(PlayerAction.StateEnum.RollEnd, 1f);
  284. }
  285. public void QTEFinalHurt()
  286. {
  287. EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.QTEHurt);
  288. EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.GameObject, args);
  289. }
  290. public void ExecuteCameraMoveUp()
  291. {
  292. R.Camera.Controller.CameraMoveToBySpeed(base.transform.position + Vector3.up * 9f, 25f, false, Ease.Linear);
  293. R.Camera.Controller.CameraShake(0.166666672f, 0.2f, CameraController.ShakeTypeEnum.Rect, false);
  294. this.ExecuteAirHurt();
  295. }
  296. public void ExecuteCameraMoveDown()
  297. {
  298. R.Camera.Controller.CameraShake(0.166666672f, 0.3f, CameraController.ShakeTypeEnum.Rect, false);
  299. this._baseHurt.HitEffect(this._baseHurt.center.localPosition, "Atk1");
  300. R.Camera.Controller.CameraMoveToBySpeed(base.transform.position - Vector3.up * 9f, 25f, false, Ease.Linear);
  301. }
  302. public void ExecuteShadeAtk(int dir)
  303. {
  304. Transform transform = R.Effect.Generate(177, null, this._baseHurt.center.position + Vector3.down, default(Vector3), default(Vector3), true);
  305. Vector3 localScale = transform.localScale;
  306. localScale.x = (float)dir;
  307. transform.localScale = localScale;
  308. R.Camera.Controller.CameraShake(0.166666672f, 0.3f, CameraController.ShakeTypeEnum.Rect, false);
  309. }
  310. public void ExecutePlayerRoll()
  311. {
  312. this.player.Transform.position = base.transform.position + Vector3.up * 16f;
  313. this.player.Action.ChangeState(PlayerAction.StateEnum.DahalRoll, 1f);
  314. }
  315. public void ExecuteCameraShake()
  316. {
  317. R.Camera.Controller.CameraShake(0.166666672f, 0.3f, CameraController.ShakeTypeEnum.Rect, true);
  318. }
  319. public void ExecuteAirHurt()
  320. {
  321. this._baseHurt.HitEffect(this._baseHurt.center.localPosition, "Atk1");
  322. }
  323. public void ExecuteFinalHurt()
  324. {
  325. EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.Execute, string.Empty);
  326. EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.GameObject, args);
  327. }
  328. public void ExecuteCameraRecover()
  329. {
  330. R.Camera.Controller.CameraZoomFinished();
  331. }
  332. public float MaxFlyHeight;
  333. private DahalFAction _eAction;
  334. private EnemyAttribute _eAttr;
  335. private EnemyAtk _atk;
  336. private JsonData _atkData;
  337. private bool _pushDown;
  338. [SerializeField]
  339. private Transform SparkL;
  340. [SerializeField]
  341. private Transform SparkR;
  342. [SerializeField]
  343. private Transform SparkLGun;
  344. [SerializeField]
  345. private Transform SparkRGun;
  346. [SerializeField]
  347. private Transform LBlade;
  348. [SerializeField]
  349. private Transform RBlade;
  350. [SerializeField]
  351. private Transform DahalAtk6Effect;
  352. private OnionCreator _onion;
  353. [SerializeField]
  354. private GameObject[] onionObj;
  355. private EnemyBaseHurt _baseHurt;
  356. [SerializeField]
  357. private int[] atk2Sound;
  358. }