Пример #1
0
 public SpawnManager(DbSpawn _baseSpawn, Map _map)
 {
     BaseType     = ServerDatabase.Context.Monstertype.GetById(_baseSpawn.MonsterType);
     DropRules    = ServerDatabase.Context.DropRules.GetRulesByMonsterType(_baseSpawn.MonsterType).ToList();
     TopLeft      = new Point(_baseSpawn.X1, _baseSpawn.Y1);
     BottomRight  = new Point(_baseSpawn.X2, _baseSpawn.Y2);
     Frequency    = _baseSpawn.Frequency;
     AmountPer    = _baseSpawn.AmountPer;
     AmountMax    = _baseSpawn.AmountMax;
     DeadMembers  = new Queue <Monster>();
     DyingMembers = new ConcurrentDictionary <uint, Monster>();
     AliveMembers = new ConcurrentDictionary <uint, Monster>();
     Map          = _map;
     for (int i = 0; i < AmountMax; i++)
     {
         DeadMembers.Enqueue(new Monster(BaseType, this));
     }
 }
        private static void Process_AddSpawn(Player client, string[] command)
        {
            if (client.Account.Permission < PlayerPermission.GM)
            {
                return;
            }

            if (command.Length < 4)
            {
                client.SendMessage("Error: Proper format is /addspawn id count radius");
            }
            else
            {
                uint   uid, id;
                int    count;
                ushort radius;
                if (uint.TryParse(command[1], out id) &&
                    int.TryParse(command[2], out count) &&
                    ushort.TryParse(command[3], out radius))
                {
                    var monsterType = ServerDatabase.Context.Monstertype.GetById(id);
                    if (monsterType == null)
                    {
                        client.SendMessage("ERROR: No such monster ID: " + id);
                    }
                    else
                    {
                        var dbSpawn = new DbSpawn();
                        dbSpawn.MonsterType = monsterType.ID;
                        dbSpawn.X1          = (ushort)(client.Location.X - radius);
                        dbSpawn.Y1          = (ushort)(client.Location.Y - radius);
                        dbSpawn.X2          = (ushort)(client.Location.X + radius);
                        dbSpawn.Y2          = (ushort)(client.Location.Y + radius);
                        dbSpawn.Map         = client.MapID;
                        dbSpawn.AmountMax   = count;
                        dbSpawn.AmountPer   = count / 2;
                        dbSpawn.Frequency   = 10;
                        ServerDatabase.Context.Spawns.Add(dbSpawn);
                        client.Map.Spawns.Add(new Managers.SpawnManager(dbSpawn, client.Map));
                    }
                }
            }
        }