From 4b2d35a733fa5f7b84477375ff54f45649e83345 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 23 Dec 2022 09:22:22 +0100 Subject: [PATCH] Item refactoring --- assets/Media/Prefabs/Game/Drops/Chest.prefab | 41 +- assets/Media/Prefabs/Game/Drops/Gold.prefab | 7 +- .../Prefabs/Game/Drops/HealthPotion.prefab | 10 +- assets/Media/Prefabs/Game/Drops/Magnet.prefab | 37 +- assets/Media/Prefabs/Game/Drops/XP.prefab | 43 +- assets/Media/Prefabs/Game/Player.prefab | 109 ++++- .../AudioSettingsModalWindow.prefab | 2 +- .../LevelUp/LevelUpModalWindow.prefab | 86 ++-- .../Upgrades/UpgradesModalWindow.prefab | 2 +- assets/Scenes/Game.scene | 452 +++++++++++------- assets/Scripts/Game/Audio/GameAudioAdapter.ts | 3 +- .../Game/Collision/PlayerCollisionSystem.ts | 22 +- assets/Scripts/Game/GroupType.ts | 5 +- assets/Scripts/Game/Items/Gold.meta | 12 - assets/Scripts/Game/Items/Gold/Gold.ts | 24 - assets/Scripts/Game/Items/Gold/GoldSpawner.ts | 26 - assets/Scripts/Game/Items/HealthPotion.meta | 12 - .../Game/Items/HealthPotion/HealthPotion.ts | 27 -- .../Items/HealthPotion/HealthPotionSpawner.ts | 27 -- .../HealthPotion/HealthPotionSpawner.ts.meta | 9 - assets/Scripts/Game/Items/Item.ts | 30 ++ .../HealthPotion.ts.meta => Item.ts.meta} | 2 +- assets/Scripts/Game/Items/ItemManager.ts | 62 +-- assets/Scripts/Game/Items/ItemSpawner.ts | 26 + ...oldSpawner.ts.meta => ItemSpawner.ts.meta} | 2 +- assets/Scripts/Game/Items/ItemType.ts | 7 + .../{Gold/Gold.ts.meta => ItemType.ts.meta} | 2 +- assets/Scripts/Game/Items/XP.meta | 12 - assets/Scripts/Game/Items/XP.ts | 14 + assets/Scripts/Game/Items/{XP => }/XP.ts.meta | 2 +- assets/Scripts/Game/Items/XP/XP.ts | 33 -- assets/Scripts/Game/Items/XP/XPSpawner.ts | 26 - .../Scripts/Game/Items/XP/XPSpawner.ts.meta | 9 - settings/v2/packages/project.json | 13 +- 34 files changed, 618 insertions(+), 578 deletions(-) delete mode 100644 assets/Scripts/Game/Items/Gold.meta delete mode 100644 assets/Scripts/Game/Items/Gold/Gold.ts delete mode 100644 assets/Scripts/Game/Items/Gold/GoldSpawner.ts delete mode 100644 assets/Scripts/Game/Items/HealthPotion.meta delete mode 100644 assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts delete mode 100644 assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts delete mode 100644 assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts.meta create mode 100644 assets/Scripts/Game/Items/Item.ts rename assets/Scripts/Game/Items/{HealthPotion/HealthPotion.ts.meta => Item.ts.meta} (70%) create mode 100644 assets/Scripts/Game/Items/ItemSpawner.ts rename assets/Scripts/Game/Items/{Gold/GoldSpawner.ts.meta => ItemSpawner.ts.meta} (70%) create mode 100644 assets/Scripts/Game/Items/ItemType.ts rename assets/Scripts/Game/Items/{Gold/Gold.ts.meta => ItemType.ts.meta} (70%) delete mode 100644 assets/Scripts/Game/Items/XP.meta create mode 100644 assets/Scripts/Game/Items/XP.ts rename assets/Scripts/Game/Items/{XP => }/XP.ts.meta (70%) delete mode 100644 assets/Scripts/Game/Items/XP/XP.ts delete mode 100644 assets/Scripts/Game/Items/XP/XPSpawner.ts delete mode 100644 assets/Scripts/Game/Items/XP/XPSpawner.ts.meta diff --git a/assets/Media/Prefabs/Game/Drops/Chest.prefab b/assets/Media/Prefabs/Game/Drops/Chest.prefab index 3a6d88b..dd2729e 100644 --- a/assets/Media/Prefabs/Game/Drops/Chest.prefab +++ b/assets/Media/Prefabs/Game/Drops/Chest.prefab @@ -308,23 +308,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "cfXyVJoitMGp/0liEUZfNP" }, - { - "__type__": "7a536G2OudFtpTsoF8yLXiW", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 15 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "72AObOIbxCf6LIYsYqoFZF" - }, { "__type__": "cc.Animation", "_name": "", @@ -334,7 +317,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 17 + "__id__": 15 }, "playOnLoad": true, "_clips": [ @@ -362,10 +345,10 @@ }, "_enabled": true, "__prefab": { - "__id__": 19 + "__id__": 17 }, "tag": 0, - "_group": 1, + "_group": 16, "_density": 1, "_sensor": false, "_friction": 0.2, @@ -386,6 +369,24 @@ "__type__": "cc.CompPrefabInfo", "fileId": "b5zZIKDzhK3q3Rd8OiKUPa" }, + { + "__type__": "724bauqfhVH0YWsXug16uHL", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 19 + }, + "itemType": 4, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "9eD6pXLdNKw4xswCPxsN+q" + }, { "__type__": "cc.PrefabInfo", "root": { diff --git a/assets/Media/Prefabs/Game/Drops/Gold.prefab b/assets/Media/Prefabs/Game/Drops/Gold.prefab index 775d951..41bec80 100644 --- a/assets/Media/Prefabs/Game/Drops/Gold.prefab +++ b/assets/Media/Prefabs/Game/Drops/Gold.prefab @@ -348,7 +348,7 @@ "__id__": 17 }, "tag": 0, - "_group": 128, + "_group": 16, "_density": 1, "_sensor": false, "_friction": 0.2, @@ -370,7 +370,7 @@ "fileId": "67joCa7ptP34A+uWLWHsEf" }, { - "__type__": "41f67AOEYRMTLXwNf7CG9iO", + "__type__": "724bauqfhVH0YWsXug16uHL", "_name": "", "_objFlags": 0, "node": { @@ -380,11 +380,12 @@ "__prefab": { "__id__": 19 }, + "itemType": 1, "_id": "" }, { "__type__": "cc.CompPrefabInfo", - "fileId": "08V7VtIFBG1bgEhFLO5GoU" + "fileId": "9eg+N94AJL7qX1hwDoulo4" }, { "__type__": "cc.PrefabInfo", diff --git a/assets/Media/Prefabs/Game/Drops/HealthPotion.prefab b/assets/Media/Prefabs/Game/Drops/HealthPotion.prefab index ea9e89a..10782ac 100644 --- a/assets/Media/Prefabs/Game/Drops/HealthPotion.prefab +++ b/assets/Media/Prefabs/Game/Drops/HealthPotion.prefab @@ -320,7 +320,7 @@ "__id__": 15 }, "tag": 0, - "_group": 256, + "_group": 16, "_density": 1, "_sensor": false, "_friction": 0.2, @@ -366,7 +366,7 @@ "fileId": "3ag4rexLNJW6A/sp6OpwZ8" }, { - "__type__": "18f8d5p42FOc4uYonNdBzCm", + "__type__": "724bauqfhVH0YWsXug16uHL", "_name": "", "_objFlags": 0, "node": { @@ -376,14 +376,12 @@ "__prefab": { "__id__": 19 }, - "animation": { - "__id__": 16 - }, + "itemType": 2, "_id": "" }, { "__type__": "cc.CompPrefabInfo", - "fileId": "65lXWGNONBy5ucPc5KmOaR" + "fileId": "c3RTRN6tpK45dDIl3T8NlW" }, { "__type__": "cc.PrefabInfo", diff --git a/assets/Media/Prefabs/Game/Drops/Magnet.prefab b/assets/Media/Prefabs/Game/Drops/Magnet.prefab index c198d5d..e2e8337 100644 --- a/assets/Media/Prefabs/Game/Drops/Magnet.prefab +++ b/assets/Media/Prefabs/Game/Drops/Magnet.prefab @@ -306,23 +306,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "75WVRoLrtKLrJihCVsxa4D" }, - { - "__type__": "7a536G2OudFtpTsoF8yLXiW", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 1 - }, - "_enabled": false, - "__prefab": { - "__id__": 15 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "72AObOIbxCf6LIYsYqoFZF" - }, { "__type__": "cc.Animation", "_name": "", @@ -332,7 +315,7 @@ }, "_enabled": false, "__prefab": { - "__id__": 17 + "__id__": 15 }, "playOnLoad": true, "_clips": [ @@ -351,6 +334,24 @@ "__type__": "cc.CompPrefabInfo", "fileId": "3ag4rexLNJW6A/sp6OpwZ8" }, + { + "__type__": "724bauqfhVH0YWsXug16uHL", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 17 + }, + "itemType": 3, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "acBeV6ARtPG5vuHymyG+Tp" + }, { "__type__": "cc.PrefabInfo", "root": { diff --git a/assets/Media/Prefabs/Game/Drops/XP.prefab b/assets/Media/Prefabs/Game/Drops/XP.prefab index ed0f34b..1d464d3 100644 --- a/assets/Media/Prefabs/Game/Drops/XP.prefab +++ b/assets/Media/Prefabs/Game/Drops/XP.prefab @@ -337,26 +337,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "75WVRoLrtKLrJihCVsxa4D" }, - { - "__type__": "7a536G2OudFtpTsoF8yLXiW", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 17 - }, - "animation": { - "__id__": 18 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "72AObOIbxCf6LIYsYqoFZF" - }, { "__type__": "cc.Animation", "_name": "", @@ -366,7 +346,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 19 + "__id__": 17 }, "playOnLoad": true, "_clips": [ @@ -385,6 +365,27 @@ "__type__": "cc.CompPrefabInfo", "fileId": "3ag4rexLNJW6A/sp6OpwZ8" }, + { + "__type__": "801bc1fEuVM5pPn2btm9NKZ", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 19 + }, + "itemType": 0, + "animation": { + "__id__": 16 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2aiKM2kApHv7jncY6Pmvgt" + }, { "__type__": "cc.PrefabInfo", "root": { diff --git a/assets/Media/Prefabs/Game/Player.prefab b/assets/Media/Prefabs/Game/Player.prefab index bfa48ce..1d2a98c 100644 --- a/assets/Media/Prefabs/Game/Player.prefab +++ b/assets/Media/Prefabs/Game/Player.prefab @@ -26,22 +26,25 @@ }, { "__id__": 40 + }, + { + "__id__": 136 } ], "_active": true, "_components": [ - { - "__id__": 136 - }, - { - "__id__": 138 - }, { "__id__": 140 + }, + { + "__id__": 142 + }, + { + "__id__": 144 } ], "_prefab": { - "__id__": 142 + "__id__": 146 }, "_lpos": { "__type__": "cc.Vec3", @@ -2902,6 +2905,90 @@ }, "fileId": "c6aL8FlztEHJ6sRFCXQnge" }, + { + "__type__": "cc.Node", + "_name": "Magnet", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 137 + } + ], + "_prefab": { + "__id__": 139 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.CircleCollider2D", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 136 + }, + "_enabled": true, + "__prefab": { + "__id__": 138 + }, + "tag": 0, + "_group": 1, + "_density": 1, + "_sensor": false, + "_friction": 0.2, + "_restitution": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_radius": 260, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2cKwIyAIBAm5fq0pDIOT0e" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "aec1+SeS9G0b8TjOixk1ws" + }, { "__type__": "cc.UITransform", "_name": "", @@ -2911,7 +2998,7 @@ }, "_enabled": false, "__prefab": { - "__id__": 137 + "__id__": 141 }, "_contentSize": { "__type__": "cc.Size", @@ -2938,10 +3025,10 @@ }, "_enabled": true, "__prefab": { - "__id__": 139 + "__id__": 143 }, "collider": { - "__id__": 140 + "__id__": 144 }, "playerUI": { "__id__": 37 @@ -2973,7 +3060,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 141 + "__id__": 145 }, "tag": 0, "_group": 2, diff --git a/assets/Media/Prefabs/ModalWindows/AudioSettings/AudioSettingsModalWindow.prefab b/assets/Media/Prefabs/ModalWindows/AudioSettings/AudioSettingsModalWindow.prefab index baa99f3..64dc52d 100644 --- a/assets/Media/Prefabs/ModalWindows/AudioSettings/AudioSettingsModalWindow.prefab +++ b/assets/Media/Prefabs/ModalWindows/AudioSettings/AudioSettingsModalWindow.prefab @@ -2317,7 +2317,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "96r5a19KlArZj66lP1XbqT" + "fileId": "e4VgJe0ytLH585U+gaoqU4" }, { "__type__": "cc.PrefabInfo", diff --git a/assets/Media/Prefabs/ModalWindows/LevelUp/LevelUpModalWindow.prefab b/assets/Media/Prefabs/ModalWindows/LevelUp/LevelUpModalWindow.prefab index 3010e96..caabff5 100644 --- a/assets/Media/Prefabs/ModalWindows/LevelUp/LevelUpModalWindow.prefab +++ b/assets/Media/Prefabs/ModalWindows/LevelUp/LevelUpModalWindow.prefab @@ -429,34 +429,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "2eO+M9deJI1KYyU2Otv4xD" }, - { - "__type__": "f7ac68qK+pC7LXQWJdgAYVs", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 21 - }, - "animation": { - "__id__": 15 - }, - "testField": "", - "skillPrefab": { - "__uuid__": "5dccf426-aeb0-4b4e-9e1c-ae9fd74dcf7a", - "__expectedType__": "cc.Prefab" - }, - "skillParent": { - "__id__": 9 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "2f6poVi1pJKJ3WzVB7L/Nq" - }, { "__type__": "cc.Widget", "_name": "", @@ -467,7 +439,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 23 + "__id__": 21 }, "_alignFlags": 45, "_target": null, @@ -493,6 +465,35 @@ "__type__": "cc.CompPrefabInfo", "fileId": "67Ws0zREFMYKNYvOHw9C0b" }, + { + "__type__": "f7ac68qK+pC7LXQWJdgAYVs", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 23 + }, + "animation": { + "__id__": 15 + }, + "closeButton": null, + "backgroundCloseButton": null, + "skillPrefab": { + "__uuid__": "5dccf426-aeb0-4b4e-9e1c-ae9fd74dcf7a", + "__expectedType__": "cc.Prefab" + }, + "skillParent": { + "__id__": 9 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "00cUXISL9FB7Ezx2pI9k4V" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -502,31 +503,6 @@ "__id__": 0 }, "fileId": "32U/bJCUBDlaQxxGFNXZTu", - "targetOverrides": [ - { - "__id__": 25 - } - ] - }, - { - "__type__": "cc.TargetOverrideInfo", - "source": { - "__id__": 20 - }, - "sourceInfo": null, - "propertyPath": [ - "skills", - "2" - ], - "target": null, - "targetInfo": { - "__id__": 26 - } - }, - { - "__type__": "cc.TargetInfo", - "localID": [ - "8fXLBTR/JKgZXZPA29Dci3" - ] + "targetOverrides": [] } ] \ No newline at end of file diff --git a/assets/Media/Prefabs/ModalWindows/Upgrades/UpgradesModalWindow.prefab b/assets/Media/Prefabs/ModalWindows/Upgrades/UpgradesModalWindow.prefab index 3f62409..30d4101 100644 --- a/assets/Media/Prefabs/ModalWindows/Upgrades/UpgradesModalWindow.prefab +++ b/assets/Media/Prefabs/ModalWindows/Upgrades/UpgradesModalWindow.prefab @@ -1112,7 +1112,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "dcTNwE4SNLOZujvnWi9lB6" + "fileId": "0cPaLYMJxO4aigeWF8icoV" }, { "__type__": "cc.PrefabInfo", diff --git a/assets/Scenes/Game.scene b/assets/Scenes/Game.scene index e6c9257..d8b9932 100644 --- a/assets/Scenes/Game.scene +++ b/assets/Scenes/Game.scene @@ -27,11 +27,11 @@ "_active": true, "_components": [], "_prefab": { - "__id__": 112 + "__id__": 116 }, "autoReleaseAssets": false, "_globals": { - "__id__": 115 + "__id__": 119 }, "_id": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f" }, @@ -238,25 +238,25 @@ "__id__": 40 }, { - "__id__": 50 + "__id__": 54 }, { - "__id__": 54 + "__id__": 58 } ], "_active": true, "_components": [ { - "__id__": 106 + "__id__": 110 }, { - "__id__": 107 + "__id__": 111 }, { - "__id__": 108 + "__id__": 112 }, { - "__id__": 109 + "__id__": 113 } ], "_prefab": null, @@ -855,12 +855,18 @@ }, { "__id__": 47 + }, + { + "__id__": 49 + }, + { + "__id__": 51 } ], "_active": true, "_components": [ { - "__id__": 49 + "__id__": 53 } ], "_prefab": null, @@ -936,7 +942,7 @@ "_id": "b7cM/vyZtNY6PANwPA4aXG" }, { - "__type__": "ab9e2Br8RpBfIFLB9KcWe1u", + "__type__": "74c52wKzO1PKKANoBI3QmS7", "_name": "", "_objFlags": 0, "node": { @@ -944,11 +950,11 @@ }, "_enabled": true, "__prefab": null, - "xpPrefab": { + "itemPrefab": { "__uuid__": "b83dbe32-6b43-4ea9-b0e2-5f96c09f459d", "__expectedType__": "cc.Prefab" }, - "_id": "cbPY3r6KtPXJ5MuqA3BqfN" + "_id": "74SD65OzxL97xx+bjixxu6" }, { "__type__": "cc.Node", @@ -994,7 +1000,7 @@ "_id": "4c8/jo4pJOlpZd+rBu+9OO" }, { - "__type__": "abf1f+QyaNNZYu5Gsnr631R", + "__type__": "74c52wKzO1PKKANoBI3QmS7", "_name": "", "_objFlags": 0, "node": { @@ -1002,11 +1008,11 @@ }, "_enabled": true, "__prefab": null, - "goldPrefab": { + "itemPrefab": { "__uuid__": "eb604b78-90e3-4379-bb3a-7f1271d8a403", "__expectedType__": "cc.Prefab" }, - "_id": "e09xeGmLJFQZ8h6y27oyCC" + "_id": "c0UNQTkjRNP4kkXqFPMw4j" }, { "__type__": "cc.Node", @@ -1052,7 +1058,7 @@ "_id": "17lYyBgbtI7ZCekaxNE2yC" }, { - "__type__": "1e3b0x/yDFHeIaI2OLA9twA", + "__type__": "74c52wKzO1PKKANoBI3QmS7", "_name": "", "_objFlags": 0, "node": { @@ -1060,15 +1066,15 @@ }, "_enabled": true, "__prefab": null, - "healthPotionPrefab": { + "itemPrefab": { "__uuid__": "ef33cda3-5ce0-41e6-ba03-7194178de12c", "__expectedType__": "cc.Prefab" }, - "_id": "3dd0khZZRLb4rd4dwkgaIN" + "_id": "72Dz+rQopMS4DJXvXrFAcs" }, { "__type__": "cc.Node", - "_name": "PickupEffectManager", + "_name": "MagnetSpawner", "_objFlags": 0, "_parent": { "__id__": 40 @@ -1107,6 +1113,122 @@ "y": 0, "z": 0 }, + "_id": "d3puzP7sNB4KI0qEF0BHBR" + }, + { + "__type__": "74c52wKzO1PKKANoBI3QmS7", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 47 + }, + "_enabled": true, + "__prefab": null, + "itemPrefab": { + "__uuid__": "00455faa-84a3-4c25-993b-84732eca0f80", + "__expectedType__": "cc.Prefab" + }, + "_id": "38TwQ96mZLgLT++iB8KnY2" + }, + { + "__type__": "cc.Node", + "_name": "ChestSpawner", + "_objFlags": 0, + "_parent": { + "__id__": 40 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 50 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "40jL+o7cpKSbqCR+zI3BKp" + }, + { + "__type__": "74c52wKzO1PKKANoBI3QmS7", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 49 + }, + "_enabled": true, + "__prefab": null, + "itemPrefab": { + "__uuid__": "46ebbe9e-799f-4aa0-8e69-482ef73fd734", + "__expectedType__": "cc.Prefab" + }, + "_id": "08I6gl4JNEbaCMH16LKZCw" + }, + { + "__type__": "cc.Node", + "_name": "PickupEffectManager", + "_objFlags": 0, + "_parent": { + "__id__": 40 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 52 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, "_id": "98e6SJrnJIlYvBUzvAiGSQ" }, { @@ -1114,7 +1236,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 47 + "__id__": 51 }, "_enabled": true, "__prefab": null, @@ -1142,9 +1264,15 @@ "healthPotionSpawner": { "__id__": 46 }, - "pickupEffectManager": { + "magnetSpawner": { "__id__": 48 }, + "chestSpawner": { + "__id__": 50 + }, + "pickupEffectManager": { + "__id__": 52 + }, "_id": "98EDpSoeBKp7eDmPXKNFJ0" }, { @@ -1156,13 +1284,13 @@ }, "_children": [ { - "__id__": 51 + "__id__": 55 } ], "_active": true, "_components": [ { - "__id__": 53 + "__id__": 57 } ], "_prefab": null, @@ -1199,13 +1327,13 @@ "_name": "EnemySpawner", "_objFlags": 0, "_parent": { - "__id__": 50 + "__id__": 54 }, "_children": [], "_active": true, "_components": [ { - "__id__": 52 + "__id__": 56 } ], "_prefab": null, @@ -1242,7 +1370,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 51 + "__id__": 55 }, "_enabled": true, "__prefab": null, @@ -1279,12 +1407,12 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 50 + "__id__": 54 }, "_enabled": true, "__prefab": null, "enemySpawner": { - "__id__": 52 + "__id__": 56 }, "_id": "1ffjazmm5IkZwKInsSIULY" }, @@ -1297,28 +1425,28 @@ }, "_children": [ { - "__id__": 55 + "__id__": 59 }, { - "__id__": 90 + "__id__": 94 }, { - "__id__": 93 + "__id__": 97 }, { - "__id__": 96 + "__id__": 100 }, { - "__id__": 99 + "__id__": 103 }, { - "__id__": 102 + "__id__": 106 } ], "_active": true, "_components": [ { - "__id__": 105 + "__id__": 109 } ], "_prefab": null, @@ -1355,20 +1483,20 @@ "_name": "GameUI", "_objFlags": 0, "_parent": { - "__id__": 54 + "__id__": 58 }, "_children": [ { - "__id__": 56 + "__id__": 60 }, { - "__id__": 80 + "__id__": 84 } ], "_active": true, "_components": [ { - "__id__": 89 + "__id__": 93 } ], "_prefab": null, @@ -1405,26 +1533,26 @@ "_name": "TopUI", "_objFlags": 0, "_parent": { - "__id__": 55 + "__id__": 59 }, "_children": [ { - "__id__": 57 + "__id__": 61 }, { - "__id__": 66 + "__id__": 70 }, { - "__id__": 69 + "__id__": 73 } ], "_active": true, "_components": [ { - "__id__": 78 + "__id__": 82 }, { - "__id__": 79 + "__id__": 83 } ], "_prefab": null, @@ -1461,23 +1589,23 @@ "_name": "XpBar", "_objFlags": 0, "_parent": { - "__id__": 56 + "__id__": 60 }, "_children": [ { - "__id__": 58 + "__id__": 62 }, { - "__id__": 61 + "__id__": 65 } ], "_active": true, "_components": [ { - "__id__": 64 + "__id__": 68 }, { - "__id__": 65 + "__id__": 69 } ], "_prefab": null, @@ -1514,16 +1642,16 @@ "_name": "Background", "_objFlags": 0, "_parent": { - "__id__": 57 + "__id__": 61 }, "_children": [], "_active": true, "_components": [ { - "__id__": 59 + "__id__": 63 }, { - "__id__": 60 + "__id__": 64 } ], "_prefab": null, @@ -1560,7 +1688,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 58 + "__id__": 62 }, "_enabled": true, "__prefab": null, @@ -1581,7 +1709,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 58 + "__id__": 62 }, "_enabled": true, "__prefab": null, @@ -1619,16 +1747,16 @@ "_name": "MovableBar", "_objFlags": 0, "_parent": { - "__id__": 57 + "__id__": 61 }, "_children": [], "_active": true, "_components": [ { - "__id__": 62 + "__id__": 66 }, { - "__id__": 63 + "__id__": 67 } ], "_prefab": null, @@ -1665,7 +1793,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 61 + "__id__": 65 }, "_enabled": true, "__prefab": null, @@ -1686,7 +1814,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 61 + "__id__": 65 }, "_enabled": true, "__prefab": null, @@ -1724,7 +1852,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 57 + "__id__": 61 }, "_enabled": true, "__prefab": null, @@ -1745,12 +1873,12 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 57 + "__id__": 61 }, "_enabled": true, "__prefab": null, "_barSprite": { - "__id__": 63 + "__id__": 67 }, "_mode": 0, "_totalLength": 600, @@ -1763,16 +1891,16 @@ "_name": "TimeAliveText", "_objFlags": 0, "_parent": { - "__id__": 56 + "__id__": 60 }, "_children": [], "_active": true, "_components": [ { - "__id__": 67 + "__id__": 71 }, { - "__id__": 68 + "__id__": 72 } ], "_prefab": null, @@ -1809,7 +1937,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 66 + "__id__": 70 }, "_enabled": true, "__prefab": null, @@ -1830,7 +1958,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 66 + "__id__": 70 }, "_enabled": true, "__prefab": null, @@ -1871,29 +1999,29 @@ "_name": "PauseBtn", "_objFlags": 0, "_parent": { - "__id__": 56 + "__id__": 60 }, "_children": [ { - "__id__": 70 + "__id__": 74 } ], "_active": true, "_components": [ - { - "__id__": 73 - }, - { - "__id__": 74 - }, - { - "__id__": 75 - }, - { - "__id__": 76 - }, { "__id__": 77 + }, + { + "__id__": 78 + }, + { + "__id__": 79 + }, + { + "__id__": 80 + }, + { + "__id__": 81 } ], "_prefab": null, @@ -1930,16 +2058,16 @@ "_name": "Square", "_objFlags": 0, "_parent": { - "__id__": 69 + "__id__": 73 }, "_children": [], "_active": true, "_components": [ { - "__id__": 71 + "__id__": 75 }, { - "__id__": 72 + "__id__": 76 } ], "_prefab": null, @@ -1976,7 +2104,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 70 + "__id__": 74 }, "_enabled": true, "__prefab": null, @@ -1997,7 +2125,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 70 + "__id__": 74 }, "_enabled": true, "__prefab": null, @@ -2038,7 +2166,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 69 + "__id__": 73 }, "_enabled": true, "__prefab": null, @@ -2059,7 +2187,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 69 + "__id__": 73 }, "_enabled": true, "__prefab": null, @@ -2097,7 +2225,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 69 + "__id__": 73 }, "_enabled": true, "__prefab": null, @@ -2151,7 +2279,7 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 69 + "__id__": 73 }, "_id": "44V8O8mzZKQZv5NNhU9U2X" }, @@ -2160,7 +2288,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 69 + "__id__": 73 }, "_enabled": true, "__prefab": null, @@ -2171,12 +2299,12 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 69 + "__id__": 73 }, "_enabled": true, "__prefab": null, "button": { - "__id__": 76 + "__id__": 80 }, "_id": "19CfluWQpOB4qddmLDK5n9" }, @@ -2185,7 +2313,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 56 + "__id__": 60 }, "_enabled": true, "__prefab": null, @@ -2206,7 +2334,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 56 + "__id__": 60 }, "_enabled": true, "__prefab": null, @@ -2235,17 +2363,17 @@ "_name": "UI", "_objFlags": 0, "_parent": { - "__id__": 55 + "__id__": 59 }, "_children": [ { - "__id__": 81 + "__id__": 85 } ], "_active": true, "_components": [ { - "__id__": 88 + "__id__": 92 } ], "_prefab": null, @@ -2282,23 +2410,23 @@ "_name": "VirtualJoystic", "_objFlags": 0, "_parent": { - "__id__": 80 + "__id__": 84 }, "_children": [ { - "__id__": 82 + "__id__": 86 } ], "_active": true, "_components": [ { - "__id__": 85 + "__id__": 89 }, { - "__id__": 86 + "__id__": 90 }, { - "__id__": 87 + "__id__": 91 } ], "_prefab": null, @@ -2335,16 +2463,16 @@ "_name": "Knob", "_objFlags": 0, "_parent": { - "__id__": 81 + "__id__": 85 }, "_children": [], "_active": true, "_components": [ { - "__id__": 83 + "__id__": 87 }, { - "__id__": 84 + "__id__": 88 } ], "_prefab": null, @@ -2381,7 +2509,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 82 + "__id__": 86 }, "_enabled": true, "__prefab": null, @@ -2402,7 +2530,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 82 + "__id__": 86 }, "_enabled": true, "__prefab": null, @@ -2440,7 +2568,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 81 + "__id__": 85 }, "_enabled": true, "__prefab": null, @@ -2461,7 +2589,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 81 + "__id__": 85 }, "_enabled": true, "__prefab": null, @@ -2499,13 +2627,13 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 81 + "__id__": 85 }, "_enabled": true, "__prefab": null, "maxDistance": 50, "knob": { - "__id__": 82 + "__id__": 86 }, "_id": "50ceZG62tGlYXvZWEvSDKl" }, @@ -2514,7 +2642,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 80 + "__id__": 84 }, "_enabled": true, "__prefab": null, @@ -2535,18 +2663,18 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 55 + "__id__": 59 }, "_enabled": true, "__prefab": null, "xpBar": { - "__id__": 65 + "__id__": 69 }, "timeAliveText": { - "__id__": 68 + "__id__": 72 }, "pauseBtn": { - "__id__": 76 + "__id__": 80 }, "_id": "bau/7eItRFrKKoAZZb/uYL" }, @@ -2555,16 +2683,16 @@ "_name": "ModalWindowManager", "_objFlags": 0, "_parent": { - "__id__": 54 + "__id__": 58 }, "_children": [], "_active": true, "_components": [ { - "__id__": 91 + "__id__": 95 }, { - "__id__": 92 + "__id__": 96 } ], "_prefab": null, @@ -2601,7 +2729,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 90 + "__id__": 94 }, "_enabled": true, "__prefab": null, @@ -2622,7 +2750,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 90 + "__id__": 94 }, "_enabled": true, "__prefab": null, @@ -2647,16 +2775,16 @@ "_name": "Sprite", "_objFlags": 0, "_parent": { - "__id__": 54 + "__id__": 58 }, "_children": [], "_active": true, "_components": [ { - "__id__": 94 + "__id__": 98 }, { - "__id__": 95 + "__id__": 99 } ], "_prefab": null, @@ -2693,7 +2821,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 93 + "__id__": 97 }, "_enabled": true, "__prefab": null, @@ -2714,7 +2842,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 93 + "__id__": 97 }, "_enabled": true, "__prefab": null, @@ -2752,16 +2880,16 @@ "_name": "Sprite-001", "_objFlags": 0, "_parent": { - "__id__": 54 + "__id__": 58 }, "_children": [], "_active": true, "_components": [ { - "__id__": 97 + "__id__": 101 }, { - "__id__": 98 + "__id__": 102 } ], "_prefab": null, @@ -2798,7 +2926,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 96 + "__id__": 100 }, "_enabled": true, "__prefab": null, @@ -2819,7 +2947,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 96 + "__id__": 100 }, "_enabled": true, "__prefab": null, @@ -2857,16 +2985,16 @@ "_name": "Sprite-002", "_objFlags": 0, "_parent": { - "__id__": 54 + "__id__": 58 }, "_children": [], "_active": true, "_components": [ { - "__id__": 100 + "__id__": 104 }, { - "__id__": 101 + "__id__": 105 } ], "_prefab": null, @@ -2903,7 +3031,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 99 + "__id__": 103 }, "_enabled": true, "__prefab": null, @@ -2924,7 +3052,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 99 + "__id__": 103 }, "_enabled": true, "__prefab": null, @@ -2962,16 +3090,16 @@ "_name": "Sprite-003", "_objFlags": 0, "_parent": { - "__id__": 54 + "__id__": 58 }, "_children": [], "_active": true, "_components": [ { - "__id__": 103 + "__id__": 107 }, { - "__id__": 104 + "__id__": 108 } ], "_prefab": null, @@ -3008,7 +3136,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 102 + "__id__": 106 }, "_enabled": true, "__prefab": null, @@ -3029,7 +3157,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 102 + "__id__": 106 }, "_enabled": true, "__prefab": null, @@ -3067,7 +3195,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 54 + "__id__": 58 }, "_enabled": true, "__prefab": null, @@ -3136,7 +3264,7 @@ "_enabled": true, "__prefab": null, "_cameraComponent": { - "__id__": 105 + "__id__": 109 }, "_alignCanvasWithScreen": true, "_id": "12O/ljcVlEqLmVm3U2gEOQ" @@ -3180,7 +3308,7 @@ "_enabled": true, "__prefab": null, "virtualJoystic": { - "__id__": 87 + "__id__": 91 }, "player": null, "haloProjectileLauncherComponent": { @@ -3196,25 +3324,25 @@ "__id__": 31 }, "enemyManager": { - "__id__": 53 + "__id__": 57 }, "itemManager": { - "__id__": 49 + "__id__": 53 }, "camera": { - "__id__": 105 + "__id__": 109 }, "gameUI": { - "__id__": 89 + "__id__": 93 }, "background": { "__id__": 23 }, "modalWindowManager": { - "__id__": 92 + "__id__": 96 }, "gameAudioAdapter": { - "__id__": 110 + "__id__": 114 }, "_id": "3a9z1bqlFCGL4/WyDwU4L5" }, @@ -3223,7 +3351,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 111 + "__id__": 115 }, "_enabled": true, "__prefab": null, @@ -3286,7 +3414,7 @@ "_active": true, "_components": [ { - "__id__": 110 + "__id__": 114 } ], "_prefab": null, @@ -3323,7 +3451,7 @@ "fileId": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f", "targetOverrides": [ { - "__id__": 113 + "__id__": 117 } ], "nestedPrefabInstanceRoots": [ @@ -3341,7 +3469,7 @@ { "__type__": "cc.TargetOverrideInfo", "source": { - "__id__": 109 + "__id__": 113 }, "sourceInfo": null, "propertyPath": [ @@ -3351,7 +3479,7 @@ "__id__": 32 }, "targetInfo": { - "__id__": 114 + "__id__": 118 } }, { @@ -3363,19 +3491,19 @@ { "__type__": "cc.SceneGlobals", "ambient": { - "__id__": 116 + "__id__": 120 }, "shadows": { - "__id__": 117 + "__id__": 121 }, "_skybox": { - "__id__": 118 + "__id__": 122 }, "fog": { - "__id__": 119 + "__id__": 123 }, "octree": { - "__id__": 120 + "__id__": 124 } }, { diff --git a/assets/Scripts/Game/Audio/GameAudioAdapter.ts b/assets/Scripts/Game/Audio/GameAudioAdapter.ts index 96a4ced..8cca900 100644 --- a/assets/Scripts/Game/Audio/GameAudioAdapter.ts +++ b/assets/Scripts/Game/Audio/GameAudioAdapter.ts @@ -1,7 +1,8 @@ import { _decorator, Component, Node, AudioClip } from "cc"; import { AppRoot } from "../../AppRoot/AppRoot"; import { AudioPlayer } from "../../Services/AudioPlayer/AudioPlayer"; -import { ItemManager, ItemType } from "../Items/ItemManager"; +import { ItemManager } from "../Items/ItemManager"; +import { ItemType } from "../Items/ItemType"; import { Enemy } from "../Unit/Enemy/Enemy"; import { EnemyManager } from "../Unit/Enemy/EnemyManager"; import { Player } from "../Unit/Player/Player"; diff --git a/assets/Scripts/Game/Collision/PlayerCollisionSystem.ts b/assets/Scripts/Game/Collision/PlayerCollisionSystem.ts index afdd0c4..91109c4 100644 --- a/assets/Scripts/Game/Collision/PlayerCollisionSystem.ts +++ b/assets/Scripts/Game/Collision/PlayerCollisionSystem.ts @@ -3,10 +3,8 @@ import { ISignal } from "../../Services/EventSystem/ISignal"; import { Signal } from "../../Services/EventSystem/Signal"; import { GameTimer } from "../../Services/GameTimer"; import { GroupType } from "../GroupType"; -import { Gold } from "../Items/Gold/Gold"; -import { HealthPotion } from "../Items/HealthPotion/HealthPotion"; +import { Item } from "../Items/Item"; import { ItemManager } from "../Items/ItemManager"; -import { XP } from "../Items/XP/XP"; import { Projectile } from "../Projectile/Projectile"; import { Enemy } from "../Unit/Enemy/Enemy"; import { Player } from "../Unit/Player/Player"; @@ -29,9 +27,7 @@ export class PlayerCollisionSystem { this.groupToResolver.set(GroupType.ENEMY, this.resolveEnemyContact.bind(this)); this.groupToResolver.set(GroupType.ENEMY_PROJECTILE, this.resolveEnemyProjectileContact.bind(this)); - this.groupToResolver.set(GroupType.XP, this.resolveXpContact.bind(this)); - this.groupToResolver.set(GroupType.GOLD, this.resolveGoldContact.bind(this)); - this.groupToResolver.set(GroupType.HEALTH_POTION, this.resolveHealthPotionContact.bind(this)); + this.groupToResolver.set(GroupType.ITEM, this.resolveItemContact.bind(this)); } public gameTick(deltaTime: number): void { @@ -86,16 +82,8 @@ export class PlayerCollisionSystem { this.player.Health.damage(damage); } - private resolveXpContact(xpCollider: Collider2D): void { - console.log("Collided with XP"); - this.itemManager.pickupXP(xpCollider.node.getComponent(XP)); - } - - private resolveGoldContact(goldCollider: Collider2D): void { - this.itemManager.pickupGold(goldCollider.node.getComponent(Gold)); - } - - private resolveHealthPotionContact(healthPotionCollider: Collider2D): void { - this.itemManager.pickupHealthPotion(healthPotionCollider.node.getComponent(HealthPotion)); + private resolveItemContact(xpCollider: Collider2D): void { + console.log("Collided with item"); + this.itemManager.pickupItem(xpCollider.node.getComponent(Item)); } } diff --git a/assets/Scripts/Game/GroupType.ts b/assets/Scripts/Game/GroupType.ts index cdb7960..be99602 100644 --- a/assets/Scripts/Game/GroupType.ts +++ b/assets/Scripts/Game/GroupType.ts @@ -5,9 +5,8 @@ export enum GroupType { PLAYER = 1 << 1, ENEMY = 1 << 2, WEAPON = 1 << 3, - XP = 1 << 4, + ITEM = 1 << 4, PLAYER_PROJECTILE = 1 << 5, ENEMY_PROJECTILE = 1 << 6, - GOLD = 1 << 7, - HEALTH_POTION = 1 << 8 + MAGNET_RANGE = 1 << 7 } diff --git a/assets/Scripts/Game/Items/Gold.meta b/assets/Scripts/Game/Items/Gold.meta deleted file mode 100644 index 149f100..0000000 --- a/assets/Scripts/Game/Items/Gold.meta +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ver": "1.1.0", - "importer": "directory", - "imported": true, - "uuid": "51704601-c62e-4fff-93ee-73a81cac6e1b", - "files": [], - "subMetas": {}, - "userData": { - "compressionType": {}, - "isRemoteBundle": {} - } -} diff --git a/assets/Scripts/Game/Items/Gold/Gold.ts b/assets/Scripts/Game/Items/Gold/Gold.ts deleted file mode 100644 index e7a88f1..0000000 --- a/assets/Scripts/Game/Items/Gold/Gold.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, Vec3, _decorator } from "cc"; -import { ISignal } from "../../../Services/EventSystem/ISignal"; -import { Signal } from "../../../Services/EventSystem/Signal"; - -const { ccclass, property } = _decorator; - -@ccclass("Gold") -export class Gold extends Component { - private pickUpEvent: Signal = new Signal(); - - public setup(position: Vec3): void { - this.node.setWorldPosition(position); - this.node.active = true; - } - - public get PickupEvent(): ISignal { - return this.pickUpEvent; - } - - public pickup(): void { - this.pickUpEvent.trigger(this); - this.node.active = false; - } -} diff --git a/assets/Scripts/Game/Items/Gold/GoldSpawner.ts b/assets/Scripts/Game/Items/Gold/GoldSpawner.ts deleted file mode 100644 index 4032362..0000000 --- a/assets/Scripts/Game/Items/Gold/GoldSpawner.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Component, Prefab, Vec3, _decorator } from "cc"; -import { ObjectPool } from "../../../Services/ObjectPool"; -import { Gold } from "./Gold"; - -const { ccclass, property } = _decorator; - -@ccclass("GoldSpawner") -export class GoldSpawner extends Component { - @property(Prefab) public goldPrefab: Prefab; - - private goldPool: ObjectPool; - public init(): void { - this.goldPool = new ObjectPool(this.goldPrefab, this.node, 5, "Gold"); - } - - public spawn(position: Vec3): void { - const gold: Gold = this.goldPool.borrow(); - gold.setup(position); - gold.PickupEvent.on(this.return, this); - } - - private return(gold: Gold): void { - gold.PickupEvent.off(this.return); - this.goldPool.return(gold); - } -} diff --git a/assets/Scripts/Game/Items/HealthPotion.meta b/assets/Scripts/Game/Items/HealthPotion.meta deleted file mode 100644 index 6576869..0000000 --- a/assets/Scripts/Game/Items/HealthPotion.meta +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ver": "1.1.0", - "importer": "directory", - "imported": true, - "uuid": "5f34fac0-e23f-42da-9c26-d55b9df6ef32", - "files": [], - "subMetas": {}, - "userData": { - "compressionType": {}, - "isRemoteBundle": {} - } -} diff --git a/assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts b/assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts deleted file mode 100644 index 09908d9..0000000 --- a/assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Animation, Component, Vec3, _decorator } from "cc"; -import { ISignal } from "../../../Services/EventSystem/ISignal"; -import { Signal } from "../../../Services/EventSystem/Signal"; - -const { ccclass, property } = _decorator; - -@ccclass("HealthPotion") -export class HealthPotion extends Component { - @property(Animation) private animation: Animation; - - private pickUpEvent: Signal = new Signal(); - - public setup(position: Vec3): void { - this.node.setWorldPosition(position); - this.node.active = true; - this.animation.play("DropStart"); - } - - public get PickupEvent(): ISignal { - return this.pickUpEvent; - } - - public pickup(): void { - this.pickUpEvent.trigger(this); - this.node.active = false; - } -} diff --git a/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts b/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts deleted file mode 100644 index ceeb5c8..0000000 --- a/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Component, Prefab, Vec3, _decorator } from "cc"; -import { ObjectPool } from "../../../Services/ObjectPool"; -import { HealthPotion } from "./HealthPotion"; - -const { ccclass, property } = _decorator; - -@ccclass("HealthPotionSpawner") -export class HealthPotionSpawner extends Component { - @property(Prefab) public healthPotionPrefab: Prefab; - - private healthPotionPool: ObjectPool; - - public init(): void { - this.healthPotionPool = new ObjectPool(this.healthPotionPrefab, this.node, 5, "HealthPotion"); - } - - public spawn(position: Vec3): void { - const healthPotion: HealthPotion = this.healthPotionPool.borrow(); - healthPotion.setup(position); - healthPotion.PickupEvent.on(this.return, this); - } - - private return(healthPotion: HealthPotion): void { - healthPotion.PickupEvent.off(this.return); - this.healthPotionPool.return(healthPotion); - } -} diff --git a/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts.meta b/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts.meta deleted file mode 100644 index 8734aef..0000000 --- a/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts.meta +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ver": "4.0.23", - "importer": "typescript", - "imported": true, - "uuid": "1e3b0c7f-c831-4778-8688-d8e2c0f6dc00", - "files": [], - "subMetas": {}, - "userData": {} -} diff --git a/assets/Scripts/Game/Items/Item.ts b/assets/Scripts/Game/Items/Item.ts new file mode 100644 index 0000000..d980fda --- /dev/null +++ b/assets/Scripts/Game/Items/Item.ts @@ -0,0 +1,30 @@ +import { _decorator, Component, Node, Vec3, ccenum, Enum } from "cc"; +import { ISignal } from "../../Services/EventSystem/ISignal"; +import { Signal } from "../../Services/EventSystem/Signal"; +import { ItemType } from "./ItemType"; +const { ccclass, property } = _decorator; + +@ccclass("Item") +export class Item extends Component { + @property({ type: Enum(ItemType) }) private itemType: ItemType; + + private pickUpEvent = new Signal(); + + public get ItemType(): ItemType { + return this.itemType; + } + + public setup(position: Vec3): void { + this.node.setWorldPosition(position); + this.node.active = true; + } + + public get PickupEvent(): ISignal { + return this.pickUpEvent; + } + + public pickup(): void { + this.pickUpEvent.trigger(this); + this.node.active = false; + } +} diff --git a/assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts.meta b/assets/Scripts/Game/Items/Item.ts.meta similarity index 70% rename from assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts.meta rename to assets/Scripts/Game/Items/Item.ts.meta index 972915c..1104b39 100644 --- a/assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts.meta +++ b/assets/Scripts/Game/Items/Item.ts.meta @@ -2,7 +2,7 @@ "ver": "4.0.23", "importer": "typescript", "imported": true, - "uuid": "18f8de69-e361-4e73-8b98-a2735d0730a6", + "uuid": "724babaa-7e15-47d1-85ac-5ee835eae1cb", "files": [], "subMetas": {}, "userData": {} diff --git a/assets/Scripts/Game/Items/ItemManager.ts b/assets/Scripts/Game/Items/ItemManager.ts index 525bc83..a28b9e5 100644 --- a/assets/Scripts/Game/Items/ItemManager.ts +++ b/assets/Scripts/Game/Items/ItemManager.ts @@ -6,20 +6,20 @@ import { GameResult } from "../Game"; import { Enemy } from "../Unit/Enemy/Enemy"; import { EnemyManager } from "../Unit/Enemy/EnemyManager"; import { Player } from "../Unit/Player/Player"; -import { Gold } from "./Gold/Gold"; -import { GoldSpawner } from "./Gold/GoldSpawner"; -import { HealthPotion } from "./HealthPotion/HealthPotion"; -import { HealthPotionSpawner } from "./HealthPotion/HealthPotionSpawner"; +import { Item } from "./Item"; +import { ItemSpawner } from "./ItemSpawner"; +import { ItemType } from "./ItemType"; import { PickupEffectManager } from "./PickupEffect/PickupEffectManager"; -import { XP } from "./XP/XP"; -import { XPSpawner } from "./XP/XPSpawner"; + const { ccclass, property } = _decorator; @ccclass("ItemManager") export class ItemManager extends Component { - @property(XPSpawner) private xpSpawner: XPSpawner; - @property(GoldSpawner) private goldSpawner: GoldSpawner; - @property(HealthPotionSpawner) private healthPotionSpawner: HealthPotionSpawner; + @property(ItemSpawner) private xpSpawner: ItemSpawner; + @property(ItemSpawner) private goldSpawner: ItemSpawner; + @property(ItemSpawner) private healthPotionSpawner: ItemSpawner; + @property(ItemSpawner) private magnetSpawner: ItemSpawner; + @property(ItemSpawner) private chestSpawner: ItemSpawner; @property(PickupEffectManager) private pickupEffectManager: PickupEffectManager; private player: Player; @@ -28,6 +28,8 @@ export class ItemManager extends Component { private pickupEvent = new Signal(); + private itemTypeToAction = new Map void>(); + public init(enemyManager: EnemyManager, player: Player, gameResult: GameResult, settings: ItemSettings): void { this.player = player; this.gameResult = gameResult; @@ -39,34 +41,40 @@ export class ItemManager extends Component { this.xpSpawner.init(); this.goldSpawner.init(); this.healthPotionSpawner.init(); + this.magnetSpawner.init(); + this.chestSpawner.init(); + this.pickupEffectManager.init(); + + this.itemTypeToAction.set(ItemType.XP, this.addXP.bind(this)); + this.itemTypeToAction.set(ItemType.Gold, this.addGold.bind(this)); + this.itemTypeToAction.set(ItemType.HealthPotion, this.useHealthPotion.bind(this)); } public get PickupEvent(): ISignal { return this.pickupEvent; } - public pickupXP(xp: XP): void { - this.pickupEffectManager.showEffect(xp.node.worldPosition); - this.pickupEvent.trigger(ItemType.XP); + public pickupItem(item: Item): void { + if (!this.itemTypeToAction.has(item.ItemType)) throw new Error("Does not have behaviour set for " + item.ItemType); - this.player.Level.addXp(xp.Value); - xp.pickup(); + this.pickupEffectManager.showEffect(item.node.worldPosition); + this.pickupEvent.trigger(item.ItemType); + + this.itemTypeToAction.get(item.ItemType)(); + + item.pickup(); } - public pickupGold(gold: Gold): void { - this.pickupEffectManager.showEffect(gold.node.worldPosition); - this.pickupEvent.trigger(ItemType.Gold); + private addXP(): void { + this.player.Level.addXp(1); + } - gold.pickup(); + private addGold(): void { this.gameResult.goldCoins++; } - public pickupHealthPotion(healthPotion: HealthPotion): void { - this.pickupEffectManager.showEffect(healthPotion.node.worldPosition); - this.pickupEvent.trigger(ItemType.HealthPotion); - - healthPotion.pickup(); + private useHealthPotion(): void { this.player.Health.heal(this.healthPerPotion); } @@ -86,7 +94,7 @@ export class ItemManager extends Component { private trySpawnXP(enemy: Enemy): void { for (let index = 0; index < enemy.XPReward; index++) { - this.xpSpawner.spawnXp(this.getRandomPosition(enemy), 1); + this.xpSpawner.spawn(this.getRandomPosition(enemy)); } } @@ -121,9 +129,3 @@ export class ItemManager extends Component { return position; } } - -export enum ItemType { - XP, - Gold, - HealthPotion -} diff --git a/assets/Scripts/Game/Items/ItemSpawner.ts b/assets/Scripts/Game/Items/ItemSpawner.ts new file mode 100644 index 0000000..223143c --- /dev/null +++ b/assets/Scripts/Game/Items/ItemSpawner.ts @@ -0,0 +1,26 @@ +import { Component, Prefab, Vec3, _decorator } from "cc"; +import { ObjectPool } from "../../Services/ObjectPool"; +import { Item } from "./Item"; + +const { ccclass, property } = _decorator; + +@ccclass("ItemSpawner") +export class ItemSpawner extends Component { + @property(Prefab) public itemPrefab: Prefab; + + private itemPool: ObjectPool; + public init(): void { + this.itemPool = new ObjectPool(this.itemPrefab, this.node, 5, "Item"); + } + + public spawn(position: Vec3): void { + const item: Item = this.itemPool.borrow(); + item.setup(position); + item.PickupEvent.on(this.return, this); + } + + private return(gold: Item): void { + gold.PickupEvent.off(this.return); + this.itemPool.return(gold); + } +} diff --git a/assets/Scripts/Game/Items/Gold/GoldSpawner.ts.meta b/assets/Scripts/Game/Items/ItemSpawner.ts.meta similarity index 70% rename from assets/Scripts/Game/Items/Gold/GoldSpawner.ts.meta rename to assets/Scripts/Game/Items/ItemSpawner.ts.meta index 96eb479..f4d9900 100644 --- a/assets/Scripts/Game/Items/Gold/GoldSpawner.ts.meta +++ b/assets/Scripts/Game/Items/ItemSpawner.ts.meta @@ -2,7 +2,7 @@ "ver": "4.0.23", "importer": "typescript", "imported": true, - "uuid": "abf1ff90-c9a3-4d65-8bb9-1ac9ebeb7d51", + "uuid": "74c52c0a-cced-4f28-a00d-a012374264bb", "files": [], "subMetas": {}, "userData": {} diff --git a/assets/Scripts/Game/Items/ItemType.ts b/assets/Scripts/Game/Items/ItemType.ts new file mode 100644 index 0000000..f678040 --- /dev/null +++ b/assets/Scripts/Game/Items/ItemType.ts @@ -0,0 +1,7 @@ +export enum ItemType { + XP, + Gold, + HealthPotion, + Magnet, + Chest +} diff --git a/assets/Scripts/Game/Items/Gold/Gold.ts.meta b/assets/Scripts/Game/Items/ItemType.ts.meta similarity index 70% rename from assets/Scripts/Game/Items/Gold/Gold.ts.meta rename to assets/Scripts/Game/Items/ItemType.ts.meta index eb7017c..65d886b 100644 --- a/assets/Scripts/Game/Items/Gold/Gold.ts.meta +++ b/assets/Scripts/Game/Items/ItemType.ts.meta @@ -2,7 +2,7 @@ "ver": "4.0.23", "importer": "typescript", "imported": true, - "uuid": "41f6700e-1184-4c4c-b5f0-35fec21bd88e", + "uuid": "bd234201-f46c-4031-8e2d-930fa90b2277", "files": [], "subMetas": {}, "userData": {} diff --git a/assets/Scripts/Game/Items/XP.meta b/assets/Scripts/Game/Items/XP.meta deleted file mode 100644 index 90098ab..0000000 --- a/assets/Scripts/Game/Items/XP.meta +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ver": "1.1.0", - "importer": "directory", - "imported": true, - "uuid": "1e85dd0e-3cbc-4870-9a6a-50e0c29cfeb7", - "files": [], - "subMetas": {}, - "userData": { - "compressionType": {}, - "isRemoteBundle": {} - } -} diff --git a/assets/Scripts/Game/Items/XP.ts b/assets/Scripts/Game/Items/XP.ts new file mode 100644 index 0000000..2c689b6 --- /dev/null +++ b/assets/Scripts/Game/Items/XP.ts @@ -0,0 +1,14 @@ +import { Animation, Vec3, _decorator } from "cc"; +import { Item } from "./Item"; + +const { ccclass, property } = _decorator; + +@ccclass("XP") +export class XP extends Item { + @property(Animation) private animation: Animation; + + public setup(position: Vec3): void { + super.setup(position); + this.animation.play("DropStart"); + } +} diff --git a/assets/Scripts/Game/Items/XP/XP.ts.meta b/assets/Scripts/Game/Items/XP.ts.meta similarity index 70% rename from assets/Scripts/Game/Items/XP/XP.ts.meta rename to assets/Scripts/Game/Items/XP.ts.meta index acc43ae..5e07313 100644 --- a/assets/Scripts/Game/Items/XP/XP.ts.meta +++ b/assets/Scripts/Game/Items/XP.ts.meta @@ -2,7 +2,7 @@ "ver": "4.0.23", "importer": "typescript", "imported": true, - "uuid": "7a5361b6-3ae7-45b6-94ec-a05f322d7896", + "uuid": "801bcd5f-12e5-4ce6-93e7-d9bb66f4d299", "files": [], "subMetas": {}, "userData": {} diff --git a/assets/Scripts/Game/Items/XP/XP.ts b/assets/Scripts/Game/Items/XP/XP.ts deleted file mode 100644 index 8dce070..0000000 --- a/assets/Scripts/Game/Items/XP/XP.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Animation, Component, Vec3, _decorator } from "cc"; -import { ISignal } from "../../../Services/EventSystem/ISignal"; -import { Signal } from "../../../Services/EventSystem/Signal"; - -const { ccclass, property } = _decorator; - -@ccclass("XP") -export class XP extends Component { - @property(Animation) private animation: Animation; - - private pickUpEvent: Signal = new Signal(); - private value = 2; - - public setup(position: Vec3, value: number): void { - this.node.setWorldPosition(position); - this.value = value; - this.node.active = true; - this.animation.play("DropStart"); - } - - public get Value(): number { - return this.value; - } - - public get PickupEvent(): ISignal { - return this.pickUpEvent; - } - - public pickup(): void { - this.pickUpEvent.trigger(this); - this.node.active = false; - } -} diff --git a/assets/Scripts/Game/Items/XP/XPSpawner.ts b/assets/Scripts/Game/Items/XP/XPSpawner.ts deleted file mode 100644 index cc0f426..0000000 --- a/assets/Scripts/Game/Items/XP/XPSpawner.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Component, Prefab, Vec3, _decorator } from "cc"; -import { ObjectPool } from "../../../Services/ObjectPool"; - -import { XP } from "./XP"; -const { ccclass, property } = _decorator; - -@ccclass("XPSpawner") -export class XPSpawner extends Component { - @property(Prefab) public xpPrefab: Prefab; - - private xpPool: ObjectPool; - public init(): void { - this.xpPool = new ObjectPool(this.xpPrefab, this.node, 5, "XP"); - } - - public spawnXp(position: Vec3, value: number): void { - const xp: XP = this.xpPool.borrow(); - xp.setup(position, value); - xp.PickupEvent.on(this.returnXp, this); - } - - private returnXp(xp: XP): void { - xp.PickupEvent.off(this.returnXp); - this.xpPool.return(xp); - } -} diff --git a/assets/Scripts/Game/Items/XP/XPSpawner.ts.meta b/assets/Scripts/Game/Items/XP/XPSpawner.ts.meta deleted file mode 100644 index 6b28c13..0000000 --- a/assets/Scripts/Game/Items/XP/XPSpawner.ts.meta +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ver": "4.0.23", - "importer": "typescript", - "imported": true, - "uuid": "ab9e206b-f11a-417c-814b-07d29c59ed6e", - "files": [], - "subMetas": {}, - "userData": {} -} diff --git a/settings/v2/packages/project.json b/settings/v2/packages/project.json index 114d613..1c2fe5a 100644 --- a/settings/v2/packages/project.json +++ b/settings/v2/packages/project.json @@ -15,7 +15,7 @@ }, { "index": 4, - "name": "XP" + "name": "ITEM" }, { "index": 5, @@ -26,12 +26,8 @@ "name": "ENEMY_PROJECTILE" }, { - "index": 7, - "name": "GOLD" - }, - { - "index": 8, - "name": "HEALTH_POTION" + "index": 9, + "name": "MAGNET_RANGE" } ], "collisionMatrix": { @@ -43,7 +39,8 @@ "5": 4, "6": 2, "7": 2, - "8": 2 + "8": 2, + "9": 0 } }, "general": {