Пример #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);
    }
Пример #2
0
    public List <int> CollectPossibleDropItemIds(int dropId)
    {
        List <int> itemIds = new List <int> ();

        DropCollection collection = GetDropCollection(dropId);

        foreach (DataDrop drop in collection.drops)
        {
            if (drop.itemType == (int)DataConfig.DATA_TYPE.Item)
            {
                ListHelper.Push(itemIds, drop.itemIds);
            }
        }

        return(itemIds);
    }
Пример #3
0
        /// <summary>
        /// Tries to parse a script node.
        /// </summary>
        /// <param name="Parser">Custom parser.</param>
        /// <param name="Result">Parsed Script Node.</param>
        /// <returns>If successful in parsing a script node.</returns>
        public bool TryParse(ScriptParser Parser, out ScriptNode Result)
        {
            Result = null;

            try
            {
                string s = Parser.NextToken().ToUpper();
                switch (s)
                {
                case "INDEX":
                    ScriptNode Name = Parser.ParseNoWhiteSpace();

                    s = Parser.NextToken().ToUpper();
                    if (s != "ON")
                    {
                        return(false);
                    }

                    if (!SelectParser.TryParseSources(Parser, out SourceDefinition Source))
                    {
                        return(false);
                    }

                    Result = new DropIndex(Name, Source, Parser.Start, Parser.Length, Parser.Expression);

                    return(true);

                case "TABLE":
                case "COLLECTION":
                    if (!SelectParser.TryParseSources(Parser, out Source))
                    {
                        return(false);
                    }

                    Result = new DropCollection(Source, Parser.Start, Parser.Length, Parser.Expression);

                    return(true);

                default:
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #4
0
    public List <POSSIBLE_DROP> CollectPossibleDrops(int dropId)
    {
        List <POSSIBLE_DROP> possibleDrops = new List <POSSIBLE_DROP> ();

        DropCollection collection = GetDropCollection(dropId);

        foreach (DataDrop drop in collection.drops)
        {
            foreach (int id in drop.itemIds)
            {
                POSSIBLE_DROP possible = new POSSIBLE_DROP();
                possible.type = drop.itemType;
                possible.id   = drop.id;

                possibleDrops.Add(possible);
            }
        }

        return(possibleDrops);
    }
Пример #5
0
    public void Load(string name)
    {
        byte[] bin     = DynamicFileControl.QueryFileContent(name);
        string content = StringHelper.ReadFromBytes(bin);

        LitJson.JSONNode json = LitJson.JSON.Parse(content);

        _dropCollectionMap = new Dictionary <int, DropCollection> ();

        foreach (LitJson.JSONNode subNode in json.Childs)
        {
            DataDrop data = new DataDrop();
            data.Load(subNode);

            if (!_dropCollectionMap.ContainsKey(data.id))
            {
                _dropCollectionMap.Add(data.id, new DropCollection());
            }
            DropCollection collection = _dropCollectionMap[data.id];

            collection.drops.Add(data);
        }
    }