public static void DoPveUseItem(Units unit, ItemInfo targetItem, List <ItemInfo> possessItemsP)
        {
            List <ItemInfo> items = new List <ItemInfo>(possessItemsP);

            BattleEquipTools_op.RemoveItem(items, targetItem);
            BattleEquipTools_op.SetHeroItems(unit, items);
        }
        public static void DoPveBuy(ShopInfo shopInfo, Units unit, string targetItemID, List <ItemInfo> possessItemsP, int realPrice)
        {
            List <ItemInfo> list        = new List <ItemInfo>(possessItemsP);
            List <string>   composition = BattleEquipTools_Travers.GetComposition(targetItemID, list);

            if (composition != null || composition.Count > 0)
            {
                for (int i = 0; i < composition.Count; i++)
                {
                    ItemInfo target;
                    int      index;
                    if (BattleEquipTools_Travers.GetItem_last_least(list, composition[i], out target, out index))
                    {
                        BattleEquipTools_op.RemoveItem(list, target, index);
                    }
                }
            }
            BattleEquipTools_op.AddItem(list, targetItemID);
            BattleEquipTools_op.ChangeHeroMoney(unit.unique_id, -realPrice);
            BattleEquipTools_op.SetHeroItems(unit, list);
            byte[] msgParam = SerializeHelper.Serialize <P2CBuyItem>(new P2CBuyItem
            {
                itemoid  = 0,
                retaCode = 0
            });
            MobaMessage message = MobaMessageManager.GetMessage(PvpCode.C2P_BuyItem, msgParam, 0f, null);

            MobaMessageManager.DispatchMsg(message);
        }
        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);
        }
        private bool callback(SysBattleItemsVo info, int depth)
        {
            bool result = depth < this._depth;

            if (depth == 0)
            {
                this.equip_need.Clear();
            }
            else if (info != null)
            {
                ItemInfo target;
                int      index;
                if (BattleEquipTools_Travers.GetItem_first(this.equip_has, info.items_id, out target, out index))
                {
                    this.equip_need.Add(info.items_id);
                    BattleEquipTools_op.RemoveItem(this.equip_has, target, index);
                    result = false;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
 public static bool RemoveItem(List <ItemInfo> items, ItemInfo target)
 {
     if (items != null || target != null)
     {
         int index = items.IndexOf(target);
         return(BattleEquipTools_op.RemoveItem(items, target, index));
     }
     return(false);
 }
        public static bool RemoveItem(List <ItemInfo> items, ItemInfo target, int index)
        {
            bool result = false;

            if (items != null && target != null)
            {
                if (!(result = BattleEquipTools_op.SubstractItemNum(target)))
                {
                    if (result = BattleEquipTools_op.RemoveItem(items, index))
                    {
                    }
                }
            }
            return(result);
        }
예제 #7
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);
            }
        }
