Started to implement road generation.
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								Documentation/Lucrare Licenta.docx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Documentation/Lucrare Licenta.docx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -53,6 +53,9 @@ | |||||||
|      <Compile Include="Assets\Scripts\Model\Biome.cs" /> |      <Compile Include="Assets\Scripts\Model\Biome.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" /> |      <Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Model\Map.cs" /> |      <Compile Include="Assets\Scripts\Model\Map.cs" /> | ||||||
|  |      <Compile Include="Assets\Scripts\Model\Road\RoadNetwork.cs" /> | ||||||
|  |      <Compile Include="Assets\Scripts\Model\Road\RoadNode.cs" /> | ||||||
|  |      <Compile Include="Assets\Scripts\Model\Road\RoadSegment.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Model\Texture.cs" /> |      <Compile Include="Assets\Scripts\Model\Texture.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" /> |      <Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" /> |      <Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" /> | ||||||
| @@ -65,6 +68,7 @@ | |||||||
|      <Compile Include="Assets\Scripts\Utils\Logger.cs" /> |      <Compile Include="Assets\Scripts\Utils\Logger.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" /> |      <Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\Range.cs" /> |      <Compile Include="Assets\Scripts\Utils\Range.cs" /> | ||||||
|  |      <Compile Include="Assets\Scripts\Utils\SerializationHelper.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\Task.cs" /> |      <Compile Include="Assets\Scripts\Utils\Task.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" /> |      <Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\XmlHelper.cs" /> |      <Compile Include="Assets\Scripts\Utils\XmlHelper.cs" /> | ||||||
|   | |||||||
| @@ -53,6 +53,9 @@ | |||||||
|      <Compile Include="Assets\Scripts\Model\Biome.cs" /> |      <Compile Include="Assets\Scripts\Model\Biome.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" /> |      <Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Model\Map.cs" /> |      <Compile Include="Assets\Scripts\Model\Map.cs" /> | ||||||
|  |      <Compile Include="Assets\Scripts\Model\Road\RoadNetwork.cs" /> | ||||||
|  |      <Compile Include="Assets\Scripts\Model\Road\RoadNode.cs" /> | ||||||
|  |      <Compile Include="Assets\Scripts\Model\Road\RoadSegment.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Model\Texture.cs" /> |      <Compile Include="Assets\Scripts\Model\Texture.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" /> |      <Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" /> |      <Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" /> | ||||||
| @@ -65,6 +68,7 @@ | |||||||
|      <Compile Include="Assets\Scripts\Utils\Logger.cs" /> |      <Compile Include="Assets\Scripts\Utils\Logger.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" /> |      <Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\Range.cs" /> |      <Compile Include="Assets\Scripts\Utils\Range.cs" /> | ||||||
|  |      <Compile Include="Assets\Scripts\Utils\SerializationHelper.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\Task.cs" /> |      <Compile Include="Assets\Scripts\Utils\Task.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" /> |      <Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" /> | ||||||
|      <Compile Include="Assets\Scripts\Utils\XmlHelper.cs" /> |      <Compile Include="Assets\Scripts\Utils\XmlHelper.cs" /> | ||||||
|   | |||||||
										
											Binary file not shown.
										
									
								
							| @@ -21,7 +21,7 @@ namespace TransportGame.Business | |||||||
