StatusViewer.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 bool isEnabledGameModeChangeButton
  40. {
  41. get
  42. {
  43. return !(this.gameModeChangeBtn == null) && this.gameModeChangeBtn.gameObject.activeSelf;
  44. }
  45. set
  46. {
  47. if (this.gameModeChangeBtn == null)
  48. {
  49. return;
  50. }
  51. this.gameModeChangeBtn.gameObject.SetActive(value);
  52. }
  53. }
  54. public void Awake()
  55. {
  56. if (DailyMgr.IsLegacy)
  57. {
  58. base.gameObject.SetActive(false);
  59. return;
  60. }
  61. for (int i = 0; i < this.clubGauges.Length; i++)
  62. {
  63. this.clubGauges[i].type = UIBasicSprite.Type.Filled;
  64. }
  65. this.clubNameInputPanel.gameObject.SetActive(false);
  66. EventDelegate.Add(this.clubNameInput.onChange, new EventDelegate.Callback(this.OnInputClubName));
  67. EventDelegate.Add(this.clubNameChangeBtn.onClick, new EventDelegate.Callback(this.OpenClubNameInputPanel));
  68. EventDelegate.Add(this.clubNameInputOk.onClick, new EventDelegate.Callback(this.OnInputClubNameOK));
  69. EventDelegate.Add(this.clubNameInputCancel.onClick, new EventDelegate.Callback(this.CloseClubNameInputPanel));
  70. EventDelegate.Add(this.mainBusinessChangeBtn.onClick, new EventDelegate.Callback(this.OnClickMainBusinessChange));
  71. if (this.gameModeChangeBtn != null)
  72. {
  73. EventDelegate.Add(this.gameModeChangeBtn.onClick, new EventDelegate.Callback(this.OnClickGameModeChange));
  74. }
  75. bool flag = false;
  76. this.isEnabledMainBusinessChangeButton = flag;
  77. this.isEnabledClubNameChangeButton = flag;
  78. this.isEnabledGameModeChangeButton = false;
  79. }
  80. public void Start()
  81. {
  82. this.UpdateInfoData();
  83. }
  84. public void UpdateInfoData()
  85. {
  86. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  87. this.clubNameLabel.text = characterMgr.status.clubName;
  88. this.clubEvaluationLabel.text = characterMgr.status.clubEvaluation.ToString();
  89. this.numberOfMaidsLabel.text = characterMgr.GetStockMaidCount().ToString();
  90. this.daysLabel.text = characterMgr.status.days.ToString();
  91. this.moneyLabel.text = characterMgr.status.moneyText;
  92. for (int i = 0; i < this.gradeImages.Length; i++)
  93. {
  94. this.gradeImages[i].SetActive(i < characterMgr.status.clubGrade);
  95. }
  96. int num = characterMgr.status.clubGauge;
  97. for (int j = 0; j < this.clubGauges.Length; j++)
  98. {
  99. float num2 = (float)num / (100f / (float)this.clubGauges.Length);
  100. num2 = wf.Math.RoundMinMax(num2, 0f, 1f);
  101. this.clubGauges[j].fillAmount = num2;
  102. num -= (int)(100f / (float)this.clubGauges.Length);
  103. }
  104. if (0 <= GameMain.Instance.FacilityMgr.NowBusinessTypeID)
  105. {
  106. FacilityDataTable.BusinessTypeData facilityBusinessTypeData = FacilityDataTable.GetFacilityBusinessTypeData(GameMain.Instance.FacilityMgr.NowBusinessTypeID);
  107. this.mainBusinessLabel.text = facilityBusinessTypeData.name;
  108. }
  109. else
  110. {
  111. this.mainBusinessLabel.text = "-";
  112. }
  113. }
  114. private void OnClickMainBusinessChange()
  115. {
  116. Action<bool, string> callback = delegate(bool changed, string imageName)
  117. {
  118. if (changed)
  119. {
  120. this.UpdateInfoData();
  121. }
  122. };
  123. this.mainBusinessWindow.OpenBusinessWindow(callback);
  124. }
  125. private void OnClickGameModeChange()
  126. {
  127. this.gameModeChangeWindow.Open(null);
  128. }
  129. private void OnInputClubName()
  130. {
  131. string clubName = GameMain.Instance.CharacterMgr.status.clubName;
  132. GameMain.Instance.CharacterMgr.status.clubName = UIInput.current.value;
  133. UIInput.current.value = GameMain.Instance.CharacterMgr.status.clubName;
  134. GameMain.Instance.CharacterMgr.status.clubName = clubName;
  135. }
  136. private void OnInputClubNameOK()
  137. {
  138. GameMain.Instance.CharacterMgr.status.clubName = this.clubNameInput.value;
  139. this.clubNameLabel.text = GameMain.Instance.CharacterMgr.status.clubName;
  140. this.CloseClubNameInputPanel();
  141. }
  142. private void OpenClubNameInputPanel()
  143. {
  144. this.clubNameInput.value = GameMain.Instance.CharacterMgr.status.clubName;
  145. this.clubNameInputPanel.gameObject.SetActive(true);
  146. this.clubNameInputPanel.alpha = 0f;
  147. this.clubNameInputOk.GetComponent<BoxCollider>().enabled = true;
  148. this.clubNameInputCancel.GetComponent<BoxCollider>().enabled = true;
  149. TweenAlpha tweenAlpha = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  150. if (tweenAlpha != null)
  151. {
  152. UnityEngine.Object.DestroyImmediate(tweenAlpha);
  153. }
  154. tweenAlpha = this.clubNameInputPanel.gameObject.AddComponent<TweenAlpha>();
  155. tweenAlpha.from = 0f;
  156. tweenAlpha.to = 1f;
  157. tweenAlpha.duration = 0.3f;
  158. tweenAlpha.PlayForward();
  159. EventDelegate.Set(tweenAlpha.onFinished, delegate()
  160. {
  161. TweenAlpha component = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  162. if (component != null)
  163. {
  164. UnityEngine.Object.DestroyImmediate(component);
  165. }
  166. this.clubNameInput.isSelected = true;
  167. });
  168. }
  169. private void CloseClubNameInputPanel()
  170. {
  171. this.clubNameInput.RemoveFocus();
  172. this.clubNameInputOk.GetComponent<BoxCollider>().enabled = false;
  173. this.clubNameInputCancel.GetComponent<BoxCollider>().enabled = false;
  174. TweenAlpha tweenAlpha = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  175. if (tweenAlpha != null)
  176. {
  177. UnityEngine.Object.DestroyImmediate(tweenAlpha);
  178. }
  179. tweenAlpha = this.clubNameInputPanel.gameObject.AddComponent<TweenAlpha>();
  180. tweenAlpha.from = 1f;
  181. tweenAlpha.to = 0f;
  182. tweenAlpha.duration = 0.3f;
  183. tweenAlpha.PlayForward();
  184. EventDelegate.Set(tweenAlpha.onFinished, delegate()
  185. {
  186. TweenAlpha component = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  187. if (component != null)
  188. {
  189. UnityEngine.Object.DestroyImmediate(component);
  190. }
  191. this.clubNameInputPanel.gameObject.SetActive(false);
  192. });
  193. }
  194. [SerializeField]
  195. private UILabel clubNameLabel;
  196. [SerializeField]
  197. private UIButton clubNameChangeBtn;
  198. [SerializeField]
  199. private UILabel mainBusinessLabel;
  200. [SerializeField]
  201. private UIButton mainBusinessChangeBtn;
  202. [SerializeField]
  203. private UISprite mainBusinessImage;
  204. [SerializeField]
  205. private UIButton gameModeChangeBtn;
  206. [SerializeField]
  207. private UILabel clubEvaluationLabel;
  208. [SerializeField]
  209. private UILabel numberOfMaidsLabel;
  210. [SerializeField]
  211. private UILabel daysLabel;
  212. [SerializeField]
  213. private UILabel moneyLabel;
  214. [SerializeField]
  215. private GameObject[] gradeImages;
  216. [SerializeField]
  217. private UISprite[] clubGauges;
  218. [SerializeField]
  219. private UIPanel clubNameInputPanel;
  220. [SerializeField]
  221. private UIInput clubNameInput;
  222. [SerializeField]
  223. private UIButton clubNameInputOk;
  224. [SerializeField]
  225. private UIButton clubNameInputCancel;
  226. [SerializeField]
  227. private MainBusinessWindow mainBusinessWindow;
  228. [SerializeField]
  229. private LifeModeChangeWindow gameModeChangeWindow;
  230. }