Skip to content

Commit 667e992

Browse files
committed
Fixed a couple lines, added media, readme
1 parent ed89e70 commit 667e992

18 files changed

Lines changed: 1763 additions & 13 deletions

Assets/Sample/Data/TileRoom1.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ MonoBehaviour:
1010
m_Enabled: 1
1111
m_EditorHideFlags: 0
1212
m_Script: {fileID: 11500000, guid: 5dfc0daf1cfa4628ab7d4d02f7d4b01d, type: 3}
13-
m_Name: TileRoom1
13+
m_Name: 'Tile: Tile Room 1'
1414
m_EditorClassIdentifier:
1515
referenceName: Tile Room 1
1616
selectionWeight: 1

Assets/Sample/Data/TileRoom2.asset

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: 5dfc0daf1cfa4628ab7d4d02f7d4b01d, type: 3}
13+
m_Name: TileRoom2
14+
m_EditorClassIdentifier:
15+
referenceName: TileRoom2
16+
selectionWeight: 1
17+
tileType: 3
18+
validConnectionTypes: 00000000010000000200000003000000
19+
tilePrefab: {fileID: 2395136204823937822, guid: 80d7eba128e3f7f49800c14873f2729f, type: 3}
20+
autoFindMesh: 1
21+
mesh: {fileID: 8577867832124546071, guid: e0e7659df4170f7428b8faa6f02c981a, type: 3}

Assets/Sample/Data/TileRoom2.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
11.6 KB
Binary file not shown.
0 Bytes
Binary file not shown.

Assets/Sample/Models/Tiles.fbx