|         public static void LoadConfiguration() |         public static void LoadConfiguration() | ||||||
|         { |         { | ||||||
|             // Load terrgen config |             // Load terrgen config | ||||||
|             TerrGenConfig = XmlHelper.Deserialize<TerrainGeneratorConfig>(Path.Combine(ConfigurationDirectory, TerrGenConfigFile)); |             TerrGenConfig = SerializationHelper.Deserialize<TerrainGeneratorConfig>(Path.Combine(ConfigurationDirectory, TerrGenConfigFile)); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -50,6 +50,8 @@ namespace TransportGame.Generator | |||||||
|             float waterAmount = random.NextSingle(map.Biome.Moisture.Minimum, map.Biome.Moisture.Maximum); |             float waterAmount = random.NextSingle(map.Biome.Moisture.Minimum, map.Biome.Moisture.Maximum); | ||||||
|             map.WaterLevel = Mathf.Pow(waterAmount, ConfigurationManager.TerrGenConfig.WaterNonLinearPower) * map.Biome.Height; |             map.WaterLevel = Mathf.Pow(waterAmount, ConfigurationManager.TerrGenConfig.WaterNonLinearPower) * map.Biome.Height; | ||||||
|  |  | ||||||
|  |             DumpData(map, "dump.map"); | ||||||
|  |  | ||||||
|             return map; |             return map; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -65,7 +67,7 @@ namespace TransportGame.Generator | |||||||
|         { |         { | ||||||
|             for (int x = 0; x < map.Width; ++x) |             for (int x = 0; x < map.Width; ++x) | ||||||
|                 for (int y = 0; y < map.Height; ++y) |                 for (int y = 0; y < map.Height; ++y) | ||||||
|                     map.Heights[x, y] = Noise.Generate(x, y, 0, 1); |                     map.Heightmap[x, y] = Noise.Generate(x, y, 0, 1); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private void DumpData(Map map, string filename) |         private void DumpData(Map map, string filename) | ||||||
|   | |||||||
| @@ -3,6 +3,8 @@ using System.Collections.Generic; | |||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Xml.Serialization; | using System.Xml.Serialization; | ||||||
|  | using TransportGame.Model.Road; | ||||||
|  | using TransportGame.Utils; | ||||||
|  |  | ||||||
| namespace TransportGame.Model | namespace TransportGame.Model | ||||||
| { | { | ||||||
| @@ -10,6 +12,15 @@ namespace TransportGame.Model | |||||||
|     public class Map |     public class Map | ||||||
|     { |     { | ||||||
|         private float[,] grid; |         private float[,] grid; | ||||||
|  |         private float[,] population; | ||||||
|  |  | ||||||
|  |         #region Properties | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the biome | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlElement("biome")] | ||||||
|  |         public Biome Biome { get; set; } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets or sets the water level |         /// Gets or sets the water level | ||||||
| @@ -17,17 +28,11 @@ namespace TransportGame.Model | |||||||
|         [XmlElement("waterLevel")] |         [XmlElement("waterLevel")] | ||||||
|         public float WaterLevel { get; set; } |         public float WaterLevel { get; set; } | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// Gets or sets the biome |  | ||||||
|         /// </summary> |  | ||||||
|         [XmlElement("biome")] |  | ||||||
|         public Biome Biome { get; set; } |  | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets the heights array in range [0,1] |         /// Gets the heights array in range [0,1] | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [XmlIgnore()] |         [XmlIgnore()] | ||||||
|         public float[,] Heights |         public float[,] Heightmap | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
| @@ -38,49 +43,85 @@ namespace TransportGame.Model | |||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets or sets the heights as raw bytes |         /// Gets or sets the heights as raw bytes | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <remarks> |         [XmlElement("heightmap")] | ||||||
|         /// Bytes are stored as such: |         public byte[] HeightmapRaw | ||||||
|         ///  |  | ||||||
|         ///     Offset  Size    Content |  | ||||||
|         ///     ------------------------ |  | ||||||
|         ///     0       4       Width |  | ||||||
|         ///     4       8       Height |  | ||||||
|         ///     8       var     32bit floating point values     |  | ||||||
|         ///      |  | ||||||
|         /// </remarks> |  | ||||||
|         [XmlElement("heights")] |  | ||||||
|         public byte[] HeightsRaw |  | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 List<byte> bytes = new List<byte>(); |                 return grid.ToByteArray(); | ||||||
|  |  | ||||||
|                 bytes.AddRange(BitConverter.GetBytes(Width)); |  | ||||||
|                 bytes.AddRange(BitConverter.GetBytes(Height)); |  | ||||||
|  |  | ||||||
|                 for (int x = 0; x < Width; x++) |  | ||||||
|                     for (int y = 0; y < Height; y++) |  | ||||||
|                         bytes.AddRange(BitConverter.GetBytes(grid[x, y])); |  | ||||||
|                  |  | ||||||
|                 return bytes.ToArray(); |  | ||||||
|             } |             } | ||||||
|             set |             set | ||||||
|             { |             { | ||||||
|                 int pos = 0; |                 grid = value.GetFloatMatrix(); | ||||||
|                 int w = BitConverter.ToInt32(value, pos); pos += sizeof(int); |  | ||||||
|                 int h = BitConverter.ToInt32(value, pos); pos += sizeof(int); |  | ||||||
|  |  | ||||||
|                 grid = new float[w, h]; |  | ||||||
|  |  | ||||||
|                 for (int x = 0; x < w; x++) |  | ||||||
|                     for (int y = 0; y < h; y++) |  | ||||||
|                     { |  | ||||||
|                         grid[x, y] = BitConverter.ToSingle(value, pos); |  | ||||||
|                         pos += sizeof(float); |  | ||||||
|                     } |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets width of heightmap | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public int Width { get { return (grid == null) ? 0 : grid.GetLength(0); } } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets height of heightmap | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public int Height { get { return (grid == null) ? 0 : grid.GetLength(1); } } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets the population map | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore()] | ||||||
|  |         public float[,] Population | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return population; | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 population = value; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the population as raw bytes | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlElement("population")] | ||||||
|  |         public byte[] PopulationRaw | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return population.ToByteArray(); | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 population = value.GetFloatMatrix(); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets width of population map | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public int PopulationWidth { get { return (population == null) ? 0 : population.GetLength(0); } } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets height of population map | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public int PopulationHeight { get { return (population == null) ? 0 : population.GetLength(1); } } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the articulation road network | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlElement("roadNetwork")] | ||||||
|  |         public RoadNetwork RoadNetwork { get; set; } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|  |         #region Constructors | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Initializes the map |         /// Initializes the map | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @@ -94,43 +135,36 @@ namespace TransportGame.Model | |||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Initializes the map |         /// Initializes the map | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="width"></param> |         /// <param name="width">Width</param> | ||||||
|         /// <param name="height"></param> |         /// <param name="height">Height</param> | ||||||
|         public Map(int width, int height) |         public Map(int width, int height) | ||||||
|         { |         { | ||||||
|             grid = new float[width, height]; |             grid = new float[width, height]; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets or sets the cell at specified position in range [0, Biome.Height] |         /// Gets the cell at specified position in range [0, Biome.Height] | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="x">X</param> |         /// <param name="x">X</param> | ||||||
|         /// <param name="y">Y</param> |         /// <param name="y">Y</param> | ||||||
|         /// <returns>Cell</returns> |         /// <returns>Value</returns> | ||||||
|         [XmlIgnore] |         public float GetHeight(int x, int y) | ||||||
|         public float this[int x, int y] |  | ||||||
|         { |         { | ||||||
|             get |             return grid[x, y] * Biome.Height; | ||||||
|             { |  | ||||||
|                 return grid[x, y] * Biome.Height; |  | ||||||
|             } |  | ||||||
|             set |  | ||||||
|             { |  | ||||||
|                 grid[x, y] = value / Biome.Height; |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets width of map |         /// Sets the height at specified position in range [0, Biome.Height] | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [XmlIgnore] |         /// <param name="x">X</param> | ||||||
|         public int Width { get { return grid.GetLength(0); } } |         /// <param name="y">Y</param> | ||||||
|  |         /// <param name="value">Value</param> | ||||||
|         /// <summary> |         public void SetHeight(int x, int y, float value) | ||||||
|         /// Gets height of map |         { | ||||||
|         /// </summary> |             grid[x, y] = value / Biome.Height; | ||||||
|         [XmlIgnore] |         } | ||||||
|         public int Height { get { return grid.GetLength(1); } } |  | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Returns true if specified cell is a water cell |         /// Returns true if specified cell is a water cell | ||||||
| @@ -140,7 +174,7 @@ namespace TransportGame.Model | |||||||
|         /// <returns></returns> |         /// <returns></returns> | ||||||
|         public bool IsWater(int x, int y) |         public bool IsWater(int x, int y) | ||||||
|         { |         { | ||||||
|             return this[x, y] <= WaterLevel; |             return GetHeight(x, y) <= WaterLevel; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								Game/Assets/Scripts/Model/Road.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Game/Assets/Scripts/Model/Road.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: dc46a301e57a8af41872e48f0b2cbd61 | ||||||
|  | folderAsset: yes | ||||||
|  | timeCreated: 1431600774 | ||||||
|  | licenseType: Free | ||||||
|  | DefaultImporter: | ||||||
|  |   userData:  | ||||||
|  |   assetBundleName:  | ||||||
|  |   assetBundleVariant:  | ||||||
							
								
								
									
										147
									
								
								Game/Assets/Scripts/Model/Road/RoadNetwork.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								Game/Assets/Scripts/Model/Road/RoadNetwork.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,147 @@ | |||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Xml.Serialization; | ||||||
|  |  | ||||||
|  | namespace TransportGame.Model.Road | ||||||
|  | { | ||||||
|  |     [XmlRoot("roadNetwork")] | ||||||
|  |     public class RoadNetwork | ||||||
|  |     { | ||||||
|  |         private int lastNodeId = -1, lastSegmentId = -1; | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the road nodes | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public Dictionary<int, RoadNode> Nodes { get; private set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the road segments for the articulation graph | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public Dictionary<int, RoadSegment> ArticulationSegments { get; private set; } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the road segments for the intersection graph | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public Dictionary<int, RoadSegment> IntersectionSegments { get; private set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the nodes | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlArray("nodes")] | ||||||
|  |         public RoadNode[] NodesArray | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return Nodes.Values.ToArray(); | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 Nodes.Clear(); | ||||||
|  |                 foreach (var node in value) | ||||||
|  |                     Nodes.Add(node.Id, node); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the segments | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlArray("articulationGraph")] | ||||||
|  |         public RoadSegment[] ArticulationSegmentsArray | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return ArticulationSegments.Values.ToArray(); | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 ArticulationSegments.Clear(); | ||||||
|  |                 foreach (var segment in value) | ||||||
|  |                     ArticulationSegments.Add(segment.Id, segment); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the segments | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlArray("intersectionGraph")] | ||||||
|  |         public RoadSegment[] IntersectionSegmentsArray | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return ArticulationSegments.Values.ToArray(); | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 ArticulationSegments.Clear(); | ||||||
|  |                 foreach (var segment in value) | ||||||
|  |                     ArticulationSegments.Add(segment.Id, segment); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |      | ||||||
|  |         /// <summary> | ||||||
|  |         /// Creates a node and returns it | ||||||
|  |         /// </summary> | ||||||
|  |         /// <returns>Created node</returns> | ||||||
|  |         public RoadNode CreateNode() | ||||||
|  |         { | ||||||
|  |             // Skip IDs that already exist | ||||||
|  |             while (Nodes.ContainsKey(++lastNodeId)) ; | ||||||
|  |  | ||||||
|  |             // Create node | ||||||
|  |             RoadNode node = new RoadNode() | ||||||
|  |             { | ||||||
|  |                 Id = lastNodeId, | ||||||
|  |                 ParentNetwork = this | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             Nodes.Add(node.Id, node); | ||||||
|  |             return node; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Creates a segment and returns it | ||||||
|  |         /// </summary> | ||||||
|  |         /// <returns>Created segment</returns> | ||||||
|  |         public RoadSegment CreateArticulationSegment() | ||||||
|  |         { | ||||||
|  |             // Skip IDs that already exist | ||||||
|  |             while (ArticulationSegments.ContainsKey(++lastSegmentId)) ; | ||||||
|  |  | ||||||
|  |             // Create segment | ||||||
|  |             RoadSegment segment = new RoadSegment() | ||||||
|  |             { | ||||||
|  |                 Id = lastSegmentId, | ||||||
|  |                 ParentNetwork = this | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             ArticulationSegments.Add(segment.Id, segment); | ||||||
|  |             return segment; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Creates a segment and returns it | ||||||
|  |         /// </summary> | ||||||
|  |         /// <returns>Created segment</returns> | ||||||
|  |         public RoadSegment CreateIntersectionSegment() | ||||||
|  |         { | ||||||
|  |             // Skip IDs that already exist | ||||||
|  |             while (IntersectionSegments.ContainsKey(++lastSegmentId)) ; | ||||||
|  |  | ||||||
|  |             // Create segment | ||||||
|  |             RoadSegment segment = new RoadSegment() | ||||||
|  |             { | ||||||
|  |                 Id = lastSegmentId, | ||||||
|  |                 ParentNetwork = this | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             IntersectionSegments.Add(segment.Id, segment); | ||||||
|  |             return segment; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -1,6 +1,6 @@ | |||||||
| fileFormatVersion: 2 | fileFormatVersion: 2 | ||||||
| guid: a4d12846fa3e22f4fbd829e42582d6a9 | guid: bc333e8a29fbb8242856e43239c57425 | ||||||
| timeCreated: 1425647029 | timeCreated: 1431612790 | ||||||
| licenseType: Free | licenseType: Free | ||||||
| MonoImporter: | MonoImporter: | ||||||
|   serializedVersion: 2 |   serializedVersion: 2 | ||||||
							
								
								
									
										86
									
								
								Game/Assets/Scripts/Model/Road/RoadNode.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								Game/Assets/Scripts/Model/Road/RoadNode.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,86 @@ | |||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Xml.Serialization; | ||||||
|  |  | ||||||
|  | namespace TransportGame.Model.Road | ||||||
|  | { | ||||||
|  |     /// <summary> | ||||||
|  |     /// Road node | ||||||
|  |     /// </summary> | ||||||
|  |     [XmlRoot("node")] | ||||||
|  |     public class RoadNode | ||||||
|  |     { | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets a unique identifier for this node | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlAttribute("id")] | ||||||
|  |         public int Id { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the X coordinate of the node | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlAttribute("x")] | ||||||
|  |         public float X { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the Y coordinate of the node | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlAttribute("y")] | ||||||
|  |         public float Y { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the adjacent articulation segment IDs | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlArray("articulationSegments")] | ||||||
|  |         [XmlArrayItem("id")] | ||||||
|  |         public List<int> ArticulationSegmentIds { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the adjacent articulation segment IDs | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlArray("intersectionSegments")] | ||||||
|  |         [XmlArrayItem("id")] | ||||||
|  |         public List<int> IntersectionSegmentIds { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the parent network | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public RoadNetwork ParentNetwork { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets the adjacent articulation segments | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public IEnumerable<RoadSegment> ArticulationSegments | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return ArticulationSegmentIds.Select(id => ParentNetwork.ArticulationSegments[id]); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets the adjacent setments | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public IEnumerable<RoadSegment> Segments | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return IntersectionSegmentIds.Select(id => ParentNetwork.ArticulationSegments[id]); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Initializes the node | ||||||
|  |         /// </summary> | ||||||
|  |         public RoadNode() | ||||||
|  |         { | ||||||
|  |             ArticulationSegmentIds = new List<int>(); | ||||||
|  |             IntersectionSegmentIds = new List<int>(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										12
									
								
								Game/Assets/Scripts/Model/Road/RoadNode.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								Game/Assets/Scripts/Model/Road/RoadNode.cs.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: 5be58fb83def956479e9e3af7e96a347 | ||||||
|  | timeCreated: 1431600782 | ||||||
|  | licenseType: Free | ||||||
|  | MonoImporter: | ||||||
|  |   serializedVersion: 2 | ||||||
|  |   defaultReferences: [] | ||||||
|  |   executionOrder: 0 | ||||||
|  |   icon: {instanceID: 0} | ||||||
|  |   userData:  | ||||||
|  |   assetBundleName:  | ||||||
|  |   assetBundleVariant:  | ||||||
							
								
								
									
										92
									
								
								Game/Assets/Scripts/Model/Road/RoadSegment.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								Game/Assets/Scripts/Model/Road/RoadSegment.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,92 @@ | |||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Xml.Serialization; | ||||||
|  |  | ||||||
|  | namespace TransportGame.Model.Road | ||||||
|  | { | ||||||
|  |     /// <summary> | ||||||
|  |     /// Represents a road segment | ||||||
|  |     /// </summary> | ||||||
|  |     [XmlRoot("segment")] | ||||||
|  |     public class RoadSegment | ||||||
|  |     { | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the id | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlAttribute("id")] | ||||||
|  |         public int Id { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the parent network | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public RoadNetwork ParentNetwork { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the id of the first terminal | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlAttribute("term1")] | ||||||
|  |         public int Terminal1Id { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the id of the second terminal | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlAttribute("term2")] | ||||||
|  |         public int Terminal2Id { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the first terminal | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public RoadNode Terminal1 | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return ParentNetwork.Nodes[Terminal1Id]; | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 Terminal1Id = value.Id; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the second terminal | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlIgnore] | ||||||
|  |         public RoadNode Terminal2 | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return ParentNetwork.Nodes[Terminal2Id]; | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 Terminal2Id = value.Id; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the number of lanes going from terminal 1 to terminal 2 | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlAttribute("lanesTo2")] | ||||||
|  |         public int LanesTo2 { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets or sets the number of lanes going form terminal 2 to terminal 1 | ||||||
|  |         /// </summary> | ||||||
|  |         [XmlAttribute("lanesTo1")] | ||||||
|  |         public int LanesTo1 { get; set; } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Initializes road segment | ||||||
|  |         /// </summary> | ||||||
|  |         public RoadSegment() | ||||||
|  |         { | ||||||
|  |             LanesTo1 = 1; | ||||||
|  |             LanesTo2 = 1; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										12
									
								
								Game/Assets/Scripts/Model/Road/RoadSegment.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								Game/Assets/Scripts/Model/Road/RoadSegment.cs.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: 51c5431eea527e34a8de870e7648758c | ||||||
|  | timeCreated: 1431600775 | ||||||
|  | licenseType: Free | ||||||
|  | MonoImporter: | ||||||
|  |   serializedVersion: 2 | ||||||
|  |   defaultReferences: [] | ||||||
|  |   executionOrder: 0 | ||||||
|  |   icon: {instanceID: 0} | ||||||
|  |   userData:  | ||||||
|  |   assetBundleName:  | ||||||
|  |   assetBundleVariant:  | ||||||
| @@ -26,7 +26,7 @@ public class TerrainGeneratorScript : MonoBehaviour | |||||||
| 		TerrainGenerator generator = new TerrainGenerator(); | 		TerrainGenerator generator = new TerrainGenerator(); | ||||||
| 		map = generator.Generate(TerrainWidth, TerrainHeight); | 		map = generator.Generate(TerrainWidth, TerrainHeight); | ||||||
| 	} | 	} | ||||||
|  |      | ||||||
| 	private Mesh GenerateWater() | 	private Mesh GenerateWater() | ||||||
| 	{ | 	{ | ||||||
| 		Mesh water = new Mesh(); | 		Mesh water = new Mesh(); | ||||||
| @@ -51,7 +51,7 @@ public class TerrainGeneratorScript : MonoBehaviour | |||||||
|  |  | ||||||
| 	private IEnumerator GenerateMap() | 	private IEnumerator GenerateMap() | ||||||
| 	{ | 	{ | ||||||
| 		// Wait for the map generation thread | 		// Generate terrain | ||||||
| 		foreach (var i in Task.RunAsync(GenerateTerrainThread)) | 		foreach (var i in Task.RunAsync(GenerateTerrainThread)) | ||||||
| 			yield return i; | 			yield return i; | ||||||
|  |  | ||||||
| @@ -60,7 +60,7 @@ public class TerrainGeneratorScript : MonoBehaviour | |||||||
| 		terrainData.heightmapResolution = Mathf.Max(map.Height, map.Width) + 1; | 		terrainData.heightmapResolution = Mathf.Max(map.Height, map.Width) + 1; | ||||||
| 		terrainData.size = new Vector3(map.Width, map.Biome.Height, map.Height); | 		terrainData.size = new Vector3(map.Width, map.Biome.Height, map.Height); | ||||||
| 		terrainData.SetDetailResolution(1024, 8); | 		terrainData.SetDetailResolution(1024, 8); | ||||||
| 		terrainData.SetHeights(0, 0, map.Heights); | 		terrainData.SetHeights(0, 0, map.Heightmap); | ||||||
| 		terrainData.name = "Generated Terrain Data"; | 		terrainData.name = "Generated Terrain Data"; | ||||||
|         yield return null; |         yield return null; | ||||||
|          |          | ||||||
| @@ -120,21 +120,20 @@ public class TerrainGeneratorScript : MonoBehaviour | |||||||
|                 int iy = Mathf.RoundToInt(y_01 * TerrainHeight); |                 int iy = Mathf.RoundToInt(y_01 * TerrainHeight); | ||||||
|  |  | ||||||
|                 // Get height |                 // Get height | ||||||
|                 float height = map.Heights[ix, iy] * terrainData.size.y; |                 float height = map.GetHeight(ix, iy); | ||||||
|                  |                  | ||||||
|                 // Get steepness |                 // Get steepness | ||||||
|                 int safex = (ix == 0) ? 1 : ix; |                 int safex = (ix == 0) ? 1 : ix; | ||||||
|                 int safey = (iy == 0) ? 1 : iy; |                 int safey = (iy == 0) ? 1 : iy; | ||||||
|  |  | ||||||
|                 float dx = map.Heights[safex - 1, safey] * map.Biome.Height - height; |                 float dx = map.GetHeight(safex - 1, safey)  - height; | ||||||
|                 float dy = map.Heights[safex, safey - 1] * map.Biome.Height - height; |                 float dy = map.GetHeight(safex, safey - 1)  - height; | ||||||
|                 float steepness = dx * dx + dy * dy; |                 float steepness = dx * dx + dy * dy; | ||||||
|                  |                  | ||||||
|  |                 // Go through each texture layer | ||||||
|                 float[] weights = new float[terrainData.alphamapLayers]; |                 float[] weights = new float[terrainData.alphamapLayers]; | ||||||
|                 float sum = 0; |                 float sum = 0; | ||||||
|  |  | ||||||
|                 // Go through each texture layer |  | ||||||
|                 for (int t = 0; t < terrainData.alphamapLayers; t++) |                 for (int t = 0; t < terrainData.alphamapLayers; t++) | ||||||
|                 { |                 { | ||||||
|                     // Set up expression |                     // Set up expression | ||||||
|   | |||||||
							
								
								
									
										96
									
								
								Game/Assets/Scripts/Utils/SerializationHelper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								Game/Assets/Scripts/Utils/SerializationHelper.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | |||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.IO; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Xml.Serialization; | ||||||
|  |  | ||||||
|  | namespace TransportGame.Utils | ||||||
|  | { | ||||||
|  |     public static class SerializationHelper | ||||||
|  |     { | ||||||
|  |         /// <summary> | ||||||
|  |         /// Converts float matrix to byte array | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="matrix">Matrix to convert</param> | ||||||
|  |         /// <remarks> | ||||||
|  |         /// Bytes are stored as such: | ||||||
|  |         ///  | ||||||
|  |         ///     Offset  Size    Content | ||||||
|  |         ///     ------------------------ | ||||||
|  |         ///     0       4       Width | ||||||
|  |         ///     4       8       Height | ||||||
|  |         ///     8       var     32bit floating point values     | ||||||
|  |         ///      | ||||||
|  |         /// </remarks> | ||||||
|  |         /// <returns>Byte array</returns> | ||||||
|  |         public static byte[] ToByteArray(this float[,] matrix) | ||||||
|  |         { | ||||||
|  |             if (matrix == null) | ||||||
|  |                 return null; | ||||||
|  |  | ||||||
|  |             int w = matrix.GetLength(0); | ||||||
|  |             int h = matrix.GetLength(1); | ||||||
|  |  | ||||||
|  |             List<byte> bytes = new List<byte>(); | ||||||
|  |  | ||||||
|  |             bytes.AddRange(BitConverter.GetBytes(w)); | ||||||
|  |             bytes.AddRange(BitConverter.GetBytes(h)); | ||||||
|  |  | ||||||
|  |             for (int x = 0; x < w; x++) | ||||||
|  |                 for (int y = 0; y < h; y++) | ||||||
|  |                     bytes.AddRange(BitConverter.GetBytes(matrix[x, y])); | ||||||
|  |  | ||||||
|  |             return bytes.ToArray(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Converts byte array to float matrix | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="array">Byte array</param> | ||||||
|  |         /// /// <remarks> | ||||||
|  |         /// Bytes are expected to be stored as such: | ||||||
|  |         ///  | ||||||
|  |         ///     Offset  Size    Content | ||||||
|  |         ///     ------------------------ | ||||||
|  |         ///     0       4       Width | ||||||
|  |         ///     4       8       Height | ||||||
|  |         ///     8       var     32bit floating point values     | ||||||
|  |         ///      | ||||||
|  |         /// </remarks> | ||||||
|  |         /// <returns>Float matrix</returns> | ||||||
|  |         public static float[,] GetFloatMatrix(this byte[] array) | ||||||
|  |         { | ||||||
|  |             if (array == null) | ||||||
|  |                 return null; | ||||||
|  |  | ||||||
|  |             int pos = 0; | ||||||
|  |             int w = BitConverter.ToInt32(array, pos); pos += sizeof(int); | ||||||
|  |             int h = BitConverter.ToInt32(array, pos); pos += sizeof(int); | ||||||
|  |  | ||||||
|  |             float[,] grid = new float[w, h]; | ||||||
|  |  | ||||||
|  |             for (int x = 0; x < w; x++) | ||||||
|  |                 for (int y = 0; y < h; y++) | ||||||
|  |                 { | ||||||
|  |                     grid[x, y] = BitConverter.ToSingle(array, pos); | ||||||
|  |                     pos += sizeof(float); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |             return grid; | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|  |         /// Deserializes a file | ||||||
|  |         /// </summary> | ||||||
|  |         /// <typeparam name="T">Type to deserialize</typeparam> | ||||||
|  |         /// <param name="filename">File name</param> | ||||||
|  |         /// <returns>Deserialized object</returns> | ||||||
|  |         public static T Deserialize<T>(string filename) | ||||||
|  |         { | ||||||
|  |             XmlSerializer serializer = new XmlSerializer(typeof(T)); | ||||||
|  |             var stream = new StreamReader(filename); | ||||||
|  |             return (T)serializer.Deserialize(stream); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										12
									
								
								Game/Assets/Scripts/Utils/SerializationHelper.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								Game/Assets/Scripts/Utils/SerializationHelper.cs.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: 56d534d0f2e8f454698a8650dab0afb4 | ||||||
|  | timeCreated: 1431612790 | ||||||
|  | licenseType: Free | ||||||
|  | MonoImporter: | ||||||
|  |   serializedVersion: 2 | ||||||
|  |   defaultReferences: [] | ||||||
|  |   executionOrder: 0 | ||||||
|  |   icon: {instanceID: 0} | ||||||
|  |   userData:  | ||||||
|  |   assetBundleName:  | ||||||
|  |   assetBundleVariant:  | ||||||
| @@ -1,25 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.IO; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Xml.Serialization; |  | ||||||
|  |  | ||||||
| namespace TransportGame.Utils |  | ||||||
| { |  | ||||||
|     public static class XmlHelper |  | ||||||
|     { |  | ||||||
|         /// <summary> |  | ||||||
|         /// Deserializes a file |  | ||||||
|         /// </summary> |  | ||||||
|         /// <typeparam name="T">Type to deserialize</typeparam> |  | ||||||
|         /// <param name="filename">File name</param> |  | ||||||
|         /// <returns>Deserialized object</returns> |  | ||||||
|         public static T Deserialize<T>(string filename) |  | ||||||
|         { |  | ||||||
|             XmlSerializer serializer = new XmlSerializer(typeof(T)); |  | ||||||
|             var stream = new StreamReader(filename); |  | ||||||
|             return (T)serializer.Deserialize(stream); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -23,7 +23,7 @@ Global | |||||||
| 	GlobalSection(SolutionProperties) = preSolution | 	GlobalSection(SolutionProperties) = preSolution | ||||||
| 		HideSolutionNode = FALSE | 		HideSolutionNode = FALSE | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 																																																																																						GlobalSection(MonoDevelopProperties) = preSolution | 																																																																																												GlobalSection(MonoDevelopProperties) = preSolution | ||||||
| 		StartupItem = Assembly-CSharp.csproj | 		StartupItem = Assembly-CSharp.csproj | ||||||
| 		Policies = $0 | 		Policies = $0 | ||||||
| 		$0.TextStylePolicy = $1 | 		$0.TextStylePolicy = $1 | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ Global | |||||||
| 	GlobalSection(SolutionProperties) = preSolution | 	GlobalSection(SolutionProperties) = preSolution | ||||||
| 		HideSolutionNode = FALSE | 		HideSolutionNode = FALSE | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 																																																																																					GlobalSection(MonoDevelopProperties) = preSolution | 																																																																																											GlobalSection(MonoDevelopProperties) = preSolution | ||||||
| 		StartupItem = Assembly-CSharp.csproj | 		StartupItem = Assembly-CSharp.csproj | ||||||
| 		Policies = $0 | 		Policies = $0 | ||||||
| 		$0.TextStylePolicy = $1 | 		$0.TextStylePolicy = $1 | ||||||
|   | |||||||
| @@ -7,14 +7,16 @@ | |||||||
|     <SchemaVersion>2.0</SchemaVersion> |     <SchemaVersion>2.0</SchemaVersion> | ||||||
|     <ProjectGuid>{02576F1D-BE9C-CFA7-763D-1EBF63B36977}</ProjectGuid> |     <ProjectGuid>{02576F1D-BE9C-CFA7-763D-1EBF63B36977}</ProjectGuid> | ||||||
|     <OutputType>Library</OutputType> |     <OutputType>Library</OutputType> | ||||||
|     <RootNamespace></RootNamespace> |     <RootNamespace> | ||||||
|  |     </RootNamespace> | ||||||
|     <AssemblyName>Assembly-CSharp</AssemblyName> |     <AssemblyName>Assembly-CSharp</AssemblyName> | ||||||
|     <FileAlignment>512</FileAlignment> |     <FileAlignment>512</FileAlignment> | ||||||
|     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||||||
|     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier> |     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier> | ||||||
|     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||||||
|     <TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile> |     <TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile> | ||||||
|     <CompilerResponseFile></CompilerResponseFile> |     <CompilerResponseFile> | ||||||
|  |     </CompilerResponseFile> | ||||||
|     <UnityProjectType>Game:1</UnityProjectType> |     <UnityProjectType>Game:1</UnityProjectType> | ||||||
|     <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget> |     <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget> | ||||||
|     <UnityVersion>5.0.1f1</UnityVersion> |     <UnityVersion>5.0.1f1</UnityVersion> | ||||||
| @@ -75,6 +77,9 @@ | |||||||
|     <Compile Include="Assets\Scripts\Model\Biome.cs" /> |     <Compile Include="Assets\Scripts\Model\Biome.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" /> |     <Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Model\Map.cs" /> |     <Compile Include="Assets\Scripts\Model\Map.cs" /> | ||||||
|  |     <Compile Include="Assets\Scripts\Model\Road\RoadNetwork.cs" /> | ||||||
|  |     <Compile Include="Assets\Scripts\Model\Road\RoadNode.cs" /> | ||||||
|  |     <Compile Include="Assets\Scripts\Model\Road\RoadSegment.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Model\Texture.cs" /> |     <Compile Include="Assets\Scripts\Model\Texture.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" /> |     <Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" /> |     <Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" /> | ||||||
| @@ -87,9 +92,9 @@ | |||||||
|     <Compile Include="Assets\Scripts\Utils\Logger.cs" /> |     <Compile Include="Assets\Scripts\Utils\Logger.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" /> |     <Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Utils\Range.cs" /> |     <Compile Include="Assets\Scripts\Utils\Range.cs" /> | ||||||
|  |     <Compile Include="Assets\Scripts\Utils\SerializationHelper.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Utils\Task.cs" /> |     <Compile Include="Assets\Scripts\Utils\Task.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" /> |     <Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" /> | ||||||
|     <Compile Include="Assets\Scripts\Utils\XmlHelper.cs" /> |  | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <None Include="Assets\Data\Biomes\Grassland.xml" /> |     <None Include="Assets\Data\Biomes\Grassland.xml" /> | ||||||
| @@ -98,4 +103,4 @@ | |||||||
|     <None Include="Assets\Standard Assets\Environment\Water (Basic)\Shaders\FXWaterBasic.shader" /> |     <None Include="Assets\Standard Assets\Environment\Water (Basic)\Shaders\FXWaterBasic.shader" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <Import Project="$(MSBuildExtensionsPath)\SyntaxTree\UnityVS\2013\UnityVS.CSharp.targets" /> |   <Import Project="$(MSBuildExtensionsPath)\SyntaxTree\UnityVS\2013\UnityVS.CSharp.targets" /> | ||||||
| </Project> | </Project> | ||||||
| @@ -1,8 +1,12 @@ | |||||||
|  |  | ||||||
| Microsoft Visual Studio Solution File, Format Version 12.00 | Microsoft Visual Studio Solution File, Format Version 12.00 | ||||||
| # Visual Studio 2012 | # Visual Studio 2013 | ||||||
|  | VisualStudioVersion = 12.0.31101.0 | ||||||
|  | MinimumVisualStudioVersion = 10.0.40219.1 | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapViewer", "MapViewer\MapViewer.csproj", "{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapViewer", "MapViewer\MapViewer.csproj", "{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}" | ||||||
| EndProject | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityVS.Game.CSharp", "..\..\Game\UnityVS.Game.CSharp.csproj", "{02576F1D-BE9C-CFA7-763D-1EBF63B36977}" | ||||||
|  | EndProject | ||||||
| Global | Global | ||||||
| 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||||
| 		Debug|Any CPU = Debug|Any CPU | 		Debug|Any CPU = Debug|Any CPU | ||||||
| @@ -13,6 +17,10 @@ Global | |||||||
| 		{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Debug|Any CPU.Build.0 = Debug|Any CPU | 		{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
| 		{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Release|Any CPU.ActiveCfg = Release|Any CPU | 		{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
| 		{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Release|Any CPU.Build.0 = Release|Any CPU | 		{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{02576F1D-BE9C-CFA7-763D-1EBF63B36977}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{02576F1D-BE9C-CFA7-763D-1EBF63B36977}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{02576F1D-BE9C-CFA7-763D-1EBF63B36977}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{02576F1D-BE9C-CFA7-763D-1EBF63B36977}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 	GlobalSection(SolutionProperties) = preSolution | 	GlobalSection(SolutionProperties) = preSolution | ||||||
| 		HideSolutionNode = FALSE | 		HideSolutionNode = FALSE | ||||||
|   | |||||||
| @@ -79,7 +79,7 @@ namespace TransportGame.MapViewer | |||||||
|                     // Draw elevation |                     // Draw elevation | ||||||
|                     else if (elevation) |                     else if (elevation) | ||||||
|                     { |                     { | ||||||
|                         float alpha = map.Heights[mapX, mapY]; // map.Heights range is [0,1] |                         float alpha = map.Heightmap[mapX, mapY]; // map.Heights range is [0,1] | ||||||
|                         bitmap[x, y] = Color.Multiply(ElevationTerrainColor, alpha); |                         bitmap[x, y] = Color.Multiply(ElevationTerrainColor, alpha); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -53,12 +53,6 @@ | |||||||
|       <Generator>MSBuild:Compile</Generator> |       <Generator>MSBuild:Compile</Generator> | ||||||
|       <SubType>Designer</SubType> |       <SubType>Designer</SubType> | ||||||
|     </ApplicationDefinition> |     </ApplicationDefinition> | ||||||
|     <Compile Include="..\..\..\Game\Assets\Scripts\Model\Biome.cs"> |  | ||||||
|       <Link>Model\Biome.cs</Link> |  | ||||||
|     </Compile> |  | ||||||
|     <Compile Include="..\..\..\Game\Assets\Scripts\Model\Map.cs"> |  | ||||||
|       <Link>Model\Map.cs</Link> |  | ||||||
|     </Compile> |  | ||||||
|     <Compile Include="Business\BitmapExtensions.cs" /> |     <Compile Include="Business\BitmapExtensions.cs" /> | ||||||
|     <Compile Include="Model\Bitmap24.cs" /> |     <Compile Include="Model\Bitmap24.cs" /> | ||||||
|     <Compile Include="Storage\MapStorage.cs" /> |     <Compile Include="Storage\MapStorage.cs" /> | ||||||
| @@ -66,9 +60,6 @@ | |||||||
|       <Generator>MSBuild:Compile</Generator> |       <Generator>MSBuild:Compile</Generator> | ||||||
|       <SubType>Designer</SubType> |       <SubType>Designer</SubType> | ||||||
|     </Page> |     </Page> | ||||||
|     <Compile Include="..\..\..\Game\Assets\Scripts\Utils\Range.cs"> |  | ||||||
|       <Link>Utils\Range.cs</Link> |  | ||||||
|     </Compile> |  | ||||||
|     <Compile Include="App.xaml.cs"> |     <Compile Include="App.xaml.cs"> | ||||||
|       <DependentUpon>App.xaml</DependentUpon> |       <DependentUpon>App.xaml</DependentUpon> | ||||||
|       <SubType>Code</SubType> |       <SubType>Code</SubType> | ||||||
| @@ -116,6 +107,15 @@ | |||||||
|     <Resource Include="Resources\zoom_in.png" /> |     <Resource Include="Resources\zoom_in.png" /> | ||||||
|     <Resource Include="Resources\zoom_out.png" /> |     <Resource Include="Resources\zoom_out.png" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <ProjectReference Include="..\..\..\Game\UnityVS.Game.CSharp.csproj"> | ||||||
|  |       <Project>{02576f1d-be9c-cfa7-763d-1ebf63b36977}</Project> | ||||||
|  |       <Name>UnityVS.Game.CSharp</Name> | ||||||
|  |     </ProjectReference> | ||||||
|  |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <Folder Include="Utils\" /> | ||||||
|  |   </ItemGroup> | ||||||
|   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||||
|   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.  |   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.  | ||||||
|        Other similar extension points exist, see Microsoft.Common.targets. |        Other similar extension points exist, see Microsoft.Common.targets. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user