Exemplo n.º 1
0
    public static DROP_TYPE CheckDropType(int dropId)
    {
        Assert.assert(dropId > 0);

        DataDropGroup dataDropGroup = DataManager.instance.dataDropGroup;

        DropCollection collection = dataDropGroup.GetDropCollection(dropId);

        if (collection.drops.Count > 1)
        {
            //validate
            foreach (DataDrop d in collection.drops)
            {
                Assert.assert(d.itemType != (int)DataConfig.DATA_TYPE.Exp);
            }

            return(DROP_TYPE.MIX);
        }

        DataDrop drop = collection.drops [0];

        if (drop.itemType == (int)DataConfig.DATA_TYPE.Exp)
        {
            return(DROP_TYPE.EXP);
        }

        return(DROP_TYPE.MIX);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
0
    // ========================
    // helper

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

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