Various improvements

This commit is contained in:
Tiberiu Chibici 2015-06-10 14:43:57 +03:00
parent 3ab95e13fe
commit 52548b09e1
20 changed files with 45 additions and 55 deletions

View File

@ -91,9 +91,6 @@
<None Include="Assets\Standard Assets\Environment\Water (Basic)\Shaders\FXWaterBasic.shader" /> <None Include="Assets\Standard Assets\Environment\Water (Basic)\Shaders\FXWaterBasic.shader" />
<None Include="Assets\Data\Biomes\Grassland.xml" /> <None Include="Assets\Data\Biomes\Grassland.xml" />
<None Include="Assets\Data\Biomes\Mountain.xml" /> <None Include="Assets\Data\Biomes\Mountain.xml" />
<Reference Include="Assembly-UnityScript-firstpass">
<HintPath>C:/Users/Tibi/Google Drive/FacultateCY/$ Licenta/Game/Library/ScriptAssemblies/Assembly-UnityScript-firstpass.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI"> <Reference Include="UnityEngine.UI">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
</Reference> </Reference>
@ -101,10 +98,6 @@
<HintPath>C:/Program Files/Unity/Editor/Data/PlaybackEngines/iossupport/UnityEditor.iOS.Extensions.Xcode.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/PlaybackEngines/iossupport/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="Assembly-CSharp-firstpass-vs.csproj">
<Project>{D8888F6A-ABE1-C49B-1A38-F65A81021668}</Project> <Name>Assembly-CSharp-firstpass-vs</Name> </ProjectReference>
</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.

View File

@ -98,12 +98,6 @@
<HintPath>C:/Program Files/Unity/Editor/Data/PlaybackEngines/iossupport/UnityEditor.iOS.Extensions.Xcode.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/PlaybackEngines/iossupport/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="Assembly-CSharp-firstpass.csproj">
<Project>{D8888F6A-ABE1-C49B-1A38-F65A81021668}</Project> <Name>Assembly-CSharp-firstpass</Name> </ProjectReference>
<ProjectReference Include="Assembly-UnityScript-firstpass.unityproj">
<Project>{6F824ECF-F2BC-827E-A29D-FB10759A3283}</Project> <Name>Assembly-UnityScript-firstpass</Name> </ProjectReference>
</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.

View File

@ -15,9 +15,9 @@
<MaximumRandomStraightAngle>45</MaximumRandomStraightAngle> <MaximumRandomStraightAngle>45</MaximumRandomStraightAngle>
<MaximumBranchAngleVariation>12</MaximumBranchAngleVariation> <MaximumBranchAngleVariation>12</MaximumBranchAngleVariation>
<MaximumIntersectingRoads>5</MaximumIntersectingRoads> <MaximumIntersectingRoads>5</MaximumIntersectingRoads>
<SidewalkWidth>0.8</SidewalkWidth> <SidewalkWidth>1</SidewalkWidth>
<LaneWidth>1</LaneWidth> <LaneWidth>1.3</LaneWidth>
<RaiseOffset>0.8</RaiseOffset> <RaiseOffset>0.8</RaiseOffset>
<SidewalkHeight>0.1</SidewalkHeight> <SidewalkHeight>0.1</SidewalkHeight>
<SideCoverHeight>0.1</SideCoverHeight> <SideCoverHeight>0.4</SideCoverHeight>
</RoadGeneratorConfig> </RoadGeneratorConfig>

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 8b97fa810c6224244a5ec1c8d5b27493 guid: 8b97fa810c6224244a5ec1c8d5b27493
timeCreated: 1433342482 timeCreated: 1433931275
licenseType: Free licenseType: Free
TextScriptImporter: TextScriptImporter:
userData: userData:

View File