2.69 KB
Binary file not shown.
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &5611913716464771452
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
serializedVersion: 6
10+
m_Component:
11+
- component: {fileID: 2179667317964346533}
12+
- component: {fileID: 6252434735407536742}
13+
m_Layer: 0
14+
m_Name: Connector (3)
15+
m_TagString: Untagged
16+
m_Icon: {fileID: 0}
17+
m_NavMeshLayer: 0
18+
m_StaticEditorFlags: 0
19+
m_IsActive: 1
20+
--- !u!4 &2179667317964346533
21+
Transform:
22+
m_ObjectHideFlags: 0
23+
m_CorrespondingSourceObject: {fileID: 0}
24+
m_PrefabInstance: {fileID: 0}
25+
m_PrefabAsset: {fileID: 0}
26+
m_GameObject: {fileID: 5611913716464771452}
27+
m_LocalRotation: {x: 0, y: -1, z: 0, w: 0}
28+
m_LocalPosition: {x: -2.3400087, y: -4.820526, z: 2.444107}
29+
m_LocalScale: {x: 1, y: 1, z: 1}
30+
m_ConstrainProportionsScale: 0
31+
m_Children: []
32+
m_Father: {fileID: 4996802630935972373}
33+
m_RootOrder: 0
34+
m_LocalEulerAnglesHint: {x: 0, y: -180, z: 0}
35+
--- !u!114 &6252434735407536742
36+
MonoBehaviour:
37+
m_ObjectHideFlags: 0
38+
m_CorrespondingSourceObject: {fileID: 0}
39+
m_PrefabInstance: {fileID: 0}
40+
m_PrefabAsset: {fileID: 0}
41+
m_GameObject: {fileID: 5611913716464771452}
42+
m_Enabled: 1
43+
m_EditorHideFlags: 0
44+
m_Script: {fileID: 11500000, guid: b1df24c64aa44e8ab543a41cd3151d67, type: 3}
45+
m_Name:
46+
m_EditorClassIdentifier:
47+
_size: {x: 8, y: 8}
48+
isConnected: 0
49+
connectedTile: {fileID: 0}
50+
connectedConnector: {fileID: 0}
51+
--- !u!1 &6840520116079981836
52+
GameObject:
53+
m_ObjectHideFlags: 0
54+
m_CorrespondingSourceObject: {fileID: 0}
55+
m_PrefabInstance: {fileID: 0}
56+
m_PrefabAsset: {fileID: 0}
57+
serializedVersion: 6
58+
m_Component:
59+
- component: {fileID: 2079094169976486728}
60+
- component: {fileID: 9010868892298864444}
61+
m_Layer: 0
62+
m_Name: Connector (4)
63+
m_TagString: Untagged
64+
m_Icon: {fileID: 0}
65+
m_NavMeshLayer: 0
66+
m_StaticEditorFlags: 0
67+
m_IsActive: 1
68+
--- !u!4 &2079094169976486728
69+
Transform:
70+
m_ObjectHideFlags: 0
71+
m_CorrespondingSourceObject: {fileID: 0}
72+
m_PrefabInstance: {fileID: 0}
73+
m_PrefabAsset: {fileID: 0}
74+
m_GameObject: {fileID: 6840520116079981836}
75+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
76+
m_LocalPosition: {x: -2.3400087, y: -4.820526, z: 21.444107}
77+
m_LocalScale: {x: 1, y: 1, z: 1}
78+
m_ConstrainProportionsScale: 0
79+
m_Children: []
80+
m_Father: {fileID: 4996802630935972373}
81+
m_RootOrder: 1
82+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
83+
--- !u!114 &9010868892298864444
84+
MonoBehaviour:
85+
m_ObjectHideFlags: 0
86+
m_CorrespondingSourceObject: {fileID: 0}
87+
m_PrefabInstance: {fileID: 0}
88+
m_PrefabAsset: {fileID: 0}
89+
m_GameObject: {fileID: 6840520116079981836}
90+
m_Enabled: 1
91+
m_EditorHideFlags: 0
92+
m_Script: {fileID: 11500000, guid: b1df24c64aa44e8ab543a41cd3151d67, type: 3}
93+
m_Name:
94+
m_EditorClassIdentifier:
95+
_size: {x: 8, y: 8}
96+
isConnected: 0
97+
connectedTile: {fileID: 0}
98+
connectedConnector: {fileID: 0}
99+
--- !u!1 &8083800034004268488
100+
GameObject:
101+
m_ObjectHideFlags: 0
102+
m_CorrespondingSourceObject: {fileID: 0}
103+
m_PrefabInstance: {fileID: 0}
104+
m_PrefabAsset: {fileID: 0}
105+
serializedVersion: 6
106+
m_Component:
107+
- component: {fileID: 4996802630935972373}
108+
m_Layer: 0
109+
m_Name: Connectors
110+
m_TagString: Untagged
111+
m_Icon: {fileID: 0}
112+
m_NavMeshLayer: 0
113+
m_StaticEditorFlags: 0
114+
m_IsActive: 1
115+
--- !u!4 &4996802630935972373
116+
Transform:
117+
m_ObjectHideFlags: 0
118+
m_CorrespondingSourceObject: {fileID: 0}
119+
m_PrefabInstance: {fileID: 0}
120+
m_PrefabAsset: {fileID: 0}
121+
m_GameObject: {fileID: 8083800034004268488}
122+
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
123+
m_LocalPosition: {x: 0.5850022, y: 1.2051315, z: -2.1110268}
124+
m_LocalScale: {x: 0.25, y: 0.25, z: 0.25}
125+
m_ConstrainProportionsScale: 0
126+
m_Children:
127+
- {fileID: 2179667317964346533}
128+
- {fileID: 2079094169976486728}
129+
m_Father: {fileID: 4720231337082515399}
130+
m_RootOrder: 0
131+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
132+
--- !u!1 &8933834729502825542
133+
GameObject:
134+
m_ObjectHideFlags: 0
135+
m_CorrespondingSourceObject: {fileID: 0}
136+
m_PrefabInstance: {fileID: 0}
137+
m_PrefabAsset: {fileID: 0}
138+
serializedVersion: 6
139+
m_Component:
140+
- component: {fileID: 4720231337082515399}
141+
- component: {fileID: 2644310469348416320}
142+
- component: {fileID: 6885036904353558549}
143+
- component: {fileID: 2395136204823937822}
144+
m_Layer: 6
145+
m_Name: Tile_Room_2
146+
m_TagString: Untagged
147+
m_Icon: {fileID: 0}
148+
m_NavMeshLayer: 0
149+
m_StaticEditorFlags: 0
150+
m_IsActive: 1
151+
--- !u!4 &4720231337082515399
152+
Transform:
153+
m_ObjectHideFlags: 0
154+
m_CorrespondingSourceObject: {fileID: 0}
155+
m_PrefabInstance: {fileID: 0}
156+
m_PrefabAsset: {fileID: 0}
157+
m_GameObject: {fileID: 8933834729502825542}
158+
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
159+
m_LocalPosition: {x: -0, y: 0, z: 0}
160+
m_LocalScale: {x: 4, y: 4, z: 4}
161+
m_ConstrainProportionsScale: 0
162+
m_Children:
163+
- {fileID: 4996802630935972373}
164+
m_Father: {fileID: 0}
165+
m_RootOrder: 0
166+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
167+
--- !u!33 &2644310469348416320
168+
MeshFilter:
169+
m_ObjectHideFlags: 0
170+
m_CorrespondingSourceObject: {fileID: 0}
171+
m_PrefabInstance: {fileID: 0}
172+
m_PrefabAsset: {fileID: 0}
173+
m_GameObject: {fileID: 8933834729502825542}
174+
m_Mesh: {fileID: 8577867832124546071, guid: e0e7659df4170f7428b8faa6f02c981a, type: 3}
175+
--- !u!23 &6885036904353558549
176+
MeshRenderer:
177+
m_ObjectHideFlags: 0
178+
m_CorrespondingSourceObject: {fileID: 0}
179+
m_PrefabInstance: {fileID: 0}
180+
m_PrefabAsset: {fileID: 0}
181+
m_GameObject: {fileID: 8933834729502825542}
182+
m_Enabled: 1
183+
m_CastShadows: 1
184+
m_ReceiveShadows: 1
185+
m_DynamicOccludee: 1
186+
m_StaticShadowCaster: 0
187+
m_MotionVectors: 1
188+
m_LightProbeUsage: 1
189+
m_ReflectionProbeUsage: 1
190+
m_RayTracingMode: 2
191+
m_RayTraceProcedural: 0
192+
m_RenderingLayerMask: 1
193+
m_RendererPriority: 0
194+
m_Materials:
195+
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
196+
m_StaticBatchInfo:
197+
firstSubMesh: 0
198+
subMeshCount: 0
199+
m_StaticBatchRoot: {fileID: 0}
200+
m_ProbeAnchor: {fileID: 0}
201+
m_LightProbeVolumeOverride: {fileID: 0}
202+
m_ScaleInLightmap: 1
203+
m_ReceiveGI: 1
204+
m_PreserveUVs: 0
205+
m_IgnoreNormalsForChartDetection: 0
206+
m_ImportantGI: 0
207+
m_StitchLightmapSeams: 1
208+
m_SelectedEditorRenderState: 3
209+
m_MinimumChartSize: 4
210+
m_AutoUVMaxDistance: 0.5
211+
m_AutoUVMaxAngle: 89
212+
m_LightmapParameters: {fileID: 0}
213+
m_SortingLayerID: 0
214+
m_SortingLayer: 0
215+
m_SortingOrder: 0
216+
m_AdditionalVertexStreams: {fileID: 0}
217+
--- !u!114 &2395136204823937822
218+
MonoBehaviour:
219+
m_ObjectHideFlags: 0
220+
m_CorrespondingSourceObject: {fileID: 0}
221+
m_PrefabInstance: {fileID: 0}
222+
m_PrefabAsset: {fileID: 0}
223+
m_GameObject: {fileID: 8933834729502825542}
224+
m_Enabled: 1
225+
m_EditorHideFlags: 0
226+
m_Script: {fileID: 11500000, guid: 65176aa815bc4fbf9af8724a3bc7af54, type: 3}
227+
m_Name:
228+
m_EditorClassIdentifier:
229+
tileData: {fileID: 11400000, guid: b68600d3f3bce884aab0a5da4878e376, type: 2}
230+
findRelevantObjectsAutomatically: 1
231+
connectors: []
232+
lights: []
233+
connectorContainer: {fileID: 0}
234+
tileLayerName: Tile

