Ejemplo n.º 1
0
    public static USE_ITEM_RESULT CheckUseItem(int itemId, int num, int targetId)
    {
        if (!DataItemGroup.IsUseable(itemId))
        {
            return(USE_ITEM_RESULT.NOT_USEABLE);
        }

        DataItem item = DataManager.instance.dataItemGroup.GetItem(itemId);

        DataDropGroup.DROP_TYPE dropType = DataDropGroup.CheckDropType(item.dropGroup);
        if (dropType == DataDropGroup.DROP_TYPE.EXP)
        {
            if (targetId <= 0)
            {
                return(USE_ITEM_RESULT.LACK_TARGET);
            }
        }

        int itemCount = InstancePlayer.instance.model_User.model_itemGroup.GetItemCount(itemId);

        if (itemCount < num)
        {
            return(USE_ITEM_RESULT.LACK_ITEM);
        }

        return(USE_ITEM_RESULT.OK);
    }
Ejemplo n.º 2
0
    override protected void DisposeContent(UseItemResponse content)
    {
        dropPrizeItems = content.prizeItems;


        DataItem item = DataManager.instance.dataItemGroup.GetItem(_request.itemId);

        DataDropGroup.DROP_TYPE dropType = DataDropGroup.CheckDropType(item.dropGroup);
        if (dropType == DataDropGroup.DROP_TYPE.EXP)
        {
            SlgPB.PrizeItem prizeItem = dropPrizeItems [0];
            Assert.assert(prizeItem.type == (int)DataConfig.DATA_TYPE.Exp);

            int             exp            = prizeItem.num;
            int             targetHeroId   = _request.target;
            Model_HeroGroup modelHeroGroup = InstancePlayer.instance.model_User.model_heroGroup;
            modelHeroGroup.AddExp(targetHeroId, exp);
        }

        InstancePlayer.instance.model_User.model_itemGroup.AddItemCount(_request.itemId, -_request.num);
    }
Ejemplo n.º 3
0
    // ========================
    // helper

    public static DataDropGroup.DROP_TYPE CheckDropType(int itemId)
    {
        DataItem item = DataManager.instance.dataItemGroup.GetItem(itemId);

        return(DataDropGroup.CheckDropType(item.dropGroup));
    }