public static bool CanOpenBattleShop(Units player, ShopInfo shopInfo, EBattleShopOpenType openType, out string err)
        {
            err = null;
            bool result = false;

            if (shopInfo != null && null != player && openType == EBattleShopOpenType.eFromButton)
            {
                switch (shopInfo.ShopType)
                {
                case EBattleShopType.eLM:
                    result = (!BattleEquipTools_op.IsOnLineBattle() || Singleton <PvpManager> .Instance.SelfTeamType == TeamType.LM);
                    break;

                case EBattleShopType.eBL:
                    result = (BattleEquipTools_op.IsOnLineBattle() && Singleton <PvpManager> .Instance.SelfTeamType == TeamType.BL);
                    break;

                case EBattleShopType.eNeutral:
                case EBattleShopType.eNeutral_2:
                {
                    bool flag = null != player && BattleEquipTools_op.WithinShopArea(shopInfo, player.transform.position);
                    result = flag;
                    break;
                }

                case EBattleShopType.eTeam3:
                    result = (Singleton <PvpManager> .Instance.SelfTeamType == TeamType.Team_3);
                    break;
                }
            }
            return(result);
        }
Beispiel #2
0
        private void DoSell(MsgData_BattleShop_sell sellInfo)
        {
            string text = null;

            if (sellInfo == null || sellInfo.curShop == null)
            {
                text = BattleEquipTools_config.Notice_SystemError;
            }
            else if (sellInfo.targetItem == null)
            {
                text = BattleEquipTools_config.Notice_SystemError;
            }
            else
            {
                EBattleShopState state = sellInfo.curShop.State;
                if (state != EBattleShopState.eIdle)
                {
                    text = BattleEquipTools_config.Notice_ShopBusy;
                }
            }
            if (text == null)
            {
                ItemInfo targetItem           = sellInfo.targetItem;
                MsgData_BattleShop_onOP param = new MsgData_BattleShop_onOP
                {
                    op         = EBattleShopOP.eSell,
                    shopType   = sellInfo.curShop.ShopType,
                    targetItem = targetItem.ID,
                    itemInfo   = targetItem
                };
                MobaMessageManagerTools.SendClientMsg(ClientC2C.BattleShop_onOP, param, false);
                List <string> recommendItems = ModelManager.Instance.Get_BattleShop_rItems();
                if (BattleEquipTools_op.IsOnLineBattle())
                {
                    BattleEquipTools_op.DoPvpSell(sellInfo.curShop, targetItem, recommendItems);
                }
                else
                {
                    Units           player        = MapManager.Instance.GetPlayer();
                    List <ItemInfo> possessItemsP = ModelManager.Instance.Get_BattleShop_pItems();
                    BattleEquipTools_op.DoPveSell(sellInfo.curShop, player, targetItem, possessItemsP);
                }
            }
            else if (!text.Equals(BattleEquipTools_config.Notice_ShopBusy))
            {
                Singleton <TipView> .Instance.ShowViewSetText(text, 1f);
            }
        }
Beispiel #3
0
        private void DoRollback(MsgData_BattleShop_rollback rollbackInfo)
        {
            ShopInfo shopInfo = null;
            string   text     = null;

            if (rollbackInfo == null || rollbackInfo.curShop == null)
            {
                text = BattleEquipTools_config.Notice_outOfShoppingArea;
            }
            else
            {
                shopInfo = rollbackInfo.curShop;
                EBattleShopState state = shopInfo.State;
                if (state != EBattleShopState.eIdle)
                {
                    text = BattleEquipTools_config.Notice_ShopBusy;
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                MsgData_BattleShop_onOP param = new MsgData_BattleShop_onOP
                {
                    op       = EBattleShopOP.eRevert,
                    shopType = shopInfo.ShopType
                };
                MobaMessageManagerTools.SendClientMsg(ClientC2C.BattleShop_onOP, param, false);
                if (BattleEquipTools_op.IsOnLineBattle())
                {
                    BattleEquipTools_op.DoPvpRollback();
                }
                else
                {
                    Units player = MapManager.Instance.GetPlayer();
                    BattleEquipTools_op.DoPveRollback(shopInfo, player);
                }
            }
            else if (!text.Equals(BattleEquipTools_config.Notice_ShopBusy))
            {
                Singleton <TipView> .Instance.ShowViewSetText(text, 1f);
            }
        }
Beispiel #4
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);
            }
        }