Assets/Sample/Prefabs/Tile_Room_2.prefab.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Sample/Scenes/SampleScene.unity

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ MonoBehaviour:
425425
- {fileID: 11400000, guid: 187ddaf5b10943c4086116adc98e5956, type: 2}
426426
- {fileID: 11400000, guid: fb8aaee9c2f0b344b811657636229de8, type: 2}
427427
- {fileID: 11400000, guid: 2a3e99b9160517f42a7a829d358c5a02, type: 2}
428+
- {fileID: 11400000, guid: b68600d3f3bce884aab0a5da4878e376, type: 2}
428429
_connectorBlockers:
429430
- connector: {fileID: 5794692968534909478, guid: c7a44a27b9f972f4eb39f474e392cec3, type: 3}
430431
localPositionOffset: {x: 0, y: 0, z: 0}
@@ -435,12 +436,12 @@ MonoBehaviour:
435436
_doorwayHavingDoorChance: 0.5
436437
_tileLayerName: Tile
437438
_doorLayerName: Door
438-
_useWeightedSelection: 0
439+
_useWeightedSelection: 1
439440
_mainPathTileCount: 20
440441
_maxNumberOfAttemptsPerTile: 100
441442
_maxFailureCount: 100
442443
_mainBranchEndingTileType: 1
443-
_branchingChance: 0.5
444+
_branchingChance: 1
444445
_virtualBranchingCap: 20
445446
_branchesMinTileCount: 5
446447
_branchesMaxTileCount: 10

