Пример #1
0
        //
        // GameEncounterPoint
        //
        public EncounterPoint(World world, GameClient client, Type monsterType, int numMonsters, Vector3D position)
        {
            ObjectIdsSpawned = new List<Monster>();
            _client = client;

            numMonsters += RandomHelper.Next(3);

            for (int i = 0; i < numMonsters; i++)
            {
                // Allocate the monster with the world.
                Monster monster = (Monster)world.SpawnNPC(monsterType);

                // Random spawn offset.
                float xpos = (float)(RandomHelper.NextDouble() * 20);
                float ypos = (float)(RandomHelper.NextDouble() * 20);
                
                // Init the monster and set the position with the randomized coordinates.
                monster.Init(_client.GetNextValidObjectID(), ref client);
                monster.SetPosition(position.Field0 + xpos, position.Field1 + ypos, position.Field2);

                // Spawn the monster.
                world.SpawnMob(client, monster.Position, monster);

                System.Threading.Thread.Sleep(15); // Required to not generate the same random value twice...

                ObjectIdsSpawned.Add(monster);
            }
        }