Exemplo n.º 1
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.CreateSimpleEquipmentEntity((ECategory)drop.cat, drop.id, drop.count, GetGround(drop.pos));
                    }

                    List <ItemDrop> extra = FreeItemDrop.GetExtraItems(drop);
                    foreach (ItemDrop e in extra)
                    {
                        args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity((ECategory)e.cat, e.id, e.count, GetGround(drop.pos));
                    }
                    if (index >= list.Count)
                    {
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public override void DoAction(IEventArgs args)
 {
     if (remove)
     {
         args.GameContext.sceneObject.DestroyAllEntities();
     }
     else
     {
         if (MapConfigPoints.current != null)
         {
             if (MapConfigPoints.current.IDPints.Count == 0)
             {
                 Logger.Error("地图点位(组)数量为0!");
             }
             foreach (MapConfigPoints.ID_Point point in MapConfigPoints.current.IDPints)
             {
                 List <ItemDrop> list = FreeItemDrop.GetDropItems(point.ID, args.GameContext.session.commonSession.RoomInfo.MapId);
                 Logger.InfoFormat("地图点位 {0} 上,将会刷新 {1} 个(组)物品", point.ID, list.Count);
                 if (list.Count > 0)
                 {
                     TimerGameAction timer = new TimerGameAction();
                     timer.time  = "200";
                     timer.count = list.Count.ToString();
                     timer.SetAction(new RefreshItemAction(list));
                     timer.Act(args);
                 }
             }
         }
         else
         {
             Logger.Error("地图点位(组)不存在!");
         }
     }
 }
Exemplo n.º 3
0
        public override void DoAction(IEventArgs args)
        {
            Vector3 p           = UnityPositionUtil.ToVector3(pos.Select(args));
            string  realName    = FreeUtil.ReplaceVar(name, args);
            var     groupEntity = args.GameContext.freeMove.CreateEntity();

            groupEntity.AddEntityKey(new EntityKey(args.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            groupEntity.AddPosition();
            groupEntity.position.Value = new Vector3(p.x, p.y, p.z);
            groupEntity.AddFreeData("", null);
            groupEntity.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
            groupEntity.freeData.Value = "";
            if (type == 1)
            {
                groupEntity.freeData.Cat = FreeEntityConstant.DeadBoxGroup;
            }
            else if (type == 2)
            {
                groupEntity.freeData.Cat = FreeEntityConstant.DropBoxGroup;
            }
            groupEntity.isFlagSyncNonSelf = true;

            if (string.IsNullOrEmpty(id))
            {
                ItemDrop[] list = FreeItemDrop.GetDropItems(FreeUtil.ReplaceVar(cat, args), FreeUtil.ReplaceInt(count, args), args.GameContext.session.commonSession.RoomInfo.MapId);
                foreach (ItemDrop drop in list)
                {
                    CreateItemFromItemDrop(args, p, drop, realName);
                    List <ItemDrop> extra = FreeItemDrop.GetExtraItems(drop);
                    foreach (ItemDrop e in extra)
                    {
                        CreateItemFromItemDrop(args, p, e, realName);
                    }
                }
            }
            else
            {
                PlayerEntity player = args.GameContext.player.GetEntityWithEntityKey(new EntityKey(FreeUtil.ReplaceInt(id, args), (short)EEntityType.Player));
                if (player != null)
                {
                    groupEntity.freeData.IntValue = player.entityKey.Value.EntityId;
                    groupEntity.freeData.Value    = realName;
                    realName = player.playerInfo.PlayerName;
                    FreeData fd = ((FreeData)player.freeData.FreeData);
                    foreach (string inv in fd.GetFreeInventory().GetInventoryManager().GetInventoryNames())
                    {
                        ItemInventory ii = fd.GetFreeInventory().GetInventoryManager().GetInventory(inv);
                        if (ii.name != ChickenConstant.BagDefault)
                        {
                            CreateItemFromInventory(args, fd, ii, p, realName);
                        }
                    }
                    CreateItemFromInventory(args, fd, fd.GetFreeInventory().GetInventoryManager().GetDefaultInventory(), p, realName);
                }
            }
        }
Exemplo n.º 4
0
        public override void DoAction(IEventArgs args)
        {
            ItemDrop[] list = FreeItemDrop.GetDropItems(FreeUtil.ReplaceVar(cat, args), FreeUtil.ReplaceInt(count, args), args.GameContext.session.commonSession.RoomInfo.MapId);

            if (list != null)
            {
                Vector3 p = UnityPositionUtil.ToVector3(pos.Select(args));
                foreach (ItemDrop drop in list)
                {
                    args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.
                    CreateSimpleEquipmentEntity((ECategory)drop.cat, drop.id, drop.count, new Vector3(p.x + RandomUtil.Random(-100, 100) / 100f, p.y, p.z + RandomUtil.Random(-100, 100) / 100f));
                }
            }
        }
Exemplo n.º 5
0
        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;
                    }
                }
            }
        }
Exemplo n.º 6
0
        public override void DoAction(IEventArgs args)
        {
            if (remove)
            {
                args.GameContext.sceneObject.DestroyAllEntities();
            }
            else
            {
                Accumulator <string> acc = new Accumulator <string>();
                if (MapConfigPoints.current != null)
                {
                    foreach (MapConfigPoints.ID_Point point in MapConfigPoints.current.IDPints)
                    {
                        List <ItemDrop> list = FreeItemDrop.GetDropItems(point.ID);

                        foreach (ItemDrop item in list)
                        {
                            acc.AddKey(string.Format("{0}_{1}", item.cat, item.id), 1);
                        }

                        TimerGameAction timer = new TimerGameAction();
                        timer.time  = "200";
                        timer.count = list.Count.ToString();
                        timer.SetAction(new RefreshItemAction(list));

                        timer.Act(args);
                    }
                }

                List <string> items = new List <string>();
                foreach (string key in acc.KeysSortedByValue())
                {
                    items.Add(string.Format("{0}={1}", key, acc.GetCount(key)));
                }
                Debug.LogFormat("items:\n{0}", string.Join("\n", items.ToArray()));
            }
        }