added pathfinding

This commit is contained in:
Janis M
2022-03-09 13:01:02 +01:00
parent a8d8b7b04b
commit 675481d8ad
21 changed files with 962 additions and 311 deletions

View File

@@ -15,4 +15,5 @@ MonoBehaviour:
nameString: Way
prefab: {fileID: 3420327930372171566, guid: 1b0d9211d89253549b71b121b268c59b, type: 3}
width: 2
height: 1
height: 2
isWalkable: 1

View File

@@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 3420327930372171566}
- component: {fileID: 3420327930372171567}
- component: {fileID: 7845977379617268391}
- component: {fileID: -2629907362058410054}
m_Layer: 0
m_Name: way_normal
m_TagString: Untagged
@@ -31,7 +32,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &3420327930372171567
SpriteRenderer:
@@ -79,7 +80,7 @@ SpriteRenderer:
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 2}
m_Size: {x: 2, y: 2}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
@@ -97,3 +98,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 56fadc4f2b895ad46bda623c68601c7e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &-2629907362058410054
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3420327930372171564}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35e95dc5ff2b64380880dd7ac5922847, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Size: {x: 4, y: 3, z: 4}
m_Center: {x: 0, y: 1, z: 0}
m_Area: 0
m_AffectedAgents: ffffffff

View File

