/// <summary> /// TODO: Multiple spawns please. /// </summary> /// <param name="world"></param> public static void Load(GameWorld world) { string path = Config.GetDataPath() + "world/spawns.xml"; XmlTextReader reader = new XmlTextReader(path); Respawn currentRespawn = null; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: while (reader.MoveToNextAttribute()) // Read attributes { if (reader.Name == "centerx") { currentRespawn = new Respawn(world); currentRespawn.CenterX = ushort.Parse(reader.Value); } else if (reader.Name == "centery") { currentRespawn.CenterY = ushort.Parse(reader.Value); } else if (reader.Name == "centerz") { currentRespawn.CenterZ = byte.Parse(reader.Value); } else if (reader.Name == "radius") { currentRespawn.Radius = int.Parse(reader.Value); } else if (reader.Name == "name") { currentRespawn.MonsterName = reader.Value; } else if (reader.Name == "spawntime") { if (currentRespawn.CanSpawn()) { currentRespawn.Spawn(); } //currentRespawn.SpawnTime = 100 * int.Parse(reader.Value); } } break; } } reader.Close(); }
public void Run(string[] args) { // TODO: Print version information #if DEBUG // TODO: Print "DEBUGGING ON"-message Log.WriteDebug("Debugging on."); #endif // Load configuration // Remove configuration asm/ if (Directory.Exists("asm")) { Directory.Delete("asm", true); } string configFile = "config.cs"; // Read config file in command line argument if (args.Length > 0) { if (!File.Exists(args[0])) { Console.WriteLine("Usage: mono cyclops.exe [config file]"); Console.WriteLine(); return; } else { configFile = args[0]; } } if (!File.Exists(configFile)) { // TODO: Create new template config file configFile = "config.cs"; } Log.WriteBegin("Loading config file (" + configFile + ")..."); try { DynamicCompile compiler = new DynamicCompile(); Dictionary <string, string> values = (Dictionary <string, string>)compiler.Compile(configFile, null); Config.Load(values); } catch (Exception e) { Log.WriteError(e.ToString()); return; } Log.WriteEnd(); // TODO: Write load-message Log.WriteBegin("Loading items..."); Item.LoadItems(); Log.WriteEnd(); // TODO: Write load-message Log.WriteBegin("Loading spells..."); Spell.Load(); Log.WriteEnd(); // TODO: Write load-message Log.WriteBegin("Loading monsters..."); Monster.Load(); Log.WriteEnd(); // TODO: Write load-message Log.WriteBegin("Loading commands..."); Command.Load(); Log.WriteEnd(); // TODO: Write load-message Log.WriteBegin("Loading map..."); Map map = Map.Load(); world = new GameWorld(map); Log.WriteEnd(); // TODO: Write load-message Log.WriteBegin("Loading non-person characters..."); NPC.Load(); List <NPC> allNPCs = NPC.GetAllNPCs(); foreach (NPC npc in allNPCs) { world.SendAddNPC(npc, npc.CurrentPosition); } Log.WriteEnd(); // TODO: Write load-message Log.WriteBegin("Loading monster spawns..."); Respawn.Load(world); Log.WriteEnd(); // TODO: Write load-message (listener) Log.WriteBegin("Starting TCP listener..."); listener = new TcpListener(IPAddress.Any, Config.GetPort()); listener.Start(); Log.WriteEnd(); Log.WriteLine("Server is now running."); // TODO: Write message: SERVER NOW RUNNING AcceptConnections(); }