MusicPlayerAction.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using DG.Tweening;
  3. using UnityEngine;
  4. public class MusicPlayerAction : BaseBehaviour
  5. {
  6. public int currentHP
  7. {
  8. get
  9. {
  10. return this._currentHP;
  11. }
  12. set
  13. {
  14. this._currentHP = Mathf.Clamp(value, this._limited, this.maxHP);
  15. }
  16. }
  17. private Animator Anim
  18. {
  19. get
  20. {
  21. Animator result;
  22. if ((result = this._anim) == null)
  23. {
  24. result = (this._anim = base.GetComponent<Animator>());
  25. }
  26. return result;
  27. }
  28. }
  29. private void Start()
  30. {
  31. this._limited = 0;
  32. this.currentHP = this.maxHP;
  33. this.ChangeState(MusicPlayerAction.State.Appear);
  34. }
  35. public void ChangeState(MusicPlayerAction.State state)
  36. {
  37. this.Anim.Play(state.ToString());
  38. }
  39. public void SetLimited(int value)
  40. {
  41. this._limited = value;
  42. }
  43. public void StartShake()
  44. {
  45. Vector3 strength = new Vector3(0.2f, 0.2f, 0f);
  46. base.transform.DOShakePosition(1f, strength, 10, 90f, false, true).SetLoops(-1);
  47. }
  48. public void StopShake()
  49. {
  50. base.transform.DOKill(false);
  51. }
  52. private Animator _anim;
  53. private int _currentHP;
  54. private int _limited;
  55. public int maxHP;
  56. public enum State
  57. {
  58. Appear,
  59. Play,
  60. ChangeMusic,
  61. Disappear,
  62. Blast
  63. }
  64. }