diff --git a/assets/Data/GameSettings.json b/assets/Data/GameSettings.json index 1d3d210..103a6a8 100644 --- a/assets/Data/GameSettings.json +++ b/assets/Data/GameSettings.json @@ -145,7 +145,8 @@ "speed": 60, "lifetime": -1, "xpReward": 1, - "goldReward": 0 + "goldReward": 0, + "healthPotionRewardChance": 0.5 }, { "id": "StandardEnemy", @@ -156,7 +157,8 @@ "speed": 65, "lifetime": -1, "xpReward": 1, - "goldReward": 0.1 + "goldReward": 0.1, + "healthPotionRewardChance": 0 }, { "id": "FastEnemy", @@ -167,7 +169,8 @@ "speed": 75, "lifetime": -1, "xpReward": 1, - "goldReward": 0.1 + "goldReward": 0.1, + "healthPotionRewardChance": 0 }, { "id": "CircleEnemy", @@ -178,7 +181,8 @@ "speed": 25, "lifetime": 29, "xpReward": 1, - "goldReward": 1 + "goldReward": 1, + "healthPotionRewardChance": 0 }, { "id": "CircleEnemyStandard", @@ -189,7 +193,8 @@ "speed": 35, "lifetime": 27, "xpReward": 1, - "goldReward": 2 + "goldReward": 2, + "healthPotionRewardChance": 0 }, { "id": "WaveEnemy", @@ -200,7 +205,8 @@ "speed": 390, "lifetime": 20, "xpReward": 1, - "goldReward": 0.2 + "goldReward": 0.2, + "healthPotionRewardChance": 0 }, { "id": "WaveEnemyArmor", @@ -211,7 +217,8 @@ "speed": 70, "lifetime": 30, "xpReward": 1, - "goldReward": 1 + "goldReward": 1, + "healthPotionRewardChance": 0 }, { "id": "WaveEnemyArmorFast", @@ -222,7 +229,8 @@ "speed": 320, "lifetime": 30, "xpReward": 1, - "goldReward": 1 + "goldReward": 1, + "healthPotionRewardChance": 0 }, { "id": "BasicBoss", @@ -233,7 +241,8 @@ "speed": 65, "lifetime": -1, "xpReward": 1, - "goldReward": 3 + "goldReward": 3, + "healthPotionRewardChance": 0 }, { "id": "StandardBoss", @@ -244,7 +253,8 @@ "speed": 75, "lifetime": -1, "xpReward": 2, - "goldReward": 5 + "goldReward": 5, + "healthPotionRewardChance": 0 }, { "id": "BasicCheetah", @@ -255,7 +265,8 @@ "speed": 120, "lifetime": -1, "xpReward": 1, - "goldReward": 1 + "goldReward": 1, + "healthPotionRewardChance": 0 } ], "periodicFollowMovers": [ @@ -483,5 +494,8 @@ "enemiesToSpawn": 14 } ] + }, + "items": { + "healthPerPotion": 10 } } \ No newline at end of file diff --git a/assets/Media/Animation/Game/Drops/DropStart.anim b/assets/Media/Animation/Game/Drops/DropStart.anim index a133ca6..06cb027 100644 --- a/assets/Media/Animation/Game/Drops/DropStart.anim +++ b/assets/Media/Animation/Game/Drops/DropStart.anim @@ -85,10 +85,10 @@ "__type__": "cc.RealCurve", "_times": [ 0, - 0.16666666666666666, - 0.3333333333333333, - 0.45, - 0.55 + 0.1666666716337204, + 0.3333333432674408, + 0.44999998807907104, + 0.550000011920929 ], "_values": [ { @@ -268,7 +268,7 @@ "__type__": "cc.RealCurve", "_times": [ 0, - 0.16666666666666666 + 0.1666666716337204 ], "_values": [ { diff --git a/assets/Media/Prefabs/Game/Drops/Health.prefab b/assets/Media/Prefabs/Game/Drops/HealthPotion.prefab similarity index 96% rename from assets/Media/Prefabs/Game/Drops/Health.prefab rename to assets/Media/Prefabs/Game/Drops/HealthPotion.prefab index 46c54c0..be6ff8b 100644 --- a/assets/Media/Prefabs/Game/Drops/Health.prefab +++ b/assets/Media/Prefabs/Game/Drops/HealthPotion.prefab @@ -1,7 +1,7 @@ [ { "__type__": "cc.Prefab", - "_name": "Health", + "_name": "HealthPotion", "_objFlags": 0, "_native": "", "data": { @@ -13,7 +13,7 @@ }, { "__type__": "cc.Node", - "_name": "Health", + "_name": "HealthPotion", "_objFlags": 0, "__editorExtras__": {}, "_parent": null, @@ -314,15 +314,15 @@ "__id__": 15 }, "tag": 0, - "_group": 16, + "_group": 256, "_density": 1, "_sensor": false, "_friction": 0.2, "_restitution": 0, "_offset": { "__type__": "cc.Vec2", - "x": 0, - "y": -7.5 + "x": 0.5, + "y": -3.4 }, "_radius": 8, "_id": "" @@ -331,23 +331,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "75WVRoLrtKLrJihCVsxa4D" }, - { - "__type__": "7a536G2OudFtpTsoF8yLXiW", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 17 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "72AObOIbxCf6LIYsYqoFZF" - }, { "__type__": "cc.Animation", "_name": "", @@ -357,7 +340,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 19 + "__id__": 17 }, "playOnLoad": true, "_clips": [ @@ -376,6 +359,26 @@ "__type__": "cc.CompPrefabInfo", "fileId": "3ag4rexLNJW6A/sp6OpwZ8" }, + { + "__type__": "18f8d5p42FOc4uYonNdBzCm", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 19 + }, + "animation": { + "__id__": 16 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "65lXWGNONBy5ucPc5KmOaR" + }, { "__type__": "cc.PrefabInfo", "root": { diff --git a/assets/Media/Prefabs/Game/Drops/Health.prefab.meta b/assets/Media/Prefabs/Game/Drops/HealthPotion.prefab.meta similarity index 84% rename from assets/Media/Prefabs/Game/Drops/Health.prefab.meta rename to assets/Media/Prefabs/Game/Drops/HealthPotion.prefab.meta index bdef251..544483c 100644 --- a/assets/Media/Prefabs/Game/Drops/Health.prefab.meta +++ b/assets/Media/Prefabs/Game/Drops/HealthPotion.prefab.meta @@ -8,6 +8,6 @@ ], "subMetas": {}, "userData": { - "syncNodeName": "Health" + "syncNodeName": "HealthPotion" } } diff --git a/assets/Scenes/Game.scene b/assets/Scenes/Game.scene index 3812416..3cadb2a 100644 --- a/assets/Scenes/Game.scene +++ b/assets/Scenes/Game.scene @@ -27,11 +27,11 @@ "_active": true, "_components": [], "_prefab": { - "__id__": 102 + "__id__": 104 }, "autoReleaseAssets": false, "_globals": { - "__id__": 105 + "__id__": 107 }, "_id": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f" }, @@ -235,25 +235,25 @@ "__id__": 32 }, { - "__id__": 40 + "__id__": 42 }, { - "__id__": 44 + "__id__": 46 } ], "_active": true, "_components": [ - { - "__id__": 98 - }, - { - "__id__": 99 - }, { "__id__": 100 }, { "__id__": 101 + }, + { + "__id__": 102 + }, + { + "__id__": 103 } ], "_prefab": null, @@ -741,12 +741,15 @@ }, { "__id__": 37 + }, + { + "__id__": 39 } ], "_active": true, "_components": [ { - "__id__": 39 + "__id__": 41 } ], "_prefab": null, @@ -896,7 +899,7 @@ }, { "__type__": "cc.Node", - "_name": "PickupEffectManager", + "_name": "HealthPotionSpawner", "_objFlags": 0, "_parent": { "__id__": 32 @@ -935,6 +938,64 @@ "y": 0, "z": 0 }, + "_id": "17lYyBgbtI7ZCekaxNE2yC" + }, + { + "__type__": "1e3b0x/yDFHeIaI2OLA9twA", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 37 + }, + "_enabled": true, + "__prefab": null, + "healthPotionPrefab": { + "__uuid__": "ef33cda3-5ce0-41e6-ba03-7194178de12c", + "__expectedType__": "cc.Prefab" + }, + "_id": "3dd0khZZRLb4rd4dwkgaIN" + }, + { + "__type__": "cc.Node", + "_name": "PickupEffectManager", + "_objFlags": 0, + "_parent": { + "__id__": 32 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 40 + } + ], + "_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" }, { @@ -942,7 +1003,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 37 + "__id__": 39 }, "_enabled": true, "__prefab": null, @@ -967,9 +1028,12 @@ "goldSpawner": { "__id__": 36 }, - "pickupEffectManager": { + "healthPotionSpawner": { "__id__": 38 }, + "pickupEffectManager": { + "__id__": 40 + }, "_id": "98EDpSoeBKp7eDmPXKNFJ0" }, { @@ -981,13 +1045,13 @@ }, "_children": [ { - "__id__": 41 + "__id__": 43 } ], "_active": true, "_components": [ { - "__id__": 43 + "__id__": 45 } ], "_prefab": null, @@ -1024,13 +1088,13 @@ "_name": "EnemySpawner", "_objFlags": 0, "_parent": { - "__id__": 40 + "__id__": 42 }, "_children": [], "_active": true, "_components": [ { - "__id__": 42 + "__id__": 44 } ], "_prefab": null, @@ -1067,7 +1131,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 41 + "__id__": 43 }, "_enabled": true, "__prefab": null, @@ -1096,12 +1160,12 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 40 + "__id__": 42 }, "_enabled": true, "__prefab": null, "enemySpawner": { - "__id__": 42 + "__id__": 44 }, "_id": "1ffjazmm5IkZwKInsSIULY" }, @@ -1114,28 +1178,28 @@ }, "_children": [ { - "__id__": 45 + "__id__": 47 }, { - "__id__": 71 + "__id__": 73 }, { - "__id__": 85 + "__id__": 87 }, { - "__id__": 88 + "__id__": 90 }, { - "__id__": 91 + "__id__": 93 }, { - "__id__": 94 + "__id__": 96 } ], "_active": true, "_components": [ { - "__id__": 97 + "__id__": 99 } ], "_prefab": null, @@ -1172,20 +1236,20 @@ "_name": "GameUI", "_objFlags": 0, "_parent": { - "__id__": 44 + "__id__": 46 }, "_children": [ { - "__id__": 46 + "__id__": 48 }, { - "__id__": 61 + "__id__": 63 } ], "_active": true, "_components": [ { - "__id__": 70 + "__id__": 72 } ], "_prefab": null, @@ -1222,23 +1286,23 @@ "_name": "TopUI", "_objFlags": 0, "_parent": { - "__id__": 45 + "__id__": 47 }, "_children": [ { - "__id__": 47 + "__id__": 49 }, { - "__id__": 56 + "__id__": 58 } ], "_active": true, "_components": [ { - "__id__": 59 + "__id__": 61 }, { - "__id__": 60 + "__id__": 62 } ], "_prefab": null, @@ -1275,23 +1339,23 @@ "_name": "XpBar", "_objFlags": 0, "_parent": { - "__id__": 46 + "__id__": 48 }, "_children": [ { - "__id__": 48 + "__id__": 50 }, { - "__id__": 51 + "__id__": 53 } ], "_active": true, "_components": [ { - "__id__": 54 + "__id__": 56 }, { - "__id__": 55 + "__id__": 57 } ], "_prefab": null, @@ -1328,16 +1392,16 @@ "_name": "Background", "_objFlags": 0, "_parent": { - "__id__": 47 + "__id__": 49 }, "_children": [], "_active": true, "_components": [ { - "__id__": 49 + "__id__": 51 }, { - "__id__": 50 + "__id__": 52 } ], "_prefab": null, @@ -1374,7 +1438,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 48 + "__id__": 50 }, "_enabled": true, "__prefab": null, @@ -1395,7 +1459,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 48 + "__id__": 50 }, "_enabled": true, "__prefab": null, @@ -1433,16 +1497,16 @@ "_name": "MovableBar", "_objFlags": 0, "_parent": { - "__id__": 47 + "__id__": 49 }, "_children": [], "_active": true, "_components": [ { - "__id__": 52 + "__id__": 54 }, { - "__id__": 53 + "__id__": 55 } ], "_prefab": null, @@ -1479,7 +1543,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 51 + "__id__": 53 }, "_enabled": true, "__prefab": null, @@ -1500,7 +1564,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 51 + "__id__": 53 }, "_enabled": true, "__prefab": null, @@ -1538,7 +1602,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 47 + "__id__": 49 }, "_enabled": true, "__prefab": null, @@ -1559,12 +1623,12 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 47 + "__id__": 49 }, "_enabled": true, "__prefab": null, "_barSprite": { - "__id__": 53 + "__id__": 55 }, "_mode": 0, "_totalLength": 600, @@ -1577,16 +1641,16 @@ "_name": "TimeAliveText", "_objFlags": 0, "_parent": { - "__id__": 46 + "__id__": 48 }, "_children": [], "_active": true, "_components": [ { - "__id__": 57 + "__id__": 59 }, { - "__id__": 58 + "__id__": 60 } ], "_prefab": null, @@ -1623,7 +1687,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 56 + "__id__": 58 }, "_enabled": true, "__prefab": null, @@ -1644,7 +1708,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 56 + "__id__": 58 }, "_enabled": true, "__prefab": null, @@ -1685,7 +1749,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 46 + "__id__": 48 }, "_enabled": true, "__prefab": null, @@ -1706,7 +1770,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 46 + "__id__": 48 }, "_enabled": true, "__prefab": null, @@ -1735,17 +1799,17 @@ "_name": "UI", "_objFlags": 0, "_parent": { - "__id__": 45 + "__id__": 47 }, "_children": [ { - "__id__": 62 + "__id__": 64 } ], "_active": true, "_components": [ { - "__id__": 69 + "__id__": 71 } ], "_prefab": null, @@ -1782,23 +1846,23 @@ "_name": "VirtualJoystic", "_objFlags": 0, "_parent": { - "__id__": 61 + "__id__": 63 }, "_children": [ { - "__id__": 63 + "__id__": 65 } ], "_active": true, "_components": [ - { - "__id__": 66 - }, - { - "__id__": 67 - }, { "__id__": 68 + }, + { + "__id__": 69 + }, + { + "__id__": 70 } ], "_prefab": null, @@ -1835,16 +1899,16 @@ "_name": "Knob", "_objFlags": 0, "_parent": { - "__id__": 62 + "__id__": 64 }, "_children": [], "_active": true, "_components": [ { - "__id__": 64 + "__id__": 66 }, { - "__id__": 65 + "__id__": 67 } ], "_prefab": null, @@ -1881,7 +1945,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 63 + "__id__": 65 }, "_enabled": true, "__prefab": null, @@ -1902,7 +1966,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 63 + "__id__": 65 }, "_enabled": true, "__prefab": null, @@ -1940,7 +2004,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 62 + "__id__": 64 }, "_enabled": true, "__prefab": null, @@ -1961,7 +2025,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 62 + "__id__": 64 }, "_enabled": true, "__prefab": null, @@ -1999,13 +2063,13 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 62 + "__id__": 64 }, "_enabled": true, "__prefab": null, "maxDistance": 50, "knob": { - "__id__": 63 + "__id__": 65 }, "_id": "50ceZG62tGlYXvZWEvSDKl" }, @@ -2014,7 +2078,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 61 + "__id__": 63 }, "_enabled": true, "__prefab": null, @@ -2035,15 +2099,15 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 45 + "__id__": 47 }, "_enabled": true, "__prefab": null, "xpBar": { - "__id__": 55 + "__id__": 57 }, "timeAliveText": { - "__id__": 58 + "__id__": 60 }, "_id": "bau/7eItRFrKKoAZZb/uYL" }, @@ -2052,20 +2116,20 @@ "_name": "ModalWindowManager", "_objFlags": 0, "_parent": { - "__id__": 44 + "__id__": 46 }, "_children": [ { - "__id__": 72 + "__id__": 74 } ], "_active": true, "_components": [ { - "__id__": 83 + "__id__": 85 }, { - "__id__": 84 + "__id__": 86 } ], "_prefab": null, @@ -2101,17 +2165,17 @@ "__type__": "cc.Node", "_objFlags": 0, "_parent": { - "__id__": 71 + "__id__": 73 }, "_prefab": { - "__id__": 73 + "__id__": 75 }, "__editorExtras__": {} }, { "__type__": "cc.PrefabInfo", "root": { - "__id__": 72 + "__id__": 74 }, "asset": { "__uuid__": "663674aa-da1c-44b0-8049-49db9b020973", @@ -2119,11 +2183,11 @@ }, "fileId": "32U/bJCUBDlaQxxGFNXZTu", "instance": { - "__id__": 74 + "__id__": 76 }, "targetOverrides": [ { - "__id__": 81 + "__id__": 83 } ] }, @@ -2133,20 +2197,20 @@ "mountedChildren": [], "mountedComponents": [], "propertyOverrides": [ - { - "__id__": 75 - }, { "__id__": 77 }, - { - "__id__": 78 - }, { "__id__": 79 }, { "__id__": 80 + }, + { + "__id__": 81 + }, + { + "__id__": 82 } ], "removedComponents": [] @@ -2154,7 +2218,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 76 + "__id__": 78 }, "propertyPath": [ "_name" @@ -2170,7 +2234,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 76 + "__id__": 78 }, "propertyPath": [ "_lpos" @@ -2185,7 +2249,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 76 + "__id__": 78 }, "propertyPath": [ "_lrot" @@ -2201,7 +2265,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 76 + "__id__": 78 }, "propertyPath": [ "_euler" @@ -2216,7 +2280,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 76 + "__id__": 78 }, "propertyPath": [ "_active" @@ -2233,7 +2297,7 @@ ], "target": null, "targetInfo": { - "__id__": 82 + "__id__": 84 } }, { @@ -2247,7 +2311,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 71 + "__id__": 73 }, "_enabled": true, "__prefab": null, @@ -2268,7 +2332,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 71 + "__id__": 73 }, "_enabled": true, "__prefab": null, @@ -2285,16 +2349,16 @@ "_name": "Sprite", "_objFlags": 0, "_parent": { - "__id__": 44 + "__id__": 46 }, "_children": [], "_active": true, "_components": [ { - "__id__": 86 + "__id__": 88 }, { - "__id__": 87 + "__id__": 89 } ], "_prefab": null, @@ -2331,7 +2395,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 85 + "__id__": 87 }, "_enabled": true, "__prefab": null, @@ -2352,7 +2416,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 85 + "__id__": 87 }, "_enabled": true, "__prefab": null, @@ -2390,16 +2454,16 @@ "_name": "Sprite-001", "_objFlags": 0, "_parent": { - "__id__": 44 + "__id__": 46 }, "_children": [], "_active": true, "_components": [ { - "__id__": 89 + "__id__": 91 }, { - "__id__": 90 + "__id__": 92 } ], "_prefab": null, @@ -2436,7 +2500,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 88 + "__id__": 90 }, "_enabled": true, "__prefab": null, @@ -2457,7 +2521,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 88 + "__id__": 90 }, "_enabled": true, "__prefab": null, @@ -2495,16 +2559,16 @@ "_name": "Sprite-002", "_objFlags": 0, "_parent": { - "__id__": 44 + "__id__": 46 }, "_children": [], "_active": true, "_components": [ { - "__id__": 92 + "__id__": 94 }, { - "__id__": 93 + "__id__": 95 } ], "_prefab": null, @@ -2541,7 +2605,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 91 + "__id__": 93 }, "_enabled": true, "__prefab": null, @@ -2562,7 +2626,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 91 + "__id__": 93 }, "_enabled": true, "__prefab": null, @@ -2600,16 +2664,16 @@ "_name": "Sprite-003", "_objFlags": 0, "_parent": { - "__id__": 44 + "__id__": 46 }, "_children": [], "_active": true, "_components": [ { - "__id__": 95 + "__id__": 97 }, { - "__id__": 96 + "__id__": 98 } ], "_prefab": null, @@ -2646,7 +2710,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 94 + "__id__": 96 }, "_enabled": true, "__prefab": null, @@ -2667,7 +2731,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 94 + "__id__": 96 }, "_enabled": true, "__prefab": null, @@ -2705,7 +2769,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 44 + "__id__": 46 }, "_enabled": true, "__prefab": null, @@ -2774,7 +2838,7 @@ "_enabled": true, "__prefab": null, "_cameraComponent": { - "__id__": 97 + "__id__": 99 }, "_alignCanvasWithScreen": true, "_id": "12O/ljcVlEqLmVm3U2gEOQ" @@ -2818,7 +2882,7 @@ "_enabled": true, "__prefab": null, "virtualJoystic": { - "__id__": 68 + "__id__": 70 }, "player": null, "haloProjectileLauncherComponent": { @@ -2831,22 +2895,22 @@ "__id__": 23 }, "enemyManager": { - "__id__": 43 + "__id__": 45 }, "itemManager": { - "__id__": 39 + "__id__": 41 }, "camera": { - "__id__": 97 + "__id__": 99 }, "gameUI": { - "__id__": 70 + "__id__": 72 }, "background": { "__id__": 17 }, "modalWindowManager": { - "__id__": 84 + "__id__": 86 }, "gameAudioAdapter": { "__id__": 14 @@ -2858,7 +2922,7 @@ "fileId": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f", "targetOverrides": [ { - "__id__": 103 + "__id__": 105 } ], "nestedPrefabInstanceRoots": [ @@ -2869,14 +2933,14 @@ "__id__": 24 }, { - "__id__": 72 + "__id__": 74 } ] }, { "__type__": "cc.TargetOverrideInfo", "source": { - "__id__": 101 + "__id__": 103 }, "sourceInfo": null, "propertyPath": [ @@ -2886,7 +2950,7 @@ "__id__": 24 }, "targetInfo": { - "__id__": 104 + "__id__": 106 } }, { @@ -2898,19 +2962,19 @@ { "__type__": "cc.SceneGlobals", "ambient": { - "__id__": 106 - }, - "shadows": { - "__id__": 107 - }, - "_skybox": { "__id__": 108 }, - "fog": { + "shadows": { "__id__": 109 }, - "octree": { + "_skybox": { "__id__": 110 + }, + "fog": { + "__id__": 111 + }, + "octree": { + "__id__": 112 } }, { diff --git a/assets/Scripts/Game/Collision/PlayerCollisionSystem.ts b/assets/Scripts/Game/Collision/PlayerCollisionSystem.ts index 6ccef01..b7e4609 100644 --- a/assets/Scripts/Game/Collision/PlayerCollisionSystem.ts +++ b/assets/Scripts/Game/Collision/PlayerCollisionSystem.ts @@ -4,6 +4,7 @@ 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 { ItemManager } from "../Items/ItemManager"; import { XP } from "../Items/XP/XP"; import { Enemy } from "../Unit/Enemy/Enemy"; @@ -28,6 +29,7 @@ export class PlayerCollisionSystem { this.groupToResolver.set(GroupType.ENEMY, this.resolveEnemyContact.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)); } public gameTick(deltaTime: number): void { @@ -81,4 +83,8 @@ export class PlayerCollisionSystem { private resolveGoldContact(goldCollider: Collider2D): void { this.itemManager.pickupGold(goldCollider.node.getComponent(Gold)); } + + private resolveHealthPotionContact(healthPotionCollider: Collider2D): void { + this.itemManager.pickupHealthPotion(healthPotionCollider.node.getComponent(HealthPotion)); + } } diff --git a/assets/Scripts/Game/Data/GameSettings.ts b/assets/Scripts/Game/Data/GameSettings.ts index 74ff556..3b03001 100644 --- a/assets/Scripts/Game/Data/GameSettings.ts +++ b/assets/Scripts/Game/Data/GameSettings.ts @@ -3,6 +3,7 @@ export class GameSettings { public upgrades: UpgradeSettings = new UpgradeSettings(); public metaUpgrades: MetaUpgradesSettings = new MetaUpgradesSettings(); public enemyManager: EnemyManagerSettings = new EnemyManagerSettings(); + public items: ItemSettings = new ItemSettings(); } export class PlayerSettings { @@ -111,6 +112,12 @@ export class EnemySettings { public damage = 0; public speed = 0; public lifetime = 0; + public xpReward = 0; public goldReward = 0; + public healthPotionRewardChance = 0; +} + +export class ItemSettings { + public healthPerPotion = 0; } diff --git a/assets/Scripts/Game/Game.ts b/assets/Scripts/Game/Game.ts index ce1ec99..d52feaa 100644 --- a/assets/Scripts/Game/Game.ts +++ b/assets/Scripts/Game/Game.ts @@ -79,7 +79,7 @@ export class Game extends Component { this.player.init(multiInput, this.createPlayerData(settings.player, metaUpgrades)); this.enemyManager.init(this.player.node, settings.enemyManager); - this.itemManager.init(this.enemyManager, this.player, gameResult); + this.itemManager.init(this.enemyManager, this.player, gameResult, settings.items); this.playerCollisionSystem = new PlayerCollisionSystem(this.player, settings.player.collisionDelay, this.itemManager); new WeaponCollisionSystem(this.player.Weapon); diff --git a/assets/Scripts/Game/GroupType.ts b/assets/Scripts/Game/GroupType.ts index 238cff2..cdb7960 100644 --- a/assets/Scripts/Game/GroupType.ts +++ b/assets/Scripts/Game/GroupType.ts @@ -8,5 +8,6 @@ export enum GroupType { XP = 1 << 4, PLAYER_PROJECTILE = 1 << 5, ENEMY_PROJECTILE = 1 << 6, - GOLD = 1 << 7 + GOLD = 1 << 7, + HEALTH_POTION = 1 << 8 } diff --git a/assets/Scripts/Game/Items/HealthPotion.meta b/assets/Scripts/Game/Items/HealthPotion.meta new file mode 100644 index 0000000..6576869 --- /dev/null +++ b/assets/Scripts/Game/Items/HealthPotion.meta @@ -0,0 +1,12 @@ +{ + "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 new file mode 100644 index 0000000..09908d9 --- /dev/null +++ b/assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts @@ -0,0 +1,27 @@ +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/HealthPotion.ts.meta b/assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts.meta new file mode 100644 index 0000000..972915c --- /dev/null +++ b/assets/Scripts/Game/Items/HealthPotion/HealthPotion.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "18f8de69-e361-4e73-8b98-a2735d0730a6", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts b/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts new file mode 100644 index 0000000..ceeb5c8 --- /dev/null +++ b/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts @@ -0,0 +1,27 @@ +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 new file mode 100644 index 0000000..8734aef --- /dev/null +++ b/assets/Scripts/Game/Items/HealthPotion/HealthPotionSpawner.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "1e3b0c7f-c831-4778-8688-d8e2c0f6dc00", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/Game/Items/ItemManager.ts b/assets/Scripts/Game/Items/ItemManager.ts index 3d77858..8a47f27 100644 --- a/assets/Scripts/Game/Items/ItemManager.ts +++ b/assets/Scripts/Game/Items/ItemManager.ts @@ -1,10 +1,13 @@ import { Component, random, randomRange, Vec3, _decorator } from "cc"; +import { ItemSettings } from "../Data/GameSettings"; 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 { PickupEffectManager } from "./PickupEffect/PickupEffectManager"; import { XP } from "./XP/XP"; import { XPSpawner } from "./XP/XPSpawner"; @@ -14,20 +17,24 @@ const { ccclass, property } = _decorator; export class ItemManager extends Component { @property(XPSpawner) private xpSpawner: XPSpawner; @property(GoldSpawner) private goldSpawner: GoldSpawner; + @property(HealthPotionSpawner) private healthPotionSpawner: HealthPotionSpawner; @property(PickupEffectManager) private pickupEffectManager: PickupEffectManager; private player: Player; private gameResult: GameResult; + private healthPerPotion: number; - public init(enemyManager: EnemyManager, player: Player, gameResult: GameResult): void { + public init(enemyManager: EnemyManager, player: Player, gameResult: GameResult, settings: ItemSettings): void { this.player = player; this.gameResult = gameResult; + this.healthPerPotion = settings.healthPerPotion; enemyManager.EnemyAddedEvent.on(this.addEnemyListeners, this); enemyManager.EnemyRemovedEvent.on(this.removeEnemyListeners, this); this.xpSpawner.init(); this.goldSpawner.init(); + this.healthPotionSpawner.init(); this.pickupEffectManager.init(); } @@ -45,6 +52,13 @@ export class ItemManager extends Component { this.gameResult.goldCoins++; } + public pickupHealthPotion(healthPotion: HealthPotion): void { + this.pickupEffectManager.showEffect(healthPotion.node.worldPosition); + + healthPotion.pickup(); + this.player.Health.heal(this.healthPerPotion); + } + private addEnemyListeners(enemy: Enemy): void { enemy.DeathEvent.on(this.trySpawnItems, this); } @@ -56,6 +70,7 @@ export class ItemManager extends Component { private trySpawnItems(enemy: Enemy): void { this.trySpawnXP(enemy); this.trySpawnGold(enemy); + this.trySpawnHealthPotion(enemy); } private trySpawnXP(enemy: Enemy): void { @@ -78,6 +93,15 @@ export class ItemManager extends Component { } } + private trySpawnHealthPotion(enemy: Enemy): void { + if (enemy.HealthPotionRewardChance <= 0) return; + + console.log("random: " + random() + " chance " + enemy.HealthPotionRewardChance); + if (random() < enemy.HealthPotionRewardChance) { + this.healthPotionSpawner.spawn(enemy.node.worldPosition); + } + } + private getRandomPosition(enemy: Enemy): Vec3 { const position: Vec3 = enemy.node.worldPosition; position.x += randomRange(-10, 10); diff --git a/assets/Scripts/Game/Unit/Enemy/Enemy.ts b/assets/Scripts/Game/Unit/Enemy/Enemy.ts index 7385315..24809b8 100644 --- a/assets/Scripts/Game/Unit/Enemy/Enemy.ts +++ b/assets/Scripts/Game/Unit/Enemy/Enemy.ts @@ -1,4 +1,4 @@ -import { BoxCollider2D, Color, Component, Material, randomRange, Sprite, Vec3, _decorator } from "cc"; +import { BoxCollider2D, Component, Material, randomRange, Sprite, Vec3, _decorator } from "cc"; import { ISignal } from "../../../Services/EventSystem/ISignal"; import { Signal } from "../../../Services/EventSystem/Signal"; import { delay } from "../../../Services/Utils/AsyncUtils"; @@ -28,6 +28,7 @@ export class Enemy extends Component { private xpReward: number; private goldReward: number; + private healthPotionRewardChance: number; private endOfLifetimeTriggered = false; @@ -42,6 +43,7 @@ export class Enemy extends Component { this.xpReward = settings.xpReward; this.goldReward = settings.goldReward; + this.healthPotionRewardChance = settings.healthPotionRewardChance; this.node.setWorldPosition(position); this.node.active = true; @@ -82,6 +84,10 @@ export class Enemy extends Component { return this.goldReward; } + public get HealthPotionRewardChance(): number { + return this.healthPotionRewardChance; + } + public get LifetimeEndedEvent(): ISignal { return this.lifetimeEndedEvent; } diff --git a/settings/v2/packages/project.json b/settings/v2/packages/project.json index cb25eed..114d613 100644 --- a/settings/v2/packages/project.json +++ b/settings/v2/packages/project.json @@ -28,17 +28,22 @@ { "index": 7, "name": "GOLD" + }, + { + "index": 8, + "name": "HEALTH_POTION" } ], "collisionMatrix": { "0": 0, - "1": 212, + "1": 468, "2": 42, "3": 4, "4": 2, "5": 4, "6": 2, - "7": 2 + "7": 2, + "8": 2 } }, "general": {