@@ -123,6 +123,177 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &27583984
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3765826939735456267, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_Name
value: Canvas
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456267, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3765826939735456271, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: 0043226507c3f4144a606536d0c5073d, type: 3}
--- !u!1001 &34626491
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 828325524}
m_Modifications:
- target: {fileID: 7576071103965950752, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: city
value:
objectReference: {fileID: 1538992898}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalPosition.x
value: 1.6900692
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalPosition.y
value: -3.30762
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalPosition.z
value: 0.30080035
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7576071103965950758, guid: 1f51a7651a335584097672000ac8823b, type: 3}
propertyPath: m_Name
value: Shop
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: 1f51a7651a335584097672000ac8823b, type: 3}
--- !u!4 &289118049 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
m_PrefabInstance: {fileID: 1419265417}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &334969309
PrefabInstance:
m_ObjectHideFlags: 0
@@ -194,7 +365,143 @@ PrefabInstance:
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: bba65a6ddff46b740a482e11b8970dae, type: 3}
--- !u!1 &1238329964
--- !u!1001 &415185481
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3391280458837659705, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: city
value:
objectReference: {fileID: 1538992898}
- target: {fileID: 3391280458837659708, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_Name
value: Person
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659708, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_RootOrder
value: 6
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalPosition.x
value: 6.52
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalPosition.y
value: 6.484
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3391280458837659710, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
--- !u!4 &443631392 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
m_PrefabInstance: {fileID: 935574996}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &500158195
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 828325524}
m_Modifications:
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalPosition.x
value: 1.5325851
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalPosition.y
value: -0.21042156
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalPosition.z
value: 0.30080035
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3180108334736411175, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
propertyPath: m_Name
value: City
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
--- !u!4 &637142191 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7576071103965950754, guid: 1f51a7651a335584097672000ac8823b, type: 3}
m_PrefabInstance: {fileID: 34626491}
m_PrefabAsset: {fileID: 0}
--- !u!1 &828325523
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@@ -202,43 +509,214 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1238329966}
- component: {fileID: 1238329965}
- component: {fileID: 828325524}
m_Layer: 0
m_Name: PathfindingGrid
m_Name: obj
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!156049354 &1238329965
Grid:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1238329964}
m_Enabled: 1
m_CellSize: {x: 1, y: 1, z: 0}
m_CellGap: {x: 0, y: 0, z: 0}
m_CellLayout: 0
m_CellSwizzle: 0
--- !u!4 &1238329966
m_IsActive: 0
--- !u!4 &828325524
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1238329964}
m_GameObject: {fileID: 828325523}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 26.93912, y: 11.586942, z: -0.30080035}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2044272517}
- {fileID: 1678837391}
- {fileID: 289118049}
- {fileID: 443631392}
- {fileID: 1096306728}
- {fileID: 637142191}
- {fileID: 1414856996}
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &935574996
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 828325524}
m_Modifications:
- target: {fileID: 8483988689672967182, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_Name
value: House
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967183, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: city
value:
objectReference: {fileID: 1538992898}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalPosition.x
value: -14.549119
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalPosition.y
value: 0.6230583
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalPosition.z
value: 0.30080035
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8483988689672967185, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: 23ae9a68a9ff79940adf19a8638591c2, type: 3}
--- !u!4 &1096306728 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
m_PrefabInstance: {fileID: 1686204672}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1414856994
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1414856996}
- component: {fileID: 1414856995}
m_Layer: 0
m_Name: Company
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1414856995
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1414856994}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c8213916d698eaf4dbbeed4f986c72e4, type: 3}
m_Name:
m_EditorClassIdentifier:
companyName: Company
level: 1
city: {fileID: 1538992898}
workplaces: []
--- !u!4 &1414856996
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1414856994}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.1100292, y: -2.247223, z: 0.065934256}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 828325524}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1419265417
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 828325524}
m_Modifications:
- target: {fileID: 2879071748697521144, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_Name
value: Workplace
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521145, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: company
value:
objectReference: {fileID: 1414856995}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalPosition.x
value: 1.5325851
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalPosition.y
value: 4.199149
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalPosition.z
value: 0.30080035
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2879071748697521147, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: a96d918484557ca4b80a00b49f4afcdf, type: 3}
--- !u!1 &1522634444
GameObject:
m_ObjectHideFlags: 0
@@ -250,7 +728,7 @@ GameObject:
- component: {fileID: 1522634446}
- component: {fileID: 1522634445}
m_Layer: 0
m_Name: GridBuildingSystem
m_Name: Grid
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -285,6 +763,85 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1538992898 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3180108334736411172, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
m_PrefabInstance: {fileID: 500158195}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1da1a268031cfd742a614a4d319ddc32, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1678837391 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3180108334736411173, guid: a0f5cce80f851794aa28b176e811a46e, type: 3}
m_PrefabInstance: {fileID: 500158195}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1686204672
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 828325524}
m_Modifications:
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalPosition.x
value: 9.039354
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalPosition.y
value: -0.3154106
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalPosition.z
value: 0.30080035
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593861, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6901973132363593863, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: city
value:
objectReference: {fileID: 1538992898}
- target: {fileID: 6901973132363593913, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
propertyPath: m_Name
value: Park
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: 354e6cf04a0ac984cabf402ca3339a38, type: 3}
--- !u!1001 &1762203019
PrefabInstance:
m_ObjectHideFlags: 0
@@ -344,7 +901,7 @@ PrefabInstance:
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: 40a19dcc5827c5e4cbf618d6b8c883e6, type: 3}
--- !u!1 &2044272516
--- !u!1 &1988103521
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@@ -352,195 +909,39 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2044272517}
- component: {fileID: 2044272520}
- component: {fileID: 2044272519}
- component: {fileID: 2044272518}
- component: {fileID: 1988103523}
- component: {fileID: 1988103522}
m_Layer: 0
m_Name: ways
m_Name: test
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2044272517
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2044272516}
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1238329966}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2044272518
--- !u!114 &1988103522
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2044272516}
m_GameObject: {fileID: 1988103521}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1e3fdca004f2d45fe8abbed571a8abd5, type: 3}
m_Script: {fileID: 11500000, guid: 4a9e1a4cbcd629e43960027a99f45196, type: 3}
m_Name:
m_EditorClassIdentifier:
m_OverrideArea: 1
m_Area: 0
m_IgnoreFromBuild: 0
m_AffectedAgents: ffffffff
--- !u!483693784 &2044272519
TilemapRenderer:
--- !u!4 &1988103523
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2044272516}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_ChunkSize: {x: 32, y: 32, z: 32}
m_ChunkCullingBounds: {x: 0, y: 0, z: 0}
m_MaxChunkCount: 16
m_MaxFrameAge: 16
m_SortOrder: 0
m_Mode: 0
m_DetectChunkCullingBounds: 0
m_MaskInteraction: 0
--- !u!1839735485 &2044272520
Tilemap:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2044272516}
m_Enabled: 1
m_Tiles: {}
m_AnimatedTiles: {}
m_TileAssetArray: []
m_TileSpriteArray: []
m_TileMatrixArray: []
m_TileColorArray: []
m_TileObjectToInstantiateArray: []
m_AnimationFrameRate: 1
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Origin: {x: 0, y: 0, z: 0}
m_Size: {x: 0, y: 0, z: 1}
m_TileAnchor: {x: 0.5, y: 0.5, z: 0}
m_TileOrientation: 0
m_TileOrientationMatrix:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
--- !u!1001 &2144330849
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 2
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5419475751749434128, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_Name
value: NavMesh
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434129, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_NavMeshData
value:
objectReference: {fileID: 23800000, guid: 3ff0bc68a22d3164eb6a366c9b2a82ce, type: 2}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5419475751749434130, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_AddedGameObjects: []
m_SourcePrefab: {fileID: 100100000, guid: 4ead2502cf3d7cb4889e7fa1e0fa51fa, type: 3}
m_GameObject: {fileID: 1988103521}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 26.93912, y: 11.586942, z: -0.30080035}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@@ -1,35 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Area : MonoBehaviour
{
[SerializeField] bool accessable = false;
[SerializeField] GameObject tile;
List<Tile> tiles = new List<Tile>();
int height = 16;
int width = 16;
void Start()
{
GetComponent<SpriteRenderer>().color = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
//GenerateGrid();
}
void GenerateGrid()
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
GameObject currentTile= Instantiate(tile);
currentTile.transform.position = new Vector3(x - width/2, y-height/2, 1);
//currentTile.transform.SetParent(transform);
tiles.Add(currentTile.GetComponent<Tile>());
}
}
}
}