예제 #8
0
        private void OnMsg_BattleShop_clickRItem(MobaMessage msg)
        {
            RItemData rItemData = msg.Param as RItemData;
            ShopInfo  curShopInfo;

            if (!BattleEquipTools_op.IsPlayerAlive())
            {
                curShopInfo = rItemData.GetShopByType(BattleEquipTools_op.GetShopTypeByTeamType());
            }
            else
            {
                curShopInfo = rItemData.GetAvailableShop();
            }
            MsgData_BattleShop_buy buyInfo = new MsgData_BattleShop_buy(rItemData, BuyingEquipType.eRecommend, curShopInfo);

            this.DoBuy(buyInfo);
        }
        public static void DoPveRollback(ShopInfo shopInfo, Units unit)
        {
            RollbackInfo rollbackInfo = shopInfo.RollbackStack.Peek();

            if (rollbackInfo != null)
            {
                BattleEquipTools_op.ChangeHeroMoney(unit.unique_id, -rollbackInfo._deltaMoney);
                BattleEquipTools_op.SetHeroItems(unit, rollbackInfo._items);
            }
            byte[] msgParam = SerializeHelper.Serialize <RetaMsg>(new RetaMsg
            {
                retaCode = 0
            });
            MobaMessage message = MobaMessageManager.GetMessage(PvpCode.C2P_RevertShop, msgParam, 0f, null);

            MobaMessageManager.DispatchMsg(message);
        }
        public static EBattleShopType GetNearestShopType()
        {
            Dictionary <EBattleShopType, ShopInfo> dictionary = ModelManager.Instance.Get_BattleShop_shops();
            List <ShopInfo> list            = null;
            EBattleShopType eBattleShopType = EBattleShopType.eNone;

            if (BattleEquipTools_op.IsPlayerAlive())
            {
                list = new List <ShopInfo>();
                foreach (KeyValuePair <EBattleShopType, ShopInfo> current in dictionary)
                {
                    if (current.Value.InArea)
                    {
                        list.Add(current.Value);
                    }
                }
                if (list.Count > 0)
                {
                    if (list.Count > 1)
                    {
                        float num    = 1E+07f;
                        float num2   = 0f;
                        Units player = MapManager.Instance.GetPlayer();
                        foreach (ShopInfo current2 in list)
                        {
                            BattleEquipTools_op.IsWithInShopArea(current2.Config, player, out num2);
                            if (num2 < num)
                            {
                                num             = num2;
                                eBattleShopType = current2.ShopType;
                            }
                        }
                    }
                    else
                    {
                        eBattleShopType = list[0].ShopType;
                    }
                }
            }
            if (eBattleShopType == EBattleShopType.eNone)
            {
                eBattleShopType = BattleEquipTools_op.GetShopTypeByTeamType();
            }
            return(eBattleShopType);
        }
        public static void DoPveSell(ShopInfo shopInfo, Units unit, ItemInfo targetItem, List <ItemInfo> possessItemsP)
        {
            List <ItemInfo> items     = new List <ItemInfo>(possessItemsP);
            int             itemPrice = BattleEquipTools_config.GetItemPrice(targetItem.ID);
            int             delta     = (int)((float)itemPrice * 0.8f);

            BattleEquipTools_op.RemoveItem(items, targetItem);
            BattleEquipTools_op.ChangeHeroMoney(unit.unique_id, delta);
            BattleEquipTools_op.SetHeroItems(unit, items);
            byte[] msgParam = SerializeHelper.Serialize <P2CSellItem>(new P2CSellItem
            {
                itemoid  = 0,
                retaCode = 0
            });
            MobaMessage message = MobaMessageManager.GetMessage(PvpCode.C2P_SellItem, msgParam, 0f, null);

            MobaMessageManager.DispatchMsg(message);
        }
예제 #12
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);
            }
        }
예제 #13
0
        private void OpenBattleShop(EBattleShopType type, EBattleShopOpenType openType)
        {
            Units    player   = MapManager.Instance.GetPlayer();
            ShopInfo shopInfo = ModelManager.Instance.Get_BattleShop_shopInfo(type);
            string   text;

            if (BattleEquipTools_op.CanOpenBattleShop(player, shopInfo, openType, out text))
            {
                AudioMgr.PlayUI("Play_Shop_Open", null, false, false);
                MsgData_BattleShop_onOP param = new MsgData_BattleShop_onOP
                {
                    shopType = type
                };
                MobaMessageManagerTools.SendClientMsg(ClientC2C.BattleShop_onOP, param, false);
                CtrlManager.OpenWindow(WindowID.BattleEquipmentView, null);
            }
            else if (!string.IsNullOrEmpty(text))
            {
                Singleton <TipView> .Instance.ShowViewSetText(text, 1f);
            }
        }
예제 #14
0
        public override void OnGameStateChange(GameState oldState, GameState newState)
        {
            if (!this.enable)
            {
                return;
            }
            switch (newState)
            {
            case GameState.Game_Playing:
                MobaMessageManagerTools.BattleShop_initData(Singleton <PvpManager> .Instance.IsContinuedBattle, BattleEquipTools_op.GetBattleShopContex(), LevelManager.CurLevelId, BattleEquipTools_op.GetShopTypeByTeamType(), ModelManager.Instance.Get_SettingData().recommendOn);
                this.coroutineMng.StartCoroutine(this.Check(), true);
                this.coroutineMng.StartCoroutine(this.UpdateWallet(), true);
                break;

            case GameState.Game_Over:
                this.CloseView_ShopView();
                this.CloseView_BagView();
                break;
            }
        }
예제 #15
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);
            }
        }
        public static List <string> GetHeroItemsString(Units unit)
        {
            List <ItemDynData> heroItems = BattleEquipTools_op.GetHeroItems(unit);

            return(BattleEquipTools_Travers.GetItemListString(heroItems));
        }