示例#1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="xmlBaseFactory">Instance of XmlBaseFactory</param>
 /// <param name="roofMaterial">Roof material</param>
 /// <param name="rooftopHeight">Height of rooftop</param>
 public RoofFactory(XmlBaseFactory xmlBaseFactory, Material roofMaterial, float rooftopHeight) : base(xmlBaseFactory)
 {
     roofMat    = roofMaterial;
     roofHeight = rooftopHeight;
     CreateRooftops();
     parent.name = "Rooftops";
 }
示例#2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="xmlBaseFactory">Instance of XmlBaseFactory</param>
 /// <param name="roadMaterial">Road material</param>
 /// <param name="footwayMaterial">Footway material</param>
 public RoadFactory(XmlBaseFactory xmlBaseFactory, Material roadMaterial, Material footwayMaterial) : base(xmlBaseFactory)
 {
     road    = roadMaterial;
     footway = footwayMaterial;
     CreateRoads();
     parent.name = "Roads";
 }
示例#3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="xmlBaseFactory">Instance of XmlBaseFactory</param>
 /// <param name="waterWay">Waterway material</param>
 /// <param name="greenmaterial"> Green area material</param>
 /// <param name="riverWidth">Width of river</param>
 /// <param name="steamWidth">Width of Stream</param>
 public EnvironmentFactory(XmlBaseFactory xmlBaseFactory, Material waterWay, Material greenMaterial, float riverWidth, float steamWidth) : base(xmlBaseFactory)
 {
     waterMat  = waterWay;
     greenMat  = greenMaterial;
     riverWid  = riverWidth;
     streamWid = steamWidth;
     CreaterWaterway();
     parent.name = "Environment";
 }
示例#4
0
    //Calls the factory classes and passes the values of the import window inputs
    public void Import()
    {
        var xmlBaseFactory = new XmlBaseFactory();

        xmlBaseFactory.Read(_mapFile);

        var buildingFactory    = new BuildingFactory(xmlBaseFactory, _buildingMaterial);
        var roofFactory        = new RoofFactory(xmlBaseFactory, _roofMaterial);
        var roadFactory        = new RoadFactory(xmlBaseFactory, _roadMaterial, _footwayMaterial);
        var environmentFactory = new EnvironmentFactory(xmlBaseFactory, _greenMaterial);
    }
示例#5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="xmlBaseFactory">Instance of XmlBaseFactory</param>
 /// <param name="roofMaterial">Roof material</param>
 /// <param name="rooftopHeight">Height of rooftop</param>
 public RoofFactory(XmlBaseFactory xmlBaseFactory, Material roofMaterial) : base(xmlBaseFactory)
 {
     roofMat = roofMaterial;
     CreateRooftops();
     parent.name = "Rooftops";
 }
示例#6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="xmlBaseFactory">Instance of XmlBaseFactory</param>
 /// <param name="greenmaterial"> Green area material</param>
 public EnvironmentFactory(XmlBaseFactory xmlBaseFactory, Material greenMaterial) : base(xmlBaseFactory)
 {
     greenMat = greenMaterial;
     CreaterWaterway();
     parent.name = "Environment";
 }
示例#7
0
 /// <summary>
 /// Constructor
 /// </summary>
 public InfrastructureManager(XmlBaseFactory map)
 {
     xmlBaseFactory = map;
 }
示例#8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="xmlBaseFactory">Instance of XmlBaseFactory</param>
 /// <param name="buildingMaterial">Road material</param>
 public BuildingFactory(XmlBaseFactory xmlBaseFactory, Material buildingMaterial) : base(xmlBaseFactory)
 {
     buildingMat = buildingMaterial;
     CreateBuildings();
     parent.name = "Buildings";
 }
示例#9
0
        // Function to stitch the street to the current list of nodes
        public bool Stitch(XmlBaseFactory xmlBaseFactory, WaysFactory street)
        {
            // Create list to append
            List <StreetNode> append = new List <StreetNode>();

            for (int i = 0; i < street.ndref.Count; i++)
            {
                StreetNode node = new StreetNode();
                node.id       = street.ndref[i];
                node.position = xmlBaseFactory.allNodes[node.id] - xmlBaseFactory.boundsFactory.center;
                node.waterway = street.isWaterway;
                append.Add(node);
            }

            // Atemmpt to stitch append list to current list of nodes

            // If street is empty
            if (nodes.Count == 0)
            {
                nodes = append;
            }
            // if the first node in the street is the same as the first node in the street we're trying to stich
            else if (nodes[0].id == append[0].id)
            {
                nodes.Reverse();
                nodes.AddRange(append);
            }
            // if the first node in the street is the same as the last node in the street we're trying to stitch
            else if (nodes[0].id == append[append.Count - 1].id)
            {
                append.AddRange(nodes);
                nodes = append;
            }
            // if the last node in the street is the same as the first node in the street we're trying to stitch
            else if (nodes[nodes.Count - 1].id == append[0].id)
            {
                nodes.AddRange(append);
            }
            // if the last node in the street is the same as the last node in the street we're trying to stitch
            else if (nodes[nodes.Count - 1].id == append[append.Count - 1].id)
            {
                append.Reverse();
                nodes.AddRange(append);
            }
            else
            {
                return(false);
            }

            // Cleanup data
            // Remove duplicate ids
            List <StreetNode> copy = new List <StreetNode>();

            for (int i = 0; i < nodes.Count; i++)
            {
                if (copy.Count == 0 || copy[copy.Count - 1].id != nodes[i].id)
                {
                    copy.Add(nodes[i]);
                }
            }
            nodes = copy;

            // Remove single waterways
            for (int i = 0; i < nodes.Count; i++)
            {
                bool fPrev = i - 1 >= 0 ? nodes[i - 1].waterway : !nodes[i].waterway;
                bool fNext = i + 1 < nodes.Count ? nodes[i + 1].waterway : !nodes[i].waterway;
                bool fCurr = nodes[i].waterway;
                if (fCurr != fPrev && fCurr != fNext)
                {
                    nodes[i].waterway = !(nodes[i].waterway);
                }
            }

            // Check if waterway is looped
            looped = nodes.Count > 2 && nodes[0].id == nodes[nodes.Count - 1].id;

            return(true);
        }