using System; using FaBao.Constant; using FaBao.Data; using FaBao.TAction.TShop; using FaBao.TEvent; using TEngine.Redux; namespace FaBao.UI.SaviorsTowerUI { public partial class KeeperDialog { public class KeeperDialogParam { public Action OnSwitch; } public override IArchitecture GetArchitecture() { return App.Instance; } protected override async void OnShow(object param) { base.OnShow(param); this.RegisterEvent(OnRightCardUpdate); m_btn_switch.selected = this.GetModel().JumpLevelState; if (this.GetModel().HasRight(Right.SkipTowerFloor)) { m_btn_buy.text = "已购买"; m_btn_buy.enabled = false; } else { var goodInfo = await this.GetModel().GetBattlePass(CommonValue.TowerKeeperRight_ShopId); if (goodInfo != null) { m_btn_buy.text = $"¥{goodInfo.Price}"; m_btn_buy.enabled = true; } } } protected override void OnClose() { this.UnRegisterEvent(OnRightCardUpdate); } private void OnBtnSwitch() { if (this.GetModel().HasRight(Right.SkipTowerFloor)) { //已购买爬塔管家 this.GetModel().JumpLevelState = m_btn_switch.selected; GetParam().OnSwitch?.Invoke(); return; } //提示购买 m_btn_switch.selected = this.GetModel().JumpLevelState = false; Toast.Info("请先购买管家"); } private async void OnBtnBuy() { var goodInfo = await this.GetModel().GetBattlePass(CommonValue.TowerKeeperRight_ShopId); if (goodInfo != null) { if (await this.GetModel().DispatchAction(new Shop_Action_BuyShopGood(goodInfo))) { // m_btn_buy.enabled = false; // //购买后自动启用 // this.GetModel().JumpLevelState = m_btn_switch.selected; // GetParam().OnSwitch?.Invoke(); } } } private void OnBtnClose() { Close(); } private async void OnRightCardUpdate(RightCard_Update_Event obj) { if (obj == null) return; var goodInfo = await this.GetModel().GetBattlePass(CommonValue.TowerKeeperRight_ShopId); if (goodInfo == null) return; if (goodInfo.FirstOrDefaultRight() != obj.CardId) return; if (this.GetModel().HasRight(Right.SkipTowerFloor)) { m_btn_buy.text = "已购买"; m_btn_buy.enabled = false; //购买后自动启用 this.GetModel().JumpLevelState = m_btn_switch.selected = true; GetParam().OnSwitch?.Invoke(); } else { // var goodInfo = await this.GetModel().GetBattlePass(CommonValue.TowerKeeperRight_ShopId); if (goodInfo != null) { m_btn_buy.text = $"¥{goodInfo.Price}"; m_btn_buy.enabled = true; } } } } }