Exemplo n.º 1
0
        private void ReadCrossroad(ICrossroad crossroad, IRoadmapFactory roadmapFactory, XmlNode crossroadNode)
        {
            var pivotPoint = ReadPoint(crossroadNode.SelectSingleNode("pivotPoint"));
            var index      = ushort.Parse(crossroadNode.GetFieldValue("index"));

            crossroad.PivotPoint = pivotPoint;
            crossroad.Index      = index;


            var junctionNodes = crossroadNode.SelectNodes("roadJunctions/roadJunction");

            foreach (XmlNode junctionNode in junctionNodes)
            {
                IRoadJunction junction = roadmapFactory.Junction();
                ReadRoadJunction(junction, roadmapFactory, junctionNode);
                crossroad.Junctions.Add(junction);
            }

            var boundNodes = crossroadNode.SelectNodes("bounds/point");

            foreach (XmlNode pointNode in boundNodes)
            {
                crossroad.Bounds.Add(ReadPoint(pointNode));
            }

            var semaphoreNodes = crossroadNode.SelectNodes("trafficLightSemaphores/semaphore");

            foreach (XmlNode semaphoreNode in semaphoreNodes)
            {
                ITrafficLightSemaphore semaphore = roadmapFactory.TrafficLightSemaphore();
                ReadTrafficLightSemaphore(semaphore, semaphoreNode);
                crossroad.TrafficLightSemaphores.Add(semaphore);
            }
        }
Exemplo n.º 2
0
        private void WriteTrafficLightSemaphore(ITrafficLightSemaphore semaphore, XmlDocument xml, XmlNode node)
        {
            node.AddFieldWithValue(xml, "unkn0_0", semaphore.Unkn0_0);
            node.AddFieldWithValue(xml, "unkn0_4", semaphore.Unkn0_4);
            node.AddFieldWithValue(xml, "unkn0_8", semaphore.Unkn0_8);
            node.AddFieldWithValue(xml, "unkn0_12", semaphore.Unkn0_12);
            node.AddFieldWithValue(xml, "unkn2", semaphore.Unkn2);

            var managedRoadsNode = xml.CreateElement("managedRoads");

            node.AppendChild(managedRoadsNode);
            foreach (var value in semaphore.ManagedRoads)
            {
                managedRoadsNode.AddFieldWithValue(xml, "value", value.ToStrMaxAsNegOne());
            }
        }
Exemplo n.º 3
0
        private void ReadTrafficLightSemaphore(ITrafficLightSemaphore semaphore, XmlNode semaphoreNode)
        {
            var unkn0_0  = byte.Parse(semaphoreNode.GetFieldValue("unkn0_0"));
            var unkn0_4  = byte.Parse(semaphoreNode.GetFieldValue("unkn0_4"));
            var unkn0_8  = byte.Parse(semaphoreNode.GetFieldValue("unkn0_8"));
            var unkn0_12 = byte.Parse(semaphoreNode.GetFieldValue("unkn0_12"));
            var unkn2    = ushort.Parse(semaphoreNode.GetFieldValue("unkn2"));

            semaphore.Unkn0_0  = unkn0_0;
            semaphore.Unkn0_4  = unkn0_4;
            semaphore.Unkn0_8  = unkn0_8;
            semaphore.Unkn0_12 = unkn0_12;
            semaphore.Unkn2    = unkn2;

            var managedRoadsValuesNodes = semaphoreNode.SelectNodes("managedRoads/value");

            foreach (XmlNode valueNode in managedRoadsValuesNodes)
            {
                var valueStr = valueNode.InnerText;
                var value    = StrWithMaxValueNegativeOneToUshort(valueStr);
                semaphore.ManagedRoads.Add(value);
            }
        }