StatusViewer.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. using System;
  2. using UnityEngine;
  3. using wf;
  4. public class StatusViewer : MonoBehaviour
  5. {
  6. public bool visible
  7. {
  8. get
  9. {
  10. return base.gameObject.activeSelf;
  11. }
  12. set
  13. {
  14. base.gameObject.SetActive(value);
  15. }
  16. }
  17. public bool isEnabledClubNameChangeButton
  18. {
  19. get
  20. {
  21. return this.clubNameChangeBtn.gameObject.activeSelf;
  22. }
  23. set
  24. {
  25. this.clubNameChangeBtn.gameObject.SetActive(value);
  26. }
  27. }
  28. public bool isEnabledMainBusinessChangeButton
  29. {
  30. get
  31. {
  32. return this.mainBusinessChangeBtn.gameObject.activeSelf;
  33. }
  34. set
  35. {
  36. this.mainBusinessChangeBtn.gameObject.SetActive(value);
  37. }
  38. }
  39. public void Awake()
  40. {
  41. if (DailyMgr.IsLegacy)
  42. {
  43. base.gameObject.SetActive(false);
  44. return;
  45. }
  46. for (int i = 0; i < this.clubGauges.Length; i++)
  47. {
  48. this.clubGauges[i].type = UIBasicSprite.Type.Filled;
  49. }
  50. this.clubNameInputPanel.gameObject.SetActive(false);
  51. EventDelegate.Add(this.clubNameInput.onChange, new EventDelegate.Callback(this.OnInputClubName));
  52. EventDelegate.Add(this.clubNameChangeBtn.onClick, new EventDelegate.Callback(this.OpenClubNameInputPanel));
  53. EventDelegate.Add(this.clubNameInputOk.onClick, new EventDelegate.Callback(this.OnInputClubNameOK));
  54. EventDelegate.Add(this.clubNameInputCancel.onClick, new EventDelegate.Callback(this.CloseClubNameInputPanel));
  55. EventDelegate.Add(this.mainBusinessChangeBtn.onClick, new EventDelegate.Callback(this.OnClickMainBusinessChange));
  56. bool flag = false;
  57. this.isEnabledMainBusinessChangeButton = flag;
  58. this.isEnabledClubNameChangeButton = flag;
  59. }
  60. public void Start()
  61. {
  62. this.UpdateInfoData();
  63. }
  64. public void UpdateInfoData()
  65. {
  66. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  67. this.clubNameLabel.text = characterMgr.status.clubName;
  68. this.clubEvaluationLabel.text = characterMgr.status.clubEvaluation.ToString();
  69. this.numberOfMaidsLabel.text = characterMgr.GetStockMaidCount().ToString();
  70. this.daysLabel.text = characterMgr.status.days.ToString();
  71. this.moneyLabel.text = characterMgr.status.moneyText;
  72. for (int i = 0; i < this.gradeImages.Length; i++)
  73. {
  74. this.gradeImages[i].SetActive(i < characterMgr.status.clubGrade);
  75. }
  76. int num = characterMgr.status.clubGauge;
  77. for (int j = 0; j < this.clubGauges.Length; j++)
  78. {
  79. float num2 = (float)num / (100f / (float)this.clubGauges.Length);
  80. num2 = wf.Math.RoundMinMax(num2, 0f, 1f);
  81. this.clubGauges[j].fillAmount = num2;
  82. num -= (int)(100f / (float)this.clubGauges.Length);
  83. }
  84. if (0 <= GameMain.Instance.FacilityMgr.NowBusinessTypeID)
  85. {
  86. FacilityDataTable.BusinessTypeData facilityBusinessTypeData = FacilityDataTable.GetFacilityBusinessTypeData(GameMain.Instance.FacilityMgr.NowBusinessTypeID);
  87. this.mainBusinessLabel.text = facilityBusinessTypeData.name;
  88. }
  89. else
  90. {
  91. this.mainBusinessLabel.text = "-";
  92. }
  93. }
  94. private void OnClickMainBusinessChange()
  95. {
  96. Action<bool, string> callback = delegate(bool changed, string imageName)
  97. {
  98. if (changed)
  99. {
  100. this.UpdateInfoData();
  101. }
  102. };
  103. this.mainBusinessWindow.OpenBusinessWindow(callback);
  104. }
  105. private void OnInputClubName()
  106. {
  107. string clubName = GameMain.Instance.CharacterMgr.status.clubName;
  108. GameMain.Instance.CharacterMgr.status.clubName = UIInput.current.value;
  109. UIInput.current.value = GameMain.Instance.CharacterMgr.status.clubName;
  110. GameMain.Instance.CharacterMgr.status.clubName = clubName;
  111. }
  112. private void OnInputClubNameOK()
  113. {
  114. GameMain.Instance.CharacterMgr.status.clubName = this.clubNameInput.value;
  115. this.clubNameLabel.text = GameMain.Instance.CharacterMgr.status.clubName;
  116. this.CloseClubNameInputPanel();
  117. }
  118. private void OpenClubNameInputPanel()
  119. {
  120. this.clubNameInput.value = GameMain.Instance.CharacterMgr.status.clubName;
  121. this.clubNameInputPanel.gameObject.SetActive(true);
  122. this.clubNameInputPanel.alpha = 0f;
  123. this.clubNameInputOk.GetComponent<BoxCollider>().enabled = true;
  124. this.clubNameInputCancel.GetComponent<BoxCollider>().enabled = true;
  125. TweenAlpha tweenAlpha = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  126. if (tweenAlpha != null)
  127. {
  128. UnityEngine.Object.DestroyImmediate(tweenAlpha);
  129. }
  130. tweenAlpha = this.clubNameInputPanel.gameObject.AddComponent<TweenAlpha>();
  131. tweenAlpha.from = 0f;
  132. tweenAlpha.to = 1f;
  133. tweenAlpha.duration = 0.3f;
  134. tweenAlpha.PlayForward();
  135. EventDelegate.Set(tweenAlpha.onFinished, delegate
  136. {
  137. TweenAlpha component = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  138. if (component != null)
  139. {
  140. UnityEngine.Object.DestroyImmediate(component);
  141. }
  142. this.clubNameInput.isSelected = true;
  143. });
  144. }
  145. private void CloseClubNameInputPanel()
  146. {
  147. this.clubNameInput.RemoveFocus();
  148. this.clubNameInputOk.GetComponent<BoxCollider>().enabled = false;
  149. this.clubNameInputCancel.GetComponent<BoxCollider>().enabled = false;
  150. TweenAlpha tweenAlpha = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  151. if (tweenAlpha != null)
  152. {
  153. UnityEngine.Object.DestroyImmediate(tweenAlpha);
  154. }
  155. tweenAlpha = this.clubNameInputPanel.gameObject.AddComponent<TweenAlpha>();
  156. tweenAlpha.from = 1f;
  157. tweenAlpha.to = 0f;
  158. tweenAlpha.duration = 0.3f;
  159. tweenAlpha.PlayForward();
  160. EventDelegate.Set(tweenAlpha.onFinished, delegate
  161. {
  162. TweenAlpha component = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  163. if (component != null)
  164. {
  165. UnityEngine.Object.DestroyImmediate(component);
  166. }
  167. this.clubNameInputPanel.gameObject.SetActive(false);
  168. });
  169. }
  170. [SerializeField]
  171. private UILabel clubNameLabel;
  172. [SerializeField]
  173. private UIButton clubNameChangeBtn;
  174. [SerializeField]
  175. private UILabel mainBusinessLabel;
  176. [SerializeField]
  177. private UIButton mainBusinessChangeBtn;
  178. [SerializeField]
  179. private UISprite mainBusinessImage;
  180. [SerializeField]
  181. private UILabel clubEvaluationLabel;
  182. [SerializeField]
  183. private UILabel numberOfMaidsLabel;
  184. [SerializeField]
  185. private UILabel daysLabel;
  186. [SerializeField]
  187. private UILabel moneyLabel;
  188. [SerializeField]
  189. private GameObject[] gradeImages;
  190. [SerializeField]
  191. private UISprite[] clubGauges;
  192. [SerializeField]
  193. private UIPanel clubNameInputPanel;
  194. [SerializeField]
  195. private UIInput clubNameInput;
  196. [SerializeField]
  197. private UIButton clubNameInputOk;
  198. [SerializeField]
  199. private UIButton clubNameInputCancel;
  200. [SerializeField]
  201. private MainBusinessWindow mainBusinessWindow;
  202. }