UIEnhancementDescController.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using UnityEngine;
  3. public class UIEnhancementDescController : MonoBehaviour
  4. {
  5. private int Coin
  6. {
  7. get
  8. {
  9. return int.Parse(this._coin.text);
  10. }
  11. set
  12. {
  13. this._coin.text = value.ToString();
  14. }
  15. }
  16. private int TotalCoin
  17. {
  18. get
  19. {
  20. return this._totalCoinCache;
  21. }
  22. set
  23. {
  24. if (this._totalCoinCache != value)
  25. {
  26. this._totalCoinCache = value;
  27. this._totalCoin.text = value.ToString();
  28. }
  29. }
  30. }
  31. private string Desc
  32. {
  33. get
  34. {
  35. return this._desc.text;
  36. }
  37. set
  38. {
  39. this._desc.text = value;
  40. }
  41. }
  42. private string NextLevelDesc
  43. {
  44. get
  45. {
  46. return this._nextLevelDesc.text;
  47. }
  48. set
  49. {
  50. this._nextLevelDesc.text = value;
  51. }
  52. }
  53. private string Controlkeys
  54. {
  55. get
  56. {
  57. return this.control_keys.text;
  58. }
  59. set
  60. {
  61. this.control_keys.text = value;
  62. }
  63. }
  64. private void Awake()
  65. {
  66. this._deadlyDiscIcon = this.control_keys.transform.GetChild(0).gameObject;
  67. }
  68. private void OnEnable()
  69. {
  70. if(UIEnhancementItem.Current!=null)
  71. this._coin.color = ((!UIEnhancementItem.Current.CoinEnough) ? UIEnhancementDescController.ColorRed : Color.white);
  72. }
  73. private void Update()
  74. {
  75. this.TotalCoin = R.Equipment.CoinNum;
  76. EnhancementItem current = UIEnhancementItem.Current;
  77. if (current != null && !current.Equals(this._currentItem))
  78. {
  79. this._currentItem = current;
  80. this._level = this._currentItem.Level;
  81. if (this._level == 3)
  82. {
  83. this._coin.gameObject.SetActive(false);
  84. this._nextLevelDesc.gameObject.SetActive(false);
  85. this._upGradeGameObject.SetActive(false);
  86. }
  87. else
  88. {
  89. this._coin.gameObject.SetActive(true);
  90. this._nextLevelDesc.gameObject.SetActive(true);
  91. this._upGradeGameObject.SetActive(true);
  92. this.Coin = this._currentItem.Cost;
  93. this.NextLevelDesc = this._currentItem.NextLevelDesc;
  94. }
  95. this.Desc = this._currentItem.Desc;
  96. string controlkeys = this._currentItem.Controlkeys;
  97. if (controlkeys == "流")
  98. {
  99. this.Controlkeys = string.Empty;
  100. this._deadlyDiscIcon.SetActive(true);
  101. }
  102. else
  103. {
  104. if (this._deadlyDiscIcon.activeSelf)
  105. {
  106. this._deadlyDiscIcon.SetActive(false);
  107. }
  108. this.Controlkeys = controlkeys;
  109. }
  110. this._coin.color = ((!current.CoinEnough) ? UIEnhancementDescController.ColorRed : Color.white);
  111. }
  112. }
  113. private static readonly Color ColorRed = new Color(1f, 0.333333343f, 0.333333343f);
  114. private EnhancementItem _currentItem;
  115. [SerializeField]
  116. private UILabel _desc;
  117. [SerializeField]
  118. private UILabel _coin;
  119. [SerializeField]
  120. private UILabel _totalCoin;
  121. [SerializeField]
  122. private UILabel _nextLevelDesc;
  123. [SerializeField]
  124. private UILabel control_keys;
  125. private GameObject _deadlyDiscIcon;
  126. [SerializeField]
  127. private GameObject _upGradeGameObject;
  128. private int _level;
  129. private int _totalCoinCache;
  130. }