Example #1
0
        public ObjectTool()
        {
            types = new List<EntityType>();

            ConfuseReader rdr = new ConfuseReader();
            String file = System.IO.File.ReadAllText(Program.Datapath + "/objecttypes.conf");
            ConfuseSection sect = rdr.Parse(file);

            foreach (ConfuseSection walltype in sect.subsections) {
                if (walltype.name != "objecttype") continue;

                ObjectEntityType et = new ObjectEntityType(walltype.get_string("name", ""));
                if (et.Name == "") continue;

                types.Add(et);
            }
        }
Example #2
0
        /**
         * Load
         **/
        public bool Load(string filename)
        {
            ConfuseReader rdr = new ConfuseReader();
            string input = System.IO.File.ReadAllText(filename);
            ConfuseSection parsed = rdr.Parse(input);

            this.Width = parsed.get_int("width", 200);
            this.Height = parsed.get_int("height", 200);

            this.entities = new List<Entity>();
            foreach (ConfuseSection sect in parsed.subsections) {
                Entity ent = null;

                if (sect.name == "zone") {
                    ent = Tools.Zone.loadConfig(sect);
                } else if (sect.name == "light") {
                    ent = Tools.Light.loadConfig(sect);
                } else if (sect.name == "object") {
                    ent = Tools.Object.loadConfig(sect);
                }

                if (ent == null) continue;
                if (ent.Type == null) continue;

                entities.Add(ent);
            }

            string basename = System.IO.Path.GetDirectoryName(filename);

            // Load terrain
            if (System.IO.File.Exists(basename + "\\terrain.png")) {
                this.Terrain = new Bitmap(basename + "\\terrain.png");
            } else {
                this.Terrain = new Bitmap(this.Width, this.Height);
            }

            // Load heightmap
            if (System.IO.File.Exists(basename + "\\heightmap.png")) {
                this.Heightmap = new Bitmap(basename + "\\heightmap.png");
            } else {
                this.Heightmap = new Bitmap(this.Width, this.Height);
            }

            return true;
        }