Lots of dungeon progress. Should have committed more, sorry.
This commit is contained in:
parent
8d66a06213
commit
ecbd32b6ad
@ -1,5 +1,60 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &985905253171367612
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 249722007521576760}
|
||||
- component: {fileID: 5053339003064248858}
|
||||
m_Layer: 0
|
||||
m_Name: Door U
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &249722007521576760
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 985905253171367612}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 1, w: 0}
|
||||
m_LocalPosition: {x: 0, y: 4.25, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2101345830686511700}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
|
||||
--- !u!114 &5053339003064248858
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 985905253171367612}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.up
|
||||
AllowedMatches:
|
||||
- Tag: test.down
|
||||
Weight: 1
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.diag
|
||||
Weight: 1
|
||||
--- !u!1 &1513129216089456175
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -25,11 +80,11 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1513129216089456175}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: -4, z: 0}
|
||||
m_LocalPosition: {x: 0, y: -4.25, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2101345830686511700}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2357044271177384697
|
||||
MonoBehaviour:
|
||||
@ -43,7 +98,18 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Tag: vertical
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.down
|
||||
AllowedMatches:
|
||||
- Tag: test.up
|
||||
Weight: 1
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.diag
|
||||
Weight: 1
|
||||
--- !u!1 &1912872275816598801
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -69,11 +135,11 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1912872275816598801}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068}
|
||||
m_LocalPosition: {x: 5, y: -0.0000011920928, z: 0}
|
||||
m_LocalPosition: {x: 5.25, y: -0.0000011622905, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2101345830686511700}
|
||||
m_RootOrder: 3
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90}
|
||||
--- !u!114 &1012738459284175318
|
||||
MonoBehaviour:
|
||||
@ -87,7 +153,18 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Tag: horizontal
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.right
|
||||
AllowedMatches:
|
||||
- Tag: test.left
|
||||
Weight: 1
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.diag
|
||||
Weight: 1
|
||||
--- !u!1 &2101345829801090270
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -113,11 +190,11 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2101345829801090270}
|
||||
m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068}
|
||||
m_LocalPosition: {x: -5, y: 0, z: 0}
|
||||
m_LocalPosition: {x: -5.25, y: 0.000000029802319, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2101345830686511700}
|
||||
m_RootOrder: 2
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90}
|
||||
--- !u!114 &2101345829801090271
|
||||
MonoBehaviour:
|
||||
@ -131,7 +208,18 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Tag: horizontal
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.left
|
||||
AllowedMatches:
|
||||
- Tag: test.right
|
||||
Weight: 1
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.diag
|
||||
Weight: 1
|
||||
--- !u!1 &2101345830686511723
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -143,7 +231,7 @@ GameObject:
|
||||
- component: {fileID: 2101345830686511700}
|
||||
- component: {fileID: 2101345830686511701}
|
||||
m_Layer: 0
|
||||
m_Name: debug.test1
|
||||
m_Name: Test Room 1
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -160,10 +248,11 @@ Transform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 7175683798590047672}
|
||||
- {fileID: 422348202299819723}
|
||||
- {fileID: 2101345829801090264}
|
||||
- {fileID: 646947909993633888}
|
||||
- {fileID: 249722007521576760}
|
||||
- {fileID: 7244937749187678482}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -179,16 +268,16 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 6268a80b1893dea4da88a977847d0df1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Identifier: debug.test1
|
||||
Bounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 5, y: 4, z: 0}
|
||||
- {fileID: 8002291388036001699}
|
||||
Doors:
|
||||
- {fileID: 5516082331950511926}
|
||||
- {fileID: 2357044271177384697}
|
||||
- {fileID: 2101345829801090271}
|
||||
- {fileID: 1012738459284175318}
|
||||
--- !u!1 &9158382049854172236
|
||||
- {fileID: 5053339003064248858}
|
||||
Weight: 1
|
||||
CanBeRotated: 1
|
||||
--- !u!1 &5483700677498732059
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -196,39 +285,52 @@ GameObject:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7175683798590047672}
|
||||
- component: {fileID: 5516082331950511926}
|
||||
m_Layer: 0
|
||||
m_Name: Door U
|
||||
m_TagString: Untagged
|
||||
- component: {fileID: 7244937749187678482}
|
||||
- component: {fileID: 8002291388036001699}
|
||||
m_Layer: 6
|
||||
m_Name: Bounds
|
||||
m_TagString: RoomBounds
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7175683798590047672
|
||||
--- !u!4 &7244937749187678482
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9158382049854172236}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 1, w: 0}
|
||||
m_LocalPosition: {x: 0, y: 4, z: 0}
|
||||
m_GameObject: {fileID: 5483700677498732059}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2101345830686511700}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
|
||||
--- !u!114 &5516082331950511926
|
||||
MonoBehaviour:
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!61 &8002291388036001699
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9158382049854172236}
|
||||
m_GameObject: {fileID: 5483700677498732059}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Tag: vertical
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 10, y: 8}
|
||||
m_EdgeRadius: 0
|
||||
289
Assets/Prefabs/Resources/Rooms/Test Room 2.prefab
Normal file
289
Assets/Prefabs/Resources/Rooms/Test Room 2.prefab
Normal file
@ -0,0 +1,289 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1227796095645965869
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6380430514337048435}
|
||||
- component: {fileID: 3513978694587444866}
|
||||
m_Layer: 0
|
||||
m_Name: Bounds 2
|
||||
m_TagString: RoomBounds
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6380430514337048435
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1227796095645965869}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7160743633298161740}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!61 &3513978694587444866
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1227796095645965869}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 6, y: 2}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!1 &1378710288968640192
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5618043188835114854}
|
||||
- component: {fileID: 5191196053080353493}
|
||||
m_Layer: 0
|
||||
m_Name: Bounds 1
|
||||
m_TagString: RoomBounds
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5618043188835114854
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1378710288968640192}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7160743633298161740}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!61 &5191196053080353493
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1378710288968640192}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 4, y: 12}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!1 &7160743633298161742
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7160743633298161740}
|
||||
- component: {fileID: 7160743633298161741}
|
||||
m_Layer: 0
|
||||
m_Name: Test Room 2
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7160743633298161740
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7160743633298161742}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 7160743634474190115}
|
||||
- {fileID: 7160743633937940494}
|
||||
- {fileID: 5618043188835114854}
|
||||
- {fileID: 6380430514337048435}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7160743633298161741
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7160743633298161742}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6268a80b1893dea4da88a977847d0df1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Bounds:
|
||||
- {fileID: 5191196053080353493}
|
||||
- {fileID: 3513978694587444866}
|
||||
Doors:
|
||||
- {fileID: 7160743634474190124}
|
||||
- {fileID: 7160743633937940495}
|
||||
Weight: 1
|
||||
CanBeRotated: 1
|
||||
--- !u!1 &7160743633937940488
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7160743633937940494}
|
||||
- component: {fileID: 7160743633937940495}
|
||||
m_Layer: 0
|
||||
m_Name: Door Bottom
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7160743633937940494
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7160743633937940488}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: -6.25, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7160743633298161740}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7160743633937940495
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7160743633937940488}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.hallway
|
||||
AllowedMatches:
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.left
|
||||
Weight: 1
|
||||
- Tag: test.right
|
||||
Weight: 1
|
||||
- Tag: test.down
|
||||
Weight: 1
|
||||
- Tag: test.up
|
||||
Weight: 1
|
||||
--- !u!1 &7160743634474190125
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7160743634474190115}
|
||||
- component: {fileID: 7160743634474190124}
|
||||
m_Layer: 0
|
||||
m_Name: Door Top
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7160743634474190115
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7160743634474190125}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 1, w: 0}
|
||||
m_LocalPosition: {x: 0, y: 6.25, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7160743633298161740}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
|
||||
--- !u!114 &7160743634474190124
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7160743634474190125}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.hallway
|
||||
AllowedMatches:
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.left
|
||||
Weight: 1
|
||||
- Tag: test.right
|
||||
Weight: 1
|
||||
- Tag: test.down
|
||||
Weight: 1
|
||||
- Tag: test.up
|
||||
Weight: 1
|
||||
@ -1,7 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a850575e29641144b8292c0da8ddc94
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
guid: 750413450c87d444fae4af9fd9fe2454
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
298
Assets/Prefabs/Resources/Rooms/Test Room 3.prefab
Normal file
298
Assets/Prefabs/Resources/Rooms/Test Room 3.prefab
Normal file
@ -0,0 +1,298 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1163451353649500288
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7133256318772232080}
|
||||
- component: {fileID: 3990766584289748652}
|
||||
m_Layer: 0
|
||||
m_Name: Door 2b
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7133256318772232080
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1163451353649500288}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.75, y: -2.25, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6685813788407296846}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &3990766584289748652
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1163451353649500288}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.diag
|
||||
AllowedMatches:
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.diag
|
||||
Weight: 100
|
||||
- Tag: test.left
|
||||
Weight: 1
|
||||
- Tag: test.right
|
||||
Weight: 1
|
||||
- Tag: test.up
|
||||
Weight: 1
|
||||
- Tag: test.down
|
||||
Weight: 1
|
||||
--- !u!1 &2249552984264278997
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5436232046164896168}
|
||||
- component: {fileID: 7646758486997557462}
|
||||
m_Layer: 0
|
||||
m_Name: Bounds
|
||||
m_TagString: RoomBounds
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5436232046164896168
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2249552984264278997}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6685813788407296846}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!61 &7646758486997557462
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2249552984264278997}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 4, y: 4}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!1 &6685813788407296844
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6685813788407296846}
|
||||
- component: {fileID: 6685813788407296847}
|
||||
m_Layer: 0
|
||||
m_Name: Test Room 3
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6685813788407296846
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6685813788407296844}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 6685813789027498526}
|
||||
- {fileID: 6685813789590265037}
|
||||
- {fileID: 7133256318772232080}
|
||||
- {fileID: 5436232046164896168}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &6685813788407296847
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6685813788407296844}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6268a80b1893dea4da88a977847d0df1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Bounds:
|
||||
- {fileID: 0}
|
||||
- {fileID: 7646758486997557462}
|
||||
Doors:
|
||||
- {fileID: 6685813789027498527}
|
||||
- {fileID: 6685813789590265042}
|
||||
- {fileID: 3990766584289748652}
|
||||
Weight: 1
|
||||
CanBeRotated: 1
|
||||
--- !u!1 &6685813789027498524
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6685813789027498526}
|
||||
- component: {fileID: 6685813789027498527}
|
||||
m_Layer: 0
|
||||
m_Name: Door 1
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6685813789027498526
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6685813789027498524}
|
||||
m_LocalRotation: {x: 0, y: 0, z: -0.92387956, w: 0.38268343}
|
||||
m_LocalPosition: {x: -2.1767766, y: 2.1767766, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6685813788407296846}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -135}
|
||||
--- !u!114 &6685813789027498527
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6685813789027498524}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.diag
|
||||
AllowedMatches:
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.diag
|
||||
Weight: 100
|
||||
- Tag: test.left
|
||||
Weight: 1
|
||||
- Tag: test.right
|
||||
Weight: 1
|
||||
- Tag: test.up
|
||||
Weight: 1
|
||||
- Tag: test.down
|
||||
Weight: 1
|
||||
--- !u!1 &6685813789590265043
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6685813789590265037}
|
||||
- component: {fileID: 6685813789590265042}
|
||||
m_Layer: 0
|
||||
m_Name: Door 2
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6685813789590265037
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6685813789590265043}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0.38268343, w: 0.92387956}
|
||||
m_LocalPosition: {x: 2.1767766, y: -2.1767766, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6685813788407296846}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 45}
|
||||
--- !u!114 &6685813789590265042
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6685813789590265043}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8ab941518ca8a4642828187df902b1e0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AssignWeight: 1
|
||||
Match: {fileID: 0}
|
||||
Disabled: 0
|
||||
Tags:
|
||||
- test.diag
|
||||
AllowedMatches:
|
||||
- Tag: test.hallway
|
||||
Weight: 1
|
||||
- Tag: test.diag
|
||||
Weight: 100
|
||||
- Tag: test.left
|
||||
Weight: 1
|
||||
- Tag: test.right
|
||||
Weight: 1
|
||||
- Tag: test.up
|
||||
Weight: 1
|
||||
- Tag: test.down
|
||||
Weight: 1
|
||||
7
Assets/Prefabs/Resources/Rooms/Test Room 3.prefab.meta
Normal file
7
Assets/Prefabs/Resources/Rooms/Test Room 3.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71ef2644f8da873439dfb79ab2882ebb
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -266,8 +266,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DungeonRoot: {fileID: 754085558}
|
||||
StartingRoomId: debug.test1
|
||||
RoomCountRange: {x: 20, y: 50}
|
||||
RoomCountRange: {x: 20, y: 100}
|
||||
StartingRoom: {fileID: 2101345830686511701, guid: e460ac35ac4587e498e7133f9e3962cf, type: 3}
|
||||
--- !u!4 &1726388858
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -2,11 +2,7 @@ using UnityEngine;
|
||||
|
||||
public static class GizmosHelper
|
||||
{
|
||||
public static void DrawLine(Transform transform, Vector3 from, Vector3 to) => DrawPoints(transform, new Vector3[2]
|
||||
{
|
||||
from,
|
||||
to
|
||||
});
|
||||
public static void DrawLine(Transform transform, Vector3 from, Vector3 to) => DrawPoints(transform, new Vector3[2] { from, to });
|
||||
public static void DrawPoints(Transform transform, Vector3[] points)
|
||||
{
|
||||
// Apply rotation and position.
|
||||
|
||||
@ -4,11 +4,9 @@ using UnityEngine;
|
||||
|
||||
public class DungeonGenerator : Singleton<DungeonGenerator>
|
||||
{
|
||||
// TODO: Add a weighting system.
|
||||
|
||||
public Transform DungeonRoot;
|
||||
public string StartingRoomId;
|
||||
public Vector2Int RoomCountRange;
|
||||
public RoomObject StartingRoom;
|
||||
|
||||
private RoomObject[] possibleRooms;
|
||||
|
||||
@ -19,54 +17,181 @@ public class DungeonGenerator : Singleton<DungeonGenerator>
|
||||
MakeDungeon();
|
||||
}
|
||||
|
||||
public void MakeDungeon()
|
||||
private void Update()
|
||||
{
|
||||
int rooms = Random.Range(RoomCountRange.x, RoomCountRange.y + 1);
|
||||
Debug.Log($"{rooms} rooms will be generated.");
|
||||
|
||||
List<RoomDoor> emptyDoors = new List<RoomDoor>();
|
||||
RoomObject activeRoom = GetRoomById(StartingRoomId, true);
|
||||
emptyDoors.AddRange(activeRoom.Doors);
|
||||
|
||||
while (rooms > 0 && emptyDoors.Count > 0)
|
||||
if (Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
// Pick random empty door and spawn a room there.
|
||||
RoomDoor door = emptyDoors[Random.Range(0, emptyDoors.Count)];
|
||||
RoomDoor matchingDoor = GetRoomDoorByTag(door.Tag, true);
|
||||
if (matchingDoor == null)
|
||||
foreach (Transform child in DungeonRoot.transform)
|
||||
{
|
||||
emptyDoors.Remove(door);
|
||||
continue;
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
matchingDoor.SetRoomRotationByDoor(door.transform.rotation.eulerAngles);
|
||||
matchingDoor.SetRoomPositionByDoor(door.transform.position);
|
||||
|
||||
List<RoomDoor> extraDoors = new List<RoomDoor>(matchingDoor.Room.Doors);
|
||||
extraDoors.Remove(matchingDoor);
|
||||
emptyDoors.AddRange(extraDoors);
|
||||
|
||||
rooms--;
|
||||
MakeDungeon();
|
||||
}
|
||||
}
|
||||
|
||||
public RoomObject GetRoomById(string id, bool instantiate)
|
||||
public void MakeDungeon()
|
||||
{
|
||||
RoomObject[] could = possibleRooms.Where(x => x.Identifier.StartsWith(id)).ToArray();
|
||||
RoomObject chosen = could[Random.Range(0, could.Length)];
|
||||
int rooms = Random.Range(RoomCountRange.x, RoomCountRange.y + 1);
|
||||
Debug.Log($"Attempting to generate {rooms} rooms.");
|
||||
|
||||
if (instantiate) return Instantiate(chosen, DungeonRoot);
|
||||
else return chosen;
|
||||
}
|
||||
public RoomDoor GetRoomDoorByTag(string tag, bool instantiate)
|
||||
{
|
||||
RoomObject[] could = possibleRooms.Where(x => x.Doors.Any(y => y.Tag.StartsWith(tag))).ToArray();
|
||||
if (could.Length == 0) return null;
|
||||
List<RoomObject> addedRooms = new List<RoomObject>();
|
||||
List<RoomDoor> unassignedDoors = new List<RoomDoor>();
|
||||
|
||||
RoomObject chosen = could[Random.Range(0, could.Length)];
|
||||
if (instantiate) chosen = Instantiate(chosen, DungeonRoot);
|
||||
// Pick random starting room.
|
||||
RoomObject startingRoom = Instantiate(StartingRoom, DungeonRoot);
|
||||
addedRooms.Add(startingRoom);
|
||||
unassignedDoors.AddRange(startingRoom.Doors);
|
||||
|
||||
RoomDoor[] couldDoors = chosen.Doors.Where(x => x.Tag.StartsWith(tag)).ToArray();
|
||||
return couldDoors[Random.Range(0, couldDoors.Length)];
|
||||
while (rooms > 0 && unassignedDoors.Count > 0)
|
||||
{
|
||||
// Pick a random available door (weighted).
|
||||
float weightSum = (from door in unassignedDoors select door.AssignWeight).Sum();
|
||||
RoomDoor chosenDoor = null;
|
||||
float weightChosen = Random.Range(0, weightSum);
|
||||
for (int doorIndex = 0; doorIndex < unassignedDoors.Count; doorIndex++)
|
||||
{
|
||||
RoomDoor possibleDoor = unassignedDoors[doorIndex];
|
||||
if (weightChosen < possibleDoor.AssignWeight)
|
||||
{
|
||||
chosenDoor = possibleDoor;
|
||||
break;
|
||||
}
|
||||
else weightChosen -= possibleDoor.AssignWeight;
|
||||
}
|
||||
if (chosenDoor.Disabled)
|
||||
{
|
||||
// Door is disabled, try again.
|
||||
unassignedDoors.Remove(chosenDoor);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Search for a door that matches the allowed tags of this one.
|
||||
// First, search for a tag to pick from (also weighted).
|
||||
List<TagWeight> matchDoorTags = new List<TagWeight>(chosenDoor.AllowedMatches);
|
||||
List<RoomObject> tempRooms = new List<RoomObject>(possibleRooms);
|
||||
_retryTag:
|
||||
weightSum = (from tag in matchDoorTags select tag.Weight).Sum();
|
||||
TagWeight chosenTag = null;
|
||||
weightChosen = Random.Range(0, weightSum);
|
||||
for (int tagIndex = 0; tagIndex < matchDoorTags.Count; tagIndex++)
|
||||
{
|
||||
TagWeight possibleTag = matchDoorTags[tagIndex];
|
||||
if (weightChosen < possibleTag.Weight)
|
||||
{
|
||||
chosenTag = possibleTag;
|
||||
break;
|
||||
}
|
||||
else weightChosen -= possibleTag.Weight;
|
||||
}
|
||||
if (chosenTag == null)
|
||||
{
|
||||
// None of the tags work here. Let's just skip this door.
|
||||
chosenDoor.Disabled = true;
|
||||
unassignedDoors.Remove(chosenDoor);
|
||||
continue;
|
||||
}
|
||||
|
||||
_retryRoom:
|
||||
// Now that we have our tag, find all room types with matching doors
|
||||
// and pick one at random (weighted yet again).
|
||||
RoomObject[] matchRooms = tempRooms.Where(x => chosenDoor.AllowedMatches.Any(y => x.Doors.Any(z => z.Tags.Any(w => w == y.Tag)))).ToArray();
|
||||
weightSum = (from room in matchRooms select room.Weight).Sum();
|
||||
RoomObject chosenRoom = null;
|
||||
weightChosen = Random.Range(0, weightSum);
|
||||
for (int roomIndex = 0; roomIndex < matchRooms.Length; roomIndex++)
|
||||
{
|
||||
RoomObject possibleRoom = matchRooms[roomIndex];
|
||||
if (weightChosen < possibleRoom.Weight)
|
||||
{
|
||||
chosenRoom = possibleRoom;
|
||||
break;
|
||||
}
|
||||
else weightChosen -= possibleRoom.Weight;
|
||||
}
|
||||
if (chosenRoom == null)
|
||||
{
|
||||
// This tag has no matches. Skip it and retry the tag.
|
||||
matchDoorTags.Remove(chosenTag);
|
||||
goto _retryTag;
|
||||
}
|
||||
|
||||
// Pick a random door in this room that fits the tag.
|
||||
RoomObject chosenRoomClone = Instantiate(chosenRoom, DungeonRoot);
|
||||
List<RoomDoor> tempDoors = new List<RoomDoor>(chosenRoomClone.Doors);
|
||||
_retryOtherDoor:
|
||||
RoomDoor[] otherDoors = tempDoors.Where(x => chosenDoor.AllowedMatches.Any(y => x.Tags.Any(z => z == y.Tag))).ToArray();
|
||||
weightSum = (from door in otherDoors select door.AssignWeight).Sum();
|
||||
RoomDoor otherDoor = null;
|
||||
weightChosen = Random.Range(0, weightSum);
|
||||
for (int doorIndex = 0; doorIndex < otherDoors.Length; doorIndex++)
|
||||
{
|
||||
RoomDoor possibleDoor = otherDoors[doorIndex];
|
||||
if (weightChosen < possibleDoor.AssignWeight)
|
||||
{
|
||||
otherDoor = possibleDoor;
|
||||
break;
|
||||
}
|
||||
else weightChosen -= possibleDoor.AssignWeight;
|
||||
}
|
||||
if (otherDoor == null)
|
||||
{
|
||||
// The doors we might have thought were valid might not actually be.
|
||||
// (For instance, if the room can't be rotated). Skip this room.
|
||||
Destroy(chosenRoomClone.gameObject);
|
||||
tempRooms.Remove(chosenRoom);
|
||||
goto _retryRoom;
|
||||
}
|
||||
|
||||
// Spawn the room and rotate it to the correct spot.
|
||||
if (chosenRoomClone.CanBeRotated)
|
||||
{
|
||||
float expectedDoorRot = chosenDoor.transform.rotation.eulerAngles.z + 180;
|
||||
float curDoorRot = otherDoor.transform.rotation.eulerAngles.z;
|
||||
float diff = expectedDoorRot - curDoorRot;
|
||||
|
||||
Vector3 curRoomRot = chosenRoomClone.transform.rotation.eulerAngles;
|
||||
curRoomRot.z += diff;
|
||||
chosenRoomClone.transform.rotation = Quaternion.Euler(curRoomRot);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if it's impossible.
|
||||
float diff = Mathf.Abs(otherDoor.transform.rotation.eulerAngles.z -
|
||||
chosenDoor.transform.rotation.eulerAngles.z);
|
||||
if (Mathf.Abs(diff - 180) >= 1e-1)
|
||||
{
|
||||
// Must be rotated to fit. Skip door.
|
||||
tempDoors.Remove(otherDoor);
|
||||
goto _retryOtherDoor; // Retry the door, not the room or tag.
|
||||
}
|
||||
}
|
||||
|
||||
// Move the room to position.
|
||||
Vector3 expectedDoorPos = chosenDoor.transform.position;
|
||||
Vector3 curDoorPos = otherDoor.transform.position;
|
||||
Vector3 diffPos = expectedDoorPos - curDoorPos;
|
||||
chosenRoomClone.transform.position += diffPos;
|
||||
|
||||
// See if this specific transform of the room causes it to overlap with
|
||||
// any other room.
|
||||
|
||||
// Extra stuff.
|
||||
chosenDoor.Match = otherDoor;
|
||||
otherDoor.Match = chosenDoor;
|
||||
addedRooms.Add(chosenRoomClone);
|
||||
unassignedDoors.AddRange(chosenRoomClone.Doors);
|
||||
unassignedDoors.Remove(otherDoor);
|
||||
|
||||
unassignedDoors.Remove(chosenDoor);
|
||||
rooms--;
|
||||
}
|
||||
|
||||
if (rooms > 0)
|
||||
{
|
||||
Debug.Log($"Ran out of available doors! Skipped generating {rooms} rooms.");
|
||||
}
|
||||
|
||||
// Make all remaining unavailable doors disabled.
|
||||
foreach (RoomDoor door in unassignedDoors) door.Disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
18
Assets/Scripts/RoomGeneration/GenerationProcedure.md
Normal file
18
Assets/Scripts/RoomGeneration/GenerationProcedure.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Generation Procedure
|
||||
This file details the algorithm I will be using to procedurally generate dungeons.
|
||||
It's not super complex in the grand scheme of things, but I still felt the need to
|
||||
write it out to help myself understand it before trying to implement it.
|
||||
|
||||
## Properties
|
||||
|
||||
### RoomObject
|
||||
- Bounds
|
||||
- Doors
|
||||
- CanBeRotated
|
||||
|
||||
### RoomDoor
|
||||
- ParentRoom
|
||||
- Corresponding
|
||||
- Disabled
|
||||
- Tags
|
||||
- AllowedRoomTags (tags and weights)
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecba4d6b0d9d5f14cb7163f8bee51a40
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,18 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class RoomDoor : RoomItem
|
||||
{
|
||||
public string Tag;
|
||||
|
||||
public void SetRoomRotationByDoor(Vector3 desiredDoorRotation)
|
||||
{
|
||||
Room.transform.rotation *= Quaternion.FromToRotation(Room.transform.rotation.eulerAngles, desiredDoorRotation);
|
||||
}
|
||||
public void SetRoomPositionByDoor(Vector2 desiredDoorPosition)
|
||||
{
|
||||
Vector2 curPos = transform.position;
|
||||
Vector2 diff = desiredDoorPosition - curPos;
|
||||
|
||||
Room.transform.position += (Vector3)diff;
|
||||
}
|
||||
public float AssignWeight = 1;
|
||||
public RoomDoor Match;
|
||||
public bool Disabled;
|
||||
public string[] Tags;
|
||||
public TagWeight[] AllowedMatches;
|
||||
}
|
||||
|
||||
19
Assets/Scripts/RoomGeneration/RoomGenerationExtensions.cs
Normal file
19
Assets/Scripts/RoomGeneration/RoomGenerationExtensions.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
public static class RoomGenerationExtensions
|
||||
{
|
||||
public static string GetRandom(this TagWeight[] weights)
|
||||
{
|
||||
float sumWeight = 0;
|
||||
for (int i = 0; i < weights.Length; i++) sumWeight += weights[i].Weight;
|
||||
|
||||
float chosen = UnityEngine.Random.Range(0, sumWeight);
|
||||
for (int i = 0; i < weights.Length; i++)
|
||||
{
|
||||
float expected = weights[i].Weight;
|
||||
if (chosen < expected) return weights[i].Tag;
|
||||
else chosen -= expected;
|
||||
}
|
||||
throw new Exception("How did this happen?");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 312cd75b868b8d0479d8f4f09d57e6d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -3,11 +3,11 @@ using UnityEngine;
|
||||
[ExecuteAlways]
|
||||
public abstract class RoomItem : MonoBehaviour
|
||||
{
|
||||
public RoomObject Room { get; private set; }
|
||||
public RoomObject ParentRoom { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Room = GetComponentInParent<RoomObject>();
|
||||
ParentRoom = GetComponentInParent<RoomObject>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -21,7 +21,7 @@ public abstract class RoomItem : MonoBehaviour
|
||||
private void EditorUpdate()
|
||||
{
|
||||
Awake();
|
||||
if (Room == null)
|
||||
if (ParentRoom == null)
|
||||
{
|
||||
Debug.LogError("A room item must have a parent room.");
|
||||
return;
|
||||
@ -30,6 +30,6 @@ public abstract class RoomItem : MonoBehaviour
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Room.OnDrawGizmosSelected();
|
||||
ParentRoom.OnDrawGizmosSelected();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,34 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteAlways]
|
||||
public class RoomObject : MonoBehaviour
|
||||
{
|
||||
public string Identifier;
|
||||
public Bounds Bounds;
|
||||
public Collider2D[] Bounds;
|
||||
public RoomDoor[] Doors;
|
||||
public float Weight = 1;
|
||||
public bool CanBeRotated;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Doors = GetComponentsInChildren<RoomDoor>();
|
||||
Bounds = GetComponentsInChildren<Collider2D>().Where(x => x.gameObject.CompareTag("RoomBounds")).ToArray();
|
||||
|
||||
if (Bounds.Length == 0)
|
||||
{
|
||||
const string message = "No bounds defining children detected! Make sure they have the \"RoomBounds\" tag.";
|
||||
if (Application.isPlaying) Debug.LogError(message);
|
||||
else Debug.LogWarning(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Bounds.Length; i++)
|
||||
{
|
||||
Collider2D col = Bounds[i];
|
||||
col.isTrigger = true;
|
||||
col.gameObject.layer = 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -23,28 +42,21 @@ public class RoomObject : MonoBehaviour
|
||||
private void EditorUpdate()
|
||||
{
|
||||
Awake();
|
||||
if (Bounds.extents.z != 0 || Bounds.center.z != 0)
|
||||
{
|
||||
Bounds.extents = (Vector2)Bounds.extents;
|
||||
Bounds.size = (Vector2)Bounds.size;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnDrawGizmos()
|
||||
{
|
||||
// Draw room mesh.
|
||||
Gizmos.color = new Color(1, 0.5f, 0); // Orange
|
||||
Color orange = new Color(1, 0.5f, 0);
|
||||
foreach (RoomDoor roomDoor in Doors)
|
||||
{
|
||||
GizmosHelper.DrawLine(transform, roomDoor.transform.localPosition, Bounds.center);
|
||||
if (roomDoor.Disabled) Gizmos.color = Color.red;
|
||||
else Gizmos.color = orange;
|
||||
GizmosHelper.DrawLine(transform, roomDoor.transform.localPosition, Vector2.zero);
|
||||
}
|
||||
}
|
||||
internal void OnDrawGizmosSelected()
|
||||
{
|
||||
// Draw room bounds.
|
||||
Gizmos.color = Color.white;
|
||||
GizmosHelper.DrawRect(transform, Bounds);
|
||||
|
||||
// Draw each door.
|
||||
Gizmos.color = Color.green;
|
||||
Bounds doorBounds = new Bounds(Vector2.zero, new Vector2(2, 1));
|
||||
|
||||
8
Assets/Scripts/RoomGeneration/TagWeight.cs
Normal file
8
Assets/Scripts/RoomGeneration/TagWeight.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class TagWeight
|
||||
{
|
||||
public string Tag;
|
||||
public float Weight;
|
||||
}
|
||||
11
Assets/Scripts/RoomGeneration/TagWeight.cs.meta
Normal file
11
Assets/Scripts/RoomGeneration/TagWeight.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0d7fece214db3a46b7e4bca82d3b82e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -3,7 +3,8 @@
|
||||
--- !u!78 &1
|
||||
TagManager:
|
||||
serializedVersion: 2
|
||||
tags: []
|
||||
tags:
|
||||
- RoomBounds
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
@ -11,7 +12,7 @@ TagManager:
|
||||
-
|
||||
- Water
|
||||
- UI
|
||||
-
|
||||
- RoomBounds
|
||||
-
|
||||
-
|
||||
-
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user