using System; using CIG; using SUISS.Core; using SUISSEngine; using UnityEngine; public class BuyExpansionPopupState : PopupBaseState { public CIGExpansions.ExpansionBlock Block { get { return this._block; } set { this._block = value; if (value != null) { this._price = value.Price; ((BuyExpansionPopupView)this.View).SetPrice(this._price); } else { UnityEngine.Debug.LogWarning("ExpansionBlock is null"); } } } private Currencies Price { get { return this._price; } } public override void Init() { base.Init(); } public override void Enter(State oldState) { base.Enter(oldState); this.expansions = CityIsland.Current.GetComponent(); } public void BuyWith(string currency) { string str = ", buying will be cancelled"; if (this.Block == null) { UnityEngine.Debug.LogWarning("Buying unknown block" + str); } IsometricIsland current = IsometricIsland.Current; if (current == null) { UnityEngine.Debug.LogError("Cannot find island object" + str); } CIGGameState state = SingletonMonobehaviour.Instance; if (state == null) { UnityEngine.Debug.LogError("Game state is not known" + str); } decimal value = this.Price.GetValue(currency); Currencies toSpend = new Currencies(currency, value); base.ClosePopup(delegate () { state.SpendCurrencies(toSpend, false, delegate (bool succes, Currencies spent) { if (succes) { this.expansions.UnlockBlock(this.Block, toSpend); CIGGameStats instance = SingletonMonobehaviour.Instance; if (instance != null) { bool flag = spent.GetValue("Gold") > 0m; instance.AddExpansionPurchased(flag); if (flag) { instance.AddVirtualCurrencySpent(); } } } }); }); } private CIGExpansions.ExpansionBlock _block; private Currencies _price; private CIGExpansions expansions; }