Esempio n. 1
0
        public static List <ItemDrop> GetExtraItems(ItemDrop item)
        {
            List <ItemDrop> list = new List <ItemDrop>();

            if (extraDic.ContainsKey(item.cat) && extraDic[item.cat].ContainsKey(item.id))
            {
                CatPriority cp   = extraDic[item.cat][item.id];
                int[]       cats = cp.GetCats(1);
                for (int i = 0; i < cats.Length; i++)
                {
                    if (catDic.ContainsKey(cp.cats[cats[i]]))
                    {
                        int          index        = cats[i];
                        ItemPriority itemPriority = catDic[cp.cats[index]];
                        int          count        = cp.counts[index];

                        for (int j = 0; j < count; j++)
                        {
                            foreach (ItemDrop drop in itemPriority.GetItems(1))
                            {
                                list.Add(drop);
                            }
                        }
                    }
                }
            }

            return(list);
        }
Esempio n. 2
0
        public static List <ItemDrop> GetDropItems(int id, int mapId)
        {
            Initial(mapId);

            if (dropCache.ContainsKey(id))
            {
                return(dropCache[id]);
            }

            List <ItemDrop> items = new List <ItemDrop>();

            if (dropDic.ContainsKey(id) && null != MapConfigPoints.current)
            {
                CatPriority catPriority = dropDic[id];
                DropRange   r           = rangeDic[id];

                MapConfigPoints.ID_Point idPoint = null;

                List <MapConfigPoints.ID_Point> ps = MapConfigPoints.current.IDPints;
                for (int i = 0; i < ps.Count; i++)
                {
                    if (ps[i].ID == id)
                    {
                        idPoint = ps[i];
                        break;
                    }
                }

                if (idPoint != null)
                {
                    int   itemCount = RandomUtil.Random(r.posFromCount, r.posToCount);
                    int[] pIndex    = RandomUtil.Random(0, idPoint.points.Count - 1, itemCount);
                    for (int p = 0; p < pIndex.Length; p++)
                    {
                        Vector3 pos = idPoint.points[pIndex[p]].pos;

                        int[] cats = catPriority.GetCats(RandomUtil.Random(r.dropFromCount, r.dropToCount));

                        for (int i = 0; i < cats.Length; i++)
                        {
                            if (catDic.ContainsKey(catPriority.cats[cats[i]]))
                            {
                                ItemPriority itemPriority = catDic[catPriority.cats[cats[i]]];
                                ItemDrop     item         = itemPriority.GetItems(1)[0];
                                item.pos = pos;

                                items.Add(item);
                            }
                        }
                    }
                }
            }

            return(items);
        }