ExChangeUI.cs 4.9 KB

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