Example #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);
        }
Example #2
0
        public override void DoAction(IEventArgs args)
        {
            if (index < list.Count)
            {
                for (int i = 0; i < 20; i++)
                {
                    ItemDrop drop = list[index++];
                    if (drop.cat == (int)ECategory.Vehicle)
                    {
                        VehicleEntityUtility.CreateNewVehicle(args.GameContext.vehicle, drop.id, args.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), GetGround(drop.pos));
                        break;
                    }
                    else
                    {
                        args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleObjectEntity((ECategory)drop.cat, drop.id, drop.count, GetGround(drop.pos));
                    }

                    List <ItemDrop> extra = SingletonManager.Get <FreeItemDrop>().GetExtraItems(drop);
                    foreach (ItemDrop e in extra)
                    {
                        args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleObjectEntity((ECategory)e.cat, e.id, e.count, GetGround(drop.pos));
                    }
                    if (index >= list.Count)
                    {
                        break;
                    }
                }
            }
        }
Example #3
0
        private void CreateItemFromItemDrop(IEventArgs fr, Vector3 p, ItemDrop drop, string realName)
        {
            FreeMoveEntity en = fr.GameContext.freeMove.CreateEntity();

            en.AddEntityKey(new EntityKey(fr.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            en.AddPosition();
            en.position.Value = new Vector3(p.x, p.y, p.z);

            en.AddFreeData(FreeUtil.ReplaceVar(name, fr), null);
            en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
            if (type == 1)
            {
                en.freeData.Cat = FreeEntityConstant.DeadBox;
            }
            else if (type == 2)
            {
                en.freeData.Cat = FreeEntityConstant.DropBox;
            }

            en.AddFlagImmutability(fr.GameContext.session.currentTimeObject.CurrentTime);

            SimpleItemInfo info = new SimpleItemInfo(realName, drop.cat, drop.id, drop.count, en.entityKey.Value.EntityId);

            en.freeData.Value = SingletonManager.Get <DeadBoxParser>().ToString(info);

            en.isFlagSyncNonSelf = true;
        }
Example #4
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);
        }
Example #5
0
        public ItemDrop[] GetItems(int n)
        {
            if (cats.Length == 1)
            {
                return(new ItemDrop[] { new ItemDrop(Vector3.zero, cats[0], ids[0], counts[0]) });
            }

            int[] indexs = RandomUtil.RandomWithPro(0, prioritys, n);

            ItemDrop[] ss = new ItemDrop[indexs.Length];
            for (int i = 0; i < indexs.Length; i++)
            {
                ss[i] = new ItemDrop(Vector3.zero, cats[indexs[i]], ids[indexs[i]], counts[indexs[i]]);
            }

            return(ss);
        }
        public override void DoAction(IEventArgs args)
        {
            if (index < list.Count)
            {
                for (int i = 0; i < 20; i++)
                {
                    ItemDrop drop = list[index++];
                    args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.
                    CreateSimpleEquipmentEntity((ECategory)drop.cat, drop.id, drop.count, new Vector3(drop.pos.x, drop.pos.y, drop.pos.z));

                    List <ItemDrop> extra = FreeItemDrop.GetExtraItems(drop);
                    foreach (ItemDrop e in extra)
                    {
                        args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.
                        CreateSimpleEquipmentEntity((ECategory)e.cat, e.id, e.count, new Vector3(drop.pos.x, drop.pos.y, drop.pos.z));
                    }
                    if (index >= list.Count)
                    {
                        break;
                    }
                }
            }
        }