@ -144,10 +144,10 @@ namespace TransportGame.Generator
Polygon GeneratePrimitivePolygon(BuildingLot lot) Polygon GeneratePrimitivePolygon(BuildingLot lot)
{ {
int sides = random.Next(3, 8); // Number of sides int sides = random.Next(3, 6); // Number of sides
float angle = 2 * (float)Math.PI / sides; // Angle between sides float angle = 2 * (float)Math.PI / sides; // Angle between sides
float radius = random.NextSingle(lot.Size * 0.25f, lot.Size * 0.75f) / 2; // Length of a side float radius = random.NextSingle(lot.Size * 0.15f, lot.Size * 0.4f); // Length of a side
Vector2 current = lot.Position + new Vector2(random.NextSingle(-lot.Size / 4, lot.Size / 4), random.NextSingle(-lot.Size / 4, lot.Size / 4)); Vector2 current = lot.Position + new Vector2(random.NextSingle(-lot.Size / 4, lot.Size / 4), random.NextSingle(-lot.Size / 4, lot.Size / 4));
Vector2 dir = new Vector2(random.NextSingle(), random.NextSingle()).Normalized * radius; Vector2 dir = new Vector2(random.NextSingle(), random.NextSingle()).Normalized * radius;
@ -185,7 +185,7 @@ namespace TransportGame.Generator
} }
else else
{ {
b.LevelHeights[i] = random.NextSingle(0, ConfigManager.Buildgen.MaxBuildingHeight); b.LevelHeights[i] = random.NextSingle(ConfigManager.Buildgen.MinBuildingHeight, ConfigManager.Buildgen.MaxBuildingHeight);
} }
for (int j = 0; j < random.Next(ConfigManager.Buildgen.MaxPolygonsPerLevel); j++) for (int j = 0; j < random.Next(ConfigManager.Buildgen.MaxPolygonsPerLevel); j++)

View File

@ -36,6 +36,7 @@ namespace TransportGame.Model.Config
/// Maximum height for a building /// Maximum height for a building
/// </summary> /// </summary>
public float MaxBuildingHeight { get; set; } public float MaxBuildingHeight { get; set; }
public float MinBuildingHeight { get; set; }
/// <summary> /// <summary>
/// Maximum number of primitive polygons to be generated per level /// Maximum number of primitive polygons to be generated per level
@ -49,8 +50,9 @@ namespace TransportGame.Model.Config
LotSpacing = 0.1f; LotSpacing = 0.1f;
MaxLotAttempts = 3; MaxLotAttempts = 3;
MaxBuildingHeight = 20f; MaxBuildingHeight = 20f;
MaxBuildingLevels = 5; MinBuildingHeight = 4f;
MaxPolygonsPerLevel = 3; MaxBuildingLevels = 7;
MaxPolygonsPerLevel = 4;
} }
} }
} }

View File

@ -73,11 +73,11 @@ namespace TransportGame.Model.Config
HighwayBranchDelay = 3; HighwayBranchDelay = 3;
MaximumIntersectingRoads = 5; MaximumIntersectingRoads = 5;
SidewalkWidth = .8f; SidewalkWidth = 1f;
LaneWidth = 1f; LaneWidth = 1.3f;
RaiseOffset = 0.8f; RaiseOffset = 0.8f;
SidewalkHeight = 0.1f; SidewalkHeight = 0.1f;
SideCoverHeight = 0.1f; SideCoverHeight = 0.4f;
} }
} }
} }

View File

@ -132,35 +132,16 @@ public class TerrainGeneratorScript : MonoBehaviour
} }
} }
// Generate road & building mesh (we run the loops in parallel) // Generate road & building mesh (we run the loops in parallel), and apply textures
Logger.Info("Generating buildings and roads..."); Logger.Info("Generating buildings and roads...");
BuildingMeshGenerator buildingMeshGenerator = new BuildingMeshGenerator(); BuildingMeshGenerator buildingMeshGenerator = new BuildingMeshGenerator();
buildingMeshGenerator.BuildingMaterial = BuildingMaterial; buildingMeshGenerator.BuildingMaterial = BuildingMaterial;
var it1 = buildingMeshGenerator.Generate(map).GetEnumerator();
RoadMeshGenerator roadMeshGenerator = new RoadMeshGenerator(); RoadMeshGenerator roadMeshGenerator = new RoadMeshGenerator();
roadMeshGenerator.RoadMaterial = RoadMaterial; roadMeshGenerator.RoadMaterial = RoadMaterial;
var it2 = roadMeshGenerator.Generate(map).GetEnumerator();
bool stop; foreach (var i in Task.InParallel(buildingMeshGenerator.Generate(map), roadMeshGenerator.Generate(map), EndSetupSplatmaps(terrainData)))
do
{
stop = true;
if (it1.MoveNext())
{
yield return it1.Current;
stop = false;
}
if (it2.MoveNext())
{
yield return it2.Current;
stop = false;
}
} while (!stop);
// Finish setting up textures
foreach (var i in EndSetupSplatmaps(terrainData))
yield return i; yield return i;
} }

