Refactor player and enemy scripts; remove unused classes and improve initialization

- Added base initialization call in PlayerController.
- Changed player reference in EnemyAI to be serialized for better inspector visibility.
- Ensured characters are initialized upon spawning in EnemySpawner.
- Removed obsolete EnemyAI and Chest scripts to streamline codebase.
- Added KeyChest script for key collection functionality.
- Introduced new meta files for better organization and tracking.
- Created launch configuration for Unity debugging.
This commit is contained in:
2026-06-20 18:39:30 +03:00
parent 39e4e51866
commit ad6388f330
41 changed files with 200 additions and 786 deletions
+1 -1
View File
@@ -56,5 +56,5 @@
"temp/": true,
"Temp/": true
},
"dotnet.defaultSolution": "Gnome-s-Bounty.sln"
"dotnet.defaultSolution": "Gnome-s-Bounty.slnx"
}
+14
View File
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Unity Debugger",
"type": "vstuc",
"request": "attach",
"projectPath": "${workspaceFolder}"
}
]
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 690a6b37d2b97044c8a4ecda9dce6e90
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ef7a187ce6bfdac4981745e075218235
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d17a53f2be7d3024099b8777f2cad4f3
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+78 -47
View File
@@ -23,6 +23,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 525276400490168249}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.09184216, w: 0.9957736}
m_LocalPosition: {x: 0.47947475, y: -0.00000021830333, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -30,7 +31,6 @@ Transform:
m_Children:
- {fileID: 5811801674564757355}
m_Father: {fileID: 149515315115441635}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &590046316339313264
GameObject:
@@ -55,6 +55,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 590046316339313264}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: 0.99474037, w: 0.10242856}
m_LocalPosition: {x: -0.20894979, y: 0.38865167, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -62,7 +63,6 @@ Transform:
m_Children:
- {fileID: 8606358469749982917}
m_Father: {fileID: 5409087674303824736}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1048667121803717404
GameObject:
@@ -87,6 +87,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1048667121803717404}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: -0.023249827, w: 0.9997297}
m_LocalPosition: {x: 0.6376417, y: 0.00000042807014, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -94,7 +95,6 @@ Transform:
m_Children:
- {fileID: 4494365837907247844}
m_Father: {fileID: 3749092455360134069}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1379018652768465447
GameObject:
@@ -119,6 +119,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379018652768465447}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: 0.99914443, w: 0.04135808}
m_LocalPosition: {x: -0.22025129, y: 0.55852884, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -126,7 +127,6 @@ Transform:
m_Children:
- {fileID: 9076224404461001490}
m_Father: {fileID: 8722232351462507904}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1684972463766630675
GameObject:
@@ -151,6 +151,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1684972463766630675}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: -0.9903529, w: 0.13856821}
m_LocalPosition: {x: -0.1975428, y: -1.0538633, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -158,7 +159,6 @@ Transform:
m_Children:
- {fileID: 2756356993697668737}
m_Father: {fileID: 6160691679832178371}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2247490675390607940
GameObject:
@@ -185,6 +185,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2247490675390607940}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.15, y: 0.15, z: 1}
@@ -192,10 +193,10 @@ Transform:
m_Children:
- {fileID: 5409087674303824736}
m_Father: {fileID: 965998752200834250}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &4922846619610810103
SpriteRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@@ -211,6 +212,11 @@ SpriteRenderer:
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@@ -232,9 +238,11 @@ SpriteRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 769195415
m_SortingLayer: 3
m_SortingOrder: 0
m_MaskInteraction: 0
m_Sprite: {fileID: 21300000, guid: 0b4e399229ec6ed4589eb9528207a93c, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
@@ -244,7 +252,6 @@ SpriteRenderer:
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &578132144104610540
MonoBehaviour:
@@ -277,6 +284,7 @@ MonoBehaviour:
m_Extent: {x: 2.226488, y: 3.0990145, z: 0}
m_AlwaysUpdate: 1
m_AutoRebind: 0
m_BoundsMode: 0
--- !u!1 &2837046599248874372
GameObject:
m_ObjectHideFlags: 0
@@ -300,6 +308,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2837046599248874372}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: -0.9832774, w: 0.18211432}
m_LocalPosition: {x: -0.060810946, y: -1.0876046, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -307,7 +316,6 @@ Transform:
m_Children:
- {fileID: 483243375220992577}
m_Father: {fileID: 8741895741083448917}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2929943258134430666
GameObject:
@@ -332,6 +340,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2929943258134430666}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: -0.15674467, w: 0.9876392}
m_LocalPosition: {x: 0.4865658, y: 0.0000000197559, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -339,7 +348,6 @@ Transform:
m_Children:
- {fileID: 6708163568375327027}
m_Father: {fileID: 5184328514781748300}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3156624200786225141
GameObject:
@@ -364,6 +372,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3156624200786225141}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.7502857, w: 0.66111374}
m_LocalPosition: {x: -0.3528076, y: -1.0293695, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -373,7 +382,6 @@ Transform:
- {fileID: 5750085072733903937}
- {fileID: 3749092455360134069}
m_Father: {fileID: 6530722701964707747}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3562860463672206540
GameObject:
@@ -398,6 +406,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3562860463672206540}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: -0.09895403, w: 0.99509203}
m_LocalPosition: {x: 2.327806, y: -0.000000193034, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -406,7 +415,6 @@ Transform:
- {fileID: 1571570198703180397}
- {fileID: 4539143858996250498}
m_Father: {fileID: 8722232351462507904}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3751187032616059201
GameObject:
@@ -431,13 +439,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3751187032616059201}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.28566867, w: 0.9583285}
m_LocalPosition: {x: 1.179587, y: 0.00000043012486, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4539143858996250498}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3931708971405200045
GameObject:
@@ -451,6 +459,7 @@ GameObject:
- component: {fileID: 1716637651858965058}
- component: {fileID: 1693252312754102175}
- component: {fileID: 2957004661200399871}
- component: {fileID: 5052316995701538626}
m_Layer: 7
m_Name: Player
m_TagString: Player
@@ -465,6 +474,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3931708971405200045}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -8.5, y: 3.5020008, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -475,11 +485,10 @@ Transform:
- {fileID: 4870077556839958209}
- {fileID: 8164636389946526648}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &1716637651858965058
Rigidbody2D:
serializedVersion: 4
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@@ -490,8 +499,8 @@ Rigidbody2D:
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0
m_LinearDamping: 0
m_AngularDamping: 0
m_GravityScale: 1
m_Material: {fileID: 0}
m_IncludeLayers:
@@ -513,23 +522,21 @@ MonoBehaviour:
m_GameObject: {fileID: 3931708971405200045}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9c83b0150e991b443858a82f5a1eea57, type: 3}
m_Script: {fileID: 11500000, guid: 41c6c94d439ebee4a885826d8ddc05a1, type: 3}
m_Name:
m_EditorClassIdentifier:
_animator: {fileID: 2957004661200399871}
MovementSpeed: 2.5
_bonesSide: {fileID: 9145485872817117069}
_bonesBack: {fileID: 2247490675390607940}
_movementSpeed: 1.5
_bonesSide: {fileID: 0}
_bonesBack: {fileID: 0}
_mapLayer:
serializedVersion: 2
m_Bits: 8
_hammerSpawnPoint: {fileID: 3706253573488771434}
_hammerPrefab: {fileID: 6648495433791226095, guid: 111653ffd63dcc64a91ceb9c5d52aa04, type: 3}
_regularSprite: {fileID: 21300000, guid: 618309f12a7ca8b47b9aac8c7e39fc07, type: 3}
_noHammerSprite: {fileID: 21300000, guid: c7266c68d1eb5a34882171399d35bba5, type: 3}
m_Bits: 0
_regularSprite: {fileID: 0}
_noHammerSprite: {fileID: 0}
--- !u!95 &2957004661200399871
Animator:
serializedVersion: 5
serializedVersion: 7
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@@ -543,11 +550,25 @@ Animator:
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_AnimatePhysics: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!114 &5052316995701538626
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3931708971405200045}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 907b91debf5d5864780e9466f4017f38, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PlayerState
Lives: 3
--- !u!1 &4504781120003423342
GameObject:
m_ObjectHideFlags: 0
@@ -572,13 +593,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4504781120003423342}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 2, y: 2, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 965998752200834250}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1064733234329867823
MonoBehaviour:
@@ -592,14 +613,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 073797afb82c5a1438f328866b10b3f0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ComponentVersion: 1
m_ComponentVersion: 2
m_LightType: 3
m_BlendStyleIndex: 0
m_FalloffIntensity: 0.88
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 1
m_LightVolumeIntensity: 1
m_LightVolumeIntensityEnabled: 0
m_LightVolumeEnabled: 0
m_ApplyToSortingLayers: 00000000413d3badebb708f897fdd82d8315a380
m_LightCookieSprite: {fileID: 0}
m_DeprecatedPointLightCookieSprite: {fileID: 0}
@@ -609,8 +630,10 @@ MonoBehaviour:
m_NormalMapDistance: 3
m_NormalMapQuality: 2
m_UseNormalMap: 0
m_ShadowIntensityEnabled: 0
m_ShadowsEnabled: 0
m_ShadowIntensity: 0.75
m_ShadowSoftness: 0
m_ShadowSoftnessFalloffIntensity: 0.5
m_ShadowVolumeIntensityEnabled: 0
m_ShadowVolumeIntensity: 0.75
m_LocalBounds:
@@ -649,13 +672,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4836804681656458181}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.101342775, w: 0.9948516}
m_LocalPosition: {x: 0.93103534, y: -0.00000006368785, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4952740246104246303}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5387503814025257401
GameObject:
@@ -680,6 +703,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5387503814025257401}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.005233225, w: 0.99998635}
m_LocalPosition: {x: 2.0614116, y: -0.00000060878057, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -688,7 +712,6 @@ Transform:
- {fileID: 4952740246104246303}
- {fileID: 7829894871118864405}
m_Father: {fileID: 5409087674303824736}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5442148817883688667
GameObject:
@@ -713,13 +736,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5442148817883688667}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: -0.1976952, w: 0.9802636}
m_LocalPosition: {x: 1.0464991, y: 0.0000005377195, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7829894871118864405}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5654979082866581916
GameObject:
@@ -744,6 +767,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5654979082866581916}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: 0.9924879, w: 0.12234307}
m_LocalPosition: {x: -0.060306497, y: 1.1242787, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -751,7 +775,6 @@ Transform:
m_Children:
- {fileID: 6588206840087870389}
m_Father: {fileID: 8741895741083448917}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5891751492924946482
GameObject:
@@ -776,13 +799,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5891751492924946482}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: -0.009432042, w: 0.9999556}
m_LocalPosition: {x: 0.52619857, y: -0.000000071975734, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8606358469749982917}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6370578819216229813
GameObject:
@@ -807,6 +830,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6370578819216229813}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: -0.08537734, w: 0.9963487}
m_LocalPosition: {x: 0.79349256, y: -0.0000003112512, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -814,7 +838,6 @@ Transform:
m_Children:
- {fileID: 5215692724244859341}
m_Father: {fileID: 5750085072733903937}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6935251069725712065
GameObject:
@@ -839,6 +862,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6935251069725712065}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: 0.9998863, w: 0.015082459}
m_LocalPosition: {x: -0.2367492, y: 0.9101865, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -846,7 +870,6 @@ Transform:
m_Children:
- {fileID: 2068465951755053273}
m_Father: {fileID: 6160691679832178371}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6974183028150816375
GameObject:
@@ -871,6 +894,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6974183028150816375}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: -0.98277175, w: 0.18482342}
m_LocalPosition: {x: -0.22916304, y: -0.5613261, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -878,7 +902,6 @@ Transform:
m_Children:
- {fileID: 9077912524209342039}
m_Father: {fileID: 5409087674303824736}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7100171284618724896
GameObject:
@@ -903,13 +926,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7100171284618724896}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.6197942, w: 0.78476447}
m_LocalPosition: {x: 0.8616789, y: 0.00000008766659, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 821236038366831682}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7532776947464835511
GameObject:
@@ -934,6 +957,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7532776947464835511}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: -0.99479717, w: 0.10187585}
m_LocalPosition: {x: -0.36137077, y: -0.4169112, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -941,7 +965,6 @@ Transform:
m_Children:
- {fileID: 821236038366831682}
m_Father: {fileID: 8722232351462507904}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7685356707740776633
GameObject:
@@ -966,13 +989,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7685356707740776633}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: -0.057277665, w: 0.9983583}
m_LocalPosition: {x: 0.56080276, y: -0.0000000634452, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 9077912524209342039}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7780229847895093112
GameObject:
@@ -997,13 +1020,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7780229847895093112}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.307, y: 0.006, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 965998752200834250}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &8433602964134334177
GameObject:
@@ -1028,13 +1051,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8433602964134334177}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.0051761256, w: 0.99998665}
m_LocalPosition: {x: 1.3512695, y: 0.00000011543891, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1571570198703180397}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &8448424677074956309
GameObject:
@@ -1059,6 +1082,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8448424677074956309}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.7145881, w: 0.6995455}
m_LocalPosition: {x: -0.041246947, y: -1.0994492, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -1068,7 +1092,6 @@ Transform:
- {fileID: 5184328514781748300}
- {fileID: 149515315115441635}
m_Father: {fileID: 8164636389946526648}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &8628940554944535785
GameObject:
@@ -1093,13 +1116,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8628940554944535785}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.75835073, w: 0.65184677}
m_LocalPosition: {x: 0.67761064, y: 0.00000001145022, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 9076224404461001490}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &9145485872817117069
GameObject:
@@ -1126,6 +1149,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9145485872817117069}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -0.05, z: 0}
m_LocalScale: {x: 0.14, y: 0.14, z: 0.14}
@@ -1133,10 +1157,10 @@ Transform:
m_Children:
- {fileID: 8722232351462507904}
m_Father: {fileID: 965998752200834250}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &6787737943033011046
SpriteRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@@ -1152,6 +1176,11 @@ SpriteRenderer:
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@@ -1173,9 +1202,11 @@ SpriteRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 769195415
m_SortingLayer: 3
m_SortingOrder: 0
m_MaskInteraction: 0
m_Sprite: {fileID: 21300000, guid: 618309f12a7ca8b47b9aac8c7e39fc07, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
@@ -1185,7 +1216,6 @@ SpriteRenderer:
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &8710076703627450349
MonoBehaviour:
@@ -1218,3 +1248,4 @@ MonoBehaviour:
m_Extent: {x: 0.411973, y: 0.41254616, z: 0}
m_AlwaysUpdate: 1
m_AutoRebind: 0
m_BoundsMode: 0
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1894a524a4002784fbf2d10e74478b33
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4d7148405c33f2f45ae0479592e8cb6e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -25,6 +25,7 @@ public class PlayerController : Character
_hammerThrower = GetComponent<HammerThrower>();
_inputManager.OnFire += OnFireButtonPressed;
base.Init();
}
private void OnEnable()
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 41c6c94d439ebee4a885826d8ddc05a1
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 239d5eb73385f2d4ea050bc2c19298a2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+2 -2
View File
@@ -24,7 +24,7 @@ public class EnemyAI : Character
private float _stunTimer = 0f;
private float _patrolDirection = 1f;
private static readonly Player _player = null;
[SerializeField] private Character _player = null;
public EnemyState CurrentState => _currentState;
@@ -58,7 +58,7 @@ public class EnemyAI : Character
}
// Get player position if available
var player = Player.Instance;
var player = _player;
if (player == null)
{
HandlePatrol();
+1
View File
@@ -40,6 +40,7 @@ public class EnemySpawner : MonoBehaviour
_respawnElementTimer = _respawnTimeout;
var prefab= Instantiate(_prefab, _spawnPoint.position, _spawnPoint.rotation);
var character=prefab.GetComponent<Character>();
character.Init();
character.OnCharacterDeath+=OnCharacterDeath;
_characters.Add(character);
-171
View File
@@ -1,171 +0,0 @@
using UnityEngine;
using System;
public enum EnemyState
{
Patrol,
Investigate,
Chase,
Stunned
}
public class EnemyAI : Character
{
[SerializeField] private float _patrolSpeed = 1f;
[SerializeField] private float _patrolRange = 5f;
[SerializeField] private float _investigateRange = 8f;
[SerializeField] private float _chaseRange = 10f;
[SerializeField] private float _stunDuration = 1f;
[SerializeField] private bool _debugMode = false;
private EnemyState _currentState = EnemyState.Patrol;
private Vector3 _patrolTarget;
private Vector3 _investigatePosition;
private float _stunTimer = 0f;
private float _patrolDirection = 1f;
private static readonly Player _player = null;
public EnemyState CurrentState => _currentState;
protected override void SetClimbingAnimation(bool isClimbing)
{
// Implement climbing animation if needed
}
protected override void SetWalkingAnimation(bool isWalking)
{
_animator.SetBool("Walk", isWalking);
}
private void Start()
{
_patrolTarget = transform.position;
SetState(EnemyState.Patrol);
}
private void Update()
{
// Update stun timer
if (_currentState == EnemyState.Stunned)
{
_stunTimer -= Time.deltaTime;
if (_stunTimer <= 0f)
{
SetState(EnemyState.Patrol);
}
return;
}
// Get player position if available
var player = Player.Instance;
if (player == null)
{
HandlePatrol();
return;
}
float distanceToPlayer = Vector3.Distance(transform.position, player.transform.position);
// State transitions
switch (_currentState)
{
case EnemyState.Patrol:
if (distanceToPlayer < _investigateRange)
{
SetState(EnemyState.Chase);
}
else
{
HandlePatrol();
}
break;
case EnemyState.Investigate:
if (distanceToPlayer < _chaseRange)
{
SetState(EnemyState.Chase);
}
else if (Vector3.Distance(transform.position, _investigatePosition) < 0.5f)
{
SetState(EnemyState.Patrol);
}
else
{
HandleInvestigate();
}
break;
case EnemyState.Chase:
if (distanceToPlayer > _chaseRange)
{
SetState(EnemyState.Patrol);
}
else
{
HandleChase(player.transform.position);
}
break;
}
}
private void SetState(EnemyState newState)
{
if (_currentState == newState)
return;
if (_debugMode)
Debug.Log($"[EnemyAI] State changed: {_currentState} -> {newState}");
_currentState = newState;
}
private void HandlePatrol()
{
// Simple back-and-forth patrol
if (Vector3.Distance(transform.position, _patrolTarget) < 0.3f)
{
_patrolDirection *= -1f;
_patrolTarget = transform.position + Vector3.right * _patrolRange * _patrolDirection;
}
float direction = _patrolTarget.x > transform.position.x ? 1f : -1f;
MoveTo(direction * _patrolSpeed, 0f);
}
private void HandleInvestigate()
{
float direction = _investigatePosition.x > transform.position.x ? 1f : -1f;
MoveTo(direction * _patrolSpeed, 0f);
}
private void HandleChase(Vector3 playerPosition)
{
float direction = playerPosition.x > transform.position.x ? 1f : -1f;
MoveTo(direction * _patrolSpeed, 0f);
}
public void OnNoise(Vector3 noisePosition)
{
if (_currentState == EnemyState.Stunned)
return;
if (_currentState != EnemyState.Chase)
{
_investigatePosition = noisePosition;
SetState(EnemyState.Investigate);
if (_debugMode)
Debug.Log($"[EnemyAI] Investigating noise at {noisePosition}");
}
}
public void OnHitByHammer(float stunDuration)
{
_stunTimer = stunDuration;
SetState(EnemyState.Stunned);
if (_debugMode)
Debug.Log($"[EnemyAI] Stunned for {stunDuration} seconds");
}
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: de0c7abb53bb1e645a77e9b03418ae21
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-52
View File
@@ -1,52 +0,0 @@
using UnityEngine;
public class Chest : MonoBehaviour
{
[SerializeField]
private Animator animator;
[SerializeField]
private TreasureSO _treasureSO;
private Transform _treasureObject;
private bool _isOpen = false;
private void Awake()
{
_treasureObject = transform.GetChild(1);
var spriteRenderer = _treasureObject.GetComponent<SpriteRenderer>();
spriteRenderer.sprite = _treasureSO.Image;
}
private void OnTriggerEnter2D(Collider2D collider)
{
var playerState = collider.GetComponent<PlayerState>();
if (playerState != null && !_isOpen)
{
_isOpen = true;
animator.SetTrigger("OpenChest");
switch (_treasureSO.Treasure)
{
case TreasureType.Coin:
playerState.AddCoin();
if (GameManager.Instance != null)
{
GameManager.Instance.AddTreasure(1);
}
break;
case TreasureType.Key:
playerState.SetKey();
if (GameManager.Instance != null)
{
GameManager.Instance.SetKeyState(true);
}
if (LevelManager.Instance != null)
{
LevelManager.Instance.NotifyKeyCollected();
}
break;
}
}
}
}
-2
View File
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: ded23e667cffbfd46b2633ae22204797
-63
View File
@@ -1,63 +0,0 @@
using Assets.Scripts;
using System;
using UnityEngine;
public class Door : MonoBehaviour, IDoor
{
[SerializeField]
private Sprite _openDoor;
[SerializeField]
private bool _debugMode = false;
private SpriteRenderer _spriteRenderer;
private BoxCollider2D _boxCollider;
private bool _isLocked = true;
public bool IsLocked => _isLocked;
public event EventHandler OnDoorOpened;
private void Awake()
{
_spriteRenderer = GetComponentInChildren<SpriteRenderer>();
_boxCollider = gameObject.GetComponent<BoxCollider2D>();
}
public void OpenDoor()
{
if (!_isLocked)
return;
_isLocked = false;
// Update visuals
if (_spriteRenderer != null && _openDoor != null)
{
_spriteRenderer.sprite = _openDoor;
}
// Disable collision
if (_boxCollider != null)
{
_boxCollider.enabled = false;
}
if (_debugMode)
Debug.Log("[Door] Door opened!");
OnDoorOpened?.Invoke(this, EventArgs.Empty);
}
public void LockDoor()
{
_isLocked = true;
if (_boxCollider != null)
{
_boxCollider.enabled = true;
}
if (_debugMode)
Debug.Log("[Door] Door locked!");
}
}
-2
View File
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: af69aa896ad8a3947947ed21a9b9cacd
@@ -1,45 +0,0 @@
using Assets.Scripts;
using UnityEngine;
public class DoorInteract : MonoBehaviour
{
[SerializeField] private GameObject _doorGameObject;
[SerializeField] private bool _debugMode = false;
private IDoor _door;
private bool _hasTriggered = false;
private void Awake()
{
_door = _doorGameObject.GetComponent<IDoor>();
}
private void OnTriggerEnter2D(Collider2D collider)
{
if (_hasTriggered)
return;
var playerState = collider.GetComponent<PlayerState>();
if (playerState != null)
{
// Check if player has key through GameManager
if (GameManager.Instance != null && GameManager.Instance.HasKey)
{
_hasTriggered = true;
if (_debugMode)
Debug.Log("[DoorInteract] Player exiting with key!");
// Notify LevelManager that level is complete
if (LevelManager.Instance != null)
{
LevelManager.Instance.NotifyLevelComplete();
}
}
else if (_debugMode)
{
Debug.Log("[DoorInteract] Player reached door but does not have key!");
}
}
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 73fd9f6c116c2de4ab3d773fbb908df4
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 87152ae05a4335f4cbf3907d245027eb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 86cce1993173eb04daddb1edd164da94
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,82 +0,0 @@
using UnityEngine;
public class BreakableWall : MapElement
{
[SerializeField] private float _noiseRadius = 10f;
[SerializeField] private bool _emitNoiseOnBreak = true;
private float _respawnElementTimer;
private int _respawnTimeout = 4;
private bool _needRespawn = false;
private bool _characterInRange = false;
private BoxCollider2D _boxCollider;
private SpriteRenderer _spriteRenderer;
[SerializeField]
private GameObject _hitParticles;
private void Start()
{
_respawnElementTimer = _respawnTimeout;
_boxCollider = GetComponent<BoxCollider2D>();
_spriteRenderer = GetComponentInChildren<SpriteRenderer>();
}
public override void Hit()
{
IsEnabled = false;
_boxCollider.isTrigger = true;
_spriteRenderer.enabled = IsEnabled;
Instantiate(_hitParticles, transform.position, Quaternion.identity);
// Emit noise when wall breaks
if (_emitNoiseOnBreak && NoiseSystem.Instance != null)
{
NoiseSystem.Instance.Emit(transform.position, _noiseRadius);
}
_respawnElementTimer = _respawnTimeout;
_needRespawn = true;
}
private void Update()
{
if (_needRespawn)
{
_respawnElementTimer -= Time.deltaTime;
if (_respawnElementTimer <= 0)
{
_respawnElementTimer = _respawnTimeout;
if (_characterInRange)
{
print("Character is dead");
}
IsEnabled = true;
_boxCollider.isTrigger = false;
_spriteRenderer.enabled = IsEnabled;
_needRespawn = false;
}
}
}
private void OnTriggerEnter2D(Collider2D collider)
{
var character = collider.GetComponent<Character>();
if (character)
{
_characterInRange = true;
}
}
private void OnTriggerExit2D(Collider2D collider)
{
var character = collider.GetComponent<Character>();
if (character)
{
_characterInRange = false;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d25d392c71acf0a43a02538234591802
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5b7fcd68a9cc8f64bbc27a6eb9ec68a1
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6f6373350bf47454e899b0333377f443
-97
View File
@@ -1,97 +0,0 @@
using UnityEngine;
public class Hammer : MonoBehaviour
{
[SerializeField] private float _lifespan = 5f;
[SerializeField] private float _stunDuration = 1f;
[SerializeField] private float _impactNoiseRadius = 10f;
[SerializeField] private bool _emitNoiseOnImpact = true;
private float _lifeTimer;
private Vector2 _velocity;
private bool _facingRight;
private Rigidbody2D _rigidbody;
private bool _hasCollided = false;
private void Awake()
{
_rigidbody = GetComponent<Rigidbody2D>();
_lifeTimer = _lifespan;
}
public void Initialize(bool facingRight, float speed)
{
_facingRight = facingRight;
_velocity = new Vector2(facingRight ? speed : -speed, 0);
if (_rigidbody != null)
{
_rigidbody.linearVelocity = _velocity;
}
}
private void Update()
{
// Self-destruct after lifespan expires
_lifeTimer -= Time.deltaTime;
if (_lifeTimer <= 0)
{
Destroy(gameObject);
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (_hasCollided)
return;
_hasCollided = true;
// Check for enemy collision (stun)
var enemy = collision.gameObject.GetComponent<Character>();
if (enemy != null)
{
HandleEnemyCollision(enemy, collision.relativeVelocity);
EmitImpactNoise(collision.GetContact(0).point);
Destroy(gameObject);
return;
}
// Check for breakable wall collision
var mapElement = collision.collider.GetComponent<MapElement>();
if (mapElement != null && mapElement is BreakableWall)
{
mapElement.Hit();
EmitImpactNoise(collision.GetContact(0).point);
Destroy(gameObject);
return;
}
// Fallback: destroy on any collision
EmitImpactNoise(collision.GetContact(0).point);
Destroy(gameObject);
}
private void HandleEnemyCollision(Character enemy, Vector2 impactVelocity)
{
// Apply stun to enemy
var enemyAI = enemy as EnemyAI;
if (enemyAI != null)
{
enemyAI.OnHitByHammer(_stunDuration);
}
}
private void EmitImpactNoise(Vector2 position)
{
if (!_emitNoiseOnImpact)
return;
// Check if NoiseSystem exists and emit noise
var noiseSystem = NoiseSystem.Instance;
if (noiseSystem != null)
{
noiseSystem.Emit(position, _impactNoiseRadius);
}
}
}
-69
View File
@@ -1,69 +0,0 @@
using System;
using UnityEngine;
public class HammerThrower : MonoBehaviour
{
[SerializeField] private Transform _spawnPoint;
[SerializeField] private GameObject _hammerPrefab;
[SerializeField] private float _throwSpeed = 5f;
[SerializeField] private float _throwCooldown = 1.5f;
private GameObject _currentHammer;
private bool _hasHammer = true;
private bool _facingRight = true;
private float _cooldownTimer = 0f;
public bool HasHammer => _hasHammer;
public bool CanThrow => _hasHammer && _cooldownTimer <= 0f;
public float CooldownRemaining => Mathf.Max(0f, _cooldownTimer);
public void SetFacingDirection(bool facingRight)
{
_facingRight = facingRight;
}
public bool TryThrowHammer()
{
if (!CanThrow)
return false;
ThrowHammer();
return true;
}
private void ThrowHammer()
{
_hasHammer = false;
_cooldownTimer = _throwCooldown;
_currentHammer = Instantiate(_hammerPrefab, _spawnPoint.position, _spawnPoint.rotation);
// Initialize hammer with direction and speed
var hammerComponent = _currentHammer.GetComponent<Hammer>();
if (hammerComponent != null)
{
hammerComponent.Initialize(_facingRight, _throwSpeed);
}
// Flip hammer visual based on direction
_currentHammer.transform.localScale = new Vector2(
_currentHammer.transform.localScale.x * (_facingRight ? 1 : -1),
_currentHammer.transform.localScale.y
);
}
private void Update()
{
// Update cooldown timer
if (_cooldownTimer > 0f)
{
_cooldownTimer -= Time.deltaTime;
}
// Hammer destroyed → hammer returned
if (!_hasHammer && _currentHammer == null)
{
_hasHammer = true;
}
}
}
-37
View File
@@ -1,37 +0,0 @@
using UnityEngine;
public class KeyChest : MonoBehaviour
{
private bool _isOpened = false;
private void OnTriggerEnter2D(Collider2D collider)
{
if (_isOpened)
return;
var playerState = collider.GetComponent<PlayerState>();
if (playerState != null)
{
_isOpened = true;
// Update player state
playerState.SetKey();
// Notify GameManager of key collection
if (GameManager.Instance != null)
{
GameManager.Instance.SetKeyState(true);
}
// Notify LevelManager of key collection
if (LevelManager.Instance != null)
{
LevelManager.Instance.NotifyKeyCollected();
}
// Destroy the chest
Destroy(gameObject);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8f37247791475bc4bb2887347a0f905a
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 95776c7bbfb13d646b34788f8187536f
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 897c2741fe0100e4990a32480e24d9ae
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f581a5f2ca3d85c4e802df5ab7e0968b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-102
View File
@@ -1,102 +0,0 @@
using System;
using UnityEngine;
public class PlayerController : Character
{
[SerializeField]
private Sprite _regularSprite;
[SerializeField]
private Sprite _noHammerSprite;
private GameObject _hammer;
private bool _isHoldingHammer = true;
public event EventHandler<TreasureType> OnPlayerTakeItem;
private InputManager _inputManager;
private PlayerState _playerState;
private HammerThrower _hammerThrower;
private void Awake()
{
_inputManager = GetComponent<InputManager>();
_playerState = GetComponent<PlayerState>();
_hammerThrower = GetComponent<HammerThrower>();
_inputManager.OnFire += OnFireButtonPressed;
}
private void OnEnable()
{
_inputManager.OnEnable();
}
private void OnDisable()
{
_inputManager.OnDisable();
}
private void Update()
{
if (_hammer == null && !_isHoldingHammer)
{
_spriteRenderer.sprite = _regularSprite;
_isHoldingHammer = true;
}
Vector2 move = _inputManager.Movement;
MoveTo(move.x, isAllowVertical ? move.y : 0);
_hammerThrower.SetFacingDirection(_facingRight);
}
private void OnFireButtonPressed()
{
if (_hammerThrower.CanThrow)
{
_animator.SetTrigger("Body_ThrowHammer");
}
}
// Animation event
public void ThrowHammerObject()
{
_hammerThrower.TryThrowHammer();
UpdatePlayerSprite();
}
private void UpdatePlayerSprite()
{
_spriteRenderer.sprite = _hammerThrower.HasHammer
? _regularSprite
: _noHammerSprite;
}
protected override void SetWalkingAnimation(bool isWalking)
{
_bonesBack.SetActive(false);
_bonesSide.SetActive(true);
_animator.SetBool("Legs_Walk", isWalking);
_animator.SetBool("Body_Walk", isWalking);
}
protected override void SetClimbingAnimation(bool isClimbing)
{
if (isClimbing)
{
_bonesBack.SetActive(true);
_bonesSide.SetActive(false);
}
_animator.SetBool("Climb", isClimbing);
}
protected void OnDeath()
{
_playerState.Lives--;
if (_playerState.Lives == 0)
{
Debug.Log("Game over");
}
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 9c83b0150e991b443858a82f5a1eea57
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2f79ba21609b9ec4e8dc6985c2ec27f5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+1 -1
View File
@@ -37,7 +37,7 @@ public abstract class Character : MonoBehaviour
public event EventHandler OnCharacterDeath;
private void Start()
public void Init()
{
_body = GetComponent<Rigidbody2D>();
_capsuleCollider = GetComponent<CapsuleCollider2D>();
+3
View File
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Assembly-CSharp.csproj" />
</Solution>