diff --git a/Assets/Objects/way_normal.asset b/Assets/Objects/way_normal.asset index 26315b8..6041f04 100644 --- a/Assets/Objects/way_normal.asset +++ b/Assets/Objects/way_normal.asset @@ -15,4 +15,5 @@ MonoBehaviour: nameString: Way prefab: {fileID: 3420327930372171566, guid: 1b0d9211d89253549b71b121b268c59b, type: 3} width: 2 - height: 1 + height: 2 + isWalkable: 1 diff --git a/Assets/Objects/way_normal.prefab b/Assets/Objects/way_normal.prefab index 2831c46..586f7b6 100644 --- a/Assets/Objects/way_normal.prefab +++ b/Assets/Objects/way_normal.prefab @@ -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 diff --git a/Assets/Scenes/GridScene.unity b/Assets/Scenes/GridScene.unity index 0bb696d..e2c6343 100644 --- a/Assets/Scenes/GridScene.unity +++ b/Assets/Scenes/GridScene.unity @@ -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} diff --git a/Assets/Scenes/GridScene/NavMesh-NavMesh.asset b/Assets/Scenes/GridScene/NavMesh-NavMesh.asset index 0e521da..4ac9d8b 100644 Binary files a/Assets/Scenes/GridScene/NavMesh-NavMesh.asset and b/Assets/Scenes/GridScene/NavMesh-NavMesh.asset differ diff --git a/Assets/Scripts/Area.cs b/Assets/Scripts/Area.cs deleted file mode 100644 index 6899843..0000000 --- a/Assets/Scripts/Area.cs +++ /dev/null @@ -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 tiles = new List(); - - int height = 16; - int width = 16; - - void Start() - { - GetComponent().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()); - } - } - } -} diff --git a/Assets/Scripts/Grid/GridBuildingSystem.cs b/Assets/Scripts/Grid/GridBuildingSystem.cs index 85b6ed2..50db64b 100644 --- a/Assets/Scripts/Grid/GridBuildingSystem.cs +++ b/Assets/Scripts/Grid/GridBuildingSystem.cs @@ -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 placedObjectTypeSOList = new List(); // https://youtu.be/dulosHPl82A?t=1192 PlacedObjectTypeSO placedObjectTypeSO; - Grid grid; + public Grid buildingGrid; void Awake() { + if (instance == null) + instance = this; + int gridWidth = 20; int gridHeight = 20; - float cellSize = 2f; + float cellSize = 1f; - grid = new Grid(gridWidth, gridHeight, cellSize, Vector3.zero, (Grid g, int x, int y) => new GridObject(g, x, y)); + buildingGrid = new Grid(gridWidth, gridHeight, cellSize, Vector3.zero, (Grid 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 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(); } } diff --git a/Assets/Scripts/PlacedObject.cs b/Assets/Scripts/Grid/PlacedObject.cs similarity index 64% rename from Assets/Scripts/PlacedObject.cs rename to Assets/Scripts/Grid/PlacedObject.cs index 71ebadb..d5506e2 100644 --- a/Assets/Scripts/PlacedObject.cs +++ b/Assets/Scripts/Grid/PlacedObject.cs @@ -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); } } \ No newline at end of file diff --git a/Assets/Scripts/PlacedObject.cs.meta b/Assets/Scripts/Grid/PlacedObject.cs.meta similarity index 100% rename from Assets/Scripts/PlacedObject.cs.meta rename to Assets/Scripts/Grid/PlacedObject.cs.meta diff --git a/Assets/Scripts/Grid/PlacedObjectTypeSO.cs b/Assets/Scripts/Grid/PlacedObjectTypeSO.cs index aee8ff7..06e5136 100644 --- a/Assets/Scripts/Grid/PlacedObjectTypeSO.cs +++ b/Assets/Scripts/Grid/PlacedObjectTypeSO.cs @@ -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) { diff --git a/Assets/Scripts/Managers/AreaManager.cs b/Assets/Scripts/Managers/AreaManager.cs deleted file mode 100644 index 1124890..0000000 --- a/Assets/Scripts/Managers/AreaManager.cs +++ /dev/null @@ -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 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()); - } - } - } - - private void OnDrawGizmos() - { - Gizmos.color = Color.blue; - Gizmos.DrawWireCube(Vector3Int.zero, new Vector3Int(areaSize, areaSize, 1)); - } -} diff --git a/Assets/Scripts/Pathfinding.meta b/Assets/Scripts/Pathfinding.meta new file mode 100644 index 0000000..34de2dd --- /dev/null +++ b/Assets/Scripts/Pathfinding.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: edeef0219b3e4e2429e80209bef34286 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Pathfinding/PathNode.cs b/Assets/Scripts/Pathfinding/PathNode.cs new file mode 100644 index 0000000..ef9a6f8 --- /dev/null +++ b/Assets/Scripts/Pathfinding/PathNode.cs @@ -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 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 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; + } + +} diff --git a/Assets/Scripts/Tile.cs.meta b/Assets/Scripts/Pathfinding/PathNode.cs.meta similarity index 83% rename from Assets/Scripts/Tile.cs.meta rename to Assets/Scripts/Pathfinding/PathNode.cs.meta index b50eb7f..6be8d36 100644 --- a/Assets/Scripts/Tile.cs.meta +++ b/Assets/Scripts/Pathfinding/PathNode.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5913569e16e68e54584ba0ab5b9ec15a +guid: 8a762ee25504d4344b891ad21350450f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Pathfinding/Pathfinding.cs b/Assets/Scripts/Pathfinding/Pathfinding.cs new file mode 100644 index 0000000..9b5c5e5 --- /dev/null +++ b/Assets/Scripts/Pathfinding/Pathfinding.cs @@ -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 grid; + private List openList; + private List closedList; + + public Pathfinding(int width, int height) { + Instance = this; + grid = new Grid(width, height, 1f, Vector3.zero, (Grid g, int x, int y) => new PathNode(g, x, y)); + } + + public Grid GetGrid() { + return grid; + } + + public List FindPath(Vector3 startWorldPosition, Vector3 endWorldPosition) { + grid.GetXY(startWorldPosition, out int startX, out int startY); + grid.GetXY(endWorldPosition, out int endX, out int endY); + + List path = FindPath(startX, startY, endX, endY); + if (path == null) { + return null; + } else { + List vectorPath = new List(); + foreach (PathNode pathNode in path) { + vectorPath.Add(new Vector3(pathNode.x, pathNode.y) * grid.GetCellSize() + Vector3.one * grid.GetCellSize() * .5f); + } + return vectorPath; + } + } + + public List 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 { startNode }; + closedList = new List(); + + 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 GetNeighbourList(PathNode currentNode) { + List neighbourList = new List(); + + 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 CalculatePath(PathNode endNode) { + List path = new List(); + 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 pathNodeList) { + PathNode lowestFCostNode = pathNodeList[0]; + for (int i = 1; i < pathNodeList.Count; i++) { + if (pathNodeList[i].fCost < lowestFCostNode.fCost) { + lowestFCostNode = pathNodeList[i]; + } + } + return lowestFCostNode; + } + +} diff --git a/Assets/Scripts/Area.cs.meta b/Assets/Scripts/Pathfinding/Pathfinding.cs.meta similarity index 83% rename from Assets/Scripts/Area.cs.meta rename to Assets/Scripts/Pathfinding/Pathfinding.cs.meta index b469b50..6832196 100644 --- a/Assets/Scripts/Area.cs.meta +++ b/Assets/Scripts/Pathfinding/Pathfinding.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dc2d10c80076d454fa421658fc397028 +guid: e5530caa2a712744aa8742d15eb47ac9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Pathfinding/Testing.cs b/Assets/Scripts/Pathfinding/Testing.cs new file mode 100644 index 0000000..dc7b628 --- /dev/null +++ b/Assets/Scripts/Pathfinding/Testing.cs @@ -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 path = pathfinding.FindPath(originX, originY, x, y); + if (path != null) { + float cellSize = pathfinding.GetGrid().GetCellSize(); + for (int i=0; i(); indicators = GetComponent(); - 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); - } + }*/ } diff --git a/Assets/Scripts/Person/PersonMovement.cs b/Assets/Scripts/Person/PersonMovement.cs index 116fe63..cd9eff5 100644 --- a/Assets/Scripts/Person/PersonMovement.cs +++ b/Assets/Scripts/Person/PersonMovement.cs @@ -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 pathVectorList; + private const float speed = 40f; private void Awake() { - agent = GetComponent(); - 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); } } diff --git a/Assets/Scripts/Tile.cs b/Assets/Scripts/Tile.cs deleted file mode 100644 index 8b6a6a7..0000000 --- a/Assets/Scripts/Tile.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Tile : MonoBehaviour -{ - void Start() - { - GetComponent().color = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f); - } - -} diff --git a/Assets/Sprites/way_normal.png b/Assets/Sprites/way_normal.png index 99b0413..5e2dc0d 100644 Binary files a/Assets/Sprites/way_normal.png and b/Assets/Sprites/way_normal.png differ