/// <summary>
        /// This constructor is used when creating a new world from scratch.
        /// </summary>
        /// <param name="minTile"></param>
        /// <param name="maxTile"></param>
        /// <param name="minHeight"></param>
        /// <param name="maxHeight"></param>
        /// <param name="defaultHeight"></param>
        public WorldMap(string worldName, CoordXZ minTile, CoordXZ maxTile, float minHeight, float maxHeight, float defaultHeight)
        {
            this.worldName = worldName;
            this.minTile   = minTile;
            this.maxTile   = maxTile;
            this.minHeight = minHeight;
            this.maxHeight = maxHeight;

            emptyOWP         = new List <IObjectWithProperties>();
            layerAndWorldOWP = new List <IObjectWithProperties>();

            properties = new MapProperties(this);

            layers = new Dictionary <string, MapLayer>();

            InitLayers(defaultHeight);

            // create map sections
            sections = new Dictionary <CoordXZ, MapSection>();
            zones    = new Dictionary <string, MapZone>();

            CoordXZ minSection = new CoordXZ(minTile, sectionSize);
            CoordXZ maxSection = new CoordXZ(maxTile, sectionSize);

            for (int z = minSection.z; z <= maxSection.z; z++)
            {
                for (int x = minSection.x; x <= maxSection.x; x++)
                {
                    CoordXZ sectionCoord = new CoordXZ(x, z, sectionSize);
                    sections[sectionCoord] = new MapSection(this, sectionCoord);
                }
            }
        }
Exemple #2
0
 public MapPropertyDescriptor(MapProperties properties, string propName)
     :
     base(propName, new Attribute[0])
 {
     this.propName   = propName;
     this.properties = properties;
 }
        public WorldMap(string filename)
        {
            // create map sections
            sections = new Dictionary <CoordXZ, MapSection>();
            zones    = new Dictionary <string, MapZone>();
            layers   = new Dictionary <string, MapLayer>();

            emptyOWP         = new List <IObjectWithProperties>();
            layerAndWorldOWP = new List <IObjectWithProperties>();

            properties = new MapProperties(this);

            worldPath = System.IO.Path.GetDirectoryName(filename);

            FromXml(filename);

            // add worldmap to the end of the list
            layerAndWorldOWP.Add(this);

            // create heightfield layer
            heightFieldLayer = layers["heightfield"];
            alpha0Layer      = layers["alpha0"];
            alpha1Layer      = layers["alpha1"];

            Debug.Assert(heightFieldLayer != null);
            Debug.Assert(alpha0Layer != null);
            Debug.Assert(alpha1Layer != null);
        }
        /// <summary>
        /// This constructor is used when creating a new world from scratch.
        /// </summary>
        /// <param name="minTile"></param>
        /// <param name="maxTile"></param>
        /// <param name="minHeight"></param>
        /// <param name="maxHeight"></param>
        /// <param name="defaultHeight"></param>
        public WorldMap(string worldName, CoordXZ minTile, CoordXZ maxTile, float minHeight, float maxHeight, float defaultHeight)
        {
            this.worldName = worldName;
            this.minTile = minTile;
            this.maxTile = maxTile;
            this.minHeight = minHeight;
            this.maxHeight = maxHeight;

            emptyOWP = new List<IObjectWithProperties>();
            layerAndWorldOWP = new List<IObjectWithProperties>();

            properties = new MapProperties(this);

            layers = new Dictionary<string, MapLayer>();

            InitLayers(defaultHeight);

            // create map sections
            sections = new Dictionary<CoordXZ, MapSection>();
            zones = new Dictionary<string, MapZone>();

            CoordXZ minSection = new CoordXZ(minTile, sectionSize);
            CoordXZ maxSection = new CoordXZ(maxTile, sectionSize);

            for (int z = minSection.z; z <= maxSection.z; z++)
            {
                for (int x = minSection.x; x <= maxSection.x; x++)
                {
                    CoordXZ sectionCoord = new CoordXZ(x, z, sectionSize);
                    sections[sectionCoord] = new MapSection(this, sectionCoord);
                }
            }
        }
        public MapTile(WorldMap map, CoordXZ tileCoord)
        {
            this.map = map;
            this.tileCoord = tileCoord;
            zone = null;
            this.dirty = false;

            properties = new MapProperties(this);
        }    
        public MapTile(WorldMap map, CoordXZ tileCoord)
        {
            this.map       = map;
            this.tileCoord = tileCoord;
            zone           = null;
            this.dirty     = false;

            properties = new MapProperties(this);
        }
Exemple #7
0
 public MapProperty(MapProperties collection, string name, string category, string description, Type type, object value)
 {
     this.collection  = collection;
     this.name        = name;
     this.category    = category;
     this.description = description;
     this.type        = type;
     this.value       = value;
 }