Assets/Scripts/Level Generation/LevelBuilder.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void Awake()
4949
{
5050
if (_allTileData == null || _allTileData.Length == 0)
5151
{
52-
//Debug.logError("All tile data is empty");
52+
Debug.LogError("All tile data is empty");
5353
}
5454
_Branches = new List<TileBranch>();
5555

@@ -207,7 +207,6 @@ private void HandleBranching(TileScript rootTile, ConnectorScript source = null,
207207

208208
if (rootTile == null)
209209
{
210-
//Debug.logError("EVERYTHING IS TERRIBLE");
211210
return;
212211
}
213212

@@ -362,11 +361,10 @@ private void HandleAllBranchConnectors()
362361
{
363362
if (_connectorBlockers == null || _connectorBlockers.Length == 0)
364363
{
365-
//Debug.logWarning("No blocker prefabs are designated", this);
364+
Debug.LogWarning("No blocker prefabs are designated", this);
366365
return;
367366
}
368367

369-
int count = 0;
370368
foreach (var branch in _Branches)
371369
{
372370
foreach (var tile in branch.BranchTiles)
@@ -377,7 +375,6 @@ private void HandleAllBranchConnectors()
377375
//Has no connection, spawn a blocker
378376
if (!connector.isConnected)
379377
{
380-
count++;
381378
//Debug.log($"Non-connected Connector @{branch} -> @{tile} -> @{connector}", connector.gameObject);
382379

383380
SpawnBlockerForConnector(connector);
@@ -434,8 +431,7 @@ private TileScript SpawnRandomTileAndConnect(TileBranch branch, TileScript paren
434431
: GetTilesOfTypes(types, _allTileData);
435432

436433
var randomTile = _useWeightedSelection
437-
? RandomSelectTileData(
438-
randomPickTileSet)
434+
? RandomSelectTileData(randomPickTileSet)
439435
: PickRandomItemWeighted(randomPickTileSet);
440436

441437

@@ -489,21 +485,21 @@ private TileData WeightedRandomSelectTileData(TileData[] selectionSet)
489485
}
490486

491487
//Modified version of this: https://stackoverflow.com/a/60995361
492-
public static TileData PickRandomItemWeighted (TileData[] selectionSet)
488+
public static TileData PickRandomItemWeighted(TileData[] selectionSet)
493489
{
494490
int offset = 0;
495491
(TileData Item, int RangeTo)[] rangedItems = selectionSet.ToList()
496492
.OrderBy(item => item.selectionWeight)
497493
.Select(entry => (entry, RangeTo: offset += Mathf.FloorToInt(entry.selectionWeight * 100)))
498494
.ToArray();
499495

500-
int randomNumber = (int)Random.Range(0, selectionSet.Sum(item => item.selectionWeight)) + 1;
496+
int randomNumber = (int)Random.Range(0, selectionSet.Sum(item => item.selectionWeight));
501497
return rangedItems.First(item => randomNumber <= item.RangeTo).Item;
502498
}
503499

504500
private TileData RandomSelectTileData(TileData[] selectionSet)
505501
{
506-
return selectionSet[Random.Range(0, selectionSet.Length - 1)];
502+
return selectionSet[Random.Range(0, selectionSet.Length)];
507503
}
508504

509505
private TileData[] GetTilesOfType(TileType type, TileData[] selectionSet)

0 commit comments

Comments
 (0)