From a0bfc600efcf65b886df2591929cfeef35bcff7d Mon Sep 17 00:00:00 2001 From: sylvermyon Date: Tue, 9 Jun 2026 18:46:33 -0700 Subject: [PATCH] moved stuff to a different entity script --- Assets/Prefabs/Projectile.prefab | 9 + Assets/Prefabs/Reisen.prefab | 87 +++++++++- Assets/Prefabs/ShootBullet.prefab | 3 +- Assets/Prefabs/Youmu.prefab | 185 +++++++++++++++++++-- Assets/Scenes/Prototype.unity | 253 ++++++++++++++++------------- Assets/Scripts/Ability.cs | 12 +- Assets/Scripts/AutomatedPlayer.cs | 26 ++- Assets/Scripts/Enemy.cs | 12 +- Assets/Scripts/Entity.cs | 37 +---- Assets/Scripts/EntityStats.cs | 42 +++++ Assets/Scripts/EntityStats.cs.meta | 2 + Assets/Scripts/Player.cs | 14 +- Assets/Scripts/Projectile.cs | 2 +- Assets/Scripts/ShootBullet.cs | 2 +- 14 files changed, 497 insertions(+), 189 deletions(-) create mode 100644 Assets/Scripts/EntityStats.cs create mode 100644 Assets/Scripts/EntityStats.cs.meta diff --git a/Assets/Prefabs/Projectile.prefab b/Assets/Prefabs/Projectile.prefab index a1b15e1..fd3c690 100644 --- a/Assets/Prefabs/Projectile.prefab +++ b/Assets/Prefabs/Projectile.prefab @@ -94,6 +94,15 @@ TrailRenderer: weightedMode: 0 inWeight: 0.33333334 outWeight: 0.33333334 + - serializedVersion: 3 + time: 0.88578373 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 diff --git a/Assets/Prefabs/Reisen.prefab b/Assets/Prefabs/Reisen.prefab index af25033..6cb6fb9 100644 --- a/Assets/Prefabs/Reisen.prefab +++ b/Assets/Prefabs/Reisen.prefab @@ -29,7 +29,8 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.2, y: 0.2, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 6298566175391005934} m_Father: {fileID: 1849759059644475718} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &4897167667714073556 @@ -87,6 +88,37 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &4860917236126221086 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6298566175391005934} + m_Layer: 7 + m_Name: AttackPoint + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6298566175391005934 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4860917236126221086} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 5, y: 0, z: 0} + m_LocalScale: {x: 5, y: 5, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2243782250480228875} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &4907226967481368671 GameObject: m_ObjectHideFlags: 0 @@ -209,6 +241,8 @@ GameObject: - component: {fileID: 1522197336905991381} - component: {fileID: 707193740762801077} - component: {fileID: 7249280586437786251} + - component: {fileID: 8547430362287369941} + - component: {fileID: 6505873975486236506} m_Layer: 7 m_Name: Reisen m_TagString: Player @@ -375,19 +409,60 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d4ea4a5fe3d2523039e302c010b04daf, type: 3} m_Name: m_EditorClassIdentifier: + stats: {fileID: 6505873975486236506} + abilities: [] + entitiesInRange: [] + closestEntity: {fileID: 0} + cam: {fileID: 0} +--- !u!114 &8547430362287369941 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7051425899434579382} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 88cc3202b26534d78b932ebaf49077f4, type: 3} + m_Name: + m_EditorClassIdentifier: + stats: {fileID: 6505873975486236506} + abilities: [] + entitiesInRange: [] + closestEntity: {fileID: 0} + maxTargettingRange: 0 + maxHeightDifference: 0 + minTargetJumpDistance: 0 + wallDetectors: [] + wallLayer: + serializedVersion: 2 + m_Bits: 0 + player: {fileID: 0} + playerMinDistance: 0 +--- !u!114 &6505873975486236506 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7051425899434579382} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 597d889207f92f03d81551cc8069aeee, type: 3} + m_Name: + m_EditorClassIdentifier: + thisEntity: {fileID: 7249280586437786251} health: 100 maxHealth: 100 speed: 4 jumpPower: 6 - abilities: [] - attackOriginPoint: {fileID: 1849759059644475718} - rb: {fileID: 707193740762801077} - entitiesInRange: [] - closestEntity: {fileID: 0} groundCheck: {fileID: 6047872402331640471} groundLayer: serializedVersion: 2 m_Bits: 8 + attackOriginPoint: {fileID: 6298566175391005934} + attackOriginCenter: {fileID: 2243782250480228875} + rb: {fileID: 707193740762801077} --- !u!1 &8370658841612952375 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/ShootBullet.prefab b/Assets/Prefabs/ShootBullet.prefab index ff2f0d7..a8215a6 100644 --- a/Assets/Prefabs/ShootBullet.prefab +++ b/Assets/Prefabs/ShootBullet.prefab @@ -44,11 +44,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c2e841223273eee80837e20d27430787, type: 3} m_Name: m_EditorClassIdentifier: + abilityName: Shoot Bullet thisEntity: {fileID: 0} cooldown: 1 power: 20 targetLocation: {x: 0, y: 0, z: 0} projectile: {fileID: 4968744362001082579, guid: 75dc1523a7fccf65c913e8fcd3e81206, type: 3} - projectileSpeed: 8 + projectileSpeed: 16 projectileLifetime: 5 pierceAmount: 0 diff --git a/Assets/Prefabs/Youmu.prefab b/Assets/Prefabs/Youmu.prefab index 4c1cfe2..122692f 100644 --- a/Assets/Prefabs/Youmu.prefab +++ b/Assets/Prefabs/Youmu.prefab @@ -62,6 +62,38 @@ Transform: m_Children: [] m_Father: {fileID: 4893125162624080007} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &5447721288900477139 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8123025040681778021} + m_Layer: 7 + m_Name: Abilities + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8123025040681778021 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5447721288900477139} + 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: + - {fileID: 1837572426186338970} + m_Father: {fileID: 4893125162624080007} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &7013272570264032182 GameObject: m_ObjectHideFlags: 0 @@ -106,6 +138,7 @@ GameObject: - component: {fileID: 2276909637052643796} - component: {fileID: 2047881652295913413} - component: {fileID: 8821502866947698626} + - component: {fileID: 2168594295468567769} m_Layer: 7 m_Name: Youmu m_TagString: Player @@ -132,6 +165,7 @@ Transform: - {fileID: 9142662567367472658} - {fileID: 8544749687679608375} - {fileID: 631585465756843219} + - {fileID: 8123025040681778021} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &3940513499368174321 @@ -274,19 +308,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 88cc3202b26534d78b932ebaf49077f4, type: 3} m_Name: m_EditorClassIdentifier: - health: 100 - maxHealth: 100 - speed: 4 - jumpPower: 6 - abilities: [] - attackOriginPoint: {fileID: 0} - rb: {fileID: 2047881652295913413} + stats: {fileID: 2168594295468567769} + abilities: + - {fileID: 5774395727869586210} entitiesInRange: [] closestEntity: {fileID: 0} - groundCheck: {fileID: 9142662567367472658} - groundLayer: - serializedVersion: 2 - m_Bits: 8 maxTargettingRange: 20 maxHeightDifference: 0.5 minTargetJumpDistance: 0.5 @@ -298,6 +324,30 @@ MonoBehaviour: m_Bits: 8 player: {fileID: 0} playerMinDistance: 1.2 +--- !u!114 &2168594295468567769 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7036878528139897633} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 597d889207f92f03d81551cc8069aeee, type: 3} + m_Name: + m_EditorClassIdentifier: + thisEntity: {fileID: 8821502866947698626} + health: 100 + maxHealth: 100 + speed: 4 + jumpPower: 6 + groundCheck: {fileID: 9142662567367472658} + groundLayer: + serializedVersion: 2 + m_Bits: 8 + attackOriginPoint: {fileID: 5196447376297042405} + attackOriginCenter: {fileID: 462469376723332893} + rb: {fileID: 2047881652295913413} --- !u!1 &7227609801905333812 GameObject: m_ObjectHideFlags: 0 @@ -315,7 +365,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &6446345046278479801 Transform: m_ObjectHideFlags: 0 @@ -409,7 +459,8 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.2, y: 0.2, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 5196447376297042405} m_Father: {fileID: 4893125162624080007} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &8680940919702853704 @@ -545,3 +596,111 @@ BoxCollider2D: m_AutoTiling: 0 m_Size: {x: 1, y: 1} m_EdgeRadius: 0 +--- !u!1 &8997570419459359421 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5196447376297042405} + m_Layer: 6 + m_Name: AttackPoint + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5196447376297042405 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8997570419459359421} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 5, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 462469376723332893} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &4772816046521060917 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 8123025040681778021} + m_Modifications: + - target: {fileID: 1305679653731509527, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: thisEntity + value: + objectReference: {fileID: 8821502866947698626} + - target: {fileID: 2518044865521178739, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_Name + value: ShootBullet + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalPosition.x + value: 10.320001 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalPosition.y + value: 2.69 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} +--- !u!4 &1837572426186338970 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6610207326853905583, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + m_PrefabInstance: {fileID: 4772816046521060917} + m_PrefabAsset: {fileID: 0} +--- !u!114 &5774395727869586210 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1305679653731509527, guid: 303f1513a3d6002c7a0b7b3fcc807afd, type: 3} + m_PrefabInstance: {fileID: 4772816046521060917} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c2e841223273eee80837e20d27430787, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Scenes/Prototype.unity b/Assets/Scenes/Prototype.unity index fad2fed..f31ef95 100644 --- a/Assets/Scenes/Prototype.unity +++ b/Assets/Scenes/Prototype.unity @@ -521,11 +521,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &488102006 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 7051425899434579382, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} - m_PrefabInstance: {fileID: 6873119575921479500} - m_PrefabAsset: {fileID: 0} --- !u!1 &503651302 GameObject: m_ObjectHideFlags: 0 @@ -879,7 +874,7 @@ Transform: m_GameObject: {fileID: 519420028} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 1.72, y: 0.66999996, z: -10} + m_LocalPosition: {x: 1.834, y: -2.99, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1001,6 +996,38 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &631591843 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 631591844} + m_Layer: 7 + m_Name: Center + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &631591844 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 631591843} + 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: + - {fileID: 1522071291} + m_Father: {fileID: 4201844704003245179} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &709669656 GameObject: m_ObjectHideFlags: 0 @@ -1702,6 +1729,17 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &977671504 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 6641646259750344106, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} + m_PrefabInstance: {fileID: 6873119575921479500} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c2e841223273eee80837e20d27430787, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1002049188 GameObject: m_ObjectHideFlags: 0 @@ -1970,6 +2008,17 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1214889688 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 5774395727869586210, guid: 109c16c8c32ec1d5a831de3f8cbbfc4b, type: 3} + m_PrefabInstance: {fileID: 4684006860967165701} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c2e841223273eee80837e20d27430787, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1219161079 GameObject: m_ObjectHideFlags: 0 @@ -2135,6 +2184,37 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1522071290 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1522071291} + m_Layer: 7 + m_Name: AttackPoint + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1522071291 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1522071290} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 1, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 631591844} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1575258620 GameObject: m_ObjectHideFlags: 0 @@ -2655,42 +2735,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &1863829849 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 2243782250480228875, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} - m_PrefabInstance: {fileID: 6873119575921479500} - m_PrefabAsset: {fileID: 0} ---- !u!1 &2001597554 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2001597555} - m_Layer: 7 - m_Name: AttackPoint - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &2001597555 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2001597554} - serializedVersion: 2 - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 5, y: 0, z: 0} - m_LocalScale: {x: 5, y: 5, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1863829849} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2007610691 GameObject: m_ObjectHideFlags: 0 @@ -3189,7 +3233,7 @@ Transform: m_GameObject: {fileID: 2119366494} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 1.72, y: 0.66999996, z: -10} + m_LocalPosition: {x: 1.834, y: -2.99, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -3227,6 +3271,7 @@ GameObject: - component: {fileID: 7363694730249250088} - component: {fileID: 7332886677051986745} - component: {fileID: 7363694730249250089} + - component: {fileID: 7363694730249250090} m_Layer: 7 m_Name: Enemy m_TagString: Enemy @@ -3243,10 +3288,11 @@ Transform: m_GameObject: {fileID: 1729434667953272797} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -3.7, y: -1.28, z: 0} + m_LocalPosition: {x: -4.724, y: -3.971, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 631591844} - {fileID: 2038292822} - {fileID: 2007610692} - {fileID: 1587823971} @@ -3264,13 +3310,21 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 2168594295468567769, guid: 109c16c8c32ec1d5a831de3f8cbbfc4b, type: 3} + propertyPath: abilities.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2168594295468567769, guid: 109c16c8c32ec1d5a831de3f8cbbfc4b, type: 3} + propertyPath: 'abilities.Array.data[0]' + value: + objectReference: {fileID: 1214889688} - target: {fileID: 4893125162624080007, guid: 109c16c8c32ec1d5a831de3f8cbbfc4b, type: 3} propertyPath: m_LocalPosition.x - value: -8.6 + value: -10.382 objectReference: {fileID: 0} - target: {fileID: 4893125162624080007, guid: 109c16c8c32ec1d5a831de3f8cbbfc4b, type: 3} propertyPath: m_LocalPosition.y - value: -3.02 + value: -3.994 objectReference: {fileID: 0} - target: {fileID: 4893125162624080007, guid: 109c16c8c32ec1d5a831de3f8cbbfc4b, type: 3} propertyPath: m_LocalPosition.z @@ -3382,11 +3436,11 @@ PrefabInstance: m_Modifications: - target: {fileID: 1849759059644475718, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} propertyPath: m_LocalPosition.x - value: 1.72 + value: 1.834 objectReference: {fileID: 0} - target: {fileID: 1849759059644475718, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} propertyPath: m_LocalPosition.y - value: -0.33 + value: -3.99 objectReference: {fileID: 0} - target: {fileID: 1849759059644475718, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} propertyPath: m_LocalPosition.z @@ -3420,6 +3474,14 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 6505873975486236506, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} + propertyPath: abilities.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6505873975486236506, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} + propertyPath: 'abilities.Array.data[0]' + value: + objectReference: {fileID: 977671504} - target: {fileID: 7051425899434579382, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} propertyPath: m_Name value: Reisen @@ -3429,30 +3491,24 @@ PrefabInstance: value: objectReference: {fileID: 519420031} - target: {fileID: 7249280586437786251, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} - propertyPath: attackOriginPoint - value: - objectReference: {fileID: 2001597555} + propertyPath: abilities.Array.size + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7249280586437786251, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} - propertyPath: attackOriginCenter + propertyPath: 'abilities.Array.data[0]' value: - objectReference: {fileID: 1863829849} + objectReference: {fileID: 977671504} m_RemovedComponents: [] m_RemovedGameObjects: [] - m_AddedGameObjects: - - targetCorrespondingSourceObject: {fileID: 2243782250480228875, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} - insertIndex: -1 - addedObject: {fileID: 2001597555} - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 7051425899434579382, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} - insertIndex: -1 - addedObject: {fileID: 6873119575921479510} + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} --- !u!114 &6873119575921479501 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 7249280586437786251, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} m_PrefabInstance: {fileID: 6873119575921479500} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 488102006} + m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: d4ea4a5fe3d2523039e302c010b04daf, type: 3} @@ -3463,41 +3519,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 1849759059644475718, guid: d79cfe0fe733d409a8fe68dede44bd2a, type: 3} m_PrefabInstance: {fileID: 6873119575921479500} m_PrefabAsset: {fileID: 0} ---- !u!114 &6873119575921479510 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 488102006} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 88cc3202b26534d78b932ebaf49077f4, type: 3} - m_Name: - m_EditorClassIdentifier: - health: 0 - maxHealth: 0 - speed: 0 - jumpPower: 0 - abilities: [] - attackOriginPoint: {fileID: 0} - attackOriginCenter: {fileID: 0} - rb: {fileID: 0} - entitiesInRange: [] - closestEntity: {fileID: 0} - groundCheck: {fileID: 0} - groundLayer: - serializedVersion: 2 - m_Bits: 0 - maxTargettingRange: 0 - maxHeightDifference: 0 - minTargetJumpDistance: 0 - wallDetectors: [] - wallLayer: - serializedVersion: 2 - m_Bits: 0 - player: {fileID: 0} - playerMinDistance: 0 --- !u!50 &7332886677051986745 Rigidbody2D: serializedVersion: 5 @@ -3583,20 +3604,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 29eabb6316cb9023da130abba3ba64fc, type: 3} m_Name: m_EditorClassIdentifier: - health: 10 - maxHealth: 10 - speed: 2 - jumpPower: 6 - abilities: [] - attackOriginPoint: {fileID: 0} - attackOriginCenter: {fileID: 0} - rb: {fileID: 7332886677051986745} + stats: {fileID: 7363694730249250090} entitiesInRange: [] closestEntity: {fileID: 0} - groundCheck: {fileID: 741584342} - groundLayer: - serializedVersion: 2 - m_Bits: 8 maxTargettingRange: 20 maxHeightDifference: 0.5 minTargetJumpDistance: 0 @@ -3606,6 +3616,31 @@ MonoBehaviour: wallLayer: serializedVersion: 2 m_Bits: 8 +--- !u!114 &7363694730249250090 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1729434667953272797} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 597d889207f92f03d81551cc8069aeee, type: 3} + m_Name: + m_EditorClassIdentifier: + thisEntity: {fileID: 7363694730249250089} + health: 10 + maxHealth: 10 + speed: 3 + jumpPower: 6 + groundCheck: {fileID: 741584342} + groundLayer: + serializedVersion: 2 + m_Bits: 8 + attackOriginPoint: {fileID: 1522071291} + attackOriginCenter: {fileID: 631591844} + abilities: [] + rb: {fileID: 7332886677051986745} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Ability.cs b/Assets/Scripts/Ability.cs index 8bdd822..e179fcb 100644 --- a/Assets/Scripts/Ability.cs +++ b/Assets/Scripts/Ability.cs @@ -1,11 +1,14 @@ -using System; using UnityEngine; public class Ability : MonoBehaviour { + [Header("Identification")] + public string abilityName; public Entity thisEntity; + [Header("Cooldown")] protected float currentCooldown; public float cooldown; + [Header("Stats")] public float power; public Vector3 targetLocation; @@ -15,11 +18,6 @@ public class Ability : MonoBehaviour { currentCooldown -= Time.deltaTime; } - - if (Input.GetMouseButtonDown(0)) - { - TryAbility(); //testing, please remove - } } public bool TryAbility() @@ -28,8 +26,10 @@ public class Ability : MonoBehaviour { AbilityEffects(); currentCooldown = cooldown; + Debug.Log($"Ability {abilityName} SUCCESS"); return true; } + Debug.Log($"Ability {abilityName} ON COOLDOWN"); return false; } protected virtual void AbilityEffects() diff --git a/Assets/Scripts/AutomatedPlayer.cs b/Assets/Scripts/AutomatedPlayer.cs index dd7b0bb..eaa342c 100644 --- a/Assets/Scripts/AutomatedPlayer.cs +++ b/Assets/Scripts/AutomatedPlayer.cs @@ -1,30 +1,42 @@ using System; +using Core.Extensions; using UnityEngine; public class AutomatedPlayer : AutoControlledEntity { - public Player player; public float playerMinDistance; + private void Update() + { + if (closestEntity) + { + stats.attackOriginCenter.Lookat2D(closestEntity.transform.position); + foreach (Ability ability in stats.abilities) + { + ability.TryAbility(); + } + } + } + private void FixedUpdate() { - Vector2 direction = new Vector2(0, rb.linearVelocityY); + Vector2 direction = new Vector2(0, stats.rb.linearVelocityY); Entity target = player; if (!closestEntity && Vector3.Distance(player.transform.position, transform.position) <= playerMinDistance) { - rb.linearVelocity = direction; //repeated code sucks but it works in this case i guess + stats.rb.linearVelocity = direction; //repeated code sucks but it works in this case i guess return; //do not bother running any more code lol you're already next to the player and no enemies nearby } if (closestEntity && Vector3.Distance(closestEntity.transform.position, transform.position) < maxTargettingRange) { target = closestEntity; } - direction.x = (target.transform.position - transform.position).normalized.x * speed; - if ((target.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(target.transform.position, transform.position) > minTargetJumpDistance)) && OnGround()) + direction.x = (target.transform.position - transform.position).normalized.x * stats.speed; + if ((target.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(target.transform.position, transform.position) > minTargetJumpDistance)) && stats.OnGround()) { - direction.y = jumpPower; + direction.y = stats.jumpPower; } - rb.linearVelocity = direction; + stats.rb.linearVelocity = direction; } } diff --git a/Assets/Scripts/Enemy.cs b/Assets/Scripts/Enemy.cs index a586496..0dd64f4 100644 --- a/Assets/Scripts/Enemy.cs +++ b/Assets/Scripts/Enemy.cs @@ -5,19 +5,19 @@ public class Enemy : AutoControlledEntity { private void FixedUpdate() { - Vector2 direction = new Vector2(0, rb.linearVelocityY); + Vector2 direction = new Vector2(0, stats.rb.linearVelocityY); if (closestEntity && Vector3.Distance(closestEntity.transform.position, transform.position) < maxTargettingRange) { - direction.x = (closestEntity.transform.position - transform.position).normalized.x * speed; - if ((closestEntity.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(closestEntity.transform.position, transform.position) > minTargetJumpDistance)) && OnGround()) + direction.x = (closestEntity.transform.position - transform.position).normalized.x * stats.speed; + if ((closestEntity.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(closestEntity.transform.position, transform.position) > minTargetJumpDistance)) && stats.OnGround()) { - direction.y = jumpPower; + direction.y = stats.jumpPower; } } - rb.linearVelocity = direction; + stats.rb.linearVelocity = direction; } - protected override void OnDeath() + public override void OnDeath() { base.OnDeath(); Destroy(gameObject); diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index b64a9ce..491b947 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -4,45 +4,14 @@ using UnityEngine; public class Entity : MonoBehaviour { - [Header("Health")] - public float health; - public float maxHealth; - [Header("Stats")] - public float speed; - public float jumpPower; - [Header("Abilities")] - public List abilities = new(); - public Transform attackOriginPoint; - [SerializeField] protected Transform attackOriginCenter; + [Header("Stats")] + public EntityStats stats; [Header("Cache")] - [SerializeField] protected Rigidbody2D rb; public List entitiesInRange = new(); public Entity closestEntity; - [Header("Ground Detection")] - [SerializeField] private Transform groundCheck; - [SerializeField] private LayerMask groundLayer; - public void TakeDamage(float damage) - { - health -= damage; - if (health <= 0) - { - OnDeath(); - } - } - - public void Heal(float healing) - { - health += healing; - health = Math.Clamp(health, 0, maxHealth); - } - - protected virtual void OnDeath() + public virtual void OnDeath() { } - protected bool OnGround() - { - return Physics2D.OverlapCircle(groundCheck.position, 0.05f, groundLayer); - } } diff --git a/Assets/Scripts/EntityStats.cs b/Assets/Scripts/EntityStats.cs new file mode 100644 index 0000000..1928e04 --- /dev/null +++ b/Assets/Scripts/EntityStats.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +public class EntityStats : MonoBehaviour +{ + public Entity thisEntity; + [Header("Health")] + public float health; + public float maxHealth; + [Header("Stats")] + public float speed; + public float jumpPower; + [Header("Ground Detection")] + [SerializeField] private Transform groundCheck; + [SerializeField] private LayerMask groundLayer; + [Header("Attack Origin")] + public Transform attackOriginPoint; + public Transform attackOriginCenter; + [Header("Abilities")] + public List abilities = new(); + [Header("Cache")] + public Rigidbody2D rb; + public void TakeDamage(float damage) + { + health -= damage; + if (health <= 0) + { + thisEntity.OnDeath(); + } + } + + public void Heal(float healing) + { + health += healing; + health = Math.Clamp(health, 0, maxHealth); + } + public bool OnGround() + { + return Physics2D.OverlapCircle(groundCheck.position, 0.05f, groundLayer); + } +} diff --git a/Assets/Scripts/EntityStats.cs.meta b/Assets/Scripts/EntityStats.cs.meta new file mode 100644 index 0000000..f8f903b --- /dev/null +++ b/Assets/Scripts/EntityStats.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 597d889207f92f03d81551cc8069aeee \ No newline at end of file diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index e84d19e..2539c2d 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -7,16 +7,20 @@ public class Player : Entity [SerializeField] private Camera cam; private void Update() { - attackOriginCenter.Lookat2D(cam.ScreenToWorldPoint(Input.mousePosition)); + stats.attackOriginCenter.Lookat2D(cam.ScreenToWorldPoint(Input.mousePosition)); + if (Input.GetMouseButtonDown(0)) + { + stats.abilities[0].TryAbility(); + } } private void FixedUpdate() { - Vector2 movement = new Vector2(Input.GetAxis("Horizontal") * speed, rb.linearVelocityY); - if (Input.GetKeyDown(KeyCode.Space) && OnGround()) + Vector2 movement = new Vector2(Input.GetAxis("Horizontal") * stats.speed, stats.rb.linearVelocityY); + if (Input.GetKeyDown(KeyCode.Space) && stats.OnGround()) { - movement.y = jumpPower; + movement.y = stats.jumpPower; } - rb.linearVelocity = movement; + stats.rb.linearVelocity = movement; } } diff --git a/Assets/Scripts/Projectile.cs b/Assets/Scripts/Projectile.cs index 8c82c1b..8658d3e 100644 --- a/Assets/Scripts/Projectile.cs +++ b/Assets/Scripts/Projectile.cs @@ -25,7 +25,7 @@ public class Projectile : MonoBehaviour { if (!other.CompareTag(tag) && other.TryGetComponent(out Entity isEntity)) { - isEntity.TakeDamage(damage); + isEntity.stats.TakeDamage(damage); currentPierced++; if (currentPierced > pierceAmount) { diff --git a/Assets/Scripts/ShootBullet.cs b/Assets/Scripts/ShootBullet.cs index 8d45225..a43ff37 100644 --- a/Assets/Scripts/ShootBullet.cs +++ b/Assets/Scripts/ShootBullet.cs @@ -17,6 +17,6 @@ public class ShootBullet : Ability newProjectile.damage = power; newProjectile.lifetime = projectileLifetime; newProjectile.pierceAmount = pierceAmount; - newProjectile.transform.Lookat2D(thisEntity.attackOriginPoint.position); //targetLocation); + newProjectile.transform.Lookat2D(thisEntity.stats.attackOriginPoint.position); //targetLocation); } }