using System; using UnityEngine; using UnityEngine.UI; using wf; public class ExChangeUI : MonoBehaviour { public static ExChangeUI Instance { get; private set; } public bool IsActive { get { return base.gameObject.activeSelf; } } private void Awake() { ExChangeUI.Instance = this; this.FadeInStartAction = (Action)Delegate.Combine(this.FadeInStartAction, new Action(delegate() { this.m_ExchangeButton.interactable = false; })); this.FadeInStartAction = (Action)Delegate.Combine(this.FadeInStartAction, new Action(this.SetExchangeMax)); this.FadeOutStartAction = (Action)Delegate.Combine(this.FadeOutStartAction, new Action(this.TextUIUpdate)); MoneySetttingUI moneySetting = this.m_MoneySetting; moneySetting.ValueUpdateAction = (MoneySetttingUI.ValueUpdateMethod)Delegate.Combine(moneySetting.ValueUpdateAction, new MoneySetttingUI.ValueUpdateMethod(this.UIStateUpdate)); this.m_MyCanvas = base.GetComponent(); this.m_RateText.text = string.Format("コイン1枚 = {0}CR", Utility.ConvertMoneyText(this.m_CoinRate)); this.TextUIUpdate(); this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MinValue, true); base.gameObject.SetActive(false); } private void SetExchangeMax() { long num = 999999L - GameMain.Instance.CharacterMgr.status.casinoCoin; if (num <= this.m_MoneySetting.MinValue) { num = this.m_MoneySetting.MinValue; } if (num * (long)this.m_CoinRate > GameMain.Instance.CharacterMgr.status.money) { num = GameMain.Instance.CharacterMgr.status.money / (long)this.m_CoinRate; } this.m_MoneySetting.SetMaxValue(num); } public void TextUIUpdate() { this.m_MoneyUI.text = GameMain.Instance.CharacterMgr.status.moneyText; this.m_CoinUI.text = Utility.ConvertMoneyText(GameMain.Instance.CharacterMgr.status.casinoCoin); } public void SetButtonState(bool conditon) { this.m_ExchangeButton.interactable = conditon; } public void UIStateUpdate() { long money = GameMain.Instance.CharacterMgr.status.money; this.m_BalanceText.text = string.Format("-{0:#,##0}", this.m_MoneySetting.MoneyValue * (long)this.m_CoinRate); this.m_CurrentCoin.text = Utility.ConvertMoneyText(GameMain.Instance.CharacterMgr.status.casinoCoin + this.m_MoneySetting.MoneyValue); } public void PushOKButton() { GameMain.Instance.CharacterMgr.status.money -= this.m_MoneySetting.MoneyValue * (long)this.m_CoinRate; GameMain.Instance.CharacterMgr.status.casinoCoin += this.m_MoneySetting.MoneyValue; if (this.FadeOutStartAction != null) { this.FadeOutStartAction(); } base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, this.FadeOutEndAction, true, true)); } public void PushCancelButton() { if (this.FadeOutStartAction != null) { this.FadeOutStartAction(); } base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, true, this.m_FadeTime, this.FadeOutEndAction, true, true)); } public void PushResetButton() { this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MinValue, false); } public void PushMaxButton() { this.m_MoneySetting.SetMoneyUI(this.m_MoneySetting.MaxValue, false); } public void FadeIn() { if (GameMain.Instance.CharacterMgr.status.money < this.m_MoneySetting.MinValue * (long)this.m_CoinRate) { string f_strMsg = string.Format("換金するには最低でも\n資金が{0:#,##0}CR必用です", this.m_MoneySetting.MinValue * (long)this.m_CoinRate); GameMain.Instance.SysDlg.Show(f_strMsg, SystemDialog.TYPE.OK, null, null); return; } if (GameMain.Instance.CharacterMgr.status.casinoCoin >= 999999L - this.m_MoneySetting.MinValue) { GameMain.Instance.SysDlg.Show("これ以上換金できません", SystemDialog.TYPE.OK, null, null); return; } if (this.FadeInStartAction != null) { this.FadeInStartAction(); } base.gameObject.SetActive(true); base.StartCoroutine(KasaiUtility.FadeCoroutine(this.m_MyCanvas, false, this.m_FadeTime, this.FadeInEndAction, true, true)); } private CanvasGroup m_MyCanvas; [SerializeField] private int m_CoinRate = 100; [SerializeField] private float m_FadeTime = 0.5f; [SerializeField] [Header("このUIを呼び出すボタン")] private Button m_ExchangeButton; [SerializeField] [Header("所持金表示UI")] private Text m_MoneyUI; [SerializeField] [Header("カジノコイン表示UI")] private Text m_CoinUI; [SerializeField] [HideInInspector] private MoneySetttingUI m_MoneySetting; [SerializeField] [HideInInspector] private Button m_OKButton; [SerializeField] [HideInInspector] private Button m_CancelButton; public Action FadeInStartAction; public Action FadeInEndAction; public Action FadeOutStartAction; public Action FadeOutEndAction; [SerializeField] [Header("レート表示UI")] private Text m_RateText; [SerializeField] [Header("残額UI")] private Text m_BalanceText; [SerializeField] [Header("現コイン表示UI")] private Text m_CurrentCoin; }