Exemple #1
0
        public override Entity loadConfig(ConfuseSection sect)
        {
            ObjectEntity ent = new ObjectEntity();

            // find type
            string type = sect.get_string("type", "");

            foreach (EntityType ty in this.types)
            {
                if (ty.Name == type)
                {
                    ent.Type = ty;
                    break;
                }
            }
            if (ent.Type == null)
            {
                return(null);
            }

            // load other deets
            ent.X = sect.get_int("x", 0);
            ent.Y = sect.get_int("y", 0);

            return(ent);
        }
Exemple #2
0
        public override Entity loadConfig(ConfuseSection sect)
        {
            LightEntity ent = new LightEntity();

            ent.Type = types[0];

            ent.X = sect.get_int("x", 0);
            ent.Y = sect.get_int("y", 0);

            return(ent);
        }
Exemple #3
0
        public override Entity loadConfig(ConfuseSection sect)
        {
            ZoneEntity ent = new ZoneEntity();

            ent.Type = types[0];

            ent.Width  = sect.get_int("width", 20);
            ent.Height = sect.get_int("height", 20);
            ent.X      = sect.get_int("x", 0);
            ent.Y      = sect.get_int("y", 0);
            ent.Angle  = sect.get_int("angle", 0);

            return(ent);
        }
Exemple #4
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);
        }