123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- using System;
- using System.Collections;
- using I2.Loc;
- using UnityEngine;
- using UnityEngine.UI;
- using wf;
- public class UIStates : MonoBehaviour
- {
- public static UIStates Instance { get; private set; }
- private void Awake()
- {
- UIStates.Instance = this;
- this.m_ButtonsEnabled = true;
- this.AngleDisabled();
- this.m_NextButton = this.m_ResultUI.GetComponentInChildren<Button>();
- this.m_ResultImage = this.m_ResultUI.transform.Find("Result");
- this.m_GetMoneyText = this.m_ResultUI.transform.Find("GetMoneyText").GetComponent<Text>();
- this.m_GetMoneyText.gameObject.AddComponent<Localize>();
- this.m_CurrentMouneyText = this.m_ResultUI.transform.Find("BG/CurrentMoney").GetComponent<Text>();
- this.m_ResultCanvas = this.m_ResultUI.GetComponent<CanvasGroup>();
- }
- private void Start()
- {
- this.m_ResultUI.SetActive(false);
- ExChangeUI instance = ExChangeUI.Instance;
- instance.FadeInStartAction = (Action)Delegate.Combine(instance.FadeInStartAction, new Action(delegate()
- {
- this.EnableButton(this.m_StartButton, false);
- this.EnableButton(this.m_EndButton, false);
- }));
- BetSetUI instance2 = BetSetUI.Instance;
- instance2.CancelCall = (Action)Delegate.Combine(instance2.CancelCall, new Action(delegate()
- {
- this.EnableButton(this.m_StartButton, true);
- this.EnableButton(this.m_EndButton, true);
- }));
- ExChangeUI instance3 = ExChangeUI.Instance;
- instance3.FadeOutStartAction = (Action)Delegate.Combine(instance3.FadeOutStartAction, new Action(this.OnStateChange));
- }
- public void StateReset()
- {
- this.OnStateChange();
- this.HideResultText();
- }
- public void SetEnabled(bool enabled)
- {
- this.m_ButtonsEnabled = enabled;
- if (!enabled)
- {
- this.EnableButton(this.m_DoubleDownButton, false);
- this.EnableButton(this.m_StandButton, false);
- this.EnableButton(this.m_SplitButton, false);
- this.EnableButton(this.m_SurrenderButton, false);
- this.EnableButton(this.m_HitButton, false);
- this.EnableButton(this.m_ExchangeButton, false);
- this.EnableButton(this.m_EndButton, false);
- this.EnableButton(this.m_StartButton, false);
- }
- }
- public void OnStateChange()
- {
- this.CheckBetText();
- this.CheckHit();
- this.CheckStand();
- this.CheckDoubleDown();
- this.CheckSplit();
- this.CheckCredits();
- this.CheckSurrender();
- this.CheckBetSettingUI();
- }
- public void ShowOutcomeText()
- {
- this.CheckResultText();
- }
- private void CheckHit()
- {
- if (BjPlayer.Instance.CanHit() && this.m_ButtonsEnabled)
- {
- this.EnableButton(this.m_HitButton, true);
- }
- else
- {
- this.EnableButton(this.m_HitButton, false);
- }
- }
- private void CheckStand()
- {
- if (BjPlayer.Instance.CanHit() && this.m_ButtonsEnabled)
- {
- this.EnableButton(this.m_StandButton, true);
- }
- else
- {
- this.EnableButton(this.m_StandButton, false);
- }
- }
- private void CheckDoubleDown()
- {
- if (this.m_ButtonsEnabled && !BjPlayer.Instance.IsEnded() && BjPlayer.Instance.DoubleDownAvailable())
- {
- this.EnableButton(this.m_DoubleDownButton, true);
- }
- else
- {
- this.EnableButton(this.m_DoubleDownButton, false);
- }
- }
- private void CheckSplit()
- {
- if (BjPlayer.Instance.SplitAvailable() && this.m_ButtonsEnabled)
- {
- this.EnableButton(this.m_SplitButton, true);
- }
- else
- {
- this.EnableButton(this.m_SplitButton, false);
- }
- }
- private void CheckCredits()
- {
- ExChangeUI.Instance.TextUIUpdate();
- }
- private void CheckSurrender()
- {
- if (this.m_ButtonsEnabled && BjPlayer.Instance.CanSurrender())
- {
- this.EnableButton(this.m_SurrenderButton, true);
- }
- else
- {
- this.EnableButton(this.m_SurrenderButton, false);
- }
- }
- private void CheckBetText()
- {
- if (BjPlayer.Instance.CurrentBet == 0L || !BetSetUI.Instance.IsDoBet)
- {
- this.m_BetText.text = string.Empty;
- }
- else
- {
- this.m_BetText.text = BjPlayer.Instance.CurrentBet.ToString();
- }
- if (BjPlayer.Instance.SplitBet == 0L || !BetSetUI.Instance.IsDoBet)
- {
- this.m_SplitBetText.text = string.Empty;
- }
- else
- {
- this.m_SplitBetText.text = BjPlayer.Instance.SplitBet.ToString();
- }
- }
- private void CheckBetSettingUI()
- {
- BetSetUI.Instance.UpdateUIState();
- ExChangeUI.Instance.UIStateUpdate();
- bool flag = BjPlayer.Instance.IsIdle() && !BetSetUI.Instance.Active && this.m_ButtonsEnabled;
- this.m_StartButton.interactable = flag;
- this.m_EndButton.interactable = flag;
- ExChangeUI.Instance.SetButtonState(flag);
- BetSetUI.Instance.SetBetMax();
- }
- private void SetResultImage(string image_name)
- {
- IEnumerator enumerator = this.m_ResultImage.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- Transform transform = (Transform)obj;
- transform.gameObject.SetActive(transform.name == image_name);
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- }
- private void CheckResultText()
- {
- if (this.m_ResultUI.activeSelf)
- {
- this.HideResultText();
- return;
- }
- this.m_ResultUI.SetActive(true);
- if (BjPlayer.Instance.TotalWinnings > 0L)
- {
- if (BjPlayer.Instance.ExistSurrenderHand())
- {
- BjVoiceMgr.Instance.PlayVoice("サレンダー終了", null, 0f);
- this.m_GetMoneyText.text = "コインを" + BjPlayer.Instance.TotalWinnings.ToString() + "枚支払いました";
- if (Product.supportMultiLanguage)
- {
- Localize component = this.m_GetMoneyText.GetComponent<Localize>();
- component.TermArgs = new Localize.ArgsPair[]
- {
- Localize.ArgsPair.Create(BjPlayer.Instance.TotalWinnings.ToString())
- };
- Utility.SetLocalizeTerm(component, "SceneCasino/コインを{0}枚支払いました", false);
- }
- this.SetResultImage(Translations.Instance.SURRENDER);
- }
- else if (BjPlayer.Instance.ExistWinHand())
- {
- this.m_GetMoneyText.text = "コインを" + BjPlayer.Instance.TotalWinnings.ToString() + "枚手に入れました!!";
- if (Product.supportMultiLanguage)
- {
- Localize component2 = this.m_GetMoneyText.GetComponent<Localize>();
- component2.TermArgs = new Localize.ArgsPair[]
- {
- Localize.ArgsPair.Create(BjPlayer.Instance.TotalWinnings.ToString())
- };
- Utility.SetLocalizeTerm(component2, "SceneCasino/コインを{0}枚手に入れました!!", false);
- }
- if (BjPlayer.Instance.ExistBlackJack())
- {
- this.SetResultImage(Translations.Instance.BLACKJACK);
- BjVoiceMgr.Instance.PlayVoice("ブラックジャック勝ち", null, 0f);
- }
- else
- {
- BjVoiceMgr.Instance.PlayVoice("勝利", null, 0f);
- if (BjPlayer.Instance.ExistDoubleDownwWin())
- {
- this.SetResultImage(Translations.Instance.BIG_WINNINGS);
- }
- else
- {
- this.SetResultImage(Translations.Instance.WINNINGS);
- }
- }
- BjMotionControl.Instance.PlayWinMotion(BjMotionControl.Instance.TargetMaid);
- CasinoDataMgr.Instance.AddTotalCoin((int)BjPlayer.Instance.FactMoneyDifference);
- }
- else if (BjPlayer.Instance.IsEven())
- {
- if (BjPlayer.Instance.ExistBlackJack() && Dealer.Instance.IsNatural21())
- {
- BjVoiceMgr.Instance.PlayVoice("ブラックジャック引き分け", null, 0f);
- }
- else
- {
- BjVoiceMgr.Instance.PlayVoice("引き分け", null, 0f);
- }
- this.SetResultImage(Translations.Instance.PUSH);
- this.m_GetMoneyText.text = "コイン" + BjPlayer.Instance.TotalWinnings.ToString() + "枚が手元に戻ってきます";
- if (Product.supportMultiLanguage)
- {
- Localize component3 = this.m_GetMoneyText.GetComponent<Localize>();
- component3.TermArgs = new Localize.ArgsPair[]
- {
- Localize.ArgsPair.Create(BjPlayer.Instance.TotalWinnings.ToString())
- };
- Utility.SetLocalizeTerm(component3, "SceneCasino/コイン{0}枚が手元に戻ってきます", false);
- }
- }
- else
- {
- BjVoiceMgr.Instance.PlayVoice("負け", null, 0f);
- this.SetResultImage(Translations.Instance.YOU_LOSE);
- this.m_GetMoneyText.text = "コインを" + BjPlayer.Instance.MoneyDifference.ToString() + "枚失いました...";
- if (Product.supportMultiLanguage)
- {
- Localize component4 = this.m_GetMoneyText.GetComponent<Localize>();
- component4.TermArgs = new Localize.ArgsPair[]
- {
- Localize.ArgsPair.Create(BjPlayer.Instance.MoneyDifference.ToString())
- };
- Utility.SetLocalizeTerm(component4, "SceneCasino/コインを{0}枚失いました…", false);
- }
- }
- }
- else
- {
- BjVoiceMgr.Instance.PlayVoice("負け", null, 0f);
- this.SetResultImage(Translations.Instance.YOU_LOSE);
- this.m_GetMoneyText.text = "コインを" + (BjPlayer.Instance.CurrentBet + BjPlayer.Instance.SplitBet).ToString() + "枚失いました...";
- if (Product.supportMultiLanguage)
- {
- Localize component5 = this.m_GetMoneyText.GetComponent<Localize>();
- component5.TermArgs = new Localize.ArgsPair[]
- {
- Localize.ArgsPair.Create((BjPlayer.Instance.CurrentBet + BjPlayer.Instance.SplitBet).ToString())
- };
- Utility.SetLocalizeTerm(component5, "SceneCasino/コインを{0}枚失いました…", false);
- }
- }
- long orijin_coin = BjPlayer.Instance.OrijinCredit;
- if (BjPlayer.Instance.ExistWinHand())
- {
- orijin_coin = wf.Math.RoundMinMax(BjPlayer.Instance.OrijinCredit - (BjPlayer.Instance.CurrentBet + BjPlayer.Instance.SplitBet), 0L, 999999L);
- }
- this.m_CurrentMouneyText.text = Utility.ConvertMoneyText(orijin_coin);
- base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_ResultCanvas, false, 0.5f, null, true, true));
- this.m_NextButton.interactable = false;
- if (BjPlayer.Instance.IsEven())
- {
- this.m_NextButton.interactable = true;
- }
- else if (BjPlayer.Instance.ExistSurrenderHand())
- {
- base.StartCoroutine(this.TextFluctuation(orijin_coin));
- }
- else
- {
- ChipManager instance = ChipManager.Instance;
- instance.StackEndCallBack = (Action)Delegate.Combine(instance.StackEndCallBack, new Action(delegate()
- {
- this.StartCoroutine(this.TextFluctuation(orijin_coin));
- }));
- }
- }
- private IEnumerator TextFluctuation(long orijin_coin)
- {
- long coin = GameMain.Instance.CharacterMgr.status.casinoCoin;
- float timer = 0f;
- float rate = 0f;
- if (orijin_coin > coin)
- {
- yield return new WaitForSeconds(this.m_FirstPauseTime);
- }
- else if (orijin_coin == coin)
- {
- this.m_NextButton.interactable = true;
- yield break;
- }
- for (;;)
- {
- timer += Time.deltaTime;
- rate = Mathf.Clamp01(timer / this.m_FluctuationTime);
- long money = (long)Mathf.Lerp((float)orijin_coin, (float)coin, rate);
- this.m_CurrentMouneyText.text = Utility.ConvertMoneyText(money);
- if (rate >= 1f)
- {
- break;
- }
- yield return null;
- }
- this.m_NextButton.interactable = true;
- yield break;
- yield break;
- }
- public void HideResultText()
- {
- base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_ResultCanvas, true, 0.5f, null, true, true));
- }
- public void EnableButton(Button button, bool enabled)
- {
- button.interactable = enabled;
- }
- public void AngleAbled()
- {
- this.m_AngleButton.interactable = !GameMain.Instance.VRMode;
- }
- public void AngleDisabled()
- {
- this.m_AngleButton.interactable = false;
- }
- public void SetUIActive(bool active)
- {
- this.m_BjGameUI.interactable = active;
- }
- [SerializeField]
- private float m_FluctuationTime = 0.5f;
- [SerializeField]
- private float m_NotFluctuationWait = 0.5f;
- [SerializeField]
- private float m_FirstPauseTime = 1f;
- [SerializeField]
- private float m_EndPauseTime = 0.5f;
- [SerializeField]
- private CanvasGroup m_BjGameUI;
- [SerializeField]
- [Header("ヒット用のUI")]
- private Button m_HitButton;
- [SerializeField]
- [Header("ダブルダウン用のUI")]
- private Button m_DoubleDownButton;
- [SerializeField]
- [Header("スプリット用のUI")]
- private Button m_SplitButton;
- [SerializeField]
- [Header("スタンド用のUI")]
- private Button m_StandButton;
- [SerializeField]
- [Header("サレンダー用のUI")]
- private Button m_SurrenderButton;
- [SerializeField]
- [Header("ベット額表示用のUI")]
- private Text m_BetText;
- [SerializeField]
- [Header("スプリットのベット額表示用のUI")]
- private Text m_SplitBetText;
- [SerializeField]
- [Header("換金用UI表示ボタン")]
- private Button m_ExchangeButton;
- [SerializeField]
- [Header("勝負結果表示用のUI")]
- private GameObject m_ResultUI;
- [SerializeField]
- [Header("アングル切り替えボタン")]
- private Button m_AngleButton;
- [SerializeField]
- [Header("ブラックジャック終了ボタン")]
- private Button m_EndButton;
- [SerializeField]
- [Header("ブラックジャック開始ボタン")]
- private Button m_StartButton;
- private Transform m_ResultImage;
- private Text m_GetMoneyText;
- private Text m_CurrentMouneyText;
- private Button m_NextButton;
- private CanvasGroup m_ResultCanvas;
- private bool m_ButtonsEnabled;
- }
|