BetSetUI.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using wf;
  5. public class BetSetUI : MonoBehaviour
  6. {
  7. public bool IsDoBet { get; private set; }
  8. public MoneySetttingUI MoneySetting
  9. {
  10. get
  11. {
  12. return this.m_MoneySetting;
  13. }
  14. }
  15. public bool Active
  16. {
  17. get
  18. {
  19. return base.gameObject.activeSelf;
  20. }
  21. }
  22. public long BetMoneyMax { get; private set; }
  23. public static BetSetUI Instance { get; private set; }
  24. private void Awake()
  25. {
  26. BetSetUI.Instance = this;
  27. this.m_MyCanvas = base.GetComponent<CanvasGroup>();
  28. MoneySetttingUI moneySetting = this.m_MoneySetting;
  29. moneySetting.ValueUpdateAction = (MoneySetttingUI.ValueUpdateMethod)Delegate.Combine(moneySetting.ValueUpdateAction, new MoneySetttingUI.ValueUpdateMethod(this.UpdateUIState));
  30. this.BetMoneyMax = this.m_MoneySetting.MaxValue;
  31. this.m_DialogCheck.isOn = (GameMain.Instance.CharacterMgr.status.GetFlag("ベット額警告非表示") == 1);
  32. this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MinValue, true);
  33. base.gameObject.SetActive(false);
  34. }
  35. private void Start()
  36. {
  37. ExChangeUI instance = ExChangeUI.Instance;
  38. instance.FadeInStartAction = (Action)Delegate.Combine(instance.FadeInStartAction, new Action(this.FadeOut));
  39. ExChangeUI instance2 = ExChangeUI.Instance;
  40. instance2.FadeOutEndAction = (Action)Delegate.Combine(instance2.FadeOutEndAction, new Action(this.UpdateUIState));
  41. }
  42. private void DoBet()
  43. {
  44. UIStates.Instance.SetEnabled(false);
  45. BjVoiceMgr.Instance.PlayVoice("ブラックジャック開始", null, 0f);
  46. BjMotionControl.Instance.PlayMotion("*頷く", new Action(this.DealStart), true, false);
  47. }
  48. private void DealStart()
  49. {
  50. BjPlayer.Instance.SetBet(this.m_MoneySetting.MoneyValue);
  51. ChipManager instance = ChipManager.Instance;
  52. instance.StackEndCallBack = (Action)Delegate.Combine(instance.StackEndCallBack, new Action(BlackjackGame.Instance.Deal));
  53. ChipManager.Instance.UpdateStacks();
  54. }
  55. private void BetFadeOut()
  56. {
  57. GameMain.Instance.SysDlg.Close();
  58. UIStates.Instance.SetEnabled(false);
  59. this.IsDoBet = true;
  60. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, new Action(this.DoBet), true, true));
  61. }
  62. public void SetBetMax()
  63. {
  64. long num = wf.Math.RoundMinMax(GameMain.Instance.CharacterMgr.status.casinoCoin, this.m_MoneySetting.MinValue, this.BetMoneyMax);
  65. num /= (long)Mathf.Pow(10f, (float)this.m_MoneySetting.DisableDigit);
  66. num *= (long)Mathf.Pow(10f, (float)this.m_MoneySetting.DisableDigit);
  67. this.m_MoneySetting.SetMaxValue(num);
  68. }
  69. public void StateRecet()
  70. {
  71. this.IsDoBet = false;
  72. }
  73. public void UpdateUIState()
  74. {
  75. this.m_CreditText.text = Translations.Instance.CREDITS + (GameMain.Instance.CharacterMgr.status.casinoCoin - this.m_MoneySetting.MoneyValue);
  76. }
  77. public void PushOKButton()
  78. {
  79. if (GameMain.Instance.CharacterMgr.status.GetFlag("ベット額警告非表示") == 0)
  80. {
  81. bool flag = this.m_MoneySetting.MoneyValue >= (long)this.m_WarningMoney;
  82. string warning_message_term = "SceneCasino/ダイアログ/賭けようとしています。本当に賭けますか?";
  83. string[] warning_message_term_args = new string[]
  84. {
  85. string.Format("{0:#,##0}", this.m_WarningMoney)
  86. };
  87. bool flag2 = this.m_MoneySetting.MoneyValue * 2L > GameMain.Instance.CharacterMgr.status.casinoCoin;
  88. string messageTerm = "SceneCasino/ダイアログ/現在の賭け額と所持コインの枚数ではダブルダウンとスプリットは行えません";
  89. if (flag2)
  90. {
  91. if (flag)
  92. {
  93. SystemDialog.OnClick f_dgOk = delegate()
  94. {
  95. GameMain.Instance.SysDlg.ShowFromLanguageTerm(warning_message_term, warning_message_term_args, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.BetFadeOut), null);
  96. };
  97. GameMain.Instance.SysDlg.ShowFromLanguageTerm(messageTerm, null, SystemDialog.TYPE.OK_CANCEL, f_dgOk, null);
  98. }
  99. else
  100. {
  101. GameMain.Instance.SysDlg.ShowFromLanguageTerm(messageTerm, null, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.BetFadeOut), null);
  102. }
  103. }
  104. else if (flag)
  105. {
  106. GameMain.Instance.SysDlg.ShowFromLanguageTerm(warning_message_term, warning_message_term_args, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.BetFadeOut), null);
  107. }
  108. else
  109. {
  110. this.BetFadeOut();
  111. }
  112. }
  113. else
  114. {
  115. this.BetFadeOut();
  116. }
  117. }
  118. public void PushCancelButton()
  119. {
  120. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, this.CancelCall, true, true));
  121. }
  122. public void PushResetButton()
  123. {
  124. this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MinValue, false);
  125. }
  126. public void PushMaxButton()
  127. {
  128. this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MaxValue, false);
  129. }
  130. public void SetDialogFlag()
  131. {
  132. if (this.m_DialogCheck.isOn)
  133. {
  134. GameMain.Instance.CharacterMgr.status.SetFlag("ベット額警告非表示", 1);
  135. }
  136. else
  137. {
  138. GameMain.Instance.CharacterMgr.status.SetFlag("ベット額警告非表示", 0);
  139. }
  140. }
  141. public void FadeIn()
  142. {
  143. base.gameObject.SetActive(true);
  144. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, false, this.m_FadeTime, null, true, true));
  145. }
  146. public void FadeOut()
  147. {
  148. if (!base.gameObject.activeSelf)
  149. {
  150. return;
  151. }
  152. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, null, true, true));
  153. }
  154. private CanvasGroup m_MyCanvas;
  155. [SerializeField]
  156. private float m_FadeTime = 0.5f;
  157. [SerializeField]
  158. [Header("この金額以上賭けたら警告")]
  159. private int m_WarningMoney = 10000;
  160. [SerializeField]
  161. [HideInInspector]
  162. private Text m_CreditText;
  163. [SerializeField]
  164. [HideInInspector]
  165. private MoneySetttingUI m_MoneySetting;
  166. [SerializeField]
  167. [HideInInspector]
  168. private Button m_OKButton;
  169. [SerializeField]
  170. [HideInInspector]
  171. private Toggle m_DialogCheck;
  172. public Action CancelCall;
  173. }