View File

@ -66,5 +66,26 @@ namespace TransportGame.Utils
if (Success.HasValue && !Success.Value) if (Success.HasValue && !Success.Value)
throw new Exception("Task failed", thrownException); throw new Exception("Task failed", thrownException);
} }
public static IEnumerable InParallel(params IEnumerable[] funcs)
{
// Obtain iterators
var iterators = funcs.Select(enumerable => enumerable.GetEnumerator()).ToArray();
// Execute a slice of each
bool stop;
do
{
stop = true;
foreach (var it in iterators)
if (it.MoveNext())
{
yield return it.Current;
stop = false;
}
} while (!stop);
}
} }
} }

View File

@ -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

View File

@ -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

View File

@ -16,7 +16,7 @@ Platform assembly: C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Transpo
Loading C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\TransportGame_Data\Managed\Assembly-UnityScript-firstpass.dll into Unity Child Domain Loading C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\TransportGame_Data\Managed\Assembly-UnityScript-firstpass.dll into Unity Child Domain
Platform assembly: C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\TransportGame_Data\Managed\UnityEngine.UI.dll (this message is harmless) Platform assembly: C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\TransportGame_Data\Managed\UnityEngine.UI.dll (this message is harmless)
Loading C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\TransportGame_Data\Managed\UnityEngine.UI.dll into Unity Child Domain Loading C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\TransportGame_Data\Managed\UnityEngine.UI.dll into Unity Child Domain
- Completed reload, in 0.045 seconds - Completed reload, in 0.050 seconds
desktop: 1920x1080 60Hz; virtual: 1920x1080 at 0,0 desktop: 1920x1080 60Hz; virtual: 1920x1080 at 0,0
<RI> Initializing input. <RI> Initializing input.
<RI> Input initialized. <RI> Input initialized.
@ -90,7 +90,8 @@ UnityEngine.Debug:Log(Object)
TransportGame.Utils.Logger:Log(Level, String, Object[]) (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Utils\Logger.cs:66) TransportGame.Utils.Logger:Log(Level, String, Object[]) (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Utils\Logger.cs:66)
TransportGame.Utils.Logger:Info(String, Object[]) (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Utils\Logger.cs:74) TransportGame.Utils.Logger:Info(String, Object[]) (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Utils\Logger.cs:74)
TransportGame.Unity.<Generate>c__Iterator2:MoveNext() (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Unity\RoadMeshGenerator.cs:95) TransportGame.Unity.<Generate>c__Iterator2:MoveNext() (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Unity\RoadMeshGenerator.cs:95)
<GenerateMap>c__Iterator3:MoveNext() (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Unity\TerrainGeneratorScript.cs:155) TransportGame.Utils.<InParallel>c__Iterator8:MoveNext() (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Utils\Task.cs:82)
<GenerateMap>c__Iterator3:MoveNext() (at C:\Users\Tibi\Google Drive\FacultateCY\$ Licenta\Game\Assets\Scripts\Unity\TerrainGeneratorScript.cs:144)
(Filename: C:/Users/Tibi/Google Drive/FacultateCY/$ Licenta/Game/Assets/Scripts/Utils/Logger.cs Line: 66) (Filename: C:/Users/Tibi/Google Drive/FacultateCY/$ Licenta/Game/Assets/Scripts/Utils/Logger.cs Line: 66)

View File

@ -7,16 +7,14 @@
<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>
@ -119,4 +117,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>