Destructable Crate

Polish
Sascha 2023-06-16 11:09:51 +07:00
parent fd67130275
commit c9aebbcf8d
16 changed files with 531 additions and 202 deletions

@ -124,6 +124,7 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &7764060587927922204
MonoBehaviour:
m_ObjectHideFlags: 11

@ -124,6 +124,7 @@ Material:
- _EmissionColor: {r: 4.37319, g: 16, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &3608582224199121341
MonoBehaviour:
m_ObjectHideFlags: 11

@ -126,6 +126,7 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &716143391816078910
MonoBehaviour:
m_ObjectHideFlags: 11

@ -139,3 +139,4 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1

@ -0,0 +1,154 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6742052861145951612
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9142444727976197465}
- component: {fileID: 7802226090513137756}
- component: {fileID: 9112269570178995488}
m_Layer: 8
m_Name: Crate
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &9142444727976197465
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6742052861145951612}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 8, y: 0, z: 4}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 5881830881992029899}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &7802226090513137756
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6742052861145951612}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1.2, y: 1.2, z: 1.2}
m_Center: {x: 0, y: 0.6, z: 0}
--- !u!114 &9112269570178995488
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6742052861145951612}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 32368030487579a3b947bd9853c5e9e5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &5886015247612728549
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 9142444727976197465}
m_Modifications:
- target: {fileID: 1852967516923486, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_Name
value: SM_Prop_Crate_01
objectReference: {fileID: 0}
- target: {fileID: 1852967516923486, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_Layer
value: 8
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalScale.x
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalScale.y
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalScale.z
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalPosition.y
value: 0.6
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 23391228476554062, guid: e1b9e21039285c042b92ea66c7f1c444,
type: 3}
propertyPath: 'm_Materials.Array.data[0]'
value:
objectReference: {fileID: 2100000, guid: 4d1c11ecf91c18d4e86d3818e8c650cc, type: 2}
m_RemovedComponents:
- {fileID: 64008491219568898, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e1b9e21039285c042b92ea66c7f1c444, type: 3}
--- !u!4 &5881830881992029899 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4263531196441134, guid: e1b9e21039285c042b92ea66c7f1c444,
type: 3}
m_PrefabInstance: {fileID: 5886015247612728549}
m_PrefabAsset: {fileID: 0}

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1a531e276d6ed5766a7e85e6d4642ff3
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -44,7 +44,6 @@ RenderSettings:
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
@ -163,13 +162,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 18574384}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 21
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &36003318
GameObject:
@ -212,13 +211,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 36003318}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &117986693
GameObject:
@ -284,6 +283,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 117986693}
serializedVersion: 2
m_LocalRotation: {x: -0.16184928, y: 0.34558707, z: -0.060643088, w: -0.9223322}
m_LocalPosition: {x: 7.5972843, y: 2.7512903, z: -0.9095536}
m_LocalScale: {x: 1, y: 1, z: 1}
@ -291,7 +291,6 @@ Transform:
m_Children:
- {fileID: 1192809792}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &117986696
MonoBehaviour:
@ -429,13 +428,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 275919988}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.01, y: 0, z: 3.25}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &275919990
MonoBehaviour:
@ -629,13 +628,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_LocalRotation: {x: 0.3006394, y: 0.000000016410377, z: -0.000000005172915, w: 0.9537379}
serializedVersion: 2
m_LocalRotation: {x: 0.3006394, y: -0.000000016410377, z: 0.000000005172915, w: 0.9537379}
m_LocalPosition: {x: 3.01, y: 7, z: -6.75}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &330585547
MonoBehaviour:
@ -841,13 +840,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 366831941}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 19
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &410087039
GameObject:
@ -935,13 +934,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 410087039}
serializedVersion: 2
m_LocalRotation: {x: 0.27430275, y: -0.8095801, z: 0.4104197, w: 0.31763786}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 57.013, y: -147.921, z: -19.686}
--- !u!114 &410087042
MonoBehaviour:
@ -1092,7 +1091,6 @@ RectTransform:
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 829202023}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -1235,13 +1233,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 506381886}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &537492064
GameObject:
@ -1303,13 +1301,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 537492064}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 15
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &571367561 stripped
RectTransform:
@ -1559,14 +1557,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 598754947}
m_LocalRotation: {x: 0.3006394, y: 0.000000016410377, z: -0.000000005172915, w: 0.9537379}
serializedVersion: 2
m_LocalRotation: {x: 0.3006394, y: -0.000000016410377, z: 0.000000005172915, w: 0.9537379}
m_LocalPosition: {x: 3.01, y: 7, z: -6.75}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 885582185}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &598754950
MonoBehaviour:
@ -1689,7 +1687,6 @@ RectTransform:
- {fileID: 1402454969}
- {fileID: 920935813}
m_Father: {fileID: 0}
m_RootOrder: 14
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@ -1850,7 +1847,6 @@ RectTransform:
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 1251970107}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
@ -1987,7 +1983,6 @@ RectTransform:
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 1402454969}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -2191,13 +2186,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 656768578}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 20
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &684963193 stripped
RectTransform:
@ -2414,7 +2409,6 @@ RectTransform:
- {fileID: 1093543376}
- {fileID: 481743891}
m_Father: {fileID: 920935813}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
@ -2462,13 +2456,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 832575517}
serializedVersion: 2
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: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &885582184
GameObject:
@ -2496,13 +2490,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 885582184}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 598754949}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &885582186
MonoBehaviour:
@ -2598,7 +2592,6 @@ RectTransform:
- {fileID: 1719206478}
- {fileID: 829202023}
m_Father: {fileID: 606110264}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -2669,13 +2662,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 967329130}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &972184793
GameObject:
@ -2708,7 +2701,6 @@ RectTransform:
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 1402454969}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -2850,13 +2842,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 989818456}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 23
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1000549648 stripped
Transform:
@ -3065,6 +3057,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1051832113}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 14, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@ -3076,7 +3069,6 @@ Transform:
- {fileID: 462482035}
- {fileID: 1880818556}
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1069442162
PrefabInstance:
@ -3192,13 +3184,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1077648427}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 1491138602}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1077648429
MeshRenderer:
@ -3372,7 +3364,6 @@ RectTransform:
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 829202023}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -3507,13 +3498,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1128788153}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 22
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1192809791
GameObject:
@ -3541,13 +3532,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1192809791}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 117986695}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1192809793
MonoBehaviour:
@ -3646,13 +3637,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1222726809}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1251970106
GameObject:
@ -3686,7 +3677,6 @@ RectTransform:
- {fileID: 1426854556}
- {fileID: 649590482}
m_Father: {fileID: 606110264}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -4081,7 +4071,6 @@ RectTransform:
- {fileID: 653919469}
- {fileID: 972184794}
m_Father: {fileID: 606110264}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
@ -4206,7 +4195,6 @@ RectTransform:
- {fileID: 684963193}
- {fileID: 571367561}
m_Father: {fileID: 1251970107}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
@ -4415,6 +4403,50 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 1467514632}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1482581175
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1482581177}
- component: {fileID: 1482581176}
m_Layer: 0
m_Name: PathfindingUpdater
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1482581176
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1482581175}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e4ef9594717ee8cea96e618ce3530b01, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1482581177
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1482581175}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1489419290 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 2554385331328250168, guid: adae4f13d5306d4518212283c7892fd0,
@ -4472,6 +4504,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1491138600}
serializedVersion: 2
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}
@ -4479,7 +4512,6 @@ Transform:
m_Children:
- {fileID: 1077648428}
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1499896363
PrefabInstance:
@ -4858,7 +4890,6 @@ RectTransform:
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 920935813}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
@ -5235,13 +5266,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1848247809}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 18
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1867005302
GameObject:
@ -5285,13 +5316,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1867005302}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 10, y: 10, z: 10}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 16
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1874718369
PrefabInstance:
@ -5416,6 +5447,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1917598935}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -1.494, y: 0, z: -2.487}
m_LocalScale: {x: 17.9991, y: 1, z: 10}
@ -5448,7 +5480,6 @@ Transform:
- {fileID: 1752229547}
- {fileID: 1657212586}
m_Father: {fileID: 0}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &1939846702 stripped
RectTransform:
@ -5489,7 +5520,6 @@ RectTransform:
m_Children:
- {fileID: 1973511928}
m_Father: {fileID: 920935813}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
@ -5698,7 +5728,6 @@ RectTransform:
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 1952680462}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -5844,13 +5873,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2028539469}
serializedVersion: 2
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: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2038508982
PrefabInstance:
@ -6058,6 +6087,74 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 69db74e98958f844faf6f9f1e2375043, type: 3}
--- !u!1001 &1588284869853455352
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 6742052861145951612, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_Name
value: Crate
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalPosition.x
value: 8
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalPosition.z
value: 4
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9142444727976197465, guid: 1a531e276d6ed5766a7e85e6d4642ff3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1a531e276d6ed5766a7e85e6d4642ff3, type: 3}
--- !u!1001 &3319954897312816834
PrefabInstance:
m_ObjectHideFlags: 0
@ -6340,3 +6437,33 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 4910748681285187440}
m_PrefabAsset: {fileID: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 330585546}
- {fileID: 598754949}
- {fileID: 117986695}
- {fileID: 275919989}
- {fileID: 410087041}
- {fileID: 832575519}
- {fileID: 3319954897312816834}
- {fileID: 1051832114}
- {fileID: 1917598936}
- {fileID: 1491138602}
- {fileID: 2028539471}
- {fileID: 506381888}
- {fileID: 36003320}
- {fileID: 967329132}
- {fileID: 606110264}
- {fileID: 537492067}
- {fileID: 1867005304}
- {fileID: 1222726811}
- {fileID: 1848247811}
- {fileID: 366831943}
- {fileID: 656768580}
- {fileID: 18574386}
- {fileID: 1128788156}
- {fileID: 989818458}
- {fileID: 1588284869853455352}
- {fileID: 1482581177}

