ResultIncomeCtrl.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using PlayerStatus;
  5. using UnityEngine;
  6. public class ResultIncomeCtrl : MonoBehaviour
  7. {
  8. public void Init(ResultIncomeMgr resultIncomeMgr, GameObject goPanel)
  9. {
  10. this.m_goPanel = goPanel;
  11. this.m_mgr = resultIncomeMgr;
  12. foreach (GameObject gameObject in this.disableObjectList)
  13. {
  14. gameObject.SetActive(false);
  15. }
  16. }
  17. private void InitViewer()
  18. {
  19. this.m_listTween = new List<ResultIncomeCtrl.TweenAlphaHelper>();
  20. GameObject childObject = UTY.GetChildObject(this.m_goPanel, "SalonEvaluation", false);
  21. GameObject childObject2 = UTY.GetChildObject(childObject, "ClientEvaluation/Value", false);
  22. this.m_lClientEvaluation = childObject2.GetComponent<UILabel>();
  23. GameObject childObject3 = UTY.GetChildObject(childObject, "AcquisitionEvaluation/Value", false);
  24. this.m_lAcquisitionEvaluation = childObject3.GetComponent<UILabel>();
  25. ResultIncomeCtrl.TweenAlphaHelper tweenAlphaHelper = new ResultIncomeCtrl.TweenAlphaHelper();
  26. tweenAlphaHelper.syncTarget = new List<GameObject>
  27. {
  28. childObject2,
  29. childObject3
  30. };
  31. this.m_listTween.Add(tweenAlphaHelper);
  32. GameObject childObject4 = UTY.GetChildObject(childObject, "Result/Value", false);
  33. this.m_lResult = childObject4.GetComponent<UILabel>();
  34. tweenAlphaHelper = new ResultIncomeCtrl.TweenAlphaHelper();
  35. tweenAlphaHelper.target = childObject4;
  36. this.m_listTween.Add(tweenAlphaHelper);
  37. this.m_goIncome = UTY.GetChildObject(this.m_goPanel, "Income", false);
  38. GameObject childObject5 = UTY.GetChildObject(this.m_goIncome, "WorkingFunds/Value", false);
  39. this.m_lWorkingFunds = childObject5.GetComponent<UILabel>();
  40. GameObject childObject6 = UTY.GetChildObject(this.m_goIncome, "ClubIncome/Value", false);
  41. this.m_lClubIncome = childObject6.GetComponent<UILabel>();
  42. GameObject childObject7 = UTY.GetChildObject(this.m_goIncome, "BonusIncome/Value", false);
  43. this.m_lBonusIncome = childObject7.GetComponent<UILabel>();
  44. GameObject childObject8 = UTY.GetChildObject(this.m_goIncome, "BonusIncome", false);
  45. this.m_lBonusIncomeParent = childObject8.GetComponent<UILabel>();
  46. tweenAlphaHelper = new ResultIncomeCtrl.TweenAlphaHelper();
  47. tweenAlphaHelper.syncTarget = new List<GameObject>
  48. {
  49. childObject5,
  50. childObject6
  51. };
  52. this.m_listTween.Add(tweenAlphaHelper);
  53. GameObject childObject9 = UTY.GetChildObject(this.m_goIncome, "TotalAmount/Value", false);
  54. this.m_lTotalAmount = childObject9.GetComponent<UILabel>();
  55. tweenAlphaHelper = new ResultIncomeCtrl.TweenAlphaHelper();
  56. tweenAlphaHelper.target = childObject9;
  57. this.m_listTween.Add(tweenAlphaHelper);
  58. this.m_spBG = UTY.GetChildObject(this.m_goPanel, "BG", false).GetComponent<UISprite>();
  59. this.orgHeightOfBG = this.m_spBG.height;
  60. UIButton component = UTY.GetChildObject(this.m_goPanel, "Ok", false).GetComponent<UIButton>();
  61. EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_mgr.CloseResultIncome));
  62. }
  63. public void CreateViewer(ResultIncomeCtrl.ResultIncome loadData)
  64. {
  65. if (!this.m_bInit)
  66. {
  67. this.InitViewer();
  68. this.m_bInit = true;
  69. }
  70. this.setData(loadData);
  71. }
  72. public void setData(ResultIncomeCtrl.ResultIncome loadData)
  73. {
  74. this.m_lClientEvaluation.text = loadData.clientEvaluation.ToString();
  75. this.m_lAcquisitionEvaluation.text = this.Sign(loadData.acquisitionEvaluation);
  76. this.m_lResult.text = loadData.result.ToString();
  77. this.m_goIncome.SetActive(true);
  78. this.m_lWorkingFunds.text = loadData.workingFunds.ToString("#,0");
  79. this.m_lClubIncome.text = this.SignIncome((int)loadData.clubIncome);
  80. if (loadData.bonusIncome != 0L)
  81. {
  82. this.m_lBonusIncome.text = "+" + loadData.bonusIncome.ToString("#,0");
  83. }
  84. else
  85. {
  86. this.m_lBonusIncomeParent.gameObject.SetActive(false);
  87. }
  88. this.m_lTotalAmount.text = loadData.totalAmount.ToString("#,0");
  89. }
  90. private string Sign(int input)
  91. {
  92. if (input >= 0)
  93. {
  94. return "+" + input.ToString();
  95. }
  96. return "-" + input.ToString();
  97. }
  98. private string SignIncome(int input)
  99. {
  100. if (input >= 0)
  101. {
  102. return "+" + input.ToString("#,0");
  103. }
  104. return input.ToString("#,0");
  105. }
  106. public void DispLevelUp()
  107. {
  108. Status status = GameMain.Instance.CharacterMgr.status;
  109. int clubGrade = status.clubGrade;
  110. string text = string.Format("クラブのグレードが{0}にあがりました", clubGrade);
  111. text += "\n新しい夜伽ステージが追加されました";
  112. if (3 <= clubGrade)
  113. {
  114. text += "\n新しい依頼が追加されました";
  115. }
  116. if (GameMain.Instance.CharacterMgr.status.isAvailableShop)
  117. {
  118. text += "\nショップに新しい商品が追加されました";
  119. }
  120. GameMain.Instance.SoundMgr.PlaySystem("SE008.ogg");
  121. GameMain.Instance.SysDlg.Show(text, SystemDialog.TYPE.OK, new SystemDialog.OnClick(this.m_mgr.CloseResultIncome), null);
  122. }
  123. public IEnumerator StartAnimation(Action onFinished = null)
  124. {
  125. foreach (ResultIncomeCtrl.TweenAlphaHelper tween in this.m_listTween)
  126. {
  127. if (tween.target != null)
  128. {
  129. this.PlayTweenAlpha(tween.target);
  130. yield return new WaitForSeconds(0.5f);
  131. }
  132. else if (tween.syncTarget != null)
  133. {
  134. foreach (GameObject target in tween.syncTarget)
  135. {
  136. this.PlayTweenAlpha(target);
  137. }
  138. yield return new WaitForSeconds(0.5f);
  139. }
  140. }
  141. yield return new WaitForSeconds(0.5f);
  142. if (onFinished != null)
  143. {
  144. onFinished();
  145. }
  146. yield break;
  147. }
  148. private void PlayTweenAlpha(GameObject target)
  149. {
  150. TweenAlpha tweenAlpha = target.GetComponent<TweenAlpha>();
  151. if (tweenAlpha)
  152. {
  153. UnityEngine.Object.Destroy(tweenAlpha);
  154. }
  155. tweenAlpha = target.AddComponent<TweenAlpha>();
  156. tweenAlpha.from = 0f;
  157. tweenAlpha.to = 1f;
  158. tweenAlpha.delay = 0.5f;
  159. tweenAlpha.duration = 1f;
  160. tweenAlpha.PlayForward();
  161. }
  162. public void OnDisable()
  163. {
  164. UICamera.InputEnable = true;
  165. }
  166. private ResultIncomeMgr m_mgr;
  167. private List<ResultIncomeCtrl.TweenAlphaHelper> m_listTween;
  168. private GameObject m_goPanel;
  169. private GameObject m_goIncome;
  170. private UILabel m_lClientEvaluation;
  171. private UILabel m_lAcquisitionEvaluation;
  172. private UILabel m_lResult;
  173. private UILabel m_lWorkingFunds;
  174. private UILabel m_lClubIncome;
  175. private UILabel m_lBonusIncome;
  176. private UILabel m_lBonusIncomeParent;
  177. private UILabel m_lTotalAmount;
  178. private UILabel m_lBalance;
  179. private UILabel m_lUntilFullPayment;
  180. private UISprite m_spBG;
  181. private bool m_bInit;
  182. private int orgHeightOfBG;
  183. private const int HEIGHT_OF_BG_TO_UNDISP_LOAN = 560;
  184. private const float DEFAULT_INTERVAL = 0.5f;
  185. private const string SYSTEM_UI_ROOT_PATH = "__GameMain__/SystemUI Root";
  186. private const string TEMPLATE_LEVEL_UP = "クラブのグレードが{0}にあがりました";
  187. [SerializeField]
  188. private List<GameObject> disableObjectList = new List<GameObject>();
  189. private class TweenAlphaHelper
  190. {
  191. public TweenAlphaHelper()
  192. {
  193. this.delay = 1f;
  194. this.duration = 1f;
  195. this.AlphaFrom = 0f;
  196. this.AlphaTo = 1f;
  197. }
  198. public List<GameObject> syncTarget;
  199. public GameObject target;
  200. public float delay;
  201. public float duration;
  202. public float AlphaFrom;
  203. public float AlphaTo;
  204. public const float DEFAULT_INTERVAL = 0.1f;
  205. }
  206. public class ResultIncome
  207. {
  208. public int clientEvaluation;
  209. public int acquisitionEvaluation;
  210. public int result;
  211. public long workingFunds;
  212. public long clubIncome;
  213. public long bonusIncome;
  214. public long totalAmount;
  215. public long balance;
  216. public long balanceClubIncome;
  217. public long untilFullPaymen;
  218. public int beforeCleanliness;
  219. public int afterCleanliness;
  220. public int beforeBrilliant;
  221. public int afterBrilliant;
  222. public bool fullPayment;
  223. }
  224. }