ShadeAttackSkill.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using LitJson;
  3. using UnityEngine;
  4. public class ShadeAttackSkill : BaseBehaviour
  5. {
  6. private void Start()
  7. {
  8. this.activeIndex = 0;
  9. if (this.data != null)
  10. {
  11. this.jsonData = JsonMapper.ToObject(this.data.text);
  12. }
  13. }
  14. private void Update()
  15. {
  16. if (this.activeIndex >= this.animArray.Length)
  17. {
  18. return;
  19. }
  20. this.activeTime += Time.deltaTime;
  21. if (this.activeTime > this.activeTimeArray[this.activeIndex])
  22. {
  23. this.Active();
  24. this.activeTime = 0f;
  25. }
  26. }
  27. private void Active()
  28. {
  29. if (this.activeIndex >= this.animArray.Length)
  30. {
  31. return;
  32. }
  33. this.animArray[this.activeIndex].SetActive(true);
  34. this.animArray[this.activeIndex].GetComponentInChildren<PlayerAtk>().SetData(this.jsonData["ShadeAtkSkill"], Incrementor.GetNextId());
  35. R.Audio.PlayEffect(200, new Vector3?(base.transform.position));
  36. this.activeIndex++;
  37. }
  38. private void OnDestroy()
  39. {
  40. bool isOnGround = R.Player.Attribute.isOnGround;
  41. R.Player.TimeController.SetSpeed(new Vector2(0f, 0f));
  42. R.Player.Rigidbody2D.gravityScale = 1f;
  43. R.Player.Action.ChangeState((!isOnGround) ? PlayerAction.StateEnum.RollEndFrame : PlayerAction.StateEnum.Atk14, 1f);
  44. }
  45. [SerializeField]
  46. private TextAsset data;
  47. private JsonData jsonData;
  48. [SerializeField]
  49. private GameObject[] animArray;
  50. [SerializeField]
  51. private float[] activeTimeArray;
  52. private int activeIndex;
  53. private float activeTime;
  54. }