Example #1
0
        private void DoBuy(MsgData_BattleShop_buy buyInfo)
        {
            string          text     = string.Empty;
            ShopInfo        shopInfo = null;
            bool            flag     = ModelManager.Instance.Get_BattleShop_playerAlive();
            int             num      = ModelManager.Instance.Get_BattleShop_money();
            List <ItemInfo> list     = ModelManager.Instance.Get_BattleShop_pItems();
            string          text2    = null;

            if (buyInfo == null || !buyInfo.Valid)
            {
                text2 = BattleEquipTools_config.Notice_outOfShoppingArea;
            }
            else
            {
                shopInfo = buyInfo.CurShop;
                EBattleShopState state = shopInfo.State;
                if (state != EBattleShopState.eIdle)
                {
                    text2 = BattleEquipTools_config.Notice_ShopBusy;
                }
                else if (!ModelManager.Instance.Get_BattleShop_brawlCanBuy())
                {
                    text2 = BattleEquipTools_config.Notice_brawl;
                }
                else if (num < buyInfo.RealPrice)
                {
                    text2 = BattleEquipTools_config.Notice_DeficientMoney;
                }
                else if (list.Count >= 6 && !buyInfo.Cheaper)
                {
                    text2 = BattleEquipTools_config.Notice_DeficientSpace;
                }
                else if (flag && !shopInfo.InArea)
                {
                    text2 = BattleEquipTools_config.Notice_outOfShoppingArea;
                }
                else
                {
                    text = buyInfo.TargetID;
                }
            }
            if (text2 == null)
            {
                AudioMgr.PlayUI("Play_Shop_Buy", null, false, false);
                MsgData_BattleShop_onOP param = new MsgData_BattleShop_onOP
                {
                    op         = EBattleShopOP.eBuy,
                    shopType   = shopInfo.ShopType,
                    targetItem = text,
                    realPrice  = buyInfo.RealPrice
                };
                MobaMessageManagerTools.SendClientMsg(ClientC2C.BattleShop_onOP, param, false);
                if (BattleEquipTools_op.IsOnLineBattle())
                {
                    BattleEquipTools_op.DoPvpBuy(shopInfo, text);
                }
                else
                {
                    Units player = MapManager.Instance.GetPlayer();
                    BattleEquipTools_op.DoPveBuy(shopInfo, player, text, list, buyInfo.RealPrice);
                }
            }
            else if (!text2.Equals(BattleEquipTools_config.Notice_ShopBusy))
            {
                Singleton <TipView> .Instance.ShowViewSetText(text2, 1f);
            }
        }