BetSetUI.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 = string.Format("{0:#,##0}枚以上賭けようとしています。\n本当に賭けますか?", this.m_WarningMoney);
  83. bool flag2 = this.m_MoneySetting.MoneyValue * 2L > GameMain.Instance.CharacterMgr.status.casinoCoin;
  84. string f_strMsg = "現在の賭け額と所持コインの枚数では\nダブルダウン・スプリットは行えません\n本当に賭けますか?";
  85. if (flag2)
  86. {
  87. if (flag)
  88. {
  89. SystemDialog.OnClick f_dgOk = delegate()
  90. {
  91. GameMain.Instance.SysDlg.Show(warning_message, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.BetFadeOut), null);
  92. };
  93. GameMain.Instance.SysDlg.Show(f_strMsg, SystemDialog.TYPE.OK_CANCEL, f_dgOk, null);
  94. }
  95. else
  96. {
  97. GameMain.Instance.SysDlg.Show(f_strMsg, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.BetFadeOut), null);
  98. }
  99. }
  100. else if (flag)
  101. {
  102. GameMain.Instance.SysDlg.Show(warning_message, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.BetFadeOut), null);
  103. }
  104. else
  105. {
  106. this.BetFadeOut();
  107. }
  108. }
  109. else
  110. {
  111. this.BetFadeOut();
  112. }
  113. }
  114. public void PushCancelButton()
  115. {
  116. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, this.CancelCall, true, true));
  117. }
  118. public void PushResetButton()
  119. {
  120. this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MinValue, false);
  121. }
  122. public void PushMaxButton()
  123. {
  124. this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MaxValue, false);
  125. }
  126. public void SetDialogFlag()
  127. {
  128. if (this.m_DialogCheck.isOn)
  129. {
  130. GameMain.Instance.CharacterMgr.status.SetFlag("ベット額警告非表示", 1);
  131. }
  132. else
  133. {
  134. GameMain.Instance.CharacterMgr.status.SetFlag("ベット額警告非表示", 0);
  135. }
  136. }
  137. public void FadeIn()
  138. {
  139. base.gameObject.SetActive(true);
  140. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, false, this.m_FadeTime, null, true, true));
  141. }
  142. public void FadeOut()
  143. {
  144. if (!base.gameObject.activeSelf)
  145. {
  146. return;
  147. }
  148. base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, null, true, true));
  149. }
  150. private CanvasGroup m_MyCanvas;
  151. [SerializeField]
  152. private float m_FadeTime = 0.5f;
  153. [SerializeField]
  154. [Header("この金額以上賭けたら警告")]
  155. private int m_WarningMoney = 10000;
  156. [SerializeField]
  157. [HideInInspector]
  158. private Text m_CreditText;
  159. [SerializeField]
  160. [HideInInspector]
  161. private MoneySetttingUI m_MoneySetting;
  162. [SerializeField]
  163. [HideInInspector]
  164. private Button m_OKButton;
  165. [SerializeField]
  166. [HideInInspector]
  167. private Toggle m_DialogCheck;
  168. public Action CancelCall;
  169. }