FluctuationOfParameterUnit.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using UnityEngine;
  3. public class FluctuationOfParameterUnit : MonoBehaviour
  4. {
  5. private void Awake()
  6. {
  7. this.bg_sprite_ = UTY.GetChildObject(base.gameObject, "BGGray", false).GetComponent<UISprite>();
  8. this.name_label_ = UTY.GetChildObject(base.gameObject, "Name", false).GetComponent<UILabel>();
  9. this.value_label_ = UTY.GetChildObject(base.gameObject, "Value", false).GetComponent<UILabel>();
  10. }
  11. public void SetActive(bool value)
  12. {
  13. base.gameObject.SetActive(value);
  14. }
  15. public bool IsActive()
  16. {
  17. return base.gameObject.activeSelf;
  18. }
  19. public void SetBGVisible(bool value)
  20. {
  21. this.bg_sprite_.enabled = value;
  22. }
  23. public bool IsBGVisible()
  24. {
  25. return this.bg_sprite_.enabled;
  26. }
  27. public void SetTextName(string name)
  28. {
  29. this.name_label_.text = name;
  30. }
  31. public void SetTextValue(int value)
  32. {
  33. this.value_label_.text = "0";
  34. if (this.AnimeTime <= 0f)
  35. {
  36. string str = string.Empty;
  37. if (0 < value)
  38. {
  39. str += "+";
  40. }
  41. this.value_label_.text = str + value.ToString();
  42. }
  43. else
  44. {
  45. this.anime_event_ = delegate()
  46. {
  47. iTween.ValueTo(this.gameObject, iTween.Hash(new object[]
  48. {
  49. "from",
  50. 0,
  51. "to",
  52. value,
  53. "time",
  54. this.AnimeTime,
  55. "onupdate",
  56. "UpdateValue"
  57. }));
  58. };
  59. }
  60. }
  61. public void StartAnime()
  62. {
  63. if (this.anime_event_ != null)
  64. {
  65. this.anime_event_();
  66. this.anime_event_ = null;
  67. }
  68. }
  69. public void UpdateValue(int value)
  70. {
  71. string str = string.Empty;
  72. if (0 < value)
  73. {
  74. str += "+";
  75. }
  76. this.value_label_.text = str + value.ToString();
  77. }
  78. public float AnimeTime = 1f;
  79. private UISprite bg_sprite_;
  80. private UILabel name_label_;
  81. private UILabel value_label_;
  82. private Action anime_event_;
  83. }