ExChangeUI.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System;
  2. using I2.Loc;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using wf;
  6. public class ExChangeUI : MonoBehaviour
  7. {
  8. public static ExChangeUI Instance { get; private set; }
  9. public bool IsActive
  10. {
  11. get
  12. {
  13. return base.gameObject.activeSelf;
  14. }
  15. }
  16. private void Awake()
  17. {
  18. ExChangeUI.Instance = this;
  19. this.FadeInStartAction = (Action)Delegate.Combine(this.FadeInStartAction, new Action(delegate()
  20. {
  21. this.m_ExchangeButton.interactable = false;
  22. }));
  23. this.FadeInStartAction = (Action)Delegate.Combine(this.FadeInStartAction, new Action(this.SetExchangeMax));
  24. this.FadeOutStartAction = (Action)Delegate.Combine(this.FadeOutStartAction, new Action(this.TextUIUpdate));
  25. MoneySetttingUI moneySetting = this.m_MoneySetting;
  26. moneySetting.ValueUpdateAction = (MoneySetttingUI.ValueUpdateMethod)Delegate.Combine(moneySetting.ValueUpdateAction, new MoneySetttingUI.ValueUpdateMethod(this.UIStateUpdate));
  27. this.m_MyCanvas = base.GetComponent<CanvasGroup>();
  28. this.m_RateText.text = string.Format("コイン1枚 = {0}CR", Utility.ConvertMoneyText(this.m_CoinRate));
  29. if (Product.SPP)
  30. {
  31. Localize localize = this.m_RateText.gameObject.AddComponent<Localize>();
  32. localize.TermArgs = new Localize.ArgsPair[]
  33. {
  34. Localize.ArgsPair.Create(Utility.ConvertMoneyText(this.m_CoinRate))
  35. };
  36. Utility.SetLocalizeTerm(localize, "SceneCasino/コイン1枚 = {0}CR");
  37. }
  38. this.TextUIUpdate();
  39. this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MinValue, true);
  40. base.gameObject.SetActive(false);
  41. }
  42. private void SetExchangeMax()
  43. {
  44. long num = 999999L - GameMain.Instance.CharacterMgr.status.casinoCoin;
  45. if (num <= this.m_MoneySetting.MinValue)
  46. {
  47. num = this.m_MoneySetting.MinValue;
  48. }
  49. if (num * (long)this.m_CoinRate > GameMain.Instance.CharacterMgr.status.money)
  50. {
  51. num = GameMain.Instance.CharacterMgr.status.money / (long)this.m_CoinRate;
  52. }
  53. this.m_MoneySetting.SetMaxValue(num);
  54. }
  55. public void TextUIUpdate()
  56. {
  57. this.m_MoneyUI.text = GameMain.Instance.CharacterMgr.status.moneyText;
  58. this.m_CoinUI.text = Utility.ConvertMoneyText(GameMain.Instance.CharacterMgr.status.casinoCoin);
  59. }
  60. public void SetButtonState(bool conditon)
  61. {
  62. this.m_ExchangeButton.interactable = conditon;
  63. }
  64. public void UIStateUpdate()
  65. {
  66. long money = GameMain.Instance.CharacterMgr.status.money;
  67. this.m_BalanceText.text = string.Format("-{0:#,##0}", this.m_MoneySetting.MoneyValue * (long)this.m_CoinRate);
  68. this.m_CurrentCoin.text = Utility.ConvertMoneyText(GameMain.Instance.CharacterMgr.status.casinoCoin + this.m_MoneySetting.MoneyValue);
  69. }
  70. public void PushOKButton()
  71. {
  72. GameMain.Instance.CharacterMgr.status.money -= this.m_MoneySetting.MoneyValue * (long)this.m_CoinRate;
  73. GameMain.Instance.CharacterMgr.status.casinoCoin += this.m_MoneySetting.MoneyValue;
  74. if (this.FadeOutStartAction != null)
  75. {
  76. this.FadeOutStartAction();
  77. }
  78. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, this.FadeOutEndAction, true, true));
  79. }
  80. public void PushCancelButton()
  81. {
  82. if (this.FadeOutStartAction != null)
  83. {
  84. this.FadeOutStartAction();
  85. }
  86. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, this.FadeOutEndAction, true, true));
  87. }
  88. public void PushResetButton()
  89. {
  90. this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MinValue, false);
  91. }
  92. public void PushMaxButton()
  93. {
  94. this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MaxValue, false);
  95. }
  96. public void FadeIn()
  97. {
  98. if (GameMain.Instance.CharacterMgr.status.money < this.m_MoneySetting.MinValue * (long)this.m_CoinRate)
  99. {
  100. string messageTerm = string.Format("SceneCasino/ダイアログ/換金するには最低でも資金が必用です", this.m_MoneySetting.MinValue * (long)this.m_CoinRate);
  101. GameMain.Instance.SysDlg.ShowFromLanguageTerm(messageTerm, new string[]
  102. {
  103. string.Format("{0:#,##0}", this.m_MoneySetting.MinValue * (long)this.m_CoinRate)
  104. }, SystemDialog.TYPE.OK, null, null);
  105. return;
  106. }
  107. if (GameMain.Instance.CharacterMgr.status.casinoCoin >= 999999L - this.m_MoneySetting.MinValue)
  108. {
  109. GameMain.Instance.SysDlg.ShowFromLanguageTerm("SceneCasino/ダイアログ/これ以上換金できません", null, SystemDialog.TYPE.OK, null, null);
  110. return;
  111. }
  112. if (this.FadeInStartAction != null)
  113. {
  114. this.FadeInStartAction();
  115. }
  116. base.gameObject.SetActive(true);
  117. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, false, this.m_FadeTime, this.FadeInEndAction, true, true));
  118. }
  119. private CanvasGroup m_MyCanvas;
  120. [SerializeField]
  121. private int m_CoinRate = 100;
  122. [SerializeField]
  123. private float m_FadeTime = 0.5f;
  124. [SerializeField]
  125. [Header("このUIを呼び出すボタン")]
  126. private Button m_ExchangeButton;
  127. [SerializeField]
  128. [Header("所持金表示UI")]
  129. private Text m_MoneyUI;
  130. [SerializeField]
  131. [Header("カジノコイン表示UI")]
  132. private Text m_CoinUI;
  133. [SerializeField]
  134. [HideInInspector]
  135. private MoneySetttingUI m_MoneySetting;
  136. [SerializeField]
  137. [HideInInspector]
  138. private Button m_OKButton;
  139. [SerializeField]
  140. [HideInInspector]
  141. private Button m_CancelButton;
  142. public Action FadeInStartAction;
  143. public Action FadeInEndAction;
  144. public Action FadeOutStartAction;
  145. public Action FadeOutEndAction;
  146. [SerializeField]
  147. [Header("レート表示UI")]
  148. private Text m_RateText;
  149. [SerializeField]
  150. [Header("残額UI")]
  151. private Text m_BalanceText;
  152. [SerializeField]
  153. [Header("現コイン表示UI")]
  154. private Text m_CurrentCoin;
  155. }