Exemple #1
0
    private bool CheckCanBuy()
    {
        if (ShopItemBase.SelectIndex == null || ShopItemBase.SelectIndex.Count == 0)
        {
            MsgInfoManager.Instance.ShowMsg((int)ERROR_TYPE.eT_NeedAItermID);
            return(false);
        }

        ShopSelectType type  = ShopItemBase.SelectIndex.ElementAt(0).Key;
        int            index = ShopItemBase.SelectIndex.ElementAt(0).Value;

        if (type == ShopSelectType.TypeUser)
        {
            UserPackageItem pack = (UserPackageItem)ShopItemAll[ShopSelectType.TypeUser];

            int count = 0, item = -1;
            PlayerManager.Instance.LocalPlayer.UserGameItemsCount.TryGetValue(index, out count);
            PlayerManager.Instance.LocalPlayer.UserGameItems.TryGetValue(index, out item);
            if (count == 0 || !ConfigReader.ItemXmlInfoDict.ContainsKey(item))
            {
                MsgInfoManager.Instance.ShowMsg((int)ERROR_TYPE.eT_NeedAItermID);
                return(false);
            }
        }
        return(true);
    }
Exemple #2
0
    /// <summary>
    /// 出售物品
    /// </summary>
    /// <param name="item"></param>
    public void OnUserSellItem()
    {
        bool            isEmpty = true;
        UserPackageItem pack    = (UserPackageItem)ShopItemAll[ShopSelectType.TypeUser];

        foreach (var itemCount in PlayerManager.Instance.LocalPlayer.UserGameItemsCount.Values)
        {
            if (itemCount != 0)
            {
                isEmpty = false;
                break;
            }
        }

        if (isEmpty)
        {
            MsgInfoManager.Instance.ShowMsg((int)ERROR_TYPE.eT_BagIsEmpty);
            pack.SelectSelfCloseOtherSelect(pack, -1);
            return;//如果道具个数为空
        }

        if (ShopItemBase.SelectIndex == null || ShopItemBase.SelectIndex.Count == 0)
        {
            MsgInfoManager.Instance.ShowMsg((int)ERROR_TYPE.eT_NeedABagID);
            return;
        }

        ShopSelectType type  = ShopItemBase.SelectIndex.ElementAt(0).Key;
        int            index = ShopItemBase.SelectIndex.ElementAt(0).Value;

        if (type != ShopSelectType.TypeUser)
        {
            MsgInfoManager.Instance.ShowMsg((int)ERROR_TYPE.eT_NeedABagID);
            //GameMethod.DebugError("aaaaa");
            return;
        }
        int count = 0, item = -1;

        PlayerManager.Instance.LocalPlayer.UserGameItemsCount.TryGetValue(index, out count);
        PlayerManager.Instance.LocalPlayer.UserGameItems.TryGetValue(index, out item);
        if (count != 0 && ConfigReader.ItemXmlInfoDict.ContainsKey(item))
        {
            HolyGameLogic.Instance.EmsgToss_AskSellGoods(index);
        }
        else
        {
            MsgInfoManager.Instance.ShowMsg((int)ERROR_TYPE.eT_NeedABagID);
            ShopItemBase.SelectIndex.Clear();
        }
    }
Exemple #3
0
    void OnDisable()
    {
        SendOpenShop(false);
        if (ShopItemAll.ContainsKey(ShopSelectType.TypeUser))
        {
            UserPackageItem use = (UserPackageItem)ShopItemAll[ShopSelectType.TypeUser];
            if (EventCenter.mEventTable.ContainsKey((Int32)GameEventEnum.GameEvent_UpdateUserGameItems))
            {
                EventCenter.RemoveListener((Int32)GameEventEnum.GameEvent_UpdateUserGameItems, use.OnShowItemInUserInterface);
            }
        }

        Instance = null;
    }
Exemple #4
0
    //初始化商店
    public void InitShop(int shopId)
    {
        ShopId = shopId;
        ShopItemAll.Add(ShopSelectType.TypeUser, new UserPackageItem(this.transform.Find("Backpackage")));
        ShopItemAll.Add(ShopSelectType.TypeAfter, new AfterPackageItem(this.transform.Find("PropertyAdvanced/Grid")));
        ShopItemAll.Add(ShopSelectType.TypeBuy, new BuyPackageItem(this.transform.Find("PropertySelect/Grid")));
        ShopItemAll.Add(ShopSelectType.TypeCompose, new ComposePackageItem(this.transform.Find("PropertyConstruct")));

        RegistFunctionButtons();
        itemDestribe = new ItemDestribe(transform.Find("PropertyDestribe"));
        Package      = new PackageSelect(this.transform.Find("KindSelect"), ShopId);
        UserPackageItem use = (UserPackageItem)ShopItemAll[ShopSelectType.TypeUser];

        EventCenter.AddListener((Int32)GameEventEnum.GameEvent_UpdateUserGameItems, use.OnShowItemInUserInterface);
    }