Example #1
0
 /// <summary>
 /// Load all the npcs as specified in the configuration file.
 /// </summary>
 public static void Load()
 {
     string path = Config.GetDataPath() + Config.GetNPCDirectory();
     FileInfo[] fileList = new DirectoryInfo(path).GetFiles();
     Compiler dCompile = new Compiler();
     foreach (FileInfo info in fileList) {
         NPC npc = (NPC)dCompile.Compile(path + info.Name, null);
         NPCDictionary.Add(npc.Name.ToLower(), npc);
     }
 }
Example #2
0
 private static void Compile(string path, Dictionary<string, SpellInfo> dict)
 {
     FileInfo[] fileList = new DirectoryInfo(path).GetFiles();
     Compiler dCompile = new Compiler();
     foreach (FileInfo info in fileList) {
         SpellInfo spellInfo = new SpellInfo();
         dCompile.Compile(path + info.Name, spellInfo);
         dict.Add(spellInfo.Name.ToLower(), spellInfo);
     }
 }
Example #3
0
 private static void Compile(Object arg, string path)
 {
     FileInfo[] fileList = new DirectoryInfo(path).GetFiles();
     Compiler dCompile = new Compiler();
     foreach (FileInfo info in fileList) {
         dCompile.Compile(path + info.Name, arg);
     }
 }
Example #4
0
        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 Berserker.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
            {
                Compiler compiler = new Compiler();
                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();
        }
Example #5
0
 /// <summary>
 /// Loads all the monsters.
 /// </summary>
 public static void Load()
 {
     string path = Config.GetDataPath() + Config.GetMonsterDirectory();
     FileInfo[] fileList = new DirectoryInfo(path).GetFiles();
     Compiler dCompile = new Compiler();
     foreach (FileInfo info in fileList) {
         Monster monster = (Monster)dCompile.Compile(path + info.Name, null);
         masterDictionary.Add(monster.Name.ToLower(), monster);
     }
 }