Exemple #8
0
        public MapZone(WorldMap map, string name)
        {
            this.map  = map;
            this.name = name;
            tiles     = new List <CoordXZ>();

            properties = new MapProperties(this);

            tilePropertyParent = new List <IObjectWithProperties>();
            tilePropertyParent.Add(this);
        }
        public MapLayer(WorldMap map, string layerName, int metersPerTile, int metersPerSample)
        {
            this.map             = map;
            this.layerName       = layerName;
            this.metersPerTile   = metersPerTile;
            this.tileSize        = metersPerTile * WorldMap.oneMeter;
            this.metersPerSample = metersPerSample;
            this.samplesPerTile  = metersPerTile / metersPerSample;

            tiles      = new Dictionary <CoordXZ, MapBuffer>();
            properties = new MapProperties(this);
        }
Exemple #10
0
        public MapZone(WorldMap map, XmlReader r)
        {
            this.map   = map;
            properties = new MapProperties(this);

            tilePropertyParent = new List <IObjectWithProperties>();
            tilePropertyParent.Add(this);

            FromXml(r);

            tiles = new List <CoordXZ>();
        }
Exemple #11
0
        public MapProperty(MapProperties collection, XmlReader r)
        {
            string valueString = null;

            this.collection = collection;

            // parse attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                case "Name":
                    name = r.Value;
                    break;

                case "Category":
                    category = r.Value;
                    break;

                case "Description":
                    description = r.Value;
                    break;

                case "Type":
                    type = Type.GetType(r.Value);
                    break;

                case "Value":
                    valueString = r.Value;
                    break;
                }
            }

            r.MoveToElement();

            switch (type.FullName)
            {
            case "System.String":
                value = valueString;
                break;

            default:
                throw new Exception("Attempt to parse MapProperty of unknown type: " + type.FullName);
            }
        }
Exemple #12
0
 /// <summary>
 /// This constructor is used to copy a property into a new collection.  Typically used
 /// when creating an instance of the property in a child object.
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="src"></param>
 public MapProperty(MapProperties collection, MapProperty src)
     : this(collection, src.name, src.category, src.description, src.type, src.value)
 {
 }
 public MapPropertyDescriptor(MapProperties properties, string propName)
     : base(propName, new Attribute[0])
 {
     this.propName = propName;
     this.properties = properties;
 }
 /// <summary>
 /// This constructor is used to copy a property into a new collection.  Typically used
 /// when creating an instance of the property in a child object.
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="src"></param>
 public MapProperty(MapProperties collection, MapProperty src)
     : this(collection, src.name, src.category, src.description, src.type, src.value)
 {
 }
        public MapProperty(MapProperties collection, XmlReader r)
        {
            string valueString = null;

            this.collection = collection;

            // parse attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                    case "Name":
                        name = r.Value;
                        break;
                    case "Category":
                        category = r.Value;
                        break;
                    case "Description":
                        description = r.Value;
                        break;
                    case "Type":
                        type = Type.GetType(r.Value);
                        break;
                    case "Value":
                        valueString = r.Value;
                        break;
                }
            }

            r.MoveToElement();

            switch (type.FullName)
            {
                case "System.String":
                    value = valueString;
                    break;
                default:
                    throw new Exception("Attempt to parse MapProperty of unknown type: " + type.FullName);
            }
        }
 public MapProperty(MapProperties collection, string name, string category, string description, Type type, object value)
 {
     this.collection = collection;
     this.name = name;
     this.category = category;
     this.description = description;
     this.type = type;
     this.value = value;
 }
        public WorldMap(string filename)
        {
            // create map sections
            sections = new Dictionary<CoordXZ, MapSection>();
            zones = new Dictionary<string, MapZone>();
            layers = new Dictionary<string, MapLayer>();

            emptyOWP = new List<IObjectWithProperties>();
            layerAndWorldOWP = new List<IObjectWithProperties>();

            properties = new MapProperties(this);

            worldPath = System.IO.Path.GetDirectoryName(filename);

            FromXml(filename);

            // add worldmap to the end of the list
            layerAndWorldOWP.Add(this);

            // create heightfield layer
            heightFieldLayer = layers["heightfield"];
            alpha0Layer = layers["alpha0"];
            alpha1Layer = layers["alpha1"];

            Debug.Assert(heightFieldLayer != null);
            Debug.Assert(alpha0Layer != null);
            Debug.Assert(alpha1Layer != null);
        }
        public MapLayer(WorldMap map, string layerName, int metersPerTile, int metersPerSample)
        {
            this.map = map;
            this.layerName = layerName;
            this.metersPerTile = metersPerTile;
            this.tileSize = metersPerTile * WorldMap.oneMeter;
            this.metersPerSample = metersPerSample;
            this.samplesPerTile = metersPerTile / metersPerSample;

            tiles = new Dictionary<CoordXZ, MapBuffer>();
            properties = new MapProperties(this);
        }