StatusViewer.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. if (PluginData.IsEnabled("GP001"))
  114. {
  115. this.mainBusinessImage.spriteName = GameModeManager.GetData().strBannerImageName;
  116. }
  117. else
  118. {
  119. this.mainBusinessImage.spriteName = "main_banner_dammy";
  120. }
  121. }
  122. private void OnClickMainBusinessChange()
  123. {
  124. Action<bool, string> callback = delegate(bool changed, string imageName)
  125. {
  126. if (changed)
  127. {
  128. this.UpdateInfoData();
  129. }
  130. };
  131. this.mainBusinessWindow.OpenBusinessWindow(callback);
  132. }
  133. private void OnClickGameModeChange()
  134. {
  135. this.gameModeChangeWindow.Open(delegate
  136. {
  137. this.mainBusinessImage.spriteName = GameModeManager.GetData().strBannerImageName;
  138. });
  139. }
  140. private void OnInputClubName()
  141. {
  142. string clubName = GameMain.Instance.CharacterMgr.status.clubName;
  143. GameMain.Instance.CharacterMgr.status.clubName = UIInput.current.value;
  144. UIInput.current.value = GameMain.Instance.CharacterMgr.status.clubName;
  145. GameMain.Instance.CharacterMgr.status.clubName = clubName;
  146. }
  147. private void OnInputClubNameOK()
  148. {
  149. GameMain.Instance.CharacterMgr.status.clubName = this.clubNameInput.value;
  150. this.clubNameLabel.text = GameMain.Instance.CharacterMgr.status.clubName;
  151. this.CloseClubNameInputPanel();
  152. }
  153. private void OpenClubNameInputPanel()
  154. {
  155. this.clubNameInput.value = GameMain.Instance.CharacterMgr.status.clubName;
  156. this.clubNameInputPanel.gameObject.SetActive(true);
  157. this.clubNameInputPanel.alpha = 0f;
  158. this.clubNameInputOk.GetComponent<BoxCollider>().enabled = true;
  159. this.clubNameInputCancel.GetComponent<BoxCollider>().enabled = true;
  160. TweenAlpha tweenAlpha = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  161. if (tweenAlpha != null)
  162. {
  163. UnityEngine.Object.DestroyImmediate(tweenAlpha);
  164. }
  165. tweenAlpha = this.clubNameInputPanel.gameObject.AddComponent<TweenAlpha>();
  166. tweenAlpha.from = 0f;
  167. tweenAlpha.to = 1f;
  168. tweenAlpha.duration = 0.3f;
  169. tweenAlpha.PlayForward();
  170. EventDelegate.Set(tweenAlpha.onFinished, delegate()
  171. {
  172. TweenAlpha component = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  173. if (component != null)
  174. {
  175. UnityEngine.Object.DestroyImmediate(component);
  176. }
  177. this.clubNameInput.isSelected = true;
  178. });
  179. }
  180. private void CloseClubNameInputPanel()
  181. {
  182. this.clubNameInput.RemoveFocus();
  183. this.clubNameInputOk.GetComponent<BoxCollider>().enabled = false;
  184. this.clubNameInputCancel.GetComponent<BoxCollider>().enabled = false;
  185. TweenAlpha tweenAlpha = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  186. if (tweenAlpha != null)
  187. {
  188. UnityEngine.Object.DestroyImmediate(tweenAlpha);
  189. }
  190. tweenAlpha = this.clubNameInputPanel.gameObject.AddComponent<TweenAlpha>();
  191. tweenAlpha.from = 1f;
  192. tweenAlpha.to = 0f;
  193. tweenAlpha.duration = 0.3f;
  194. tweenAlpha.PlayForward();
  195. EventDelegate.Set(tweenAlpha.onFinished, delegate()
  196. {
  197. TweenAlpha component = this.clubNameInputPanel.gameObject.GetComponent<TweenAlpha>();
  198. if (component != null)
  199. {
  200. UnityEngine.Object.DestroyImmediate(component);
  201. }
  202. this.clubNameInputPanel.gameObject.SetActive(false);
  203. });
  204. }
  205. [SerializeField]
  206. private UILabel clubNameLabel;
  207. [SerializeField]
  208. private UIButton clubNameChangeBtn;
  209. [SerializeField]
  210. private UILabel mainBusinessLabel;
  211. [SerializeField]
  212. private UIButton mainBusinessChangeBtn;
  213. [SerializeField]
  214. private UISprite mainBusinessImage;
  215. [SerializeField]
  216. private UIButton gameModeChangeBtn;
  217. [SerializeField]
  218. private UILabel clubEvaluationLabel;
  219. [SerializeField]
  220. private UILabel numberOfMaidsLabel;
  221. [SerializeField]
  222. private UILabel daysLabel;
  223. [SerializeField]
  224. private UILabel moneyLabel;
  225. [SerializeField]
  226. private GameObject[] gradeImages;
  227. [SerializeField]
  228. private UISprite[] clubGauges;
  229. [SerializeField]
  230. private UIPanel clubNameInputPanel;
  231. [SerializeField]
  232. private UIInput clubNameInput;
  233. [SerializeField]
  234. private UIButton clubNameInputOk;
  235. [SerializeField]
  236. private UIButton clubNameInputCancel;
  237. [SerializeField]
  238. private MainBusinessWindow mainBusinessWindow;
  239. [SerializeField]
  240. private LifeModeChangeWindow gameModeChangeWindow;
  241. }