View File

@@ -5,17 +5,21 @@ using UnityEngine;
// Written with https://www.youtube.com/watch?v=dulosHPl82A
public class GridBuildingSystem : MonoBehaviour
{
public static GridBuildingSystem instance;
[SerializeField] List<PlacedObjectTypeSO> placedObjectTypeSOList = new List<PlacedObjectTypeSO>(); // https://youtu.be/dulosHPl82A?t=1192
PlacedObjectTypeSO placedObjectTypeSO;
Grid<GridObject> grid;
public Grid<GridObject> buildingGrid;
void Awake()
{
if (instance == null)
instance = this;
int gridWidth = 20;
int gridHeight = 20;
float cellSize = 2f;
float cellSize = 1f;
grid = new Grid<GridObject>(gridWidth, gridHeight, cellSize, Vector3.zero, (Grid<GridObject> g, int x, int y) => new GridObject(g, x, y));
buildingGrid = new Grid<GridObject>(gridWidth, gridHeight, cellSize, Vector3.zero, (Grid<GridObject> g, int x, int y) => new GridObject(g, x, y));
placedObjectTypeSO = placedObjectTypeSOList[0];
}
public class GridObject
@@ -40,17 +44,18 @@ public class GridBuildingSystem : MonoBehaviour
}
void Update()
{
if (Input.GetMouseButtonDown(0))
// PLACE
if (Input.GetKeyDown(KeyCode.B))
{
Vector3 mousePosition = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
grid.GetXY(mousePosition, out int x, out int y);
buildingGrid.GetXY(mousePosition, out int x, out int y);
List<Vector2Int> gridPositionList = placedObjectTypeSO.GetGridPositionList(new Vector2Int(x, y), PlacedObjectTypeSO.Dir.Down);
bool canBuild = true;
foreach (Vector2Int gridPosition in gridPositionList)
{
if(!grid.GetGridObject(gridPosition.x, gridPosition.y).CanBuild())
if(!buildingGrid.GetGridObject(gridPosition.x, gridPosition.y).CanBuild())
{
// Cannot build here
canBuild = false;
@@ -60,12 +65,12 @@ public class GridBuildingSystem : MonoBehaviour
if (canBuild)
{
PlacedObject placedObject = PlacedObject.Create(grid.GetWorldPosition(x, y), new Vector2Int(x, y), PlacedObjectTypeSO.Dir.Down, placedObjectTypeSO);
PlacedObject placedObject = PlacedObject.Create(buildingGrid.GetWorldPosition(x, y), new Vector2Int(x, y), PlacedObjectTypeSO.Dir.Down, placedObjectTypeSO);
foreach(Vector2Int gridPosition in gridPositionList)
{
grid.GetGridObject(gridPosition.x, gridPosition.y).SetPlacedObject(placedObject);
buildingGrid.GetGridObject(gridPosition.x, gridPosition.y).SetPlacedObject(placedObject);
}
}
@@ -73,9 +78,10 @@ public class GridBuildingSystem : MonoBehaviour
{
Debug.Log("Cannot build here!" + " " + mousePosition);
}
}else if (Input.GetMouseButtonDown(1))
}else if (Input.GetKeyDown(KeyCode.N)) // DEMOLISH
{
GridObject gridObject = grid.GetGridObject(Camera.main.ScreenToWorldPoint(Input.mousePosition));
GridObject gridObject = buildingGrid.GetGridObject(Camera.main.ScreenToWorldPoint(Input.mousePosition));
PlacedObject placedObject = gridObject.GetPlacedObject();
if (placedObject != null)
{
@@ -85,7 +91,7 @@ public class GridBuildingSystem : MonoBehaviour
foreach (Vector2Int gridPosition in gridPositionList)
{
grid.GetGridObject(gridPosition.x, gridPosition.y).ClearPlacedObject();
buildingGrid.GetGridObject(gridPosition.x, gridPosition.y).ClearPlacedObject();
}
}

View File

@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
public class PlacedObject : MonoBehaviour
{
@@ -12,6 +13,16 @@ public class PlacedObject : MonoBehaviour
placedObject.placedObjectTypeSO = placedObjectTypeSO;
placedObject.origin = origin;
placedObject.dir = dir;
if (placedObjectTypeSO.isWalkable)
{
foreach(Vector2Int position in placedObject.GetGridPositionList())
{
Pathfinding.Instance.GetNode(position.x, position.y).SetIsWalkable(true);
}
}
return placedObject;
}
@@ -26,6 +37,13 @@ public class PlacedObject : MonoBehaviour
public void DestroySelf()
{
if (placedObjectTypeSO.isWalkable)
{
foreach (Vector2Int position in GetGridPositionList())
{
Pathfinding.Instance.GetNode(position.x, position.y).SetIsWalkable(false);
}
}
Destroy(gameObject);
}
}

View File

@@ -17,7 +17,6 @@ public class PlacedObjectTypeSO : ScriptableObject
case Dir.Right: return Dir.Down;
}
}
public enum Dir
{
Down,
@@ -31,7 +30,7 @@ public class PlacedObjectTypeSO : ScriptableObject
//public Transform visual;
public int width;
public int height;
public bool isWalkable = false;
public int GetRotationAngle(Dir dir)
{

View File

@@ -1,39 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AreaManager : MonoBehaviour
{
[SerializeField] int areaSize = 16;
[SerializeField] int width = 8;
[SerializeField] int height = 8;
[SerializeField] GameObject area;
[SerializeField] List<Area> areas;
private void Start()
{
GenerateGrid();
}
void GenerateGrid()
{
for(int x = 0; x < width; x++)
{
for(int y = 0; y < height; y++)
{
GameObject currentArea = Instantiate(area);
currentArea.transform.position = new Vector3(16*x, 16*y, 1);
areas.Add(currentArea.GetComponent<Area>());
}
}
}
private void OnDrawGizmos()
{
Gizmos.color = Color.blue;
Gizmos.DrawWireCube(Vector3Int.zero, new Vector3Int(areaSize, areaSize, 1));
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: edeef0219b3e4e2429e80209bef34286
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
/*
------------------- Code Monkey -------------------
Thank you for downloading this package
I hope you find it useful in your projects
If you have any questions let me know
Cheers!
unitycodemonkey.com
--------------------------------------------------
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PathNode {
private Grid<PathNode> grid;
public int x;
public int y;
public int gCost;
public int hCost;
public int fCost;
public bool isWalkable;
public PathNode cameFromNode;
public PathNode(Grid<PathNode> grid, int x, int y) {
this.grid = grid;
this.x = x;
this.y = y;
isWalkable = false;
}
public void CalculateFCost() {
fCost = gCost + hCost;
}
public void SetIsWalkable(bool isWalkable) {
this.isWalkable = isWalkable;
}
public override string ToString() {
return x + "," + y;
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 5913569e16e68e54584ba0ab5b9ec15a
guid: 8a762ee25504d4344b891ad21350450f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,161 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pathfinding {
private const int MOVE_STRAIGHT_COST = 10;
private const int MOVE_DIAGONAL_COST = 14;
public static Pathfinding Instance { get; private set; }
private Grid<PathNode> grid;
private List<PathNode> openList;
private List<PathNode> closedList;
public Pathfinding(int width, int height) {
Instance = this;
grid = new Grid<PathNode>(width, height, 1f, Vector3.zero, (Grid<PathNode> g, int x, int y) => new PathNode(g, x, y));
}
public Grid<PathNode> GetGrid() {
return grid;
}
public List<Vector3> FindPath(Vector3 startWorldPosition, Vector3 endWorldPosition) {
grid.GetXY(startWorldPosition, out int startX, out int startY);
grid.GetXY(endWorldPosition, out int endX, out int endY);
List<PathNode> path = FindPath(startX, startY, endX, endY);
if (path == null) {
return null;
} else {
List<Vector3> vectorPath = new List<Vector3>();
foreach (PathNode pathNode in path) {
vectorPath.Add(new Vector3(pathNode.x, pathNode.y) * grid.GetCellSize() + Vector3.one * grid.GetCellSize() * .5f);
}
return vectorPath;
}
}
public List<PathNode> FindPath(int startX, int startY, int endX, int endY) {
PathNode startNode = grid.GetGridObject(startX, startY);
PathNode endNode = grid.GetGridObject(endX, endY);
if (startNode == null || endNode == null) {
// Invalid Path
return null;
}
openList = new List<PathNode> { startNode };
closedList = new List<PathNode>();
for (int x = 0; x < grid.GetWidth(); x++) {
for (int y = 0; y < grid.GetHeight(); y++) {
PathNode pathNode = grid.GetGridObject(x, y);
pathNode.gCost = 99999999;
pathNode.CalculateFCost();
pathNode.cameFromNode = null;
}
}
startNode.gCost = 0;
startNode.hCost = CalculateDistanceCost(startNode, endNode);
startNode.CalculateFCost();
while (openList.Count > 0) {
PathNode currentNode = GetLowestFCostNode(openList);
if (currentNode == endNode) {
// Reached final node
return CalculatePath(endNode);
}
openList.Remove(currentNode);
closedList.Add(currentNode);
foreach (PathNode neighbourNode in GetNeighbourList(currentNode)) {
if (closedList.Contains(neighbourNode)) continue;
if (!neighbourNode.isWalkable) {
closedList.Add(neighbourNode);
continue;
}
int tentativeGCost = currentNode.gCost + CalculateDistanceCost(currentNode, neighbourNode);
if (tentativeGCost < neighbourNode.gCost) {
neighbourNode.cameFromNode = currentNode;
neighbourNode.gCost = tentativeGCost;
neighbourNode.hCost = CalculateDistanceCost(neighbourNode, endNode);
neighbourNode.CalculateFCost();
if (!openList.Contains(neighbourNode)) {
openList.Add(neighbourNode);
}
}
}
}
// Out of nodes on the openList
return null;
}
private List<PathNode> GetNeighbourList(PathNode currentNode) {
List<PathNode> neighbourList = new List<PathNode>();
if (currentNode.x - 1 >= 0) {
// Left
neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y));
// Left Down
if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y - 1));
// Left Up
if (currentNode.y + 1 < grid.GetHeight()) neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y + 1));
}
if (currentNode.x + 1 < grid.GetWidth()) {
// Right
neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y));
// Right Down
if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y - 1));
// Right Up
if (currentNode.y + 1 < grid.GetHeight()) neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y + 1));
}
// Down
if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x, currentNode.y - 1));
// Up
if (currentNode.y + 1 < grid.GetHeight()) neighbourList.Add(GetNode(currentNode.x, currentNode.y + 1));
return neighbourList;
}
public PathNode GetNode(int x, int y) {
return grid.GetGridObject(x, y);
}
private List<PathNode> CalculatePath(PathNode endNode) {
List<PathNode> path = new List<PathNode>();
path.Add(endNode);
PathNode currentNode = endNode;
while (currentNode.cameFromNode != null) {
path.Add(currentNode.cameFromNode);
currentNode = currentNode.cameFromNode;
}
path.Reverse();
return path;
}
private int CalculateDistanceCost(PathNode a, PathNode b) {
int xDistance = Mathf.Abs(a.x - b.x);
int yDistance = Mathf.Abs(a.y - b.y);
int remaining = Mathf.Abs(xDistance - yDistance);
return MOVE_DIAGONAL_COST * Mathf.Min(xDistance, yDistance) + MOVE_STRAIGHT_COST * remaining;
}
private PathNode GetLowestFCostNode(List<PathNode> pathNodeList) {
PathNode lowestFCostNode = pathNodeList[0];
for (int i = 1; i < pathNodeList.Count; i++) {
if (pathNodeList[i].fCost < lowestFCostNode.fCost) {
lowestFCostNode = pathNodeList[i];
}
}
return lowestFCostNode;
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: dc2d10c80076d454fa421658fc397028
guid: e5530caa2a712744aa8742d15eb47ac9
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Testing : MonoBehaviour {
private Pathfinding pathfinding;
int originX = 0;
int originY = 0;
private void Start() {
pathfinding = new Pathfinding(20, 10);
}
private void Update() {
if (Input.GetMouseButtonDown(0)) {
Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
pathfinding.GetGrid().GetXY(mouseWorldPosition, out int x, out int y);
List<PathNode> path = pathfinding.FindPath(originX, originY, x, y);
if (path != null) {
float cellSize = pathfinding.GetGrid().GetCellSize();
for (int i=0; i<path.Count - 1; i++) {
Debug.DrawLine(new Vector3(path[i].x, path[i].y) * cellSize + Vector3.one * cellSize/2, new Vector3(path[i+1].x, path[i+1].y) * cellSize + Vector3.one * cellSize/2, Color.green, 5f);
}
}
//characterPathfinding.SetTargetPosition(mouseWorldPosition);
}
if (Input.GetMouseButtonDown(1)) {
Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
pathfinding.GetGrid().GetXY(mouseWorldPosition, out int x, out int y);
pathfinding.GetNode(x, y).SetIsWalkable(!pathfinding.GetNode(x, y).isWalkable);
originX = x;
originY = y;
}
if (Input.GetMouseButtonDown(2))
{
Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
pathfinding.GetGrid().GetXY(mouseWorldPosition, out int x, out int y);
pathfinding.GetNode(x, y).SetIsWalkable(!pathfinding.GetNode(x, y).isWalkable);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0223944c58fdbb54eb34ad98462c6f27
guid: 4a9e1a4cbcd629e43960027a99f45196
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -69,12 +69,13 @@ public class Person : MonoBehaviour
movement = GetComponent<PersonMovement>();
indicators = GetComponent<PersonIndicators>();
TimeManager.OnMinuteUpdate += OnMinuteUpdate;
/* TimeManager.OnMinuteUpdate += OnMinuteUpdate;
TimeManager.OnDayUpdate += OnDayUpdate;
SetBehaivorDateTimes();
Sleep();
Sleep();*/
}
/*
void OnDayUpdate()
{
SetBehaivorDateTimes();
@@ -145,5 +146,5 @@ public class Person : MonoBehaviour
Random.Range(0, 59),
currentDateTime.Second);
}
}*/
}

View File

@@ -1,22 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class PersonMovement : MonoBehaviour
{
NavMeshAgent agent;
private int currentPathIndex;
[SerializeField] private List<Vector3> pathVectorList;
private const float speed = 40f;
private void Awake()
{
agent = GetComponent<NavMeshAgent>();
agent.updateRotation = false;
agent.updateUpAxis = false;
//agent.avoidancePriority = Random.Range(1, 100);
}
public void SetTarget(Transform target)
private void Update()
{
agent.SetDestination(target.position);
HandleMovement();
if (Input.GetMouseButton(0))
{
SetTarget(Camera.main.ScreenToWorldPoint(Input.mousePosition));
}
}
void HandleMovement()
{
if (pathVectorList != null)
{
Vector3 targetPosition = pathVectorList[currentPathIndex];
if (Vector3.Distance(transform.position, targetPosition) > 1f)
{
Vector3 moveDir = (targetPosition - transform.position).normalized;
float distanceBefore = Vector3.Distance(transform.position, targetPosition);
transform.position = transform.position + moveDir * speed * Time.deltaTime;
}
else
{
currentPathIndex++;
}
}
}
public Vector3 GetPosition()
{
return transform.position;
}
public void SetTarget(Vector3 targetTransform)
{
pathVectorList = Pathfinding.Instance.FindPath(GetPosition(), targetTransform);
}
}

View File

@@ -1,12 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tile : MonoBehaviour
{
void Start()
{
GetComponent<SpriteRenderer>().color = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 313 B