@ -0,0 +1,16 @@
using System;
using Grid;
using UnityEngine;
public class DestructableCrate : MonoBehaviour {
public GridPosition GridPosition { get; private set; }
private void Start() => GridPosition = LevelGrid.Instance.GetGridPosition(transform.position);
public static event EventHandler OnAnyDestroyed;
public void Damage() {
Destroy(gameObject);
OnAnyDestroyed?.Invoke(this, EventArgs.Empty);
}
}

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 32368030487579a3b947bd9853c5e9e5

@ -36,6 +36,7 @@ public class GrenadeProjectile : MonoBehaviour {
Collider[] hitColliderArray = Physics.OverlapSphere(targetPosition, damageRadius);
foreach (Collider hitCollider in hitColliderArray) {
if (hitCollider.TryGetComponent(out Unit targetUnit)) targetUnit.Damage(30);
if (hitCollider.TryGetComponent(out DestructableCrate destructableCrate)) destructableCrate.Damage();
}
OnAnyGrenadeExploded?.Invoke(this, EventArgs.Empty);

@ -4,153 +4,157 @@ using Grid;
using UnityEngine;
public class Pathfinding : MonoBehaviour {
private const int moveStraightCost = 10;
private const int moveDiagonalCost = 14;
[SerializeField] private Transform gridDebugObjectPrefab;
[SerializeField] private LayerMask obstaclesLayerMask;
public static Pathfinding Instance { get; private set; }
private GridSystem<PathNode> GridSystem { get; set; }
private int Width { get; set;}
private int Height { get; set; }
public float CellSize { get; private set;}
private const float raycastOffsetDistance = 5f;
public void Setup(int width, int height, float cellSize) {
Width = width;
Height = height;
CellSize = cellSize;
GridSystem = new(width, height, cellSize, (_, gridPosition) => new(gridPosition));
// GridSystem.CreateDebugObjects(gridDebugObjectPrefab);
for (int x = 0; x < Width; x++) {
for (int z = 0; z < Height; z++) {
GridPosition gridPosition = new(x, z);
Vector3 worldPosition = LevelGrid.Instance.GetWorldPosition(gridPosition);
if (Physics.Raycast(worldPosition + Vector3.down * raycastOffsetDistance, Vector3.up, raycastOffsetDistance * 2, obstaclesLayerMask)) {
GetNode(x, z).IsWalkable = false;
}
}
}
}
public bool IsWalkableGridPosition(GridPosition gridPosition) => GridSystem.GetGridObject(gridPosition).IsWalkable;
private void Awake() {
if (Instance is not null) {
Debug.LogError($"There is more than one Pathfinding! {transform} - {Instance}");
Destroy(gameObject);
return;
}
Instance = this;
}
public List<GridPosition> FindPath(GridPosition startGridPosition, GridPosition endGridPosition, out int pathLength) {
List<PathNode> openList = new();
List<PathNode> closedList = new();
PathNode startNode = GridSystem.GetGridObject(startGridPosition);
PathNode endNode = GridSystem.GetGridObject(endGridPosition);
openList.Add(startNode);
for (int x = 0; x < GridSystem.Width; x++) {
for (int z = 0; z < GridSystem.Height; z++) {
PathNode pathNode = GridSystem.GetGridObject(new(x, z));
pathNode.GCost = int.MaxValue;
pathNode.HCost = 0;
pathNode.CameFromPathNode = null;
}
}
startNode.GCost = 0;
startNode.HCost = CalculateDistance(startGridPosition, endGridPosition);
while (openList.Count > 0) {
PathNode currentNode = GetLowestFCostPathNode(openList);
if (currentNode == endNode) { // Reached final node
pathLength = endNode.FCost;
return CalculatePath(endNode);
}
openList.Remove(currentNode);
closedList.Add(currentNode); //currentNode is tested
foreach (PathNode neighbourNode in GetNeighbourList(currentNode).Where(neighbourNode => !closedList.Contains(neighbourNode))) {
if (!neighbourNode.IsWalkable) {
closedList.Add(neighbourNode); // Not walkable
continue;
}
int tentativeGCost = currentNode.GCost + CalculateDistance(currentNode.GridPosition, neighbourNode.GridPosition);
if (tentativeGCost >= neighbourNode.GCost) continue;
neighbourNode.CameFromPathNode = currentNode;
neighbourNode.GCost = tentativeGCost;
neighbourNode.HCost = CalculateDistance(neighbourNode.GridPosition, endGridPosition);
if (!openList.Contains(neighbourNode)) openList.Add(neighbourNode);
}
}
pathLength = 0; //no path found
return null;
}
private static int CalculateDistance(GridPosition gridPositionA, GridPosition gridPositionB) {
GridPosition gridPositionDistance = gridPositionA - gridPositionB;
int xDistance = Mathf.Abs(gridPositionDistance.X);
int zDistance = Mathf.Abs(gridPositionDistance.Z);
int remaining = Mathf.Abs(xDistance - zDistance);
return moveDiagonalCost * Mathf.Min(xDistance, zDistance) + moveStraightCost * remaining;
}
private static PathNode GetLowestFCostPathNode(IReadOnlyList<PathNode> pathNodeList) {
PathNode lowestFCostPathNode = pathNodeList[0];
foreach (PathNode currentPathNode in pathNodeList.Where(t => t.FCost < lowestFCostPathNode.FCost)) lowestFCostPathNode = currentPathNode;
return lowestFCostPathNode;
}
private IEnumerable<PathNode> GetNeighbourList(PathNode currentNode) {
List<PathNode> neighbourList = new();
GridPosition gridPosition = currentNode.GridPosition;
if (gridPosition.X - 1 >= 0) {
neighbourList.Add(GetNode(gridPosition.X - 1, gridPosition.Z + 0)); //Left
if (gridPosition.Z - 1 >= 0) neighbourList.Add(GetNode(gridPosition.X - 1, gridPosition.Z - 1)); //LeftDown
if (gridPosition.Z < GridSystem.Height) neighbourList.Add(GetNode(gridPosition.X - 1, gridPosition.Z + 1)); //LeftUp
}
if (gridPosition.X + 1 < GridSystem.Width) {
neighbourList.Add(GetNode(gridPosition.X + 1, gridPosition.Z + 0)); //Right
if (gridPosition.Z - 1 >= 0) neighbourList.Add(GetNode(gridPosition.X + 1, gridPosition.Z - 1)); //RightDown
if (gridPosition.Z + 1 < GridSystem.Height) neighbourList.Add(GetNode(gridPosition.X + 1, gridPosition.Z + 1)); //RightUp
}
if (gridPosition.Z - 1 >= 0) neighbourList.Add(GetNode(gridPosition.X - 0, gridPosition.Z - 1)); //Down
if (gridPosition.Z + 1 < GridSystem.Height) neighbourList.Add(GetNode(gridPosition.X - 0, gridPosition.Z + 1)); //Up
return neighbourList;
}
private PathNode GetNode(int x, int z) => GridSystem.GetGridObject(new(x, z));
private static List<GridPosition> CalculatePath(PathNode endNode) {
List<PathNode> pathNodeList = new() { endNode };
PathNode currentNode = endNode;
while (currentNode.CameFromPathNode != null) {
pathNodeList.Add(currentNode.CameFromPathNode);
currentNode = currentNode.CameFromPathNode;
}
pathNodeList.Reverse();
return pathNodeList.Select(pathNode => pathNode.GridPosition).ToList();
}
public bool HasPath(GridPosition startGridPosition, GridPosition endGridPosition) => FindPath(startGridPosition, endGridPosition, out _) != null;
public int GetPathLength(GridPosition startGridPosition, GridPosition endGridPosition) {
FindPath(startGridPosition, endGridPosition, out int pathLength);
return pathLength;
}
private const int moveStraightCost = 10;
private const int moveDiagonalCost = 14;
private const float raycastOffsetDistance = 5f;
[SerializeField] private Transform gridDebugObjectPrefab;
[SerializeField] private LayerMask obstaclesLayerMask;
public static Pathfinding Instance { get; private set; }
private GridSystem<PathNode> GridSystem { get; set; }
private int Width { get; set; }
private int Height { get; set; }
public float CellSize { get; private set; }
private void Awake() {
if (Instance is not null) {
Debug.LogError($"There is more than one Pathfinding! {transform} - {Instance}");
Destroy(gameObject);
return;
}
Instance = this;
}
public void Setup(int width, int height, float cellSize) {
Width = width;
Height = height;
CellSize = cellSize;
GridSystem = new(width, height, cellSize, (_, gridPosition) => new(gridPosition));
// GridSystem.CreateDebugObjects(gridDebugObjectPrefab);
for (int x = 0; x < Width; x++) {
for (int z = 0; z < Height; z++) {
GridPosition gridPosition = new(x, z);
Vector3 worldPosition = LevelGrid.Instance.GetWorldPosition(gridPosition);
if (Physics.Raycast(worldPosition + Vector3.down * raycastOffsetDistance, Vector3.up, raycastOffsetDistance * 2, obstaclesLayerMask)) {
GetNode(x, z).IsWalkable = false;
}
}
}
}
public bool IsWalkableGridPosition(GridPosition gridPosition) => GridSystem.GetGridObject(gridPosition).IsWalkable;
public void SetWalkableGridPosition(GridPosition gridPosition, bool isWalkable) => GridSystem.GetGridObject(gridPosition).IsWalkable = isWalkable;
public List<GridPosition> FindPath(GridPosition startGridPosition, GridPosition endGridPosition, out int pathLength) {
List<PathNode> openList = new();
List<PathNode> closedList = new();
PathNode startNode = GridSystem.GetGridObject(startGridPosition);
PathNode endNode = GridSystem.GetGridObject(endGridPosition);
openList.Add(startNode);
for (int x = 0; x < GridSystem.Width; x++) {
for (int z = 0; z < GridSystem.Height; z++) {
PathNode pathNode = GridSystem.GetGridObject(new(x, z));
pathNode.GCost = int.MaxValue;
pathNode.HCost = 0;
pathNode.CameFromPathNode = null;
}
}
startNode.GCost = 0;
startNode.HCost = CalculateDistance(startGridPosition, endGridPosition);
while (openList.Count > 0) {
PathNode currentNode = GetLowestFCostPathNode(openList);
if (currentNode == endNode) {
// Reached final node
pathLength = endNode.FCost;
return CalculatePath(endNode);
}
openList.Remove(currentNode);
closedList.Add(currentNode); //currentNode is tested
foreach (PathNode neighbourNode in GetNeighbourList(currentNode).Where(neighbourNode => !closedList.Contains(neighbourNode))) {
if (!neighbourNode.IsWalkable) {
closedList.Add(neighbourNode); // Not walkable
continue;
}
int tentativeGCost = currentNode.GCost + CalculateDistance(currentNode.GridPosition, neighbourNode.GridPosition);
if (tentativeGCost >= neighbourNode.GCost) continue;
neighbourNode.CameFromPathNode = currentNode;
neighbourNode.GCost = tentativeGCost;
neighbourNode.HCost = CalculateDistance(neighbourNode.GridPosition, endGridPosition);
if (!openList.Contains(neighbourNode)) openList.Add(neighbourNode);
}
}
pathLength = 0; //no path found
return null;
}
private static int CalculateDistance(GridPosition gridPositionA, GridPosition gridPositionB) {
GridPosition gridPositionDistance = gridPositionA - gridPositionB;
int xDistance = Mathf.Abs(gridPositionDistance.X);
int zDistance = Mathf.Abs(gridPositionDistance.Z);
int remaining = Mathf.Abs(xDistance - zDistance);
return moveDiagonalCost * Mathf.Min(xDistance, zDistance) + moveStraightCost * remaining;
}
private static PathNode GetLowestFCostPathNode(IReadOnlyList<PathNode> pathNodeList) {
PathNode lowestFCostPathNode = pathNodeList[0];
foreach (PathNode currentPathNode in pathNodeList.Where(t => t.FCost < lowestFCostPathNode.FCost)) lowestFCostPathNode = currentPathNode;
return lowestFCostPathNode;
}
private IEnumerable<PathNode> GetNeighbourList(PathNode currentNode) {
List<PathNode> neighbourList = new();
GridPosition gridPosition = currentNode.GridPosition;
if (gridPosition.X - 1 >= 0) {
neighbourList.Add(GetNode(gridPosition.X - 1, gridPosition.Z + 0)); //Left
if (gridPosition.Z - 1 >= 0) neighbourList.Add(GetNode(gridPosition.X - 1, gridPosition.Z - 1)); //LeftDown
if (gridPosition.Z < GridSystem.Height) neighbourList.Add(GetNode(gridPosition.X - 1, gridPosition.Z + 1)); //LeftUp
}
if (gridPosition.X + 1 < GridSystem.Width) {
neighbourList.Add(GetNode(gridPosition.X + 1, gridPosition.Z + 0)); //Right
if (gridPosition.Z - 1 >= 0) neighbourList.Add(GetNode(gridPosition.X + 1, gridPosition.Z - 1)); //RightDown
if (gridPosition.Z + 1 < GridSystem.Height) neighbourList.Add(GetNode(gridPosition.X + 1, gridPosition.Z + 1)); //RightUp
}
if (gridPosition.Z - 1 >= 0) neighbourList.Add(GetNode(gridPosition.X - 0, gridPosition.Z - 1)); //Down
if (gridPosition.Z + 1 < GridSystem.Height) neighbourList.Add(GetNode(gridPosition.X - 0, gridPosition.Z + 1)); //Up
return neighbourList;
}
private PathNode GetNode(int x, int z) => GridSystem.GetGridObject(new(x, z));
private static List<GridPosition> CalculatePath(PathNode endNode) {
List<PathNode> pathNodeList = new() { endNode };
PathNode currentNode = endNode;
while (currentNode.CameFromPathNode != null) {
pathNodeList.Add(currentNode.CameFromPathNode);
currentNode = currentNode.CameFromPathNode;
}
pathNodeList.Reverse();
return pathNodeList.Select(pathNode => pathNode.GridPosition).ToList();
}
public bool HasPath(GridPosition startGridPosition, GridPosition endGridPosition) => FindPath(startGridPosition, endGridPosition, out _) != null;
public int GetPathLength(GridPosition startGridPosition, GridPosition endGridPosition) {
FindPath(startGridPosition, endGridPosition, out int pathLength);
return pathLength;
}
}

@ -0,0 +1,11 @@
using System;
using UnityEngine;
public class PathfindingUpdater : MonoBehaviour {
private void Start() => DestructableCrate.OnAnyDestroyed += DestructableCrate_OnAnyDestroyed;
private void DestructableCrate_OnAnyDestroyed(object sender, EventArgs e) {
DestructableCrate destructableCrate = sender as DestructableCrate;
if (destructableCrate != null) Pathfinding.Instance.SetWalkableGridPosition(destructableCrate.GridPosition, true);
}
}

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e4ef9594717ee8cea96e618ce3530b01

@ -26,14 +26,6 @@ MonoBehaviour:
BlurQuality: 0
Falloff: 200
SampleCount: -1
m_BlueNoise256Textures:
- {fileID: 2800000, guid: 36f118343fc974119bee3d09e2111500, type: 3}
- {fileID: 2800000, guid: 4b7b083e6b6734e8bb2838b0b50a0bc8, type: 3}
- {fileID: 2800000, guid: c06cc21c692f94f5fb5206247191eeee, type: 3}
- {fileID: 2800000, guid: cb76dd40fa7654f9587f6a344f125c9a, type: 3}
- {fileID: 2800000, guid: e32226222ff144b24bf3a5a451de54bc, type: 3}
- {fileID: 2800000, guid: 3302065f671a8450b82c9ddf07426f3a, type: 3}
- {fileID: 2800000, guid: 56a77a3e8d64f47b6afe9e3c95cb57d5, type: 3}
m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
--- !u!114 &11400000
MonoBehaviour:
@ -87,7 +79,9 @@ MonoBehaviour:
blitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf,
type: 3}
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
screenSpaceLensFlare: {fileID: 4800000, guid: 701880fecb344ea4c9cd0db3407ab287,
type: 3}
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
type: 3}
m_AssetVersion: 2
m_OpaqueLayerMask:

@ -0,0 +1,7 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!655991488 &1
MultiplayerManager:
m_ObjectHideFlags: 0
m_EnableMultiplayerRoles: 0
m_ActiveMultiplayerRole: 0

@ -1,2 +1,2 @@
m_EditorVersion: 2023.2.0a18
m_EditorVersionWithRevision: 2023.2.0a18 (6ece69ab7d2d)
m_EditorVersion: 2023.2.0a19
m_EditorVersionWithRevision: 2023.2.0a19 (cab10490cda3)