diff --git a/saves/savefile.json b/saves/savefile.json index c8ab3bb83..02a71077e 100644 --- a/saves/savefile.json +++ b/saves/savefile.json @@ -1,41 +1,41 @@ { -entities: { - CompanionConfig: [ - { - class: com.csse3200.game.entities.configs.CompanionConfig - position: { - x: 22 - y: 24 - } - health: 100 - baseAttack: 5 - attackMultiplier: 1 - } - ] - PlayerConfig: [ - { - class: com.csse3200.game.entities.configs.PlayerConfig - spritePath: images/player/player.atlas - position: { - x: 23 - y: 25 - } - health: 100 - baseAttack: 10 - lives: 3 - sounds: { - soundsMap: { - low_health: sounds/playerLow_health.wav - dodge: sounds/dodgingAlertSweep.wav - boostPowerup: sounds/playerBoostRecharge.wav - healthPowerup: sounds/PlayerHealthRecharge.wav - footstep: sounds/footStepsInTheForestGround.wav - upgradeWeapon: sounds/upgradeWeapon.wav - upgradeTree: sounds/upgradeTreeTap.wav - exitbutton: sounds/ExitButton.wav, - } - } - } - ] -} + entities: { + CompanionConfig: [ + { + class: com.csse3200.game.entities.configs.CompanionConfig + position: { + x: 22 + y: 24 + } + health: 100 + baseAttack: 5 + attackMultiplier: 1 + } + ] + PlayerConfig: [ + { + class: com.csse3200.game.entities.configs.PlayerConfig + spritePath: images/player/player.atlas + position: { + x: 23 + y: 25 + } + health: 100 + baseAttack: 10 + lives: 3 + sounds: { + soundsMap: { + low_health: sounds/playerLow_health.wav + dodge: sounds/dodgingAlertSweep.wav + boostPowerup: sounds/playerBoostRecharge.wav + healthPowerup: sounds/PlayerHealthRecharge.wav + footstep: sounds/footStepsInTheForestGround.wav + upgradeWeapon: sounds/upgradeWeapon.wav + upgradeTree: sounds/upgradeTreeTap.wav + exitbutton: sounds/ExitButton.wav, + } + } + } + ] + } } \ No newline at end of file diff --git a/source/core/assets/configs/powerups.json b/source/core/assets/configs/powerups.json index cd5de61bf..a516f3128 100644 --- a/source/core/assets/configs/powerups.json +++ b/source/core/assets/configs/powerups.json @@ -20,7 +20,7 @@ }, "tempImmunityPowerup": { - "spritePath": "images/powerups/invincibility_potion.png", + "spritePath": "images/powerups/temp_immunity.png", "type": "TEMP_IMMUNITY" }, diff --git a/source/core/assets/configs/shipUpgrades.json b/source/core/assets/configs/shipUpgrades.json index f2e391fd0..d8f948700 100644 --- a/source/core/assets/configs/shipUpgrades.json +++ b/source/core/assets/configs/shipUpgrades.json @@ -1,10 +1,10 @@ { "healthUpgrade": { - "spritePath": "images/powerups/health_potion.png", + "spritePath": "images/powerups/health_boost.png", "type": "HEALTH_UPGRADE" }, "fuelUpgrade": { - "spritePath": "images/powerups/speed_potion.png", + "spritePath": "images/powerups/speed_boost.png", "type": "FUEL_UPGRADE" } } \ No newline at end of file diff --git a/source/core/assets/configs/weapons.json b/source/core/assets/configs/weapons.json index 6d53612b5..3d67e1e7c 100644 --- a/source/core/assets/configs/weapons.json +++ b/source/core/assets/configs/weapons.json @@ -1,287 +1,367 @@ { "RANGED_SLINGSHOT": { - "name" : "Slingshot", - "health" : 1, + "name": "Slingshot", + "health": 1, "description": "Reliable range, decent damage. Ideal for distant targets.", - "damage" : 20, + "damage": 20, "weaponSpeed": 10, "weaponDuration": 75, "rotationSpeed": 0, "textureAtlas": "images/weapons/ranged/slingshot.atlas", - "imageScale" : 0.4, - "imagePath" : "images/weapons/ranged/slingshotStatic.png", - "type" : "RANGED_SLINGSHOT", - "slotType" : "ranged", - "ammoUse" : 0, - "staticImageScale" : 0.3, + "imageScale": 0.4, + "imagePath": "images/weapons/ranged/slingshotStatic.png", + "type": "RANGED_SLINGSHOT", + "slotType": "ranged", + "ammoUse": 0, + "staticImageScale": 0.3, + "attackCooldown": 30, - "sound": {"soundsMap": {}} + "sound": { + "soundsMap": { + "start": "sounds/weapons/slingshot.wav", + "mid": "", + "end": "" + } + } }, - "RANGED_SNIPER" : { - "name" : "Sniper", - "health" : 1, + "RANGED_SNIPER": { + "name": "Sniper", + "health": 1, "description": "Pinpoint Accuracy", - "damage" : 50, + "damage": 100, "weaponSpeed": 35, "weaponDuration": 300, "rotationSpeed": 0, "textureAtlas": "images/weapons/ranged/sniper.atlas", - "imageScale" : 0.5, - "imagePath" : "images/weapons/ranged/sniperStatic.png", - "type" : "RANGED_SNIPER", - "slotType" : "ranged", - "ammoUse" : 1, - "staticImageScale" : 1, + "imageScale": 0.5, + "imagePath": "images/weapons/ranged/sniperStatic.png", + "type": "RANGED_SNIPER", + "slotType": "ranged", + "ammoUse": 2, + "staticImageScale": 1, "attackCooldown": 100, - "sound": {"soundsMap": {}} + "sound": { + "soundsMap": { + "start": "sounds/weapons/slingshot.wav", + "mid": "", + "end": "" + } + } }, "RANGED_BOOMERANG": { - "name" : "Boomerang", - "health" : 1, + "name": "Boomerang", + "health": 1, "description": "Capable of hitting multiple enemies at once, a versatile choice.", - "damage" : 25, + "damage": 25, "weaponSpeed": 4, - "weaponDuration": 210, + "weaponDuration": 280, "rotationSpeed": 2, "textureAtlas": "images/weapons/ranged/boomerang.atlas", - "imageScale" : 0.5, - "staticImageScale" : 0, - "imagePath" : "images/weapons/ranged/boomerangStatic.png", - "type" : "RANGED_BOOMERANG", - "slotType" : "ranged", + "imageScale": 0.5, + "staticImageScale": 0, + "imagePath": "images/weapons/ranged/boomerangStatic.png", + "type": "RANGED_BOOMERANG", + "slotType": "ranged", + "attackCooldown": 40, - "sound": {"soundsMap": {}} + "sound": { + "soundsMap": { + "start": "", + "mid": "sounds/weapons/boomerang.wav", + "end": "" + } + } }, "RANGED_BLUEMERANG": { - "name" : "Bluemerang", - "health" : 1, + "name": "Bluemerang", + "health": 1, "description": "its blue!", - "damage" : 25, + "damage": 25, "weaponSpeed": 6, - "weaponDuration": 280, + "weaponDuration": 140, "rotationSpeed": 2, "textureAtlas": "images/weapons/ranged/bluemerang.atlas", - "imageScale" : 0.5, - "staticImageScale" : 0, - "imagePath" : "images/weapons/ranged/bluemerangStatic.png", - "type" : "RANGED_BLUEMERANG", - "slotType" : "ranged", - "projectiles" : 1, + "imageScale": 0.5, + "staticImageScale": 0, + "imagePath": "images/weapons/ranged/bluemerangStatic.png", + "type": "RANGED_BLUEMERANG", + "slotType": "ranged", + "projectiles": 2, + "ammoUse": 2, + "attackCooldown": 45, - "sound": {"soundsMap": {}} + "sound": { + "soundsMap": { + "start": "", + "mid": "sounds/weapons/boomerang.wav", + "end": "" + } + } }, "RANGED_MISSILES": { - "name" : "Missile Swarm", - "health" : 1, + "name": "Missile Swarm", + "health": 1, "description": "Spray a rocket array and watch your enemies pray", - "damage" : 40, + "damage": 0, "weaponSpeed": 5, "weaponDuration": 105, "rotationSpeed": 0, "textureAtlas": "images/weapons/ranged/swarmRocket.atlas", - "imageScale" : 0.6, - "staticImageScale" : 1, - "imagePath" : "images/weapons/ranged/swarmRocketStatic.png", - "type" : "RANGED_MISSILES", - "slotType" : "ranged", - "projectiles" : 10, - "ammoUse" : 2, + "imageScale": 0.6, + "staticImageScale": 1, + "imagePath": "images/weapons/ranged/swarmRocketStatic.png", + "type": "RANGED_MISSILES", + "slotType": "ranged", + "projectiles": 6, + "ammoUse": 3, "attackCooldown": 150, - - "sound": {"soundsMap": {}} + "sound": { + "soundsMap": { + "start": "", + "mid": "sounds/weapons/missile.wav", + "end": "" + } + } }, "RANGED_GRENADE": { - "name" : "Grenade", - "health" : 1000, + "name": "Grenade", + "health": 1000, "description": "Boom boom!", - "damage" : 0, + "damage": 0, "weaponSpeed": 4, "weaponDuration": 180, "rotationSpeed": 1, "textureAtlas": "images/weapons/ranged/grenade.atlas", - "imageScale" : 0.5, - "staticImageScale" : 0, - "imagePath" : "images/weapons/ranged/grenadeStatic.png", - "type" : "RANGED_GRENADE", - "slotType" : "ranged", - "attackCooldown": 30, - "sound": {"soundsMap": {}} + "imageScale": 0.5, + "staticImageScale": 0, + "imagePath": "images/weapons/ranged/grenadeStatic.png", + "type": "RANGED_GRENADE", + "slotType": "ranged", + "attackCooldown": 45, + "sound": { + "soundsMap": { + "start": "sounds/weapons/nuke.wav", + "mid": "", + "end": "" + } + }, + "ammoUse": 2 }, "RANGED_NUKE": { - "name" : "Nuke", - "health" : 1000, + "name": "Nuke", + "health": 1000, "description": "Don't use them all at once", - "damage" : 0, + "damage": 0, "weaponSpeed": 0.1, "weaponDuration": 500, "rotationSpeed": 0, "textureAtlas": "images/weapons/ranged/nuke.atlas", - "imageScale" : 6, - "staticImageScale" : 0.6, + "imageScale": 6, + "staticImageScale": 0.6, "attackCooldown": 400, - "imagePath" : "images/weapons/ranged/nukeStatic.png", - "type" : "RANGED_NUKE", - "slotType" : "melee", - "ammoUse" : 5, - "sound": {"soundsMap": {}} + "imagePath": "images/weapons/ranged/nukeStatic.png", + "type": "RANGED_NUKE", + "slotType": "melee", + "ammoUse": 30, + "sound": { + "soundsMap": { + "start": "sounds/weapons/nuke.wav", + "mid": "", + "end": "" + } + } }, "RANGED_HOMING": { - "name" : "Friendly Missile", + "name": "Friendly Missile", "description": "No need to aim perfectly! It finds its way by following the cursor. Just launch and watch it make new friends!", - "health" : 1, - "damage" : 100, + "health": 1, + "damage": 100, "weaponSpeed": 5, "weaponDuration": 450, "rotationSpeed": 5, "textureAtlas": "images/weapons/ranged/homingRocket.atlas", - "imageScale" : 0.8, - "staticImageScale" : 1, - "imagePath" : "images/weapons/ranged/homingRocketStatic.png", - "type" : "RANGED_HOMING", - "slotType" : "ranged", + "imageScale": 0.8, + "staticImageScale": 1, + "imagePath": "images/weapons/ranged/homingRocketStatic.png", + "type": "RANGED_HOMING", + "slotType": "ranged", "attackCooldown": 80, - - "sound": {"soundsMap": {}} + "ammoUse": 2, + "sound": { + "soundsMap": { + "start": "sounds/weapons/missile.wav", + "mid": "", + "end": "" + } + } }, "MELEE_WRENCH": { - "name" : "Wrench", + "name": "Wrench", "description": "Its a wrench, what more to say.", - "damage" : 33, + "damage": 33, "weaponSpeed": 4, "weaponDuration": 26, "rotationSpeed": 1, "attackCooldown": 75, "textureAtlas": "images/weapons/melee/wrench.atlas", - "imageScale" : 0.8, - "staticImageScale" : 0, - "imagePath" : "images/weapons/melee/wrenchStatic.png", - "type" : "MELEE_WRENCH", - "slotType" : "melee", - "ammoUse" : 0, - "sound": {"soundsMap": {}} + "imageScale": 0.8, + "staticImageScale": 0, + "imagePath": "images/weapons/melee/wrenchStatic.png", + "type": "MELEE_WRENCH", + "slotType": "melee", + "ammoUse": 0, + "sound": { + "soundsMap": { + "start": "sounds/weapons/Katana.wav", + "mid": "", + "end": "" + } + } }, "MELEE_KATANA": { - "name" : "Katana", + "name": "Katana", "description": "Rich history, swift slashes. Its balance between speed and damage makes it deadly in close quarters.", - "damage" : 50, + "damage": 50, "weaponSpeed": 5, "weaponDuration": 32, "rotationSpeed": 1, "attackCooldown": 20, "textureAtlas": "images/weapons/melee/katana.atlas", - "imageScale" : 0.7, - "staticImageScale" : 0, - "imagePath" : "images/weapons/melee/katanaStatic.png", - "type" : "MELEE_KATANA", - "slotType" : "melee", - "ammoUse" : 0, - - "sound": {"soundsMap": {}} + "imageScale": 0.7, + "staticImageScale": 0, + "imagePath": "images/weapons/melee/katanaStatic.png", + "type": "MELEE_KATANA", + "slotType": "melee", + "ammoUse": 0, + "sound": { + "soundsMap": { + "start": "sounds/weapons/Katana.wav", + "mid": "", + "end": "" + } + } }, "MELEE_BEE_STING": { - "name" : "Bees", + "name": "Bees", "description": "Unleash the power of Bees!", - "damage" : 50, + "damage": 50, "weaponSpeed": 8, "weaponDuration": 45, "rotationSpeed": 0, - "attackCooldown": 10, + "attackCooldown": 30, "textureAtlas": "images/weapons/melee/bee.atlas", - "imageScale" : 0.4, - "staticImageScale" : 0.4, - "imagePath" : "images/weapons/melee/beeStatic.png", - "type" : "MELEE_BEE_STING", - "slotType" : "melee", - "ammoUse" : 4, - "projectiles" : 8, - - "sound": {"soundsMap": {}} + "imageScale": 0.4, + "staticImageScale": 0.4, + "imagePath": "images/weapons/melee/beeStatic.png", + "type": "MELEE_BEE_STING", + "slotType": "melee", + "ammoUse": 5, + "projectiles": 8, + "sound": { + "soundsMap": { + "start": "sounds/weapons/beeStringKatana.wav", + "mid": "", + "end": "" + } + } }, "MELEE_LASER_SWORD": { - "name" : "Laser and sword", + "name": "Laser and sword", "description": "glows", - "damage" : 70, + "damage": 100, "weaponSpeed": 12, "weaponDuration": 95, "rotationSpeed": 1, - "attackCooldown": 30, + "attackCooldown": 100, "textureAtlas": "images/weapons/melee/laserSword.atlas", - "imageScale" : 1.2, - "staticImageScale" : 0, - "imagePath" : "images/weapons/melee/laserSwordStatic.png", - "type" : "MELEE_LASER_SWORD", - "slotType" : "melee", - "ammoUse" : 2, - - "sound": {"soundsMap": {}} + "imageScale": 1.2, + "staticImageScale": 0, + "imagePath": "images/weapons/melee/laserSwordStatic.png", + "type": "MELEE_LASER_SWORD", + "slotType": "melee", + "ammoUse": 3, + "sound": { + "soundsMap": { + "start": "sounds/weapons/laserSword.wav", + "mid": "", + "end": "" + } + } }, "STICK": { - "name" : "Stick", + "name": "Stick", "description": "The Stick, simple yet effective. While it might not be the strongest, it does its best", - "damage" : 1, + "damage": 1, "weaponSpeed": 0.75, "weaponDuration": 75, "rotationSpeed": 6, "attackCooldown": 10, "textureAtlas": "images/weapons/sword.atlas", - "imageScale" : 1, - "imagePath" : "images/upgradetree/stick.png", - "type" : "STICK", - "slotType" : "melee", - + "imageScale": 1, + "imagePath": "images/upgradetree/stick.png", + "type": "STICK", + "slotType": "melee", "sound": { "soundsMap": { "start": "sounds/dodgingAlertSweep.wav", - "mid" : "sounds/footStepsInTheForestGround.wav", - "stop" : "sounds/PlayerHealthRecharge.wav" + "mid": "sounds/footStepsInTheForestGround.wav", + "stop": "sounds/PlayerHealthRecharge.wav" } } }, "WOODHAMMER": { - "name" : "Wooden Hammer", + "name": "Wooden Hammer", "description": "For all your buildable needs. While not suitable for combat, it's an essential tool for construction.", - "damage" : 0, + "damage": 0, "textureAtlas": "images/weapons/sword.atlas", - "imageScale" : 1, - "imagePath" : "images/upgradetree/hammer1.png", - "type" : "WOODHAMMER", - "slotType" : "building", - "ammoUse" : 0, - - "sound": {"soundsMap": {}} + "imageScale": 1, + "imagePath": "images/upgradetree/hammer1.png", + "type": "WOODHAMMER", + "slotType": "building", + "ammoUse": 0, + "staticImageScale": 0.5, + "sound": { + "soundsMap": {} + } }, "STONEHAMMER": { "textureAtlas": "images/weapons/sword.atlas", - "imageScale" : 1, - "imagePath" : "images/upgradetree/hammer2.png", - "type" : "STONEHAMMER", - "slotType" : "building", - "ammoUse" : 0, - "sound": {"soundsMap": {}} + "imageScale": 1, + "imagePath": "images/upgradetree/hammer2.png", + "type": "STONEHAMMER", + "slotType": "building", + "ammoUse": 0, + "staticImageScale": 0.5, + "sound": { + "soundsMap": {} + } }, - + "STEELHAMMER": { "textureAtlas": "images/weapons/sword.atlas", - "imageScale" : 1, - "imagePath" : "images/upgradetree/hammer2.png", - "type" : "STEELHAMMER", - "slotType" : "building", - "ammoUse" : 0, - "sound": {"soundsMap": {}} + "imageScale": 1, + "imagePath": "images/upgradetree/hammer2.png", + "type": "STEELHAMMER", + "slotType": "building", + "ammoUse": 0, + "staticImageScale": 0.5, + "sound": { + "soundsMap": {} + } } } \ No newline at end of file diff --git a/source/core/assets/images/entity/Campfire.atlas b/source/core/assets/images/entity/Campfire.atlas new file mode 100644 index 000000000..159d6493a --- /dev/null +++ b/source/core/assets/images/entity/Campfire.atlas @@ -0,0 +1,33 @@ +Campfire.png +size: 768, 192 +format: RGBA8888 +filter: Linear,Linear +repeat: none +Flicker + rotate: false + xy: 0, 0 + size: 192, 192 + orig: 192, 192 + offset: 0, 0 + index: -1 +Flicker + rotate: false + xy: 192, 0 + size: 192, 192 + orig: 192, 192 + offset: 0, 0 + index: -1 +Flicker + rotate: false + xy: 384, 0 + size: 192, 192 + orig: 192, 192 + offset: 0, 0 + index: -1 +Flicker + rotate: false + xy: 576, 0 + size: 192, 192 + orig: 192, 192 + offset: 0, 0 + index: -1 \ No newline at end of file diff --git a/source/core/assets/images/entity/Campfire.png b/source/core/assets/images/entity/Campfire.png new file mode 100644 index 000000000..6c5cad2d3 Binary files /dev/null and b/source/core/assets/images/entity/Campfire.png differ diff --git a/source/core/assets/images/player/heart.png b/source/core/assets/images/player/heart.png deleted file mode 100644 index 049bd0838..000000000 Binary files a/source/core/assets/images/player/heart.png and /dev/null differ diff --git a/source/core/assets/images/powerups/health_potion.png b/source/core/assets/images/powerups/health_potion.png deleted file mode 100644 index 391b336d5..000000000 Binary files a/source/core/assets/images/powerups/health_potion.png and /dev/null differ diff --git a/source/core/assets/images/powerups/invincibility_potion.png b/source/core/assets/images/powerups/invincibility_potion.png deleted file mode 100644 index b9a6e33d4..000000000 Binary files a/source/core/assets/images/powerups/invincibility_potion.png and /dev/null differ diff --git a/source/core/assets/images/powerups/speed_potion.png b/source/core/assets/images/powerups/speed_potion.png deleted file mode 100644 index 9bd1008bc..000000000 Binary files a/source/core/assets/images/powerups/speed_potion.png and /dev/null differ diff --git a/source/core/assets/levels/blazes_refuge/level.json b/source/core/assets/levels/blazes_refuge/level.json index fc52b4619..4f73bf980 100644 --- a/source/core/assets/levels/blazes_refuge/level.json +++ b/source/core/assets/levels/blazes_refuge/level.json @@ -2,5 +2,5 @@ "areaNames": [ "main_area" ], - "nextPlanet": "END" + "nextPlanet": "cryoheim" } \ No newline at end of file diff --git a/source/core/assets/levels/blazes_refuge/main-area/main.json b/source/core/assets/levels/blazes_refuge/main-area/main.json index 569c2c664..a37200e88 100644 --- a/source/core/assets/levels/blazes_refuge/main-area/main.json +++ b/source/core/assets/levels/blazes_refuge/main-area/main.json @@ -31,11 +31,8 @@ "images/powerups/extra_life.png", "images/powerups/snap.png", "images/powerups/death_potion.png", - "images/powerups/health_potion.png", - "images/powerups/invincibility_potion.png", "images/powerups/speed_boost.png", "images/powerups/health_boost.png", - "images/powerups/health_potion.png", "images/powerups/temp_immunity.png", "map/portal.png", "images/minigame/fireAnim.png", @@ -82,6 +79,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/upgradeTreeTap.wav", @@ -93,14 +92,22 @@ "sounds/explosion/grenade.mp3", "sounds/explosion/landmine.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ "particle-effects/explosion/explosion.effect", "particle-effects/extractor/durasteel.effect", "particle-effects/extractor/nebulite.effect", "particle-effects/extractor/solstite.effect", - "particle-effects/explosion/bigBallCombustion.effect" + "particle-effects/explosion/bigBallCombustion.effect", + "particle-effects/shield/shield.effect" ], "backgroundMusicPath": "sounds/BGM_03_mp3.wav", diff --git a/source/core/assets/levels/blazes_refuge/main_area/entities/laboratoryinferno.json b/source/core/assets/levels/blazes_refuge/main_area/entities/laboratoryinferno.json index df0c9ddbf..e9a550554 100644 --- a/source/core/assets/levels/blazes_refuge/main_area/entities/laboratoryinferno.json +++ b/source/core/assets/levels/blazes_refuge/main_area/entities/laboratoryinferno.json @@ -2,7 +2,7 @@ "entityType": "LaboratoryConfig", "entities": [ { - class: com.csse3200.game.entities.configs.LaboratoryConfig, + "class": "com.csse3200.game.entities.configs.LaboratoryConfig", "spritePath": "images/companion/laboratoryinferno.png", "position": {"x":34, "y": 49 diff --git a/source/core/assets/levels/blazes_refuge/main_area/entities/player.json b/source/core/assets/levels/blazes_refuge/main_area/entities/player.json index 4424a5e7f..7f0c20f6e 100644 --- a/source/core/assets/levels/blazes_refuge/main_area/entities/player.json +++ b/source/core/assets/levels/blazes_refuge/main_area/entities/player.json @@ -2,12 +2,13 @@ "entityType": "PlayerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PlayerConfig, + "class": "com.csse3200.game.entities.configs.PlayerConfig", "position": { - "x": 10, + "x": 20, "y": 40 }, "health": 100, + "maxHealth": 100, "baseAttack": 10, "attackMultiplier": 1, "isImmune": false, diff --git a/source/core/assets/levels/blazes_refuge/main_area/entities/portals.json b/source/core/assets/levels/blazes_refuge/main_area/entities/portals.json index d4d3505e7..7598b3c50 100644 --- a/source/core/assets/levels/blazes_refuge/main_area/entities/portals.json +++ b/source/core/assets/levels/blazes_refuge/main_area/entities/portals.json @@ -2,7 +2,7 @@ "entityType": "PortalConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PortalConfig, + "class": "com.csse3200.game.entities.configs.PortalConfig", "teleportX" : 40, "teleportY" : 10, "position": { @@ -11,7 +11,7 @@ } }, { - class: com.csse3200.game.entities.configs.PortalConfig, + "class": "com.csse3200.game.entities.configs.PortalConfig", "teleportX" : 16, "teleportY" : 20, "position": { diff --git a/source/core/assets/levels/blazes_refuge/main_area/entities/safezone.json b/source/core/assets/levels/blazes_refuge/main_area/entities/safezone.json index b56d6c879..bec8be078 100644 --- a/source/core/assets/levels/blazes_refuge/main_area/entities/safezone.json +++ b/source/core/assets/levels/blazes_refuge/main_area/entities/safezone.json @@ -2,8 +2,8 @@ "entityType": "SafeZoneConfig", "entities": [ { - class: com.csse3200.game.entities.configs.SafeZoneConfig, - "spritePath": "map/coolzone.png", + "class": "com.csse3200.game.entities.configs.SafeZoneConfig", + "spritePath": "map/Coolzone.atlas", "position": { "x": 25, "y": 67 diff --git a/source/core/assets/levels/blazes_refuge/main_area/entities/ship.json b/source/core/assets/levels/blazes_refuge/main_area/entities/ship.json index b4d652836..a201859d8 100644 --- a/source/core/assets/levels/blazes_refuge/main_area/entities/ship.json +++ b/source/core/assets/levels/blazes_refuge/main_area/entities/ship.json @@ -2,7 +2,7 @@ "entityType": "ShipConfig", "entities": [ { - class: com.csse3200.game.entities.configs.ShipConfig, + "class": "com.csse3200.game.entities.configs.ShipConfig", "spritePath": "images/ship/Ship.png", "position": { "x": 33, diff --git a/source/core/assets/levels/blazes_refuge/main_area/entities/spawners.json b/source/core/assets/levels/blazes_refuge/main_area/entities/spawners.json index 67899f524..6c8f09aa2 100644 --- a/source/core/assets/levels/blazes_refuge/main_area/entities/spawners.json +++ b/source/core/assets/levels/blazes_refuge/main_area/entities/spawners.json @@ -2,7 +2,7 @@ "entityType": "SpawnerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.SpawnerConfig, + "class": "com.csse3200.game.entities.configs.SpawnerConfig", "wave1" : { "redGhost" : 30, "roboMan" : 30, diff --git a/source/core/assets/levels/blazes_refuge/main_area/main.json b/source/core/assets/levels/blazes_refuge/main_area/main.json index 9d753e6d3..48548b791 100644 --- a/source/core/assets/levels/blazes_refuge/main_area/main.json +++ b/source/core/assets/levels/blazes_refuge/main_area/main.json @@ -31,11 +31,8 @@ "images/powerups/extra_life.png", "images/powerups/snap.png", "images/powerups/death_potion.png", - "images/powerups/health_potion.png", - "images/powerups/invincibility_potion.png", "images/powerups/speed_boost.png", "images/powerups/health_boost.png", - "images/powerups/health_potion.png", "images/powerups/temp_immunity.png", "map/portal.png", "images/minigame/fireAnim.png", @@ -83,6 +80,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/upgradeTreeTap.wav", @@ -94,20 +93,28 @@ "sounds/explosion/grenade.mp3", "sounds/explosion/landmine.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ "particle-effects/explosion/explosion.effect", "particle-effects/extractor/durasteel.effect", "particle-effects/extractor/nebulite.effect", "particle-effects/extractor/solstite.effect", - "particle-effects/explosion/bigBallCombustion.effect" + "particle-effects/explosion/bigBallCombustion.effect", + "particle-effects/shield/shield.effect" ], "backgroundMusicPath": "sounds/BGM_03_mp3.wav" }, - "mapName": "Infernal Challenge", - "planetImage": "images/planets/space_navigation_planet_3.png", + "mapName": "Blaze's Refuge", + "planetImage": "images/navigationmap/planets/blazes_refuge.png", "terrainPath": "map/Hellmapp.tmx", "winConditions": [ { diff --git a/source/core/assets/levels/controls/main_area/entities/fissures.json b/source/core/assets/levels/controls/main_area/entities/fissures.json index 09e3d2cc1..c3f136a67 100644 --- a/source/core/assets/levels/controls/main_area/entities/fissures.json +++ b/source/core/assets/levels/controls/main_area/entities/fissures.json @@ -2,7 +2,7 @@ "entityType": "FissureConfig", "entities": [ { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Solstite", "position": { "x": 34, @@ -10,7 +10,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Nebulite", "position": { "x": 40, @@ -18,7 +18,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Durasteel", "position": { "x": 46, diff --git a/source/core/assets/levels/controls/main_area/entities/player.json b/source/core/assets/levels/controls/main_area/entities/player.json index 788a4bbf7..779fbdc59 100644 --- a/source/core/assets/levels/controls/main_area/entities/player.json +++ b/source/core/assets/levels/controls/main_area/entities/player.json @@ -2,7 +2,7 @@ "entityType": "PlayerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PlayerConfig, + "class": "com.csse3200.game.entities.configs.PlayerConfig", "position": { "x": 30, "y": 70 diff --git a/source/core/assets/levels/controls/main_area/entities/spawners.json b/source/core/assets/levels/controls/main_area/entities/spawners.json index 2d2f38fe2..755e324cd 100644 --- a/source/core/assets/levels/controls/main_area/entities/spawners.json +++ b/source/core/assets/levels/controls/main_area/entities/spawners.json @@ -2,7 +2,7 @@ "entityType": "SpawnerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.SpawnerConfig, + "class": "com.csse3200.game.entities.configs.SpawnerConfig", "wave1" : [ 1, 1, diff --git a/source/core/assets/levels/controls/main_area/main.json b/source/core/assets/levels/controls/main_area/main.json index 9c07347a5..41594f7a0 100644 --- a/source/core/assets/levels/controls/main_area/main.json +++ b/source/core/assets/levels/controls/main_area/main.json @@ -32,11 +32,8 @@ "images/powerups/extra_life.png", "images/powerups/snap.png", "images/powerups/death_potion.png", - "images/powerups/health_potion.png", - "images/powerups/invincibility_potion.png", "images/powerups/speed_boost.png", "images/powerups/health_boost.png", - "images/powerups/health_potion.png", "images/powerups/temp_immunity.png", "map/portal.png", "images/minigame/fireAnim.png", @@ -76,6 +73,7 @@ "images/structures/open_gate.atlas", "images/structures/closed_gate.atlas", "images/companion/earth_Companion_spritesheet.atlas", + "images/companion/Companion_spritesheet.atlas", "images/minigame/fire.atlas", "images/structures/ExtractorAnimation.atlas", "images/npc/Tutnpc.atlas" @@ -85,6 +83,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/upgradeTreeTap.wav", @@ -96,13 +96,21 @@ "sounds/explosion/grenade.mp3", "sounds/explosion/landmine.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ "particle-effects/explosion/explosion.effect", "particle-effects/extractor/durasteel.effect", "particle-effects/extractor/nebulite.effect", - "particle-effects/extractor/solstite.effect" + "particle-effects/extractor/solstite.effect", + "particle-effects/shield/shield.effect" ], "backgroundMusicPath": "sounds/BGM_03_mp3.wav" }, diff --git a/source/core/assets/levels/cryoheim/level.json b/source/core/assets/levels/cryoheim/level.json index 8661b517d..11135acba 100644 --- a/source/core/assets/levels/cryoheim/level.json +++ b/source/core/assets/levels/cryoheim/level.json @@ -2,5 +2,5 @@ "areaNames": [ "main_area" ], - "nextPlanet": "blazes_refuge" + "nextPlanet": "flora_haven" } \ No newline at end of file diff --git a/source/core/assets/levels/cryoheim/main_area/entities/astronaut.json b/source/core/assets/levels/cryoheim/main_area/entities/astronaut.json index a79ba5245..42973ee08 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/astronaut.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/astronaut.json @@ -2,7 +2,7 @@ "entityType": "AstronautConfig", "entities": [ { - class: com.csse3200.game.entities.configs.AstronautConfig, + "class": "com.csse3200.game.entities.configs.AstronautConfig", "spritePath": "images/npc/astronaut_npc.atlas", "position" : { "x": 15, diff --git a/source/core/assets/levels/cryoheim/main_area/entities/botanist.json b/source/core/assets/levels/cryoheim/main_area/entities/botanist.json index 18947d463..5fbb20712 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/botanist.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/botanist.json @@ -2,7 +2,7 @@ "entityType": "BotanistConfig", "entities": [ { - class: com.csse3200.game.entities.configs.BotanistConfig, + "class": "com.csse3200.game.entities.configs.BotanistConfig", "spritePath": "images/botanist.atlas", "position" : { "x": 20, diff --git a/source/core/assets/levels/cryoheim/main_area/entities/hellman.json b/source/core/assets/levels/cryoheim/main_area/entities/hellman.json index 1c8a9acae..03719af2b 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/hellman.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/hellman.json @@ -2,7 +2,7 @@ "entityType": "HellmanConfig", "entities": [ { - class: com.csse3200.game.entities.configs.HellmanConfig, + "class": "com.csse3200.game.entities.configs.HellmanConfig", "spritePath": "images/npc/Hellman.atlas", "position" : { "x": 25, diff --git a/source/core/assets/levels/cryoheim/main_area/entities/player.json b/source/core/assets/levels/cryoheim/main_area/entities/player.json index f1148699e..7f0c20f6e 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/player.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/player.json @@ -2,7 +2,7 @@ "entityType": "PlayerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PlayerConfig, + "class": "com.csse3200.game.entities.configs.PlayerConfig", "position": { "x": 20, "y": 40 diff --git a/source/core/assets/levels/cryoheim/main_area/entities/portals.json b/source/core/assets/levels/cryoheim/main_area/entities/portals.json index 55b7510a9..25dc8f000 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/portals.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/portals.json @@ -2,7 +2,7 @@ "entityType": "PortalConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PortalConfig, + "class": "com.csse3200.game.entities.configs.PortalConfig", "teleportX" : 40, "teleportY" : 5, "position": { @@ -11,7 +11,7 @@ } }, { - class: com.csse3200.game.entities.configs.PortalConfig, + "class": "com.csse3200.game.entities.configs.PortalConfig", "teleportX" : 16, "teleportY" : 20, "position": { diff --git a/source/core/assets/levels/cryoheim/main_area/entities/safezone.json b/source/core/assets/levels/cryoheim/main_area/entities/safezone.json index 6b99a09a9..417d451d2 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/safezone.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/safezone.json @@ -2,8 +2,8 @@ "entityType": "SafeZoneConfig", "entities": [ { - class: com.csse3200.game.entities.configs.SafeZoneConfig, - "spritePath": "map/heatzone.png", + "class": "com.csse3200.game.entities.configs.SafeZoneConfig", + "spritePath": "images/entity/Campfire.atlas", "position": { "x": 25, "y": 67 diff --git a/source/core/assets/levels/cryoheim/main_area/entities/ship.json b/source/core/assets/levels/cryoheim/main_area/entities/ship.json index b4d652836..a201859d8 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/ship.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/ship.json @@ -2,7 +2,7 @@ "entityType": "ShipConfig", "entities": [ { - class: com.csse3200.game.entities.configs.ShipConfig, + "class": "com.csse3200.game.entities.configs.ShipConfig", "spritePath": "images/ship/Ship.png", "position": { "x": 33, diff --git a/source/core/assets/levels/cryoheim/main_area/entities/spawners.json b/source/core/assets/levels/cryoheim/main_area/entities/spawners.json index 01e955f03..ac5b1b1d6 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/spawners.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/spawners.json @@ -2,7 +2,7 @@ "entityType": "SpawnerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.SpawnerConfig, + "class": "com.csse3200.game.entities.configs.SpawnerConfig", "wave1" : { "redGhost" : 10, "roboMan" : 10, diff --git a/source/core/assets/levels/cryoheim/main_area/entities/treeTop.json b/source/core/assets/levels/cryoheim/main_area/entities/treeTop.json index 7eb196070..a2ec14b19 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/treeTop.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/treeTop.json @@ -2,7 +2,7 @@ "entityType": "TreeTopConfig", "entities": [ { - class: com.csse3200.game.entities.configs.TreeTopConfig, + "class": "com.csse3200.game.entities.configs.TreeTopConfig", "position": { "x": 0, "y": 0 diff --git a/source/core/assets/levels/cryoheim/main_area/main.json b/source/core/assets/levels/cryoheim/main_area/main.json index bba3179d3..4df255dfe 100644 --- a/source/core/assets/levels/cryoheim/main_area/main.json +++ b/source/core/assets/levels/cryoheim/main_area/main.json @@ -43,6 +43,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/upgradeTreeTap.wav", @@ -54,10 +56,18 @@ "sounds/explosion/grenade.mp3", "sounds/explosion/landmine.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ - "particle-effects/explosion/explosion.effect" + "particle-effects/explosion/explosion.effect", + "particle-effects/shield/shield.effect" ], "backgroundMusicPath": "sounds/BGM_03_mp3.wav" }, diff --git a/source/core/assets/levels/earth/level.json b/source/core/assets/levels/earth/level.json index 11135acba..8661b517d 100644 --- a/source/core/assets/levels/earth/level.json +++ b/source/core/assets/levels/earth/level.json @@ -2,5 +2,5 @@ "areaNames": [ "main_area" ], - "nextPlanet": "flora_haven" + "nextPlanet": "blazes_refuge" } \ No newline at end of file diff --git a/source/core/assets/levels/earth/main_area/entities/astro.json b/source/core/assets/levels/earth/main_area/entities/astro.json index e32c91a70..392851fcb 100644 --- a/source/core/assets/levels/earth/main_area/entities/astro.json +++ b/source/core/assets/levels/earth/main_area/entities/astro.json @@ -2,7 +2,7 @@ "entityType": "AstroConfig", "entities": [ { - class: com.csse3200.game.entities.configs.AstroConfig, + "class": "com.csse3200.game.entities.configs.AstroConfig", "spritePath": "images/npc/Astro_NPC.atlas", "position" : { "x": 24, diff --git a/source/core/assets/levels/earth/main_area/entities/companion.json b/source/core/assets/levels/earth/main_area/entities/companion.json index 53c25d154..4e098fb9a 100644 --- a/source/core/assets/levels/earth/main_area/entities/companion.json +++ b/source/core/assets/levels/earth/main_area/entities/companion.json @@ -2,7 +2,7 @@ "entityType": "CompanionConfig", "entities": [ { - class: com.csse3200.game.entities.configs.CompanionConfig, + "class": "com.csse3200.game.entities.configs.CompanionConfig", "position": { "x": 10, "y": 50 diff --git a/source/core/assets/levels/earth/main_area/entities/fissures.json b/source/core/assets/levels/earth/main_area/entities/fissures.json index 09e3d2cc1..c3f136a67 100644 --- a/source/core/assets/levels/earth/main_area/entities/fissures.json +++ b/source/core/assets/levels/earth/main_area/entities/fissures.json @@ -2,7 +2,7 @@ "entityType": "FissureConfig", "entities": [ { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Solstite", "position": { "x": 34, @@ -10,7 +10,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Nebulite", "position": { "x": 40, @@ -18,7 +18,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Durasteel", "position": { "x": 46, diff --git a/source/core/assets/levels/earth/main_area/entities/jail.json b/source/core/assets/levels/earth/main_area/entities/jail.json index 585884205..f77c91ddf 100644 --- a/source/core/assets/levels/earth/main_area/entities/jail.json +++ b/source/core/assets/levels/earth/main_area/entities/jail.json @@ -2,7 +2,7 @@ "entityType": "JailConfig", "entities": [ { - class: com.csse3200.game.entities.configs.JailConfig, + "class": "com.csse3200.game.entities.configs.JailConfig", "spritePath": "images/Jail/jail.atlas", "position" : { "x": 24, diff --git a/source/core/assets/levels/earth/main_area/entities/laboratory.json b/source/core/assets/levels/earth/main_area/entities/laboratory.json index e1fc2c9a5..4a58a5780 100644 --- a/source/core/assets/levels/earth/main_area/entities/laboratory.json +++ b/source/core/assets/levels/earth/main_area/entities/laboratory.json @@ -2,7 +2,7 @@ "entityType": "LaboratoryConfig", "entities": [ { - class: com.csse3200.game.entities.configs.LaboratoryConfig, + "class": "com.csse3200.game.entities.configs.LaboratoryConfig", "spritePath": "images/companion/laboratory.png", "position": {"x":34, "y": 49 diff --git a/source/core/assets/levels/earth/main_area/entities/player.json b/source/core/assets/levels/earth/main_area/entities/player.json index 7b01a14e7..0d2802396 100644 --- a/source/core/assets/levels/earth/main_area/entities/player.json +++ b/source/core/assets/levels/earth/main_area/entities/player.json @@ -2,7 +2,7 @@ "entityType": "PlayerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PlayerConfig, + "class": "com.csse3200.game.entities.configs.PlayerConfig", "position": { "x": 10, "y": 40 diff --git a/source/core/assets/levels/earth/main_area/entities/portals.json b/source/core/assets/levels/earth/main_area/entities/portals.json index 55b7510a9..567c88018 100644 --- a/source/core/assets/levels/earth/main_area/entities/portals.json +++ b/source/core/assets/levels/earth/main_area/entities/portals.json @@ -2,7 +2,7 @@ "entityType": "PortalConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PortalConfig, + "class": "com.csse3200.game.entities.configs.PortalConfig", "teleportX" : 40, "teleportY" : 5, "position": { @@ -11,7 +11,7 @@ } }, { - class: com.csse3200.game.entities.configs.PortalConfig, + "class": com.csse3200.game.entities.configs.PortalConfig, "teleportX" : 16, "teleportY" : 20, "position": { diff --git a/source/core/assets/levels/earth/main_area/entities/secretpower.json b/source/core/assets/levels/earth/main_area/entities/secretpower.json index 04f2d1f48..b8e838cf2 100644 --- a/source/core/assets/levels/earth/main_area/entities/secretpower.json +++ b/source/core/assets/levels/earth/main_area/entities/secretpower.json @@ -2,7 +2,7 @@ "entityType": "PowerupConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/health_boost.png", "spritePath": "images/powerups/health_boost.png", "type": "HEALTH_BOOST", @@ -12,7 +12,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/extra_life.png", "spritePath": "images/powerups/extra_life.png", "type": "EXTRA_LIFE", @@ -22,7 +22,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/speed_boost.png", "spritePath": "images/powerups/speed_boost.png", "type": "SPEED_BOOST", @@ -32,7 +32,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/double_cross.png", "spritePath": "images/powerups/double_cross.png", "type": "DOUBLE_CROSS", @@ -42,7 +42,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/temp_immunity.png", "spritePath": "images/powerups/temp_immunity.png", "type": "TEMP_IMMUNITY", @@ -52,7 +52,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/double_damage.png", "spritePath": "images/powerups/double_damage.png", "type": "DOUBLE_DAMAGE", @@ -62,7 +62,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/snap.png", "spritePath": "images/powerups/snap.png", "type": "SNAP", diff --git a/source/core/assets/levels/earth/main_area/entities/ship.json b/source/core/assets/levels/earth/main_area/entities/ship.json index b4d652836..a201859d8 100644 --- a/source/core/assets/levels/earth/main_area/entities/ship.json +++ b/source/core/assets/levels/earth/main_area/entities/ship.json @@ -2,7 +2,7 @@ "entityType": "ShipConfig", "entities": [ { - class: com.csse3200.game.entities.configs.ShipConfig, + "class": "com.csse3200.game.entities.configs.ShipConfig", "spritePath": "images/ship/Ship.png", "position": { "x": 33, diff --git a/source/core/assets/levels/earth/main_area/entities/spawners.json b/source/core/assets/levels/earth/main_area/entities/spawners.json index 2df19c610..104de47e3 100644 --- a/source/core/assets/levels/earth/main_area/entities/spawners.json +++ b/source/core/assets/levels/earth/main_area/entities/spawners.json @@ -2,7 +2,7 @@ "entityType": "SpawnerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.SpawnerConfig, + "class": "com.csse3200.game.entities.configs.SpawnerConfig", "wave1" : { <<<<<<< Updated upstream "roboMan" : 5, @@ -45,7 +45,7 @@ } }, { - class: com.csse3200.game.entities.configs.SpawnerConfig, + "class": "com.csse3200.game.entities.configs.SpawnerConfig", "wave1" : { "Knight" : 1, "necromancer" : 0, diff --git a/source/core/assets/levels/earth/main_area/entities/treeTop.json b/source/core/assets/levels/earth/main_area/entities/treeTop.json index 361fc2493..adc8888d6 100644 --- a/source/core/assets/levels/earth/main_area/entities/treeTop.json +++ b/source/core/assets/levels/earth/main_area/entities/treeTop.json @@ -2,7 +2,7 @@ "entityType": "TreeTopConfig", "entities": [ { - class: com.csse3200.game.entities.configs.TreeTopConfig, + "class": "com.csse3200.game.entities.configs.TreeTopConfig", "position": { "x": 0, "y": 30 diff --git a/source/core/assets/levels/earth/main_area/main.json b/source/core/assets/levels/earth/main_area/main.json index a3b85bea4..a0f83cfb8 100644 --- a/source/core/assets/levels/earth/main_area/main.json +++ b/source/core/assets/levels/earth/main_area/main.json @@ -32,12 +32,9 @@ "images/powerups/extra_life.png", "images/powerups/snap.png", "images/powerups/death_potion.png", - "images/powerups/health_potion.png", - "images/powerups/invincibility_potion.png", "images/powerups/speed_boost.png", "images/powerups/speed_potion.png", "images/powerups/health_boost.png", - "images/powerups/health_potion.png", "images/powerups/temp_immunity.png", "map/portal.png", "images/minigame/fireAnim.png", @@ -88,6 +85,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/upgradeTreeTap.wav", @@ -100,7 +99,14 @@ "sounds/explosion/landmine.mp3", "sounds/Healing/HealingWalls.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ "particle-effects/explosion/explosion.effect", diff --git a/source/core/assets/levels/flora_haven/level.json b/source/core/assets/levels/flora_haven/level.json index 4f73bf980..fc52b4619 100644 --- a/source/core/assets/levels/flora_haven/level.json +++ b/source/core/assets/levels/flora_haven/level.json @@ -2,5 +2,5 @@ "areaNames": [ "main_area" ], - "nextPlanet": "cryoheim" + "nextPlanet": "END" } \ No newline at end of file diff --git a/source/core/assets/levels/flora_haven/main_area/entities/TreeTop.json b/source/core/assets/levels/flora_haven/main_area/entities/TreeTop.json index 096cd8985..38be5161e 100644 --- a/source/core/assets/levels/flora_haven/main_area/entities/TreeTop.json +++ b/source/core/assets/levels/flora_haven/main_area/entities/TreeTop.json @@ -2,7 +2,7 @@ "entityType": "TreeTopConfig", "entities": [ { - class: com.csse3200.game.entities.configs.TreeTopConfig, + "class": "com.csse3200.game.entities.configs.TreeTopConfig", "position": { "x": 0, "y": 0 diff --git a/source/core/assets/levels/flora_haven/main_area/entities/astro.json b/source/core/assets/levels/flora_haven/main_area/entities/astro.json index 56d891a2e..485c5b7da 100644 --- a/source/core/assets/levels/flora_haven/main_area/entities/astro.json +++ b/source/core/assets/levels/flora_haven/main_area/entities/astro.json @@ -2,7 +2,7 @@ "entityType": "AstronautConfig", "entities": [ { - class: com.csse3200.game.entities.configs.AstronautConfig, + "class": "com.csse3200.game.entities.configs.AstronautConfig", "spritePath": "images/npc/astronaut_npc.atlas", "position" : { "x": 13, diff --git a/source/core/assets/levels/flora_haven/main_area/entities/player.json b/source/core/assets/levels/flora_haven/main_area/entities/player.json index 43a51d60a..fbd163c2e 100644 --- a/source/core/assets/levels/flora_haven/main_area/entities/player.json +++ b/source/core/assets/levels/flora_haven/main_area/entities/player.json @@ -2,7 +2,7 @@ "entityType": "PlayerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PlayerConfig, + "class": "com.csse3200.game.entities.configs.PlayerConfig", "position": { "x": 10, "y": 40 diff --git a/source/core/assets/levels/flora_haven/main_area/entities/portals.json b/source/core/assets/levels/flora_haven/main_area/entities/portals.json index db4daea03..1b5ca0961 100644 --- a/source/core/assets/levels/flora_haven/main_area/entities/portals.json +++ b/source/core/assets/levels/flora_haven/main_area/entities/portals.json @@ -2,7 +2,7 @@ "entityType": "PortalConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PortalConfig, + "class": "com.csse3200.game.entities.configs.PortalConfig", "teleportX" : 23, "teleportY" : 4, "position": { @@ -11,7 +11,7 @@ } }, { - class: com.csse3200.game.entities.configs.PortalConfig, + "class": "com.csse3200.game.entities.configs.PortalConfig", "teleportX" : 32, "teleportY" : 22, "position": { diff --git a/source/core/assets/levels/flora_haven/main_area/entities/secretpower.json b/source/core/assets/levels/flora_haven/main_area/entities/secretpower.json index 6de38dc01..e1d285909 100644 --- a/source/core/assets/levels/flora_haven/main_area/entities/secretpower.json +++ b/source/core/assets/levels/flora_haven/main_area/entities/secretpower.json @@ -2,7 +2,7 @@ "entityType": "PowerupConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/health_boost.png", "spritePath": "images/powerups/health_boost.png", "type": "HEALTH_BOOST", @@ -12,7 +12,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/extra_life.png", "spritePath": "images/powerups/extra_life.png", "type": "EXTRA_LIFE", @@ -22,7 +22,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/speed_boost.png", "spritePath": "images/powerups/speed_boost.png", "type": "SPEED_BOOST", @@ -32,7 +32,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/double_cross.png", "spritePath": "images/powerups/double_cross.png", "type": "DOUBLE_CROSS", @@ -42,7 +42,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/temp_immunity.png", "spritePath": "images/powerups/temp_immunity.png", "type": "TEMP_IMMUNITY", @@ -52,7 +52,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/double_damage.png", "spritePath": "images/powerups/double_damage.png", "type": "DOUBLE_DAMAGE", @@ -62,7 +62,7 @@ } }, { - class: com.csse3200.game.entities.configs.PowerupConfig, + "class": "com.csse3200.game.entities.configs.PowerupConfig", "imagePath": "images/powerups/snap.png", "spritePath": "images/powerups/snap.png", "type": "SNAP", diff --git a/source/core/assets/levels/flora_haven/main_area/entities/ship.json b/source/core/assets/levels/flora_haven/main_area/entities/ship.json index 94067c789..dd182622f 100644 --- a/source/core/assets/levels/flora_haven/main_area/entities/ship.json +++ b/source/core/assets/levels/flora_haven/main_area/entities/ship.json @@ -2,7 +2,7 @@ "entityType": "ShipConfig", "entities": [ { - class: com.csse3200.game.entities.configs.ShipConfig, + "class": "com.csse3200.game.entities.configs.ShipConfig", "spritePath": "images/ship/Ship.png", "position": { "x": 53, diff --git a/source/core/assets/levels/flora_haven/main_area/entities/spawners.json b/source/core/assets/levels/flora_haven/main_area/entities/spawners.json index d2b120132..1d93fd0d0 100644 --- a/source/core/assets/levels/flora_haven/main_area/entities/spawners.json +++ b/source/core/assets/levels/flora_haven/main_area/entities/spawners.json @@ -2,7 +2,7 @@ "entityType": "SpawnerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.SpawnerConfig, + "class": "com.csse3200.game.entities.configs.SpawnerConfig", "wave1" : { "necromancer" : 5, "roboMan" : 10, @@ -29,7 +29,7 @@ } }, { - class: com.csse3200.game.entities.configs.SpawnerConfig, + "class": "com.csse3200.game.entities.configs.SpawnerConfig", "wave1" : { "Mage" : 1, "necromancer" : 0, diff --git a/source/core/assets/levels/flora_haven/main_area/main.json b/source/core/assets/levels/flora_haven/main_area/main.json index 66d57ee2d..ef562df54 100644 --- a/source/core/assets/levels/flora_haven/main_area/main.json +++ b/source/core/assets/levels/flora_haven/main_area/main.json @@ -46,6 +46,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/upgradeTreeTap.wav", @@ -57,11 +59,19 @@ "sounds/explosion/grenade.mp3", "sounds/explosion/landmine.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ "particle-effects/explosion/explosion.effect", - "particle-effects/explosion/bigBallCombustion.effect" + "particle-effects/explosion/bigBallCombustion.effect", + "particle-effects/shield/shield.effect" ], "backgroundMusicPath": "sounds/BGM_03_mp3.wav" }, diff --git a/source/core/assets/levels/game.json b/source/core/assets/levels/game.json index 96e30f9c3..56c41f1c6 100644 --- a/source/core/assets/levels/game.json +++ b/source/core/assets/levels/game.json @@ -1,8 +1,8 @@ { "levelNames": [ "earth", + "blazes_refuge", "cryoheim", - "flora_haven", - "blazes_refuge" + "flora_haven" ] } \ No newline at end of file diff --git a/source/core/assets/levels/global_assets.json b/source/core/assets/levels/global_assets.json index 80ea7233f..3c72896c7 100644 --- a/source/core/assets/levels/global_assets.json +++ b/source/core/assets/levels/global_assets.json @@ -66,6 +66,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/playerDead.wav", @@ -77,7 +79,14 @@ "sounds/explosion/landmine.mp3", "sounds/turret_shoot.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ "particle-effects/extractor/extractor_rubble_solstite.effect", diff --git a/source/core/assets/levels/tutorial/main-area/main.json b/source/core/assets/levels/tutorial/main-area/main.json index 47b6a4b49..9c7858ea6 100644 --- a/source/core/assets/levels/tutorial/main-area/main.json +++ b/source/core/assets/levels/tutorial/main-area/main.json @@ -31,11 +31,8 @@ "images/powerups/extra_life.png", "images/powerups/snap.png", "images/powerups/death_potion.png", - "images/powerups/health_potion.png", - "images/powerups/invincibility_potion.png", "images/powerups/speed_boost.png", "images/powerups/health_boost.png", - "images/powerups/health_potion.png", "images/powerups/temp_immunity.png", "map/portal.png", "images/minigame/fireAnim.png", @@ -75,6 +72,7 @@ "images/structures/open_gate.atlas", "images/structures/closed_gate.atlas", "images/companion/earth_Companion_spritesheet.atlas", + "images/companion/Companion_spritesheet.atlas", "images/minigame/fire.atlas", "images/structures/ExtractorAnimation.atlas", "images/npc/Tutnpc.atlas" @@ -84,6 +82,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/upgradeTreeTap.wav", @@ -95,14 +95,22 @@ "sounds/explosion/grenade.mp3", "sounds/explosion/landmine.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ "particle-effects/explosion/explosion.effect", "particle-effects/extractor/durasteel.effect", "particle-effects/extractor/nebulite.effect", "particle-effects/extractor/solstite.effect", - "particle-effects/explosion/bigBallCombustion.effect" + "particle-effects/explosion/bigBallCombustion.effect", + "particle-effects/shield/shield.effect" ], "backgroundMusicPath": "sounds/BGM_03_mp3.wav", diff --git a/source/core/assets/levels/tutorial/main_area/entities/fissures.json b/source/core/assets/levels/tutorial/main_area/entities/fissures.json index 09e3d2cc1..c3f136a67 100644 --- a/source/core/assets/levels/tutorial/main_area/entities/fissures.json +++ b/source/core/assets/levels/tutorial/main_area/entities/fissures.json @@ -2,7 +2,7 @@ "entityType": "FissureConfig", "entities": [ { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Solstite", "position": { "x": 34, @@ -10,7 +10,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Nebulite", "position": { "x": 40, @@ -18,7 +18,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Durasteel", "position": { "x": 46, diff --git a/source/core/assets/levels/tutorial/main_area/entities/player.json b/source/core/assets/levels/tutorial/main_area/entities/player.json index b5e5b018f..32bec4dc2 100644 --- a/source/core/assets/levels/tutorial/main_area/entities/player.json +++ b/source/core/assets/levels/tutorial/main_area/entities/player.json @@ -2,7 +2,7 @@ "entityType": "PlayerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.PlayerConfig, + "class": "com.csse3200.game.entities.configs.PlayerConfig", "position": { "x": 10, "y": 40 diff --git a/source/core/assets/levels/tutorial/main_area/entities/spawners.json b/source/core/assets/levels/tutorial/main_area/entities/spawners.json index 2d2f38fe2..755e324cd 100644 --- a/source/core/assets/levels/tutorial/main_area/entities/spawners.json +++ b/source/core/assets/levels/tutorial/main_area/entities/spawners.json @@ -2,7 +2,7 @@ "entityType": "SpawnerConfig", "entities": [ { - class: com.csse3200.game.entities.configs.SpawnerConfig, + "class": "com.csse3200.game.entities.configs.SpawnerConfig", "wave1" : [ 1, 1, diff --git a/source/core/assets/levels/tutorial/main_area/entities/tutnpc.json b/source/core/assets/levels/tutorial/main_area/entities/tutnpc.json index 1e1940e2a..59399b516 100644 --- a/source/core/assets/levels/tutorial/main_area/entities/tutnpc.json +++ b/source/core/assets/levels/tutorial/main_area/entities/tutnpc.json @@ -2,7 +2,7 @@ "entityType": "TutnpcConfig", "entities": [ { - class: com.csse3200.game.entities.configs.TutnpcConfig, + "class": "com.csse3200.game.entities.configs.TutnpcConfig", "spritePath": "images/npc/Tutnpc.atlas", "position" : { "x": 10, diff --git a/source/core/assets/levels/tutorial/main_area/main.json b/source/core/assets/levels/tutorial/main_area/main.json index acf56e668..d50e4b0c1 100644 --- a/source/core/assets/levels/tutorial/main_area/main.json +++ b/source/core/assets/levels/tutorial/main_area/main.json @@ -31,11 +31,8 @@ "images/powerups/extra_life.png", "images/powerups/snap.png", "images/powerups/death_potion.png", - "images/powerups/health_potion.png", - "images/powerups/invincibility_potion.png", "images/powerups/speed_boost.png", "images/powerups/health_boost.png", - "images/powerups/health_potion.png", "images/powerups/temp_immunity.png", "map/portal.png", "images/minigame/fireAnim.png", @@ -74,6 +71,7 @@ "images/structures/open_gate.atlas", "images/structures/closed_gate.atlas", "images/companion/earth_Companion_spritesheet.atlas", + "images/companion/Companion_spritesheet.atlas", "images/minigame/fire.atlas", "images/structures/ExtractorAnimation.atlas", "images/npc/Tutnpc.atlas" @@ -83,6 +81,8 @@ "sounds/playerLow_health.wav", "sounds/dodgingAlertSweep.wav", "sounds/footStepsInTheForestGround.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", "sounds/PlayerHealthRecharge.wav", "sounds/playerBoostRecharge.wav", "sounds/upgradeTreeTap.wav", @@ -94,13 +94,21 @@ "sounds/explosion/grenade.mp3", "sounds/explosion/landmine.mp3", "sounds/ExitButton.wav", - "sounds/structurePlace.wav" + "sounds/structurePlace.wav", + "sounds/weapons/Katana.wav", + "sounds/weapons/boomerang.wav", + "sounds/weapons/slingshot.wav", + "sounds/weapons/beeStringKatana.wav", + "sounds/weapons/nuke.wav", + "sounds/weapons/missile.wav", + "sounds/weapons/laserSword.wav" ], "particleEffectPaths": [ "particle-effects/explosion/explosion.effect", "particle-effects/extractor/durasteel.effect", "particle-effects/extractor/nebulite.effect", - "particle-effects/extractor/solstite.effect" + "particle-effects/extractor/solstite.effect", + "particle-effects/shield/shield.effect" ], "backgroundMusicPath": "sounds/BGM_03_mp3.wav" }, diff --git a/source/core/assets/map/Coolzone.atlas b/source/core/assets/map/Coolzone.atlas new file mode 100644 index 000000000..b5025b544 --- /dev/null +++ b/source/core/assets/map/Coolzone.atlas @@ -0,0 +1,12 @@ +coolzone.png +size: 392, 392 +format: RGBA8888 +filter: Linear,Linear +repeat: none +Flicker + rotate: false + xy: 0, 0 + size: 392, 392 + orig: 392, 392 + offset: 0, 0 + index: -1 \ No newline at end of file diff --git a/source/core/assets/sounds/weapons/Katana.wav b/source/core/assets/sounds/weapons/Katana.wav new file mode 100644 index 000000000..1448fcb40 Binary files /dev/null and b/source/core/assets/sounds/weapons/Katana.wav differ diff --git a/source/core/assets/sounds/weapons/beeStringKatana.wav b/source/core/assets/sounds/weapons/beeStringKatana.wav new file mode 100644 index 000000000..98475113f Binary files /dev/null and b/source/core/assets/sounds/weapons/beeStringKatana.wav differ diff --git a/source/core/assets/sounds/weapons/boomerang.wav b/source/core/assets/sounds/weapons/boomerang.wav new file mode 100644 index 000000000..926505070 Binary files /dev/null and b/source/core/assets/sounds/weapons/boomerang.wav differ diff --git a/source/core/assets/sounds/weapons/laserSword.wav b/source/core/assets/sounds/weapons/laserSword.wav new file mode 100644 index 000000000..579c1f350 Binary files /dev/null and b/source/core/assets/sounds/weapons/laserSword.wav differ diff --git a/source/core/assets/sounds/weapons/missile.wav b/source/core/assets/sounds/weapons/missile.wav new file mode 100644 index 000000000..b399cbbb2 Binary files /dev/null and b/source/core/assets/sounds/weapons/missile.wav differ diff --git a/source/core/assets/sounds/weapons/nuke.wav b/source/core/assets/sounds/weapons/nuke.wav new file mode 100644 index 000000000..0867ae875 Binary files /dev/null and b/source/core/assets/sounds/weapons/nuke.wav differ diff --git a/source/core/assets/sounds/weapons/slingshot.wav b/source/core/assets/sounds/weapons/slingshot.wav new file mode 100644 index 000000000..ddb3d9bc5 Binary files /dev/null and b/source/core/assets/sounds/weapons/slingshot.wav differ diff --git a/source/core/src/main/com/csse3200/game/areas/MapGameArea.java b/source/core/src/main/com/csse3200/game/areas/MapGameArea.java index 8ab7a9276..7c18c8636 100644 --- a/source/core/src/main/com/csse3200/game/areas/MapGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/MapGameArea.java @@ -27,12 +27,12 @@ import com.csse3200.game.entities.configs.*; import com.csse3200.game.entities.factories.*; import com.csse3200.game.files.UserSettings; +import com.csse3200.game.input.InputOverrideComponent; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.services.TerrainService; import com.csse3200.game.ui.QuestBox; import com.csse3200.game.utils.math.GridPoint2Utils; -import com.badlogic.gdx.scenes.scene2d.Stage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,6 +53,7 @@ public class MapGameArea extends GameArea{ private final GdxGame game; protected boolean validLoad = true; private static boolean freezing; + private final InputOverrideComponent inputOverrideComponent; public MapGameArea(String levelName, String gamearea, TerrainFactory terrainFactory, GdxGame game) { try { @@ -62,6 +63,7 @@ public MapGameArea(String levelName, String gamearea, TerrainFactory terrainFact logger.error("FAILED TO LOAD GAME IN CONSTRUCTOR - {}", exception.getMessage()); validLoad = false; } + inputOverrideComponent = new InputOverrideComponent(); this.game = game; this.terrainFactory = terrainFactory; } @@ -105,9 +107,6 @@ public void create() { spawnAstronaut(); - //spawnEnvironmentDamage(); -// spawnFreezingArea(); -// spawnEnvironmentDamage(); spawnSafeZone(player); displayUI(); @@ -147,7 +146,6 @@ private void displayUI() { Entity ui = new Entity(); //Ensure non-null mapConfig.mapName = mapConfig.mapName == null ? "" : mapConfig.mapName; - //ui.addComponent(new GameAreaDisplay(map_config.mapName)); ui.addComponent(new PlanetHudDisplay(mapConfig.mapName, mapConfig.planetImage)) .addComponent(new InventoryDisplayComponent()); QuestBox questBox=new QuestBox("Rescue Astro",skin,stage); @@ -177,20 +175,6 @@ private void spawnSafeZone(Entity playerEntity) { spawnEntityAt(safeZone, safeZoneConfig.position, false, false); } -// private void spawnEnvironmentDamage() { -// if (mapConfig.areaEntityConfig == null) return; -// -// Entity envDamage = EnvironmentalDamageFactory.createDamage(); -// spawnEntityAt(envDamage, new GridPoint2(45, 45), false, false); -// } -// -// private void spawnFreezingArea() { -// if (mapConfig.areaEntityConfig == null) return; -// -// Entity freezeArea = FreezingAreaFactory.createFreezingArea(); -// spawnEntityAt(freezeArea, new GridPoint2(40, 60), false, false); -// } - public static float getSpeedMult() { TiledMapTileLayer collisionLayer = (TiledMapTileLayer) terrain.getMap().getLayers().get("Base"); Vector2 playerPos = getPlayer().getPosition(); @@ -209,14 +193,6 @@ public static boolean isOnIce() { return onIce != null && (boolean) onIce; } -// public static boolean isFreezing() { -// return freezing; -// } -// -// public static void toggleFreezing(Entity player) { -// freezing = !freezing; -// } - /** * Checks if the player should be taking damage from standing on fire or lava */ @@ -253,22 +229,22 @@ private void spawnTerrain() { // Left spawnEntityAt( - ObstacleFactory.createWall(ObstacleFactory.WALL_SIZE, worldBounds.y), GridPoint2Utils.ZERO, false, false); + ObstacleFactory.createWall(ObstacleFactory.wallSize, worldBounds.y), GridPoint2Utils.ZERO, false, false); // Right spawnEntityAt( - ObstacleFactory.createWall(ObstacleFactory.WALL_SIZE, worldBounds.y), + ObstacleFactory.createWall(ObstacleFactory.wallSize, worldBounds.y), new GridPoint2(tileBounds.x, 0), false, false); // Top spawnEntityAt( - ObstacleFactory.createWall(worldBounds.x, ObstacleFactory.WALL_SIZE), + ObstacleFactory.createWall(worldBounds.x, ObstacleFactory.wallSize), new GridPoint2(0, tileBounds.y), false, false); // Bottom spawnEntityAt( - ObstacleFactory.createWall(worldBounds.x, ObstacleFactory.WALL_SIZE), GridPoint2Utils.ZERO, false, false); + ObstacleFactory.createWall(worldBounds.x, ObstacleFactory.wallSize), GridPoint2Utils.ZERO, false, false); ServiceLocator.registerTerrainService(new TerrainService(terrain)); } @@ -629,6 +605,7 @@ protected void unloadAssets() { */ private boolean initiateDeathScreen() { int lives = getPlayer().getComponent(CombatStatsComponent.class).getLives(); + ServiceLocator.getInputService().unregister(inputOverrideComponent); switch (lives) { case 0 -> { Gdx.app.postRunnable(() -> game.setScreen(GdxGame.ScreenType.PLAYER_DEATH_0)); diff --git a/source/core/src/main/com/csse3200/game/areas/ShopArea.java b/source/core/src/main/com/csse3200/game/areas/ShopArea.java index 597f6eb4a..cce21de9d 100644 --- a/source/core/src/main/com/csse3200/game/areas/ShopArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ShopArea.java @@ -26,8 +26,8 @@ public class ShopArea extends GameArea { private static final String[] spaceMiniGameTextures = { "images/minigame/SpaceMiniGameBackground.png", "images/structure-icons/stone_wall.png", - "images/powerups/health_potion.png", - "images/powerups/speed_potion.png" + "images/powerups/health_boost.png", + "images/powerups/speed_boost.png" }; private static final String[] spaceTextureAtlases = {"images/minigame/ship.atlas"}; private final TerrainFactory terrainFactory; diff --git a/source/core/src/main/com/csse3200/game/areas/SpaceGameArea.java b/source/core/src/main/com/csse3200/game/areas/SpaceGameArea.java index 057943b2e..1872cfc3b 100644 --- a/source/core/src/main/com/csse3200/game/areas/SpaceGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/SpaceGameArea.java @@ -39,11 +39,11 @@ public class SpaceGameArea extends GameArea { "images/minigame/obstacle-enemy.png", "images/minigame/mainship.png" }; - private static final String BackgroundMusic = "sounds/WereWasI.ogg"; //public domain https://opengameart.org/content/where-was-i - private static final String[] spaceMusic = {BackgroundMusic}; + private static final String backgroundMusic = "sounds/WereWasI.ogg"; //public domain https://opengameart.org/content/where-was-i + private static final String[] spaceMusic = {backgroundMusic}; private final TerrainFactory terrainFactory; - private final ArrayList TargeTables; + private final ArrayList targetTables; private static final String[] spaceTextureAtlases = {"images/minigame/ship.atlas"}; @@ -54,7 +54,7 @@ public class SpaceGameArea extends GameArea { public SpaceGameArea(TerrainFactory terrainFactory) { super(); this.terrainFactory = terrainFactory; - this.TargeTables = new ArrayList<>(); + this.targetTables = new ArrayList<>(); } /** @@ -81,7 +81,7 @@ public void create() { */ private void playMusic() { UserSettings.Settings settings = UserSettings.get(); - Music music = ServiceLocator.getResourceService().getAsset(BackgroundMusic, Music.class); + Music music = ServiceLocator.getResourceService().getAsset(backgroundMusic, Music.class); music.setLooping(true); music.setVolume(settings.musicVolume); music.play(); @@ -204,7 +204,7 @@ private Entity spawnShip() { Entity newShip = MinigameShipFactory.createMinigameShip(); spawnEntityAt(newShip, SHIP_SPAWN, true, true); - TargeTables.add(newShip); + targetTables.add(newShip); ship = newShip; return newShip; } diff --git a/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java b/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java index 57a423dc9..1ee24bca8 100644 --- a/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java +++ b/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java @@ -108,7 +108,7 @@ public void setHealth(int health) { if (isDead() && entity.getEntityType().equals("extractor") && !dead) { ServiceLocator.getGameArea().getEvent().trigger("reTarget"); } - if (isDead() && entity.getEntityType().equals("player") && dead == false) { + if (isDead() && entity.getEntityType().equals("player") && !dead) { dead = true; entity.getComponent(KeyboardPlayerInputComponent.class).clearWalking(); // Stop player from walking entity.getComponent(CombatStatsComponent.class).setImmunity(true); // Prevent dying before respawn @@ -296,13 +296,11 @@ public int getLives() { * @param attacker The entity causing the damage. */ public void hit(CombatStatsComponent attacker) { - if (getImmunity() == true) { - - return; + if (!getImmunity()) { + int newHealth; + newHealth = getHealth() - attacker.getAttack(); + setHealth(newHealth); } - int newHealth; - newHealth = getHealth() - attacker.getAttack(); - setHealth(newHealth); } diff --git a/source/core/src/main/com/csse3200/game/components/DeathComponent.java b/source/core/src/main/com/csse3200/game/components/DeathComponent.java index 4b266b49c..b61f52d73 100644 --- a/source/core/src/main/com/csse3200/game/components/DeathComponent.java +++ b/source/core/src/main/com/csse3200/game/components/DeathComponent.java @@ -18,7 +18,6 @@ public class DeathComponent extends Component { private CombatStatsComponent combatStats; private Boolean notkilled; - private Random rand = new Random(); private boolean isDying = false; // True when the entity is currently in the process of dying and playing death // animation. diff --git a/source/core/src/main/com/csse3200/game/components/EnvironmentStatsComponent.java b/source/core/src/main/com/csse3200/game/components/EnvironmentStatsComponent.java index cd0620ed4..6afab4a4d 100644 --- a/source/core/src/main/com/csse3200/game/components/EnvironmentStatsComponent.java +++ b/source/core/src/main/com/csse3200/game/components/EnvironmentStatsComponent.java @@ -90,6 +90,12 @@ public void damage(CombatStatsComponent player) { @Override public void run() { MapGameArea.isBurning(); + if (burning) { + player.addHealth(-2); + if (player.getHealth() <= 0) { + timer.stop(); + } + } if (getImmunity()) { if (getIsFreeze()) { if (getFrozenLevel() > 4) { @@ -100,12 +106,6 @@ public void run() { } return; } - if (burning) { - player.addHealth(-1); - if (player.getHealth() <= 0) { - timer.stop(); - } - } if (getIsFreeze()) { if (getFrozenLevel() < 50) { setFrozenLevel(getFrozenLevel() + 2); diff --git a/source/core/src/main/com/csse3200/game/components/EnvironmentalAttackComponent.java b/source/core/src/main/com/csse3200/game/components/EnvironmentalAttackComponent.java index 93dfd7e7a..ff919286a 100644 --- a/source/core/src/main/com/csse3200/game/components/EnvironmentalAttackComponent.java +++ b/source/core/src/main/com/csse3200/game/components/EnvironmentalAttackComponent.java @@ -64,8 +64,6 @@ private void damage(EnvironmentStatsComponent targetState, CombatStatsComponent if (targetState.getFrozenLevel() < 100) { targetState.setFrozenLevel(targetState.getFrozenLevel() + 1); } - // else { - //} } /** diff --git a/source/core/src/main/com/csse3200/game/components/ItemPickupComponent.java b/source/core/src/main/com/csse3200/game/components/ItemPickupComponent.java index 683f00b25..5d4261de2 100644 --- a/source/core/src/main/com/csse3200/game/components/ItemPickupComponent.java +++ b/source/core/src/main/com/csse3200/game/components/ItemPickupComponent.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.physics.box2d.Fixture; -import com.csse3200.game.components.companion.CompanionInventoryComponent; import com.csse3200.game.entities.Entity; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; diff --git a/source/core/src/main/com/csse3200/game/components/LaboratoryInventoryComponent.java b/source/core/src/main/com/csse3200/game/components/LaboratoryInventoryComponent.java index 9c7c3f070..cc96fee6b 100644 --- a/source/core/src/main/com/csse3200/game/components/LaboratoryInventoryComponent.java +++ b/source/core/src/main/com/csse3200/game/components/LaboratoryInventoryComponent.java @@ -13,7 +13,7 @@ * specifically the number of potions it contains. */ public class LaboratoryInventoryComponent extends Component { - private static final Logger logger = LoggerFactory.getLogger(InteractableComponent.class); + private static final Logger logger = LoggerFactory.getLogger(LaboratoryInventoryComponent.class); private int potion; /** diff --git a/source/core/src/main/com/csse3200/game/components/PowerupComponent.java b/source/core/src/main/com/csse3200/game/components/PowerupComponent.java index ed5180cd4..898028b04 100644 --- a/source/core/src/main/com/csse3200/game/components/PowerupComponent.java +++ b/source/core/src/main/com/csse3200/game/components/PowerupComponent.java @@ -76,11 +76,24 @@ public void applyEffect() { applyDoubleCross(); break; case SNAP: - applySnap(); - break; + if (player.getComponent(PlayerActions.class) == null) { + return; + } else { + List enemies = EnemyFactory.getEnemyList(); + int enemyCount = enemies.size() / 2; + for (int i = 1; i <= enemyCount; i++) { + int nextInt = random.nextInt(enemies.size()) - 1; + Entity enemy = enemies.get(nextInt); + while (enemy == null) { + nextInt = random.nextInt(enemies.size()) - 1; + enemy = enemies.get(nextInt); + } + enemy.dispose(); + } + break; + } case DEATH_POTION: applyDeath(); - default: throw new IllegalArgumentException("You must specify a valid PowerupType"); } diff --git a/source/core/src/main/com/csse3200/game/components/ShipInteractionPopup.java b/source/core/src/main/com/csse3200/game/components/ShipInteractionPopup.java index 11d824cce..7f123365b 100644 --- a/source/core/src/main/com/csse3200/game/components/ShipInteractionPopup.java +++ b/source/core/src/main/com/csse3200/game/components/ShipInteractionPopup.java @@ -15,17 +15,18 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.csse3200.game.GdxGame; -import com.csse3200.game.input.InputOverrideComponent; +import com.csse3200.game.components.maingame.MainGameActions; +import com.csse3200.game.entities.Entity; import com.csse3200.game.services.ServiceLocator; import static com.csse3200.game.components.mainmenu.MainMenuActions.game; public class ShipInteractionPopup extends Window { - private final InputOverrideComponent inputOverrideComponent; - public ShipInteractionPopup() { super("", new Window.WindowStyle(new BitmapFont(), Color.BLACK, getBrownBackgroundStatic())); - + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("pauseGame"); + } Stage stage = ServiceLocator.getRenderService().getStage(); float popupWidth = (float) (stage.getWidth() * 0.3); //setting the width of the popup float popupHeight = (float) (stage.getHeight() * 0.5); //setting the height of the popup @@ -60,15 +61,13 @@ public void changed(ChangeEvent event, Actor actor) { okButton.setSize(150, 50); okButton.setPosition((getWidth() - okButton.getWidth()) / 2, 20); this.addActor(okButton); - - inputOverrideComponent = new InputOverrideComponent(); - - ServiceLocator.getInputService().register(inputOverrideComponent); } @Override public boolean remove() { - ServiceLocator.getInputService().unregister(inputOverrideComponent); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("resumeGame"); + } return super.remove(); } private static TextureRegionDrawable getBrownBackgroundStatic() { diff --git a/source/core/src/main/com/csse3200/game/components/SoundComponent.java b/source/core/src/main/com/csse3200/game/components/SoundComponent.java index fb4a2adf1..fc9e480e5 100644 --- a/source/core/src/main/com/csse3200/game/components/SoundComponent.java +++ b/source/core/src/main/com/csse3200/game/components/SoundComponent.java @@ -56,6 +56,11 @@ public void create() { for (var entry : soundsConfig.soundsMap.entries()) { logger.debug("Entity {} loading in sound {} with id {}", entity, entry.value, entry.key); + if (entry.value.isEmpty()) { + logger.warn("Blank file specifed, Entity {}", entity); + continue; + } + Sound sound = ServiceLocator.getResourceService().getAsset(entry.value, Sound.class); if (sound == null) { diff --git a/source/core/src/main/com/csse3200/game/components/TouchAttackComponent.java b/source/core/src/main/com/csse3200/game/components/TouchAttackComponent.java index 5ccdec953..3d931e798 100644 --- a/source/core/src/main/com/csse3200/game/components/TouchAttackComponent.java +++ b/source/core/src/main/com/csse3200/game/components/TouchAttackComponent.java @@ -8,7 +8,6 @@ import com.csse3200.game.physics.PhysicsLayer; import com.csse3200.game.physics.components.HitboxComponent; import com.csse3200.game.physics.components.PhysicsComponent; -import com.csse3200.game.ui.DialogComponent; import com.badlogic.gdx.utils.Timer; /** @@ -85,7 +84,6 @@ private void onCollisionStart(Fixture me, Fixture other) { Entity target = ((BodyUserData) other.getBody().getUserData()).entity; Entity source = ((BodyUserData) me.getBody().getUserData()).entity; - DialogComponent dialogue = target.getComponent(DialogComponent.class); CombatStatsComponent targetStats = target.getComponent(CombatStatsComponent.class); CombatStatsComponent sourceStats = source.getComponent(CombatStatsComponent.class); leftContact = false; diff --git a/source/core/src/main/com/csse3200/game/components/Weapons/SpecWeapon/BoomerangController.java b/source/core/src/main/com/csse3200/game/components/Weapons/SpecWeapon/BoomerangController.java index efae6158d..ca4a74bdc 100644 --- a/source/core/src/main/com/csse3200/game/components/Weapons/SpecWeapon/BoomerangController.java +++ b/source/core/src/main/com/csse3200/game/components/Weapons/SpecWeapon/BoomerangController.java @@ -25,7 +25,7 @@ protected void set_animations() { @Override protected void initial_rotation() { - currentRotation += 45 * (attackNum % 2 == 0 ? 1 : -1); + currentRotation += 75 * (attackNum % 2 == 0 ? 1 : -1);; } @Override diff --git a/source/core/src/main/com/csse3200/game/components/Weapons/SpecWeapon/StaticController.java b/source/core/src/main/com/csse3200/game/components/Weapons/SpecWeapon/StaticController.java index bf8b9301a..a2e2537d4 100644 --- a/source/core/src/main/com/csse3200/game/components/Weapons/SpecWeapon/StaticController.java +++ b/source/core/src/main/com/csse3200/game/components/Weapons/SpecWeapon/StaticController.java @@ -16,7 +16,7 @@ public StaticController(WeaponConfig config, float attackDirection, Entity player) { super(config, attackDirection, player); - this.remainingDuration = config.slotType.equals("building") ? Integer.MAX_VALUE : 20; + this.remainingDuration = 25; this.player_last_pos = player.getPosition(); } diff --git a/source/core/src/main/com/csse3200/game/components/Weapons/WeaponControllerComponent.java b/source/core/src/main/com/csse3200/game/components/Weapons/WeaponControllerComponent.java index b2ceb41c6..37fb3c609 100644 --- a/source/core/src/main/com/csse3200/game/components/Weapons/WeaponControllerComponent.java +++ b/source/core/src/main/com/csse3200/game/components/Weapons/WeaponControllerComponent.java @@ -107,7 +107,9 @@ protected void set_sound() { if (sComp.checkExists("start")) { sComp.playSound("start"); } - + if (sComp.checkExists("mid")) { + sComp.loopSound("mid"); + } } /** @@ -144,7 +146,13 @@ protected void set_sound() { * respawn a weapon when it runs out of duration or health */ protected void despawn() { - //entity.getEvents().trigger("playSound", "stop"); + SoundComponent sComp = entity.getComponent(SoundComponent.class); + if (sComp.checkExists("mid")) { + sComp.stopSound("mid"); + } + if (sComp.checkExists("stop")) { + sComp.playSound("stop"); + } animator.stopAnimation(); Gdx.app.postRunnable(entity::dispose); } diff --git a/source/core/src/main/com/csse3200/game/components/companion/CompanionInventoryComponent.java b/source/core/src/main/com/csse3200/game/components/companion/CompanionInventoryComponent.java index eec7b2bf2..db02a52ee 100644 --- a/source/core/src/main/com/csse3200/game/components/companion/CompanionInventoryComponent.java +++ b/source/core/src/main/com/csse3200/game/components/companion/CompanionInventoryComponent.java @@ -122,11 +122,7 @@ public void addPowerup(Entity item) { if (powerupType != null) { int currentCount = powerupCounts.get(powerupType); powerupCounts.put(powerupType, currentCount + 1); - //System.out.println("Collecting powerup: " + powerupType + ", Count: " + powerupCounts.get(powerupType)); } - //System.out.println("Current powerupCounts: " + powerupCounts); - //System.out.println("Collecting powerup: " + powerupType ); - logger.debug("item added"); } } diff --git a/source/core/src/main/com/csse3200/game/components/companion/CompanionInventoryDisplay.java b/source/core/src/main/com/csse3200/game/components/companion/CompanionInventoryDisplay.java index 08bcfe319..b64025fd2 100644 --- a/source/core/src/main/com/csse3200/game/components/companion/CompanionInventoryDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/companion/CompanionInventoryDisplay.java @@ -13,6 +13,8 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.csse3200.game.components.PowerupType; +import com.csse3200.game.components.maingame.MainGameActions; +import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.configs.PowerupConfig; import com.csse3200.game.entities.configs.PowerupConfigs; import com.csse3200.game.files.FileLoader; @@ -44,6 +46,9 @@ public static CompanionInventoryDisplay createUpgradeDisplay(CompanionInventoryC Texture background = ServiceLocator.getResourceService().getAsset("images/upgradetree/background.png", Texture.class); background.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("pauseGame"); + } return new CompanionInventoryDisplay(background, inventoryComponent); //return new CompanionInventoryComponent(); } @@ -225,7 +230,6 @@ private TextButton createCountButton(PowerupConfig powerupConfig, float x, float @Override public void changed(ChangeEvent event, Actor actor) { int updatedCount = inventoryComponent.getPowerupCount(powerupType); - //System.out.println("Power-up Type: " + powerupType + ", Updated Count: " + updatedCount); updateCountButton(updatedCount, countButton); } }); @@ -314,6 +318,9 @@ private void exitUpgradeTree() { public boolean remove() { //Stop overriding input when exiting ServiceLocator.getInputService().unregister(inputOverrideComponent); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("resumeGame"); + } return super.remove(); } diff --git a/source/core/src/main/com/csse3200/game/components/companion/CompanionWeaponComponent.java b/source/core/src/main/com/csse3200/game/components/companion/CompanionWeaponComponent.java index cbac322fe..540c3eb99 100644 --- a/source/core/src/main/com/csse3200/game/components/companion/CompanionWeaponComponent.java +++ b/source/core/src/main/com/csse3200/game/components/companion/CompanionWeaponComponent.java @@ -31,7 +31,6 @@ public void create() { } // private void tempPrintAmmo(int ammo, int maxAmmo) { -// System.out.println("Currently: " + ammo + " / " + maxAmmo); // } diff --git a/source/core/src/main/com/csse3200/game/components/controls/ControlsScreenActions.java b/source/core/src/main/com/csse3200/game/components/controls/ControlsScreenActions.java index 47cc9af72..0faaed70f 100644 --- a/source/core/src/main/com/csse3200/game/components/controls/ControlsScreenActions.java +++ b/source/core/src/main/com/csse3200/game/components/controls/ControlsScreenActions.java @@ -13,16 +13,14 @@ public class ControlsScreenActions extends Component { private static final Logger logger = LoggerFactory.getLogger(ControlsScreenActions.class); private final GdxGame game; - private int lives; /** * Creates a new instance of ControlsScreenActions. * * @param game The main game instance. */ - public ControlsScreenActions(GdxGame game, int lives) { + public ControlsScreenActions(GdxGame game) { this.game = game; - this.lives = lives; } /** @@ -30,7 +28,8 @@ public ControlsScreenActions(GdxGame game, int lives) { */ @Override public void create() { - entity.getEvents().addListener("exit", this::onExit); + entity.getEvents().addListener("exitToSettings", this::onExitToSettings); + entity.getEvents().addListener("exitToGame", this::onExit); entity.getEvents().addListener("w", this::onW); entity.getEvents().addListener("a", this::onA); entity.getEvents().addListener("s", this::onS); @@ -41,9 +40,11 @@ public void create() { entity.getEvents().addListener("2", this::on2); entity.getEvents().addListener("3", this::on3); entity.getEvents().addListener("4", this::on4); - } + public void onExitToSettings() { + game.setScreen(GdxGame.ScreenType.SETTINGS); + } private void onW() { logger.info("W clicked"); @@ -86,18 +87,12 @@ private void on4() { } - - - /** - * Action to handle the 'exit' event, returning the game to the main menu. + * Action to handle the 'exit' event, returning to the current game. */ void onExit() { logger.info("Relaunching main game screen"); - ServiceLocator.getGameStateObserverService().trigger("updatePlayer", "lives", "set", lives); + ServiceLocator.getGameStateObserverService().trigger("updatePlayer", "lives", "set", (int) ServiceLocator.getGameStateObserverService().getStateData("player/lives")); new PlanetTravel(game).returnToCurrent(); } - - public void getLogger() { - } } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/controls/ControlsScreenDisplay.java b/source/core/src/main/com/csse3200/game/components/controls/ControlsScreenDisplay.java index d42a9291b..d076ef012 100644 --- a/source/core/src/main/com/csse3200/game/components/controls/ControlsScreenDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/controls/ControlsScreenDisplay.java @@ -1,42 +1,33 @@ package com.csse3200.game.components.controls; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.csse3200.game.GdxGame; import com.csse3200.game.components.mainmenu.InsertButtons; -import com.csse3200.game.entities.Entity; import com.csse3200.game.services.PlanetTravel; import com.csse3200.game.ui.UIComponent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; - -import static com.csse3200.game.GdxGame.ScreenType.EXTRACTOR_GAME; /** * A UI component responsible for displaying the controls screen's user interface. */ public class ControlsScreenDisplay extends UIComponent { private static final Logger logger = LoggerFactory.getLogger(ControlsScreenDisplay.class); - private Table table,table1; + private Table table; + private GdxGame.ScreenType screenType; private GdxGame game; - private PlanetTravel planetTravel; - private boolean Isgame= true; - public ControlsScreenDisplay(GdxGame game, boolean isgame){ + public ControlsScreenDisplay(GdxGame game, GdxGame.ScreenType screenType){ this.game=game; planetTravel = new PlanetTravel(game); - Isgame=isgame; + this.screenType=screenType; } - @Override public void create() { super.create(); @@ -54,14 +45,20 @@ private void addActors() { String exitTextureHover = "images/controls-images/on_exit_hover.PNG"; ImageButton exitBtn; exitBtn = bothButtons.draw(exitTexture, exitTextureHover); - exitBtn.setPosition(800f, 100f); + exitBtn.setPosition(1600f, 200f); exitBtn.setSize(250, 100); exitBtn.addListener(new ChangeListener() { @Override public void changed(ChangeEvent changeEvent, Actor actor) { logger.debug("Exit button clicked"); - entity.getEvents().trigger("exit"); + if (screenType.equals(GdxGame.ScreenType.SETTINGS)) { + game.setScreen(GdxGame.ScreenType.SETTINGS); + } else if (screenType.equals(GdxGame.ScreenType.TUTORIAL_SCREEN)) { + game.setScreen(GdxGame.ScreenType.TUTORIAL_SCREEN); + } else { + entity.getEvents().trigger("exitToGame"); + } } }); diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/PlanetHudDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/PlanetHudDisplay.java index f9ed9d564..6b4437ff5 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/PlanetHudDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/PlanetHudDisplay.java @@ -44,7 +44,7 @@ private void addActors() { planetLabel.setFontScale(0.22f); Table overlayTable = new Table(); - overlayTable.add(planetImage).size(130f).padLeft(5f).padBottom(15f); + overlayTable.add(planetImage).size(160f).padTop(-10f);//.padBottom(15f);//.padLeft(5f) overlayTable.row(); overlayTable.add(planetLabel); @@ -86,7 +86,6 @@ public void changed(ChangeEvent event, Actor actor) { @Override public void draw(SpriteBatch batch) { - } @Override diff --git a/source/core/src/main/com/csse3200/game/components/maingame/MainGameActions.java b/source/core/src/main/com/csse3200/game/components/maingame/MainGameActions.java index b668e0c97..62ee95b54 100644 --- a/source/core/src/main/com/csse3200/game/components/maingame/MainGameActions.java +++ b/source/core/src/main/com/csse3200/game/components/maingame/MainGameActions.java @@ -1,15 +1,16 @@ package com.csse3200.game.components.maingame; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.utils.Array; import com.csse3200.game.GdxGame; import com.csse3200.game.components.CombatStatsComponent; -import com.csse3200.game.components.EnvironmentStatsComponent; +import com.csse3200.game.entities.SafeZone; import com.csse3200.game.windows.PauseWindow; import com.csse3200.game.components.Component; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.configs.PlayerConfig; import com.csse3200.game.files.FileLoader; -import com.csse3200.game.services.PlanetTravel; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +34,23 @@ public MainGameActions(GdxGame game) { this.game = game; } + /** + * Set the entity to which this component belongs. This is called by the Entity, and should not be + * set manually. + * + * @param entity The entity to which the component is attached. + */ + @Override + public void setEntity(Entity entity) { + logger.debug("Attaching {} to {}", this, entity); + this.entity = entity; + } + + /** + * Initialises class with set entity and game. + * @param entity + * @param game + */ public MainGameActions(Entity entity, GdxGame game){ this.game=game; this.entity=entity; @@ -42,32 +60,31 @@ public MainGameActions(Entity entity, GdxGame game){ @Override public void create() { entity.getEvents().addListener("pause", this::onPauseButton); - entity.getEvents().addListener("returnPlanet", this::onReturnPlanet); entity.getEvents().addListener("exitPressed", this::onExit); entity.getEvents().addListener("returnPressed", this::onReturnButton); entity.getEvents().addListener("controlsPressed", this::onControlsButton); + entity.getEvents().addListener("pauseGame", this::paused); + entity.getEvents().addListener("resumeGame", this::resumed); } + /** * Opens pause window. */ - public void onPauseButton() { - logger.info("Opening Pause Menu"); - PauseWindow pauseWindow = PauseWindow.makeNewPauseWindow(entity); - entityList = ServiceLocator.getEntityService().getEntities(); - for (Entity entity : entityList) { - if (entity.getId() != getEntity().getId()) { - entity.setEnabled(false); - } + private void onPauseButton() { + if (!isWindowOpen() && (ServiceLocator.getGameArea() != null || game.getScreenType().equals(GdxGame.ScreenType.TUTORIAL_SCREEN))) { + logger.info("Opening Pause Menu"); + PauseWindow pauseWindow = PauseWindow.makeNewPauseWindow(entity); + paused(); + ServiceLocator.getRenderService().getStage().addActor(pauseWindow); } - ServiceLocator.getEntityService().getPlayer().getComponent(CombatStatsComponent.class).setImmunity(true); - ServiceLocator.getRenderService().getStage().addActor(pauseWindow); } /** * Exits to Main Menu screen. Closes pause window. */ - private void onExit() { + public void onExit() { logger.info("Exiting main game screen"); + ServiceLocator.getGameStateObserverService().getStateData("gameArea"); ServiceLocator.getGameStateObserverService().trigger("updatePlayer", "lives", "set", config.lives); game.setScreen(GdxGame.ScreenType.MAIN_MENU); } @@ -77,27 +94,43 @@ private void onExit() { */ private void onControlsButton() { logger.debug("Control Screen button clicked"); + resumed(); game.setScreen(GdxGame.ScreenType.CONTROL_SCREEN); } - /** - * Returns to current planet screen. - */ - protected void onReturnPlanet() { - logger.info("Exiting to current planet screen"); - ServiceLocator.getGameStateObserverService().trigger("updatePlayer", "lives", "set", config.lives); - new PlanetTravel(game).returnToCurrent(); - ServiceLocator.getEntityService().getPlayer().getComponent(CombatStatsComponent.class).setImmunity(false); - } - /** * Returns to current game. Closes pause window. */ protected void onReturnButton() { logger.info("Returning to current game"); + resumed(); + } + + protected void paused() { + entityList = ServiceLocator.getEntityService().getEntities(); + SafeZone safezone = new SafeZone(ServiceLocator.getEntityService().getPlayer()); + safezone.setSafe(ServiceLocator.getEntityService().getPlayer()); + for (Entity entity : entityList) { + if (entity.getId() != getEntity().getId()) { + entity.setEnabled(false); + } + } + ServiceLocator.getEntityService().getPlayer().getComponent(CombatStatsComponent.class).setImmunity(true); + } + protected void resumed() { for (Entity entity : entityList) { entity.setEnabled(true); } + SafeZone safezone = new SafeZone(ServiceLocator.getEntityService().getPlayer()); + safezone.setUnsafe(ServiceLocator.getEntityService().getPlayer()); ServiceLocator.getEntityService().getPlayer().getComponent(CombatStatsComponent.class).setImmunity(false); } + public boolean isWindowOpen() { + for (Actor actor : ServiceLocator.getRenderService().getStage().getActors()) { + if (actor instanceof Window && actor.isVisible()) { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/player/InventoryComponent.java b/source/core/src/main/com/csse3200/game/components/player/InventoryComponent.java index 7cbcf5e1d..9d9958867 100644 --- a/source/core/src/main/com/csse3200/game/components/player/InventoryComponent.java +++ b/source/core/src/main/com/csse3200/game/components/player/InventoryComponent.java @@ -3,7 +3,7 @@ import com.badlogic.gdx.utils.Timer; import com.csse3200.game.components.Component; import com.csse3200.game.components.Weapons.WeaponType; -import com.csse3200.game.components.upgradetree.UpgradeTree; +import com.csse3200.game.entities.configs.PlayerConfig; import com.csse3200.game.entities.configs.WeaponConfigs; import java.util.*; @@ -16,32 +16,68 @@ */ public class InventoryComponent extends Component { private String equipped = "melee"; - private final LinkedHashMap equippedWMap = new LinkedHashMap<>(); // preserves insert order + private LinkedHashMap slotTypeMap = new LinkedHashMap<>(); + private LinkedHashMap equippedWMap = new LinkedHashMap<>(); // preserves insert order private final WeaponConfigs config; private boolean reload; - public InventoryComponent(WeaponConfigs config) { - create(); + public InventoryComponent(WeaponConfigs config, PlayerConfig playerConfig) { + create(playerConfig); this.config = config; } - @Override - public void create() { - equippedWMap.put("melee", new InventoryItem(WeaponType.MELEE_WRENCH, 30, 30)); - equippedWMap.put("ranged", new InventoryItem(WeaponType.RANGED_BOOMERANG, 10, 10)); - equippedWMap.put("building", new InventoryItem(WeaponType.WOODHAMMER)); + public void create(PlayerConfig playerConfig) { + this.slotTypeMap = playerConfig.slotTypeMap; + this.equipped = playerConfig.equipped; + equippedWMap = convertSave(slotTypeMap); } + @Override public void update() { this.equippedWMap.get(getEquipped()).decCoolDown(); } + /** + * Converts the saved map into a map containing the item's slot, and assigned ammo. + * + * This was done as SavableComponent cannot take the non-static `InventoryItem` class + */ + public LinkedHashMap convertSave(LinkedHashMap input) { + LinkedHashMap temp = new LinkedHashMap<>(); + if (input == null) { + return temp; + } + for (var entry : input.entrySet()) { + if (entry.getKey().equals("melee")) { + temp.put(entry.getKey(), new InventoryItem(entry.getValue(), 30, 30)); + } else if (entry.getKey().equals("ranged")) { + temp.put(entry.getKey(), new InventoryItem(entry.getValue(), 10, 10)); + } else { + temp.put(entry.getKey(), new InventoryItem(entry.getValue())); + } + } + return temp; + } + + /** + * Returns a map containing the weapon's slot, and its type + * @return LinkedHashMap containing a slot's String and its WeaponType + */ + public LinkedHashMap getSlotTypeMap() { + return slotTypeMap; + } + + /** + * Gets the weapon configs + * @return WeaponConfigs - all weapon configs + */ public WeaponConfigs getConfigs() { return config; } /** - * @return int - the equipped weapon + * Gets the equipped weapon's assigned slot + * @return String - the equipped weapon's slot: melee, ranged, or building */ public String getEquipped() { return equipped; @@ -64,6 +100,7 @@ public void setEquipped(String slot) { */ public void replaceSlotWithWeapon(String slot, WeaponType weaponType) { equippedWMap.get(slot).changeItem(weaponType); + slotTypeMap.put(slot, weaponType); if (Objects.equals(slot, equipped)) { entity.getEvents().trigger("changeWeapon", weaponType); } @@ -73,14 +110,16 @@ public void replaceSlotWithWeapon(String slot, WeaponType weaponType) { * Returns the current equipped weapons represented in an array **/ public ArrayList getEquippedWeapons() { - return equippedWMap.values().stream().map(InventoryItem::getItem).collect(Collectors.toCollection(ArrayList::new)); + return equippedWMap.values().stream().map(InventoryItem::getItem) + .collect(Collectors.toCollection(ArrayList::new)); } /** * Returns a mapping of item and its respective slot + * * @return LinkedHashMap - a hash map containing the slot and item */ - public Map getEquippedWMap() { + public LinkedHashMap getEquippedWMap() { return equippedWMap; } @@ -110,7 +149,8 @@ public int getCurrentAmmo() { } /** - * Changes the amount of ammo in current weapon slot by change (decrease for negative values of ammoChange) + * Changes the amount of ammo in current weapon slot by change (decrease for + * negative values of ammoChange) * * @param ammoChange - amount to change ammo by */ @@ -175,11 +215,12 @@ public void run() { }; entity.getEvents().trigger("updateAmmo", getCurrentAmmo(), getCurrentMaxAmmo(), getCurrentAmmoUse()); - placeTimer.scheduleTask(placeEntity,2); + placeTimer.scheduleTask(placeEntity, 2); } /** * Return if the weapon is being reloaded + * * @return True if the current equipped weapon is being reloaded */ public boolean getReloading() { diff --git a/source/core/src/main/com/csse3200/game/components/player/InventoryDisplayComponent.java b/source/core/src/main/com/csse3200/game/components/player/InventoryDisplayComponent.java index b93ebad98..9a2a2f9cf 100644 --- a/source/core/src/main/com/csse3200/game/components/player/InventoryDisplayComponent.java +++ b/source/core/src/main/com/csse3200/game/components/player/InventoryDisplayComponent.java @@ -20,7 +20,6 @@ import com.csse3200.game.ui.UIComponent; import java.util.*; -import java.util.List; /** * Represents the display component for the player's inventory in the game. diff --git a/source/core/src/main/com/csse3200/game/components/player/KeyboardPlayerInputComponent.java b/source/core/src/main/com/csse3200/game/components/player/KeyboardPlayerInputComponent.java index a0d8dff30..da6a6d53e 100644 --- a/source/core/src/main/com/csse3200/game/components/player/KeyboardPlayerInputComponent.java +++ b/source/core/src/main/com/csse3200/game/components/player/KeyboardPlayerInputComponent.java @@ -15,16 +15,10 @@ import com.csse3200.game.input.InputComponent; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.utils.math.Vector2Utils; -import com.csse3200.game.windows.PauseWindow; - import java.util.HashMap; import java.util.Timer; -import static com.csse3200.game.components.mainmenu.MainMenuActions.game; - - /** - * d * Input handler for the player for keyboard and touch (mouse) input. * This input handler only uses keyboard input. */ @@ -42,9 +36,8 @@ public class KeyboardPlayerInputComponent extends InputComponent { private Entity player; private InventoryComponent playerInventory; private int testing = 0; - - static HashMap keyFlags = new HashMap<>(); - Vector2 lastMousePos = new Vector2(0, 0); + private static HashMap keyFlags = new HashMap<>(); + private Vector2 lastMousePos = new Vector2(0, 0); public KeyboardPlayerInputComponent() { super(5); @@ -109,11 +102,6 @@ public boolean keyDown(int keycode) { return false; } switch (keycode) { - case Keys.ESCAPE -> { - // Open the pause window when the Escape key is pressed - openPauseWindow(); - return true; - } case Keys.SPACE -> { if (!dodgeAvailable || walkDirection.epsilonEquals(Vector2.Zero)) { @@ -123,6 +111,12 @@ public boolean keyDown(int keycode) { dodge(); return true; } + case Keys.ESCAPE -> { + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("pause"); + } + return true; + } case Keys.F -> { InteractionControllerComponent interactionController = entity .getComponent(InteractionControllerComponent.class); @@ -223,13 +217,13 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) { if (playerInventory.getReloading() || cooldown > 0) { return false; } + InventoryComponent invComp = entity.getComponent(InventoryComponent.class); + WeaponType weapon = invComp.getEquippedType(); switch (playerInventory.getEquipped()) { // melee/ranged case "melee", "ranged": if (button == Input.Buttons.LEFT) { - InventoryComponent invComp = entity.getComponent(InventoryComponent.class); - WeaponType weapon = invComp.getEquippedType(); entity.getEvents().trigger("weaponAttack", weapon, clickPos); } break; @@ -240,6 +234,7 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) { } else if (button == Input.Buttons.RIGHT) { entity.getEvents().trigger("remove", screenX, screenY); } + entity.getEvents().trigger("weaponPlace", weapon, clickPos); break; default: @@ -392,11 +387,10 @@ public int triggerDodgeEvent() { entity.getEvents().trigger("walk", walkDirection); entity.getEvents().trigger("dodged"); - // play the sound when player starts dodging + // play the sound when player starts dodging entity.getEvents().trigger("playSound", "dodge"); } - java.util.TimerTask stopDodge = new java.util.TimerTask() { @Override public void run() { @@ -410,7 +404,6 @@ public void run() { return DODGE_DURATION; } - /** * Triggers inventory events */ @@ -422,12 +415,6 @@ private void triggerInventoryEvent(String slot) { entity.getEvents().trigger("updateAmmo", invComp.getCurrentAmmo(), invComp.getCurrentMaxAmmo(), invComp.getCurrentAmmoUse()); } - private void openPauseWindow() { - if (!isWindowOpen()) { - MainGameActions mainGameActions = new MainGameActions(entity,game); - entity.getEvents().trigger("pause"); - } - } /** * Responsible for dodge action @@ -462,7 +449,7 @@ private boolean isPressed(int keycode) { /** * Function to convert a mouse position to a game location * - * @param screenX x of mouse location + * @param screenX x of mouse location * @param screenY y of mouse location * @return game position of mouse location */ @@ -473,7 +460,8 @@ private Vector2 mouseToGamePos(int screenX, int screenY) { } /** - * returns a scaled vector the direction should be moving based on current key presses + * returns a scaled vector the direction should be moving based on current key + * presses * * @return direction play should move */ @@ -521,5 +509,4 @@ private enum Directions { DOWNLEFT, DOWNRIGHT } - } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/player/PlayerStatsDisplay.java b/source/core/src/main/com/csse3200/game/components/player/PlayerStatsDisplay.java index eb0ec741a..f66559224 100644 --- a/source/core/src/main/com/csse3200/game/components/player/PlayerStatsDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/player/PlayerStatsDisplay.java @@ -17,6 +17,7 @@ import com.csse3200.game.entities.configs.WeaponConfig; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.ui.UIComponent; + import java.util.Timer; import java.util.TimerTask; @@ -25,387 +26,396 @@ * An ui component for displaying player stats, e.g. health, dodge cool down and player lives */ public class PlayerStatsDisplay extends UIComponent { - private final String labelStyle; - private final int maxHealth; - private float healthBarWidth; - private float dodgeBarWidth; - private Label healthLabel; - private Label dodgeLabel; - private Image healthBarFill; - private Image dodgeBarFill; - private TextureRegionDrawable highHealth; - private TextureRegionDrawable medHealth; - private TextureRegionDrawable lowHealth; - private Label maxLivesLabel; - private TextureRegion hearts; - private Image livesBarFill; - private InventoryComponent inventory; - private Label ammoLabel; - private Table weaponImageTable; - - /** - * Constructor for the PlayerStatsDisplay - * @param config the player config file - */ - public PlayerStatsDisplay(PlayerConfig config) { - labelStyle = "large"; - maxHealth = config.maxHealth; - healthBarWidth = 320f; - dodgeBarWidth = 320f; - } - - /** - * Creates reusable ui styles and adds actors to the stage. - */ - @Override - public void create() { - super.create(); - addActors(); - - entity.getEvents().addListener("updateHealth", this::updatePlayerHealthUI); - entity.getEvents().addListener("dodged", this::updateDodgeUsed); - entity.getEvents().addListener("dodgeAvailable", this::updateDodgeRefreshed); - entity.getEvents().addListener("updateLives", this::updatePlayerLives); - entity.getEvents().addListener("maxLivesAlert", this::maxLivesReached); - entity.getEvents().addListener("updateAmmo", this::updateAmmo); - entity.getEvents().addListener("changeWeapon", this::updateWeapon); - - InventoryComponent invComp = entity.getComponent(InventoryComponent.class); - this.updateAmmo(invComp.getCurrentAmmo(),invComp.getCurrentMaxAmmo(), invComp.getCurrentAmmoUse()); - } - - /** - * Creates actors and positions them on the stage using a table. - * @see Table for positioning options - */ - private void addActors() { - // Create parent table to hold all elements - Table container = new Table(); - container.top().left(); - container.setFillParent(true); - container.padTop(20f).padLeft(190f); - - // Create table to hold the health bar and dodge bar - Table statsTable = new Table(); - statsTable.top().left(); - container.setFillParent(true); - - // Creating player HP and dodge labels - int health = entity.getComponent(CombatStatsComponent.class).getHealth(); - CharSequence healthText = String.format("%d", health); - healthLabel = new Label(healthText, skin, labelStyle); - dodgeLabel = new Label("Ready!", skin, labelStyle); - healthLabel.setFontScale(0.25f); - dodgeLabel.setFontScale(0.25f); - - // Creating HUD elements and placing them into appropriate tables - createHealthBar(statsTable); - statsTable.row(); - createDodgeBar(statsTable); - statsTable.row(); - Table innerTable = new Table(); - createLivesBar(innerTable); - createAmmoBar(innerTable); - statsTable.add(innerTable).left(); - - // Places completed tables - container.add(statsTable); - container.row(); - createUpgradeTreeButton(container); - stage.addActor(container); - } - - /** - * @param table - Used to add Column/Rows and define the actors - * createUpgradeTreeButton() - creating button and defining it on the top left - * also playing the sound when on tapping it - * - */ - public void createUpgradeTreeButton(Table table) { - TextButton button = new TextButton("Upgrade Tree", skin); - - button.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - - if (event instanceof ChangeEvent) { - KeyboardPlayerInputComponent keys = - ServiceLocator.getEntityService().getPlayer().getComponent(KeyboardPlayerInputComponent.class); - keys.clearWalking(); - UpgradeDisplay display = UpgradeDisplay.createUpgradeDisplay(); - ServiceLocator.getRenderService().getStage().addActor(display); - - entity.getEvents().trigger("playSound", "upgradeTree"); + private final String labelStyle; + private final int maxHealth; + private float healthBarWidth; + private float dodgeBarWidth; + private Label healthLabel; + private Label dodgeLabel; + private Image healthBarFill; + private Image dodgeBarFill; + private TextureRegionDrawable highHealth; + private TextureRegionDrawable medHealth; + private TextureRegionDrawable lowHealth; + private Label maxLivesLabel; + private TextureRegion hearts; + private Image livesBarFill; + private InventoryComponent inventory; + private Label ammoLabel; + private Table weaponImageTable; + + /** + * Constructor for the PlayerStatsDisplay + * + * @param config the player config file + */ + public PlayerStatsDisplay(PlayerConfig config) { + labelStyle = "small"; + maxHealth = config.maxHealth; + healthBarWidth = 320f; + dodgeBarWidth = 320f; + } + + /** + * Creates reusable ui styles and adds actors to the stage. + */ + @Override + public void create() { + super.create(); + addActors(); + + entity.getEvents().addListener("updateHealth", this::updatePlayerHealthUI); + entity.getEvents().addListener("dodged", this::updateDodgeUsed); + entity.getEvents().addListener("dodgeAvailable", this::updateDodgeRefreshed); + entity.getEvents().addListener("updateLives", this::updatePlayerLives); + entity.getEvents().addListener("maxLivesAlert", this::maxLivesReached); + entity.getEvents().addListener("updateAmmo", this::updateAmmo); + entity.getEvents().addListener("changeWeapon", this::updateWeapon); + + InventoryComponent invComp = entity.getComponent(InventoryComponent.class); + this.updateAmmo(invComp.getCurrentAmmo(), invComp.getCurrentMaxAmmo(), invComp.getCurrentAmmoUse()); + } + + /** + * Creates actors and positions them on the stage using a table. + * + * @see Table for positioning options + */ + private void addActors() { + // Create parent table to hold all elements + Table container = new Table(); + container.top().left(); + container.setFillParent(true); + container.padTop(20f).padLeft(190f); + + // Create table to hold the health bar and dodge bar + Table statsTable = new Table(); + statsTable.top().left(); + container.setFillParent(true); + + // Creating player HP and dodge labels + int health = entity.getComponent(CombatStatsComponent.class).getHealth(); + CharSequence healthText = String.format("%d", health); + healthLabel = new Label(healthText, skin, labelStyle); + dodgeLabel = new Label("Ready!", skin, labelStyle); + healthLabel.setFontScale(0.25f); + dodgeLabel.setFontScale(0.25f); + + // Creating HUD elements and placing them into appropriate tables + createHealthBar(statsTable); + statsTable.row(); + createDodgeBar(statsTable); + statsTable.row(); + Table innerTable = new Table(); + createLivesBar(innerTable); + createAmmoBar(innerTable); + statsTable.add(innerTable).left(); + + // Places completed tables + container.add(statsTable); + container.row(); + createUpgradeTreeButton(container); + stage.addActor(container); + } + + /** + * @param table - Used to add Column/Rows and define the actors + * createUpgradeTreeButton() - creating button and defining it on the top left + * also playing the sound when on tapping it + */ + public void createUpgradeTreeButton(Table table) { + TextButton button = new TextButton("Upgrade Tree", skin); + + button.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + + if (event instanceof ChangeEvent) { + KeyboardPlayerInputComponent keys = + ServiceLocator.getEntityService().getPlayer().getComponent(KeyboardPlayerInputComponent.class); + keys.clearWalking(); + UpgradeDisplay display = UpgradeDisplay.createUpgradeDisplay(); + ServiceLocator.getRenderService().getStage().addActor(display); + + entity.getEvents().trigger("playSound", "upgradeTree"); + } + } + }); + table.add(button).left(); + } + + /** + * Creates the heath bar for the player HUD + * + * @param parentTable the table which the health bar is contained within + */ + public void createHealthBar(Table parentTable) { + // Retrieve health bar assets + Image healthBarFrame; + healthBarFrame = new Image(ServiceLocator.getResourceService().getAsset("images/player/statbar.png", Texture.class)); + healthBarFill = new Image(ServiceLocator.getResourceService().getAsset("images/player/bar-fill.png", Texture.class)); + highHealth = new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill.png", Texture.class)); + medHealth = new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill4.png", Texture.class)); + lowHealth = new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill5.png", Texture.class)); + + // Creates table to hold and set width of health bar + Table healthBarTable = new Table(); + healthBarTable.add(healthBarFill).size(healthBarWidth - 40f, 30f).padRight(5).padTop(3); + + // Stacks the health bar fill on the frame + Stack healthStack = new Stack(); + healthStack.add(healthBarFrame); + healthStack.add(healthBarTable); + + parentTable.add(healthStack).size(healthBarWidth, 40f).pad(5); + parentTable.add(healthLabel).left(); + } + + /** + * Creates the dodge bar for the HUD + * + * @param parentTable the table which the dodge bar is contained within + */ + public void createDodgeBar(Table parentTable) { + // Retrieve dodge bar assets + Image dodgeBarFrame; + dodgeBarFrame = new Image(ServiceLocator.getResourceService().getAsset("images/player/statbar.png", Texture.class)); + dodgeBarFill = new Image(ServiceLocator.getResourceService().getAsset("images/player/bar-fill2.png", Texture.class)); + + // Creates table to hold and set width of dodge bar + Table dodgeBarTable = new Table(); + dodgeBarTable.add(dodgeBarFill).size((dodgeBarWidth - 40f), 30f).padRight(5).padTop(3); + + // Stacks the dodge bar fill on the frame + Stack dodgeStack = new Stack(); + dodgeStack.add(dodgeBarFrame); + dodgeStack.add(dodgeBarTable); + + parentTable.add(dodgeStack).size(dodgeBarWidth, 40f).pad(5).padTop(10); + parentTable.add(dodgeLabel).left(); + } + + /** + * Creates the player lives UI for the HUD + * + * @param parentTable the table which the player lives information is contained within + */ + public void createLivesBar(Table parentTable) { + // Retrieve lives bar asset and number of player lives + int playerLives = entity.getComponent(CombatStatsComponent.class).getLives(); + Image livesBarFrame; + livesBarFrame = new Image(ServiceLocator.getResourceService().getAsset("images/player/widestatbar.png", Texture.class)); + + // Set hearts texture width to the number of heaths * width of each heart + Texture heartsTexture = ServiceLocator.getResourceService().getAsset("images/player/hearts.png", Texture.class); + hearts = new TextureRegion(heartsTexture, + playerLives * 15, + 13); + livesBarFill = new Image(hearts); + + Table heartsTable = new Table(); + heartsTable.left().padTop(10).padLeft(17); + heartsTable.add(livesBarFill).size(playerLives * 30f, 26f); + + Table livesTable = new Table(); + livesTable.add(livesBarFrame).size(150f, 65f); + + // Stacks the hearts on the lives bar frame + Stack livesStack = new Stack(); + livesStack.add(livesTable); + livesStack.add(heartsTable); + parentTable.add(livesStack).left().padLeft(5).padRight(5); + } + + /** + * Creates the weapons ammo UI for the HUD + * + * @param parentTable the table which the ammo information is contained within + */ + public void createAmmoBar(Table parentTable) { + Entity player = ServiceLocator.getEntityService().getPlayer(); + inventory = player.getComponent(InventoryComponent.class); + + Image ammoBarFrame; + ammoBarFrame = new Image(ServiceLocator.getResourceService().getAsset("images/player/widestatbar.png", Texture.class)); + + // Retrieves current weapon and ammo + WeaponConfig config = inventory.getConfigs().GetWeaponConfig(inventory.getEquippedType()); + Image weaponImage = new Image(new Texture(config.imagePath)); + int currentAmmo = inventory.getCurrentAmmo(); + int maxAmmo = inventory.getCurrentMaxAmmo(); + CharSequence ammoText = String.format("%d / %d", currentAmmo, maxAmmo); + ammoLabel = new Label(ammoText, skin, labelStyle); + ammoLabel.setFontScale(0.21f); + + Table ammoFrameTable = new Table(); + ammoFrameTable.add(ammoBarFrame).size(150f, 65f); + + weaponImageTable = new Table(); + weaponImageTable.add(weaponImage).size(25f); + + Table ammoInfo = new Table(); + ammoInfo.add(weaponImageTable).left().pad(5).padTop(10); + ammoInfo.add(ammoLabel).size(80f).right().pad(5).padTop(10); + + // Stacks ammo information on the ammo bar frame + Stack ammoStack = new Stack(); + ammoStack.add(ammoFrameTable); + ammoStack.add(ammoInfo); + parentTable.add(ammoStack).left().padLeft(5).padRight(5); + } + + @Override + public void draw(SpriteBatch batch) { + // draw is handled by the stage + } + + /** + * Updates the player's health on the ui. + * + * @param health player health + */ + public void updatePlayerHealthUI(int health) { + // Update the health label + healthLabel.setText(health); + // Update the health bar width + healthBarWidth = 280f * health / maxHealth; + healthBarFill.setSize(healthBarWidth, 30f); + + float healthPercent = (float) health / maxHealth; + if (healthPercent > 0.4) { + healthBarFill.setDrawable(highHealth); + } else if (healthPercent > 0.2) { + healthBarFill.setDrawable(medHealth); + } else { + healthBarFill.setDrawable(lowHealth); } - } - }); - table.add(button).left(); - } - - /** - * Creates the heath bar for the player HUD - * @param parentTable the table which the health bar is contained within - */ - public void createHealthBar(Table parentTable) { - // Retrieve health bar assets - Image healthBarFrame; - healthBarFrame = new Image(ServiceLocator.getResourceService().getAsset("images/player/statbar.png", Texture.class)); - healthBarFill = new Image(ServiceLocator.getResourceService().getAsset("images/player/bar-fill.png", Texture.class)); - highHealth = new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill.png", Texture.class)); - medHealth = new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill4.png", Texture.class)); - lowHealth = new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill5.png", Texture.class)); - - // Creates table to hold and set width of health bar - Table healthBarTable = new Table(); - healthBarTable.add(healthBarFill).size(healthBarWidth - 40f, 30f).padRight(5).padTop(3); - - // Stacks the health bar fill on the frame - Stack healthStack = new Stack(); - healthStack.add(healthBarFrame); - healthStack.add(healthBarTable); - - parentTable.add(healthStack).size(healthBarWidth, 40f).pad(5); - parentTable.add(healthLabel).left(); - } - - /** - * Creates the dodge bar for the HUD - * @param parentTable the table which the dodge bar is contained within - */ - public void createDodgeBar(Table parentTable) { - // Retrieve dodge bar assets - Image dodgeBarFrame; - dodgeBarFrame = new Image(ServiceLocator.getResourceService().getAsset("images/player/statbar.png", Texture.class)); - dodgeBarFill = new Image(ServiceLocator.getResourceService().getAsset("images/player/bar-fill2.png", Texture.class)); - - // Creates table to hold and set width of dodge bar - Table dodgeBarTable = new Table(); - dodgeBarTable.add(dodgeBarFill).size((dodgeBarWidth - 40f), 30f).padRight(5).padTop(3); - - // Stacks the dodge bar fill on the frame - Stack dodgeStack = new Stack(); - dodgeStack.add(dodgeBarFrame); - dodgeStack.add(dodgeBarTable); - - parentTable.add(dodgeStack).size(dodgeBarWidth, 40f).pad(5).padTop(10); - parentTable.add(dodgeLabel).left(); - } - - /** - * Creates the player lives UI for the HUD - * @param parentTable the table which the player lives information is contained within - */ - public void createLivesBar(Table parentTable) { - // Retrieve lives bar asset and number of player lives - int playerLives = entity.getComponent(CombatStatsComponent.class).getLives(); - Image livesBarFrame; - livesBarFrame = new Image(ServiceLocator.getResourceService().getAsset("images/player/widestatbar.png", Texture.class)); - - // Set hearts texture width to the number of heaths * width of each heart - Texture heartsTexture = ServiceLocator.getResourceService().getAsset("images/player/hearts.png", Texture.class); - hearts = new TextureRegion(heartsTexture, - playerLives * 15, - 13); - livesBarFill = new Image(hearts); - - Table heartsTable = new Table(); - heartsTable.left().padTop(10).padLeft(17); - heartsTable.add(livesBarFill).size(playerLives * 30f, 26f); - - Table livesTable = new Table(); - livesTable.add(livesBarFrame).size(150f, 65f); - - // Stacks the hearts on the lives bar frame - Stack livesStack = new Stack(); - livesStack.add(livesTable); - livesStack.add(heartsTable); - parentTable.add(livesStack).left().padLeft(5).padRight(5); - } - - /** - * Creates the weapons ammo UI for the HUD - * @param parentTable the table which the ammo information is contained within - */ - public void createAmmoBar(Table parentTable) { - Entity player = ServiceLocator.getEntityService().getPlayer(); - inventory = player.getComponent(InventoryComponent.class); - - Image ammoBarFrame; - ammoBarFrame = new Image(ServiceLocator.getResourceService().getAsset("images/player/widestatbar.png", Texture.class)); - - // Retrieves current weapon and ammo - WeaponConfig config = inventory.getConfigs().GetWeaponConfig(inventory.getEquippedType()); - Image weaponImage = new Image( new Texture(config.imagePath)); - int currentAmmo = inventory.getCurrentAmmo(); - int maxAmmo = inventory.getCurrentMaxAmmo(); - CharSequence ammoText = String.format("%d / %d", currentAmmo, maxAmmo); - ammoLabel = new Label(ammoText, skin, labelStyle); - ammoLabel.setFontScale(0.21f); - - Table ammoFrameTable = new Table(); - ammoFrameTable.add(ammoBarFrame).size(150f, 65f); - - weaponImageTable = new Table(); - weaponImageTable.add(weaponImage).size(25f); - - Table ammoInfo = new Table(); - ammoInfo.add(weaponImageTable).left().pad(5).padTop(10); - ammoInfo.add(ammoLabel).size(80f).right().pad(5).padTop(10); - - // Stacks ammo information on the ammo bar frame - Stack ammoStack = new Stack(); - ammoStack.add(ammoFrameTable); - ammoStack.add(ammoInfo); - parentTable.add(ammoStack).left().padLeft(5).padRight(5); - } - - @Override - public void draw(SpriteBatch batch) { - // draw is handled by the stage - } - - /** - * Updates the player's health on the ui. - * @param health player health - */ - public void updatePlayerHealthUI(int health) { - // Update the health label - healthLabel.setText(health); - // Update the health bar width - healthBarWidth = 280f * health / maxHealth; - healthBarFill.setSize(healthBarWidth, 30f); - - float healthPercent = (float) health/maxHealth; - if (healthPercent > 0.4) { - healthBarFill.setDrawable(highHealth); - } else if (healthPercent > 0.2) { - healthBarFill.setDrawable(medHealth); - } else { - healthBarFill.setDrawable(lowHealth); } - } - - /** - * Updates the visible avaliability of the dodge movement when used by the player - */ - public void updateDodgeUsed() { - // Update the dodge label - CharSequence dodgeText = ""; - dodgeLabel.setText(dodgeText); - - // Update the dodge bar width - dodgeBarFill.setSize(0, 30f); - - // Update dodge bar colour - dodgeBarFill.setDrawable(new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill3.png", Texture.class))); - - // Create refill animation - dodgeBarFill.addAction( - Actions.sequence( - Actions.parallel( - Actions.sizeTo(dodgeBarWidth - 40f, dodgeBarFill.getHeight(), 0.7f, Interpolation.linear) - ) - ) - ); - } - - /** - * Updates the visible avaliability of the dodge when it becomes available - */ - public void updateDodgeRefreshed() { - // Update dodge label - CharSequence dodgeText = "Ready!"; - dodgeLabel.setText(dodgeText); - - // Update dodge bar colour - dodgeBarFill.setDrawable(new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill2.png", Texture.class))); - - // Update dodge bar width - dodgeBarFill.setSize(dodgeBarWidth - 40f, 30f); - } - - /** - * Updates the number of lives displayed in the player HUD - * @param lives the number that is being updated to - */ - public void updatePlayerLives(int lives) { - hearts.setRegionWidth(lives * 15); // Changes the heart texture - livesBarFill.setWidth(lives * 30f); // Updates the width of the heart image - } - - /** - * Updates the current and max ammo displaying in the player HUD - * @param currentAmmo the current ammo of the weapon equipped - * @param maxAmmo the max ammo of the weapon equipped - */ - public void updateAmmo(int currentAmmo, int maxAmmo, int ammoUse) { - CharSequence ammoText = String.format("%d / %d", currentAmmo, maxAmmo); - - if (currentAmmo == 0) { - ammoText = "PRESS Q"; - } else if (inventory.getReloading()) { - ammoText = " RLD "; - } else if (ammoUse == 0) { - ammoText = " -"; + + /** + * Updates the visible avaliability of the dodge movement when used by the player + */ + public void updateDodgeUsed() { + // Update the dodge label + CharSequence dodgeText = ""; + dodgeLabel.setText(dodgeText); + + // Update the dodge bar width + dodgeBarFill.setSize(0, 30f); + + // Update dodge bar colour + dodgeBarFill.setDrawable(new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill3.png", Texture.class))); + + // Create refill animation + dodgeBarFill.addAction( + Actions.sequence( + Actions.parallel( + Actions.sizeTo(dodgeBarWidth - 40f, dodgeBarFill.getHeight(), 0.7f, Interpolation.linear) + ) + ) + ); + } + + /** + * Updates the visible avaliability of the dodge when it becomes available + */ + public void updateDodgeRefreshed() { + // Update dodge label + CharSequence dodgeText = "Ready!"; + dodgeLabel.setText(dodgeText); + + // Update dodge bar colour + dodgeBarFill.setDrawable(new TextureRegionDrawable(ServiceLocator.getResourceService().getAsset("images/player/bar-fill2.png", Texture.class))); + + // Update dodge bar width + dodgeBarFill.setSize(dodgeBarWidth - 40f, 30f); + } + + /** + * Updates the number of lives displayed in the player HUD + * + * @param lives the number that is being updated to + */ + public void updatePlayerLives(int lives) { + hearts.setRegionWidth(lives * 15); // Changes the heart texture + livesBarFill.setWidth(lives * 30f); // Updates the width of the heart image + } + + /** + * Updates the current and max ammo displaying in the player HUD + * + * @param currentAmmo the current ammo of the weapon equipped + * @param maxAmmo the max ammo of the weapon equipped + */ + public void updateAmmo(int currentAmmo, int maxAmmo, int ammoUse) { + CharSequence ammoText = String.format("%d / %d", currentAmmo, maxAmmo); + + if (inventory.getReloading()) { + ammoText = " RLD "; + } else if (ammoUse == 0) { + ammoText = " -"; + } else if (currentAmmo - ammoUse < 0) { + ammoText = "PRESS Q"; + } + ammoLabel.setText(ammoText); + } + + /** + * Updates the weapon equipped in the player HUD + * + * @param weapon the new weapon + */ + public void updateWeapon(WeaponType weapon) { + // Changes the weapon image in the ammo bar + WeaponConfig config = inventory.getConfigs().GetWeaponConfig(weapon); + Image weaponImage = new Image(new Texture(config.imagePath)); + weaponImageTable.clear(); + weaponImageTable.add(weaponImage).size(30f); + // Updates ammo levels + updateAmmo(inventory.getCurrentAmmo(), inventory.getCurrentMaxAmmo(), inventory.getCurrentAmmoUse()); + } + + /** + * Alert for when maximum number of lives (3) has been reached. Is placed in the left corner below + * number of lives player stats. + */ + private void maxLivesAlert() { + Table maxLivesAlert; + maxLivesAlert = new Table(); + maxLivesAlert.top().left(); + maxLivesAlert.setFillParent(true); + maxLivesLabel = new Label("Max Player Lives Reached", skin, labelStyle); + + maxLivesAlert.add(maxLivesLabel).padTop(250).padLeft(5f); + //launch the table onto the screen + stage.addActor(maxLivesAlert); + } + + /** + * Creates an alert for if the maximum number of lives (3) has been reached. + * Used when player picks up Powerup ('Plus one life'). + */ + public void maxLivesReached() { + maxLivesAlert(); // indicates to player that max number of lives has been reached + final Timer timer = new Timer(); + TimerTask removeAlert = new TimerTask() { + @Override + public void run() { + maxLivesLabel.remove(); + timer.cancel(); + timer.purge(); + } + }; + timer.schedule(removeAlert, 3000); // removes alert after 1 second + } + + @Override + public void dispose() { + super.dispose(); + healthLabel.remove(); + dodgeLabel.remove(); + healthBarFill.remove(); + dodgeBarFill.remove(); + livesBarFill.remove(); } - ammoLabel.setText(ammoText); - } - - /** - * Updates the weapon equipped in the player HUD - * @param weapon the new weapon - */ - public void updateWeapon(WeaponType weapon) { - // Changes the weapon image in the ammo bar - WeaponConfig config = inventory.getConfigs().GetWeaponConfig(weapon); - Image weaponImage = new Image( new Texture(config.imagePath)); - weaponImageTable.clear(); - weaponImageTable.add(weaponImage).size(30f); - // Updates ammo levels - updateAmmo(inventory.getCurrentAmmo(), inventory.getCurrentMaxAmmo(), inventory.getCurrentAmmoUse()); - } - - /** - * Alert for when maximum number of lives (3) has been reached. Is placed in the left corner below - * number of lives player stats. - */ - private void maxLivesAlert() { - Table maxLivesAlert; - maxLivesAlert = new Table(); - maxLivesAlert.top().left(); - maxLivesAlert.setFillParent(true); - maxLivesLabel = new Label("Max Player Lives Reached", skin, labelStyle); - - maxLivesAlert.add(maxLivesLabel).padTop(250).padLeft(5f); - //launch the table onto the screen - stage.addActor(maxLivesAlert); - } - - /** - * Creates an alert for if the maximum number of lives (3) has been reached. - * Used when player picks up Powerup ('Plus one life'). - */ - public void maxLivesReached() { - maxLivesAlert(); // indicates to player that max number of lives has been reached - final Timer timer = new Timer(); - TimerTask removeAlert = new TimerTask() { - @Override - public void run() { - maxLivesLabel.remove(); - timer.cancel(); - timer.purge(); - } - }; - timer.schedule(removeAlert, 3000); // removes alert after 1 second - } - - @Override - public void dispose() { - super.dispose(); - healthLabel.remove(); - dodgeLabel.remove(); - healthBarFill.remove(); - dodgeBarFill.remove(); - livesBarFill.remove(); - } } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/player/WeaponComponent.java b/source/core/src/main/com/csse3200/game/components/player/WeaponComponent.java index d5bd5b26b..1f844063c 100644 --- a/source/core/src/main/com/csse3200/game/components/player/WeaponComponent.java +++ b/source/core/src/main/com/csse3200/game/components/player/WeaponComponent.java @@ -1,11 +1,9 @@ package com.csse3200.game.components.player; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; import com.csse3200.game.components.Component; import com.csse3200.game.components.Weapons.WeaponType; import com.csse3200.game.entities.Entity; -import com.csse3200.game.entities.configs.WeaponConfig; import com.csse3200.game.entities.factories.AttackFactory; import com.csse3200.game.entities.factories.PlayerWeaponFactory; import com.csse3200.game.services.ServiceLocator; @@ -28,6 +26,7 @@ public class WeaponComponent extends Component { @Override public void create() { entity.getEvents().addListener("weaponAttack", this::playerAttacking); + entity.getEvents().addListener("weaponPlace", this::playerPlacing); entity.getEvents().addListener("changeWeapon", this::updateHolding); this.holdingWeapon = null; this.updateHolding(WeaponType.MELEE_KATANA); @@ -58,13 +57,20 @@ private void playerAttacking(WeaponType weaponType, Vector2 clickPosition) { invComp.getCurrentMaxAmmo(), invComp.getCurrentAmmoUse()); } - private void updateHolding(WeaponType weaponType) { - InventoryComponent invComp = entity.getComponent(InventoryComponent.class); - WeaponConfig config = invComp.getConfigs().GetWeaponConfig(weaponType); + /** + * Core function to respond to weapon attacks takes a position and a rotation and spawn an entity + * in that direction and begin the animation of the weapon + * + * @param weaponType - click position + * @param clickPosition - click location of mouse + */ + private void playerPlacing(WeaponType weaponType, Vector2 clickPosition) { + float attackDirection = calcRotationAngleInDegrees(entity.getCenterPosition(), clickPosition); + makeNewHolding(weaponType, attackDirection); + } - if (config.slotType.equals("building")) { - makeNewHolding(weaponType, 0); - } else if (this.holdingWeapon != null && !this.holdingWeapon.getDisposed()) { + private void updateHolding(WeaponType weaponType) { + if (this.holdingWeapon != null && !this.holdingWeapon.getDisposed()) { this.holdingWeapon.dispose(); } } diff --git a/source/core/src/main/com/csse3200/game/components/upgradetree/UpgradeDisplay.java b/source/core/src/main/com/csse3200/game/components/upgradetree/UpgradeDisplay.java index 8d8969ed4..38cf38671 100644 --- a/source/core/src/main/com/csse3200/game/components/upgradetree/UpgradeDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/upgradetree/UpgradeDisplay.java @@ -19,6 +19,7 @@ import com.badlogic.gdx.utils.ObjectMap; import com.badlogic.gdx.utils.Timer; import com.csse3200.game.components.Weapons.WeaponType; +import com.csse3200.game.components.maingame.MainGameActions; import com.csse3200.game.components.player.InventoryComponent; import com.csse3200.game.components.structures.StructureToolPicker; import com.csse3200.game.components.structures.ToolConfig; @@ -66,6 +67,9 @@ public static UpgradeDisplay createUpgradeDisplay() { Texture background = ServiceLocator.getResourceService().getAsset("images/upgradetree/background.png", Texture.class); background.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("pauseGame"); + } return new UpgradeDisplay(background); } @@ -179,12 +183,12 @@ private void buildTrees() { buildRoot = new UpgradeNode(woodhammerConfig); buildRoot.addChild(dirtNode); - buildRoot.addChild(landmineNode); + buildRoot.addChild(turretNode); dirtNode.addChild(gateNode); gateNode.addChild(stoneNode); turretNode.addChild(advancedTurretNode); + turretNode.addChild(landmineNode); landmineNode.addChild(barrelNode); - landmineNode.addChild(turretNode); trees.add(buildRoot); } @@ -524,6 +528,7 @@ private void createWeaponTooltip(Table table, UpgradeNode node) { } createTooltipLabel(table, "Cooldown", String.valueOf(config.attackCooldown)); createTooltipLabel(table, "Cost", String.valueOf(node.getNodeCost())); + createTooltipLabel(table, "Ammo", String.valueOf(config.ammoUse)); } } @@ -717,6 +722,9 @@ private void exitUpgradeTree(UpgradeTree stats) { public boolean remove() { //Stop overriding input when exiting ServiceLocator.getInputService().unregister(inputOverrideComponent); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("resumeGame"); + } return super.remove(); } diff --git a/source/core/src/main/com/csse3200/game/components/upgradetree/UpgradeNode.java b/source/core/src/main/com/csse3200/game/components/upgradetree/UpgradeNode.java index 88dc24631..bf494525d 100644 --- a/source/core/src/main/com/csse3200/game/components/upgradetree/UpgradeNode.java +++ b/source/core/src/main/com/csse3200/game/components/upgradetree/UpgradeNode.java @@ -187,4 +187,4 @@ public int getNodeCost() { WeaponConfig weaponConfig = (WeaponConfig) getConfig(); return (int) (BASE_COST * (this.getDepth() + 1) + weaponConfig.damage * 3); } -} +} \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/entities/configs/PlayerConfig.java b/source/core/src/main/com/csse3200/game/entities/configs/PlayerConfig.java index 9994b202a..50cf93ca6 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/PlayerConfig.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/PlayerConfig.java @@ -1,8 +1,10 @@ package com.csse3200.game.entities.configs; +import com.csse3200.game.components.Weapons.WeaponType; import com.csse3200.game.files.FileLoader; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Objects; @@ -14,11 +16,20 @@ public class PlayerConfig extends HealthEntityConfig { public int lives; public SoundsConfig sounds; public List unlocks; + public LinkedHashMap slotTypeMap; + public String equipped; public PlayerConfig() { this.spritePath = "images/player.atlas"; this.sounds = FileLoader.readClass(SoundsConfig.class, "configs/player_sounds.json"); unlocks = new ArrayList<>(); + + // Default unlocks + slotTypeMap = new LinkedHashMap<>(); + slotTypeMap.put("melee", WeaponType.MELEE_WRENCH); + slotTypeMap.put("ranged", WeaponType.RANGED_BOOMERANG); + slotTypeMap.put("building", WeaponType.WOODHAMMER); + equipped = "melee"; } @Override diff --git a/source/core/src/main/com/csse3200/game/entities/factories/AttackFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/AttackFactory.java index 9beba1b1e..dbe31e909 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/AttackFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/AttackFactory.java @@ -35,8 +35,6 @@ public class AttackFactory { private static final WeaponConfigs configs = FileLoader.readClass(WeaponConfigs.class, "configs/weapons.json"); - //TODO: REMOVE - LEGACY - /** * function to generate multiple attacks in a sequence attack * @param weaponType diff --git a/source/core/src/main/com/csse3200/game/entities/factories/CompanionAttackFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/CompanionAttackFactory.java index 86e950b78..619bf02d9 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/CompanionAttackFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/CompanionAttackFactory.java @@ -18,11 +18,11 @@ public class CompanionAttackFactory { private static final CompanionWeaponConfigs configs = new CompanionWeaponConfigs(); - public static Entity createAttack(CompanionWeaponType weaponType, float initRot, Entity Companion) { + public static Entity createAttack(CompanionWeaponType weaponType, float initRot, Entity companion) { CompanionWeaponConfig config = configs.GetWeaponConfig(weaponType); - CompanionInventoryComponent CompanionInventory = ServiceLocator.getEntityService().getCompanion().getComponent(CompanionInventoryComponent.class); - CompanionInventory.setEquippedCooldown(config.attackCooldown); - CompanionInventory.changeEquippedAmmo(-config.ammoUse); + CompanionInventoryComponent companionInventory = ServiceLocator.getEntityService().getCompanion().getComponent(CompanionInventoryComponent.class); + companionInventory.setEquippedCooldown(config.attackCooldown); + companionInventory.changeEquippedAmmo(-config.ammoUse); int direction = 1; switch (weaponType) { @@ -62,7 +62,7 @@ public static Entity createAttack(CompanionWeaponType weaponType, float initRot, // Set up the PowerUpController attack.addComponent(powerUpController); - attack.addComponent(new CompanionWeaponTargetComponent(weaponType, Companion)); + attack.addComponent(new CompanionWeaponTargetComponent(weaponType, companion)); return attack; } diff --git a/source/core/src/main/com/csse3200/game/entities/factories/CompanionFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/CompanionFactory.java index 7ed0fe9de..4fcbd7108 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/CompanionFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/CompanionFactory.java @@ -12,7 +12,6 @@ import com.csse3200.game.components.companion.CompanionWeaponComponent; import com.csse3200.game.components.companion.*; import com.csse3200.game.components.FollowComponent; -import com.csse3200.game.components.HealthBarComponent; import com.csse3200.game.components.SaveableComponent; import com.csse3200.game.components.player.InteractionControllerComponent; import com.csse3200.game.entities.Entity; diff --git a/source/core/src/main/com/csse3200/game/entities/factories/EnemyFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/EnemyFactory.java index ca07d50a3..be7dc3a50 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/EnemyFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/EnemyFactory.java @@ -19,7 +19,6 @@ import com.csse3200.game.entities.enemies.EnemyType; import com.csse3200.game.files.FileLoader; import com.csse3200.game.physics.PhysicsLayer; -import com.csse3200.game.physics.PhysicsUtils; import com.csse3200.game.physics.components.ColliderComponent; import com.csse3200.game.physics.components.HitboxComponent; import com.csse3200.game.physics.components.PhysicsComponent; @@ -48,7 +47,7 @@ public class EnemyFactory { public static DialogueBox dialogueBox; // Condition to see if a target is alive or not private static boolean isAlive; - public static List enemiesList = new ArrayList<>(); + protected static List enemiesList = new ArrayList<>(); /** * Creates an enemy - using the default config as defined by the type and behaviour * @param name - the name of the enemy diff --git a/source/core/src/main/com/csse3200/game/entities/factories/ExplosivesFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/ExplosivesFactory.java index 75d80743c..94b863570 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/ExplosivesFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/ExplosivesFactory.java @@ -4,10 +4,7 @@ import com.badlogic.gdx.physics.box2d.BodyDef; import com.csse3200.game.components.*; import com.csse3200.game.components.explosives.ExplosiveComponent; -import com.csse3200.game.components.explosives.ExplosiveConfig; import com.csse3200.game.components.flags.EnemyFlag; -import com.csse3200.game.components.structures.JoinLayer; -import com.csse3200.game.components.structures.JoinableComponent; import com.csse3200.game.components.structures.StructureDestroyComponent; import com.csse3200.game.entities.PlaceableEntity; import com.csse3200.game.entities.configs.ExplosiveBarrelConfig; @@ -75,7 +72,7 @@ public static PlaceableEntity createLandmine(LandmineConfig config) { .addComponent(new SaveableComponent<>(landmine -> { config.position = landmine.getGridPosition(); return config; - }, LandmineConfig.class));; + }, LandmineConfig.class)); newLandmine.setScale(0.5f,(float) texture.getHeight() / texture.getWidth() * 0.5f); diff --git a/source/core/src/main/com/csse3200/game/entities/factories/LaboratoryFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/LaboratoryFactory.java index 0e360a499..5f036df6d 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/LaboratoryFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/LaboratoryFactory.java @@ -53,7 +53,7 @@ public static Entity createLaboratory() { // Check if the laboratory is dead if (healthStats.isDead()) { - LabWindow labWindow = LabWindow.MakeNewLaboratory(); + LabWindow labWindow = LabWindow.makeNewLaboratory(); ServiceLocator.getRenderService().getStage().addActor(labWindow); } }, 5f)); diff --git a/source/core/src/main/com/csse3200/game/entities/factories/MinigameObjectFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/MinigameObjectFactory.java index f41e73286..590fe383f 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/MinigameObjectFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/MinigameObjectFactory.java @@ -2,15 +2,10 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; -import com.csse3200.game.areas.terrain.TerrainComponent; import com.csse3200.game.entities.Entity; -import com.csse3200.game.entities.PlaceableEntity; -import com.csse3200.game.entities.buildables.Turret; -import com.csse3200.game.entities.buildables.TurretType; import com.csse3200.game.entities.configs.*; import com.csse3200.game.files.FileLoader; import com.csse3200.game.physics.PhysicsLayer; -import com.csse3200.game.physics.PhysicsUtils; import com.csse3200.game.physics.components.ColliderComponent; import com.csse3200.game.physics.components.PhysicsComponent; import com.csse3200.game.components.ships.SpaceCollideDamageComponent; diff --git a/source/core/src/main/com/csse3200/game/entities/factories/MinigameShipFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/MinigameShipFactory.java index 5b93e1627..35287cd37 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/MinigameShipFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/MinigameShipFactory.java @@ -68,7 +68,6 @@ public static Entity createMinigameShip() { PhysicsUtils.setScaledCollider(ship, 0.6f, 0.3f); ship.getComponent(ColliderComponent.class).setDensity(1.5f); ship.getComponent(ShipStatDisplay.class).setShipActions(ship.getComponent(ShipActions.class)); - //ship.getComponent(TextureRenderComponent.class).scaleEntity(); //Edited by Foref, changes physics to reflect space environment //With fixed rotation off, ship will spin without additional customization of shipactions diff --git a/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java index 90ad64667..a20654de2 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java @@ -9,6 +9,7 @@ import com.csse3200.game.components.FollowComponent; import com.csse3200.game.components.InteractableComponent; import com.csse3200.game.components.TouchAttackComponent; +import com.csse3200.game.components.maingame.MainGameActions; import com.csse3200.game.components.npc.*; import com.csse3200.game.components.player.InteractionControllerComponent; import com.csse3200.game.components.tasks.ChaseTask; @@ -114,7 +115,7 @@ public static Entity createAstro(AstroConfig astroConfig) { animator.addAnimation("Astro_UpRight", 0.2f, Animation.PlayMode.LOOP); animator.addAnimation("Astro_StandDown", 0.2f); - Entity Astro = + Entity astro = new Entity() .addComponent(animator) .addComponent(new AstroAnimationController()) @@ -124,26 +125,22 @@ public static Entity createAstro(AstroConfig astroConfig) { .addComponent(new InteractionControllerComponent(true)) .addComponent(new PhysicsMovementComponent()) .addComponent(new FollowComponent(ServiceLocator.getEntityService().getPlayer(),0f)); -// .addComponent(aiComponent); - Astro.addComponent(new SaveableComponent<>(p -> { + astro.addComponent(new SaveableComponent<>(p -> { astroConfig.position = p.getGridPosition(); return astroConfig; }, AstroConfig.class)); - Astro.getComponent(ColliderComponent.class).setDensity(1.5f); - Astro.addComponent(new InteractableComponent(entity -> { - Astro.getComponent(FollowComponent.class).setEntity(Astro); - Astro.getComponent(FollowComponent.class).setFollowSpeed(2f); + astro.getComponent(ColliderComponent.class).setDensity(1.5f); + astro.addComponent(new InteractableComponent(entity -> { + astro.getComponent(FollowComponent.class).setEntity(astro); + astro.getComponent(FollowComponent.class).setFollowSpeed(2f); },3f)); animator.startAnimation("Astro_StandDown"); - return Astro; + return astro; } public static Entity createTutnpc(TutnpcConfig tutnpcConfig) { -// AITaskComponent aiComponent = new AITaskComponent(); -// aiComponent.addTask(new WanderTask(new Vector2(1.5f, 1.5f), 1f)); - AnimationRenderComponent animator = new AnimationRenderComponent( ServiceLocator.getResourceService().getAsset(tutnpcConfig.spritePath, TextureAtlas.class)); @@ -158,7 +155,7 @@ public static Entity createTutnpc(TutnpcConfig tutnpcConfig) { animator.addAnimation("Tut_StandDown", 0.2f); - Entity Tutnpc = + Entity tutnpc = new Entity() .addComponent(animator) .addComponent(new TutnpcAnimationController()) @@ -167,18 +164,16 @@ public static Entity createTutnpc(TutnpcConfig tutnpcConfig) { .addComponent(new PhysicsComponent()) .addComponent(new InteractionControllerComponent(true)) .addComponent(new PhysicsMovementComponent()); -// .addComponent(aiComponent); - Tutnpc.getComponent(ColliderComponent.class).setDensity(1.5f); - Tutnpc.scaleHeight(0.7f); + tutnpc.getComponent(ColliderComponent.class).setDensity(1.5f); + tutnpc.scaleHeight(0.7f); String[] storytext = {"I am your Tutorial Guide", "I am here to teach you how to play!"}; String[] titletext = {"", ""}; - Tutnpc.addComponent(new InteractableComponent(entity -> { - - Tutnpc.getComponent(DialogComponent.class).showdialogue(storytext, titletext); + tutnpc.addComponent(new InteractableComponent(entity -> { + tutnpc.getComponent(DialogComponent.class).showdialogue(storytext, titletext); }, 3f)); animator.startAnimation("Tut_StandDown"); - return Tutnpc; + return tutnpc; } public static Entity createHellman(HellmanConfig hellmanConfig) { @@ -269,7 +264,12 @@ public static Entity createAstronaut(AstronautConfig astronautConfig) { String[] storytext= {"Hello, I've been stuck here for weeks","Can I please come with you?"}; String[] titletext= {"",""}; astronaut.getComponent(DialogComponent.class).showdialogue(storytext,titletext); - },10f)); + // Since Dialogue Box does not show up on screen, cannot 'exit' dialogue box therefore + // the 'resumeGame' function is never called. This code is to ensure gameplay can continue + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("resumeGame"); + } + },1f)); astronaut.scaleHeight(1f); return astronaut; @@ -282,31 +282,31 @@ public static Entity createJail(JailConfig jailConfig) { animator.addAnimation("jail_close", 0.2f, Animation.PlayMode.LOOP); animator.addAnimation("jail_open", 0.2f, Animation.PlayMode.LOOP); - Entity Jail = + Entity jail = new Entity() .addComponent(animator) .addComponent(new PhysicsComponent()) .addComponent(new DialogComponent(dialogueBox)) .addComponent(new PhysicsMovementComponent()); - Jail.addComponent(new SaveableComponent<>(p -> { + jail.addComponent(new SaveableComponent<>(p -> { jailConfig.position = p.getGridPosition(); return jailConfig; }, JailConfig.class)); - Jail.addComponent(new InteractableComponent(entity -> { + jail.addComponent(new InteractableComponent(entity -> { animator.startAnimation("jail_open"); String[] storytext= {"{COLOR=BLACK}NPC: (Desperate) Hey, you there!\n Please, help me! I've been stuck in\nhere for days!" ,"{COLOR=BLACK}\n{SLOW}NPC: (Relieved) Thank you so much!\nThere's a spaceship not far from here\nthat can get us off this planet. But\nbe warned, it's guarded by infected." ,"{COLOR=BLACK}{SLOW}Emily: We can handle it. \nLead the way!"}; String[] titletext= {"","",""}; - Jail.getComponent(DialogComponent.class).showdialogue(storytext, titletext); + jail.getComponent(DialogComponent.class).showdialogue(storytext, titletext); },1f)); - Jail.scaleHeight(1.7f); + jail.scaleHeight(1.7f); animator.startAnimation("jail_close"); - return Jail; + return jail; } /** @@ -340,6 +340,4 @@ private static Entity createBaseNPC(Entity target) { public NPCFactory() { throw new IllegalStateException("Instantiating static util class"); } - - } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/entities/factories/ObstacleFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/ObstacleFactory.java index 927b34223..16d01b2a0 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/ObstacleFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/ObstacleFactory.java @@ -5,9 +5,6 @@ import com.csse3200.game.areas.terrain.TerrainComponent; import com.csse3200.game.components.SaveableComponent; import com.csse3200.game.entities.Entity; -import com.csse3200.game.entities.PlaceableEntity; -import com.csse3200.game.entities.buildables.Turret; -import com.csse3200.game.entities.buildables.TurretType; import com.csse3200.game.entities.configs.*; import com.csse3200.game.files.FileLoader; import com.csse3200.game.physics.PhysicsLayer; @@ -25,7 +22,7 @@ public class ObstacleFactory { - public static float WALL_SIZE = 0.1f; + public static float wallSize = 0.1f; private static final WallConfigs configs = FileLoader.readClass(WallConfigs.class, "configs/walls.json"); @@ -63,7 +60,6 @@ public static Entity createTree(BaseEntityConfig config) { return tree; } - //TODO: REMOVE - LEGACY /** * Creates a tree entity. * @return entity @@ -162,7 +158,6 @@ public static Entity createAsteroid(AsteroidConfig config) { return asteroid; } - //TODO: REMOVE - LEGACY /** * Creates an Asteroid that has bounce * @param width Asteroid width in world units diff --git a/source/core/src/main/com/csse3200/game/entities/factories/PlatformFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/PlatformFactory.java index e549222b7..aa274f32c 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/PlatformFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/PlatformFactory.java @@ -8,15 +8,15 @@ public class PlatformFactory { public static Entity createPlatform(){ - Entity Platform = new Entity() + Entity platform = new Entity() .addComponent(new TextureRenderComponent("images/platform.png")) .addComponent(new PhysicsComponent()); - Body platformBody = Platform.getComponent(PhysicsComponent.class).getBody(); + Body platformBody = platform.getComponent(PhysicsComponent.class).getBody(); platformBody.setType(BodyDef.BodyType.StaticBody); // Make the platform static platformBody.setFixedRotation(true); // Prevent platform from rotating - platformBody.setUserData(Platform); - Platform.getComponent(TextureRenderComponent.class).scaleEntity(); - Platform.setScale(2f,0.6f); - return Platform; + platformBody.setUserData(platform); + platform.getComponent(TextureRenderComponent.class).scaleEntity(); + platform.setScale(2f,0.6f); + return platform; } } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/entities/factories/PlayerFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/PlayerFactory.java index c716f1845..cdcce0d37 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/PlayerFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/PlayerFactory.java @@ -38,8 +38,6 @@ public class PlayerFactory { private static final WeaponConfigs weaponConfigs = FileLoader.readClass(WeaponConfigs.class, "configs/weapons.json"); - //TODO: REMOVE - LEGACY - /** * Create a player entity. * @@ -92,7 +90,7 @@ public static Entity createPlayer(PlayerConfig config) { .addComponent(new CombatStatsComponent(config.maxHealth, config.maxHealth, config.baseAttack, config.attackMultiplier, config.isImmune, config.lives)) .addComponent(new EnvironmentStatsComponent()) - .addComponent(new InventoryComponent(weaponConfigs)) + .addComponent(new InventoryComponent(weaponConfigs, config)) .addComponent(inputComponent) .addComponent(new PlayerStatsDisplay(config)) .addComponent(animator) @@ -112,7 +110,10 @@ public static Entity createPlayer(PlayerConfig config) { playerConfig.health = p.getComponent(CombatStatsComponent.class).getHealth(); playerConfig.maxHealth = p.getComponent(CombatStatsComponent.class).getMaxHealth(); playerConfig.unlocks = p.getComponent(UpgradeTree.class).getUnlockedWeaponsConfigs(); - return playerConfig; + playerConfig.slotTypeMap = p.getComponent(InventoryComponent.class).getSlotTypeMap(); + playerConfig.equipped = p.getComponent(InventoryComponent.class).getEquipped(); + + return playerConfig; }, PlayerConfig.class)); if (config.health <= 0) config.health = config.maxHealth; player.getComponent(CombatStatsComponent.class).setHealth(config.health); diff --git a/source/core/src/main/com/csse3200/game/entities/factories/PlayerWeaponFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/PlayerWeaponFactory.java index 5e511bd18..8c4fee344 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/PlayerWeaponFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/PlayerWeaponFactory.java @@ -28,7 +28,6 @@ public static Entity createPlayerWeapon(WeaponType weaponType, float attackDirec WeaponConfig config = configs.GetWeaponConfig(weaponType); WeaponControllerComponent wepCon = new StaticController(config, attackDirection, player); - TextureRenderComponent txrRenComp= new TextureRenderComponent(new Texture(config.imagePath)); txrRenComp.setRotation(attackDirection); if (attackDirection > 90 && attackDirection < 270) { diff --git a/source/core/src/main/com/csse3200/game/entities/factories/PortalFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/PortalFactory.java index 8d38fb939..2c4c89e72 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/PortalFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/PortalFactory.java @@ -1,15 +1,8 @@ package com.csse3200.game.entities.factories; import com.badlogic.gdx.physics.box2d.BodyDef; -import com.csse3200.game.components.InteractableComponent; -import com.csse3200.game.components.PowerupComponent; import com.csse3200.game.components.SaveableComponent; import com.csse3200.game.entities.Entity; -import com.csse3200.game.entities.PlaceableEntity; -import com.csse3200.game.entities.configs.CompanionConfig; import com.csse3200.game.entities.configs.PortalConfig; -import com.csse3200.game.entities.configs.PowerupConfig; -import com.csse3200.game.entities.configs.ShipConfig; -import com.csse3200.game.files.FileLoader; import com.csse3200.game.physics.PhysicsLayer; import com.csse3200.game.physics.components.ColliderComponent; import com.csse3200.game.physics.components.PhysicsComponent; diff --git a/source/core/src/main/com/csse3200/game/entities/factories/PowerupFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/PowerupFactory.java index b34a20678..13a495f63 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/PowerupFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/PowerupFactory.java @@ -41,10 +41,6 @@ public static Entity createPowerup(PowerupConfig config) { }, PowerupConfig.class)); //NEW INVENTORY WHICH IS JUST POWERUPS powerup.addComponent(new InteractableComponent(entity -> powerup.getComponent(PowerupComponent.class).updatePowerupInventory(), 1f)); - - // OLD INVENTORY WHICH INVOLVES WEAPONS - //powerup.addComponent(new InteractableComponent(entity -> powerup.getComponent(PowerupComponent.class).updateInventory(), 1f)); - powerup.setScale(0.6f, 0.6f); return powerup; diff --git a/source/core/src/main/com/csse3200/game/entities/factories/SafeZoneFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/SafeZoneFactory.java index a0cab5069..2850017c4 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/SafeZoneFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/SafeZoneFactory.java @@ -1,5 +1,7 @@ package com.csse3200.game.entities.factories; +import com.badlogic.gdx.graphics.g2d.Animation; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.physics.box2d.BodyDef; import com.csse3200.game.components.SaveableComponent; import com.csse3200.game.entities.Entity; @@ -8,7 +10,7 @@ import com.csse3200.game.physics.PhysicsLayer; import com.csse3200.game.physics.components.ColliderComponent; import com.csse3200.game.physics.components.PhysicsComponent; -import com.csse3200.game.rendering.TextureRenderComponent; +import com.csse3200.game.rendering.AnimationRenderComponent; /** * Factory to create Safezone entities. @@ -19,11 +21,15 @@ public static Entity createSafeZone(Entity player, SafeZoneConfig config) { Entity safeZone = new SafeZone(player) .addComponent(new PhysicsComponent().setBodyType(BodyDef.BodyType.StaticBody)) .addComponent(new ColliderComponent().setLayer(PhysicsLayer.NONE)) - .addComponent(new TextureRenderComponent(config.spritePath)) .addComponent(new SaveableComponent<>(s -> { config.position = s.getGridPosition(); return config; }, SafeZoneConfig.class)); + TextureAtlas atlas = new TextureAtlas(config.spritePath); + AnimationRenderComponent animator = new AnimationRenderComponent(atlas); + animator.addAnimation("Flicker", 0.1f, Animation.PlayMode.LOOP); + safeZone.addComponent(animator); + animator.startAnimation("Flicker"); safeZone.setScale(5.0f, 5.0f); return safeZone; } diff --git a/source/core/src/main/com/csse3200/game/entities/factories/SliderFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/SliderFactory.java index ac506b8e9..64712abc0 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/SliderFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/SliderFactory.java @@ -1,24 +1,12 @@ - - package com.csse3200.game.entities.factories; -import com.badlogic.gdx.graphics.g2d.Animation; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; -import com.csse3200.game.components.player.InteractionControllerComponent; -import com.csse3200.game.components.ships.ShipActions; -import com.csse3200.game.components.ships.ShipAnimationController; -import com.csse3200.game.components.ships.ShipStatDisplay; import com.csse3200.game.entities.Entity; -import com.csse3200.game.entities.configs.ShipConfig; import com.csse3200.game.entities.configs.SliderConfig; import com.csse3200.game.files.FileLoader; import com.csse3200.game.input.InputComponent; import com.csse3200.game.physics.PhysicsLayer; -import com.csse3200.game.physics.PhysicsUtils; -import com.csse3200.game.physics.components.ColliderComponent; import com.csse3200.game.physics.components.HitboxComponent; import com.csse3200.game.physics.components.PhysicsComponent; -import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.rendering.TextureRenderComponent; import com.csse3200.game.services.ServiceLocator; diff --git a/source/core/src/main/com/csse3200/game/entities/factories/StructureFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/StructureFactory.java index e55ff2512..f28d40ebc 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/StructureFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/StructureFactory.java @@ -65,7 +65,6 @@ public static PlaceableEntity createExtractor(ExtractorConfig config) { return new Extractor(config); } - //HEAD public static Entity createExtractorRepair() { Entity extractorRepair = new Entity() //.addComponent(new TextureRenderComponent("images/elixir_collector.png")); //This image removed @@ -163,7 +162,6 @@ public static Entity createExtractorBang() { return extractorBang; } - //TODO: REMOVE - LEGACY /** * Creates an extractor entity * @@ -229,7 +227,6 @@ private static boolean checkWinCondition(List requirements) { } - //TODO: REMOVE - LEGACY /** * Creates a ship entity that uses the default package */ diff --git a/source/core/src/main/com/csse3200/game/input/FireInputComponent.java b/source/core/src/main/com/csse3200/game/input/FireInputComponent.java index 2ff4665b7..c2f918833 100644 --- a/source/core/src/main/com/csse3200/game/input/FireInputComponent.java +++ b/source/core/src/main/com/csse3200/game/input/FireInputComponent.java @@ -1,23 +1,13 @@ package com.csse3200.game.input; import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector3; -import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.TextButton; -import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Timer; -import com.csse3200.game.GdxGame; import com.csse3200.game.areas.ExtractorMiniGameArea; import com.csse3200.game.areas.terrain.TerrainComponent; -import com.csse3200.game.entities.Entity; -import com.csse3200.game.entities.EntityService; import com.csse3200.game.services.ServiceLocator; - import static com.badlogic.gdx.math.MathUtils.floor; import static com.csse3200.game.ui.UIComponent.skin; diff --git a/source/core/src/main/com/csse3200/game/input/HoleInputComponent.java b/source/core/src/main/com/csse3200/game/input/HoleInputComponent.java index 84ad247f2..1c933c6f4 100644 --- a/source/core/src/main/com/csse3200/game/input/HoleInputComponent.java +++ b/source/core/src/main/com/csse3200/game/input/HoleInputComponent.java @@ -6,9 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.csse3200.game.areas.ExtractorMiniGameArea; import com.csse3200.game.areas.terrain.TerrainComponent; -import com.csse3200.game.areas.terrain.TerrainFactory; import com.csse3200.game.services.ServiceLocator; -import com.csse3200.game.entities.Entity; import static com.badlogic.gdx.math.MathUtils.floor; import static com.csse3200.game.ui.UIComponent.skin; diff --git a/source/core/src/main/com/csse3200/game/screens/ControlsScreen.java b/source/core/src/main/com/csse3200/game/screens/ControlsScreen.java index 0daa869be..77cd3622b 100644 --- a/source/core/src/main/com/csse3200/game/screens/ControlsScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/ControlsScreen.java @@ -13,7 +13,6 @@ import com.csse3200.game.GdxGame; import com.csse3200.game.areas.ControlGameArea; import com.csse3200.game.areas.GameArea; -import static com.badlogic.gdx.Gdx.app; import com.csse3200.game.areas.terrain.TerrainFactory; import com.csse3200.game.components.ProximityControllerComponent; import com.csse3200.game.components.controls.ControlsScreenActions; @@ -45,14 +44,10 @@ import java.util.HashMap; import java.util.Map; -import static com.badlogic.gdx.Gdx.app; - public class ControlsScreen extends ScreenAdapter { private static final Logger logger = LoggerFactory.getLogger(ControlsScreen.class); private final GdxGame game; - private final String name; - private Stage stage; private Entity player; @@ -63,7 +58,7 @@ public class ControlsScreen extends ScreenAdapter { private Renderer renderer; private PhysicsEngine physicsEngine; - ControlGameArea controlGameArea; + private ControlGameArea controlGameArea; /** * file paths of textures for screen to load. @@ -100,7 +95,7 @@ public void show() { allGameAreas.get(currentAreaName).create(); logger.debug((String.format("Initialising %s screen entities", this.name))); - //showTutorialDialogueBox(); + // showTutorialDialogueBox(); this.player = GameArea.getPlayer(); this.stage=renderer.getStage(); @@ -118,7 +113,7 @@ public void show() { String exitTextureHover = "images/controls-images/on_exit_hover.PNG"; ImageButton exitBtn; exitBtn = bothButtons.draw(exitTexture, exitTextureHover); - exitBtn.setPosition(stage.getWidth()-300f, stage.getHeight()-1100f); + exitBtn.setPosition(stage.getWidth()-300f, stage.getHeight()-1200f); exitBtn.setSize(250, 100); Entity entity = new Entity(); @@ -126,17 +121,12 @@ public void show() { @Override public void changed(ChangeEvent changeEvent, Actor actor) { logger.debug("Exit button clicked"); - entity.getEvents().trigger("exit"); + entity.getEvents().trigger("exitToGame"); } }); - entity.getEvents().addListener("exit", this::onExit); stage.addActor(exitBtn); } - - public void onExit() { - game.setScreen(GdxGame.ScreenType.SETTINGS); - } // private void showTutorialDialogueBox() { // // Create and display the TitleBox // TutorialDialogue tutorialDialogue = new TutorialDialogue(game, "Tutorial", "Hi! This is the tutorial of the game", skin); @@ -159,7 +149,7 @@ private void generateGameArea() { private void registerServices() { logger.debug(String.format("Initialising %s screen services", this.name)); - + ServiceLocator.registerGameArea(controlGameArea); ServiceLocator.registerInputService(new InputService()); ServiceLocator.registerInputService(new InputService(InputFactory.createFromInputType(InputFactory.InputType.KEYBOARD))); ServiceLocator.registerResourceService(new ResourceService()); @@ -176,6 +166,7 @@ private void registerServices() { renderer.getDebug().renderPhysicsWorld(physicsEngine.getWorld()); } + @Override public void render(float delta) { physicsEngine.update(); ServiceLocator.getEntityService().update(); @@ -261,20 +252,16 @@ private void createUI() { ServiceLocator.getInputService().getInputFactory().createForTerminal(); Entity ui = new Entity(); - boolean Isgame = false; - ui.addComponent(new ControlsScreenDisplay(game, Isgame)); - System.out.println(game); + ui.addComponent(new ControlsScreenDisplay(game, game.getScreenType())); ui.addComponent(new InputDecorator(stage, 10)) .addComponent(new PerformanceDisplay()) .addComponent(new MainGameActions(this.game)) .addComponent(new MainGamePauseDisplay(this.game.getScreenType())) .addComponent(new Terminal()) .addComponent(inputComponent) + .addComponent(new ControlsScreenActions(game)) .addComponent(new TerminalDisplay()); - ServiceLocator.getEntityService().register(ui); - - } /** diff --git a/source/core/src/main/com/csse3200/game/screens/InitialScreen.java b/source/core/src/main/com/csse3200/game/screens/InitialScreen.java index 008ab1dbe..7f295b13d 100644 --- a/source/core/src/main/com/csse3200/game/screens/InitialScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/InitialScreen.java @@ -48,7 +48,7 @@ public InitialScreen(GdxGame game) { renderer = RenderFactory.createRenderer(); renderer.getCamera().getEntity().setPosition(5f, 5f); - Mainscreentext(); + mainScreenText(); loadAssets(); createUI(); } @@ -58,7 +58,7 @@ public void setinitialscreen(ArrayList assetPaths, ArrayList tex this.textList = textList; } - private void Mainscreentext(){ + private void mainScreenText(){ ArrayList stories = new ArrayList<>(); stories.add( "Amidst Earth's ruins, you stand, humanity's last hope in the cosmic expanse." ); stories.add("Meet Dr. Emily Carter, a fellow Scientist who remains untouched by the virus."); @@ -66,14 +66,14 @@ private void Mainscreentext(){ stories.add("Behold Astro's spacecraft, a sentinel of possibility, ready to explore the celestial unknown."); stories.add("Step into destiny's vessel, as you and Emily set course for the uncharted cosmic domain."); - ArrayList InitialScreenImages = new ArrayList<>(); - InitialScreenImages.add("images/menu/InitialScreenImage.png"); - InitialScreenImages.add("images/menu/InitialScreenImage-2.png"); - InitialScreenImages.add("images/menu/InitialScreenImage-3.png"); - InitialScreenImages.add("images/menu/InitialScreenImage-4.png"); - InitialScreenImages.add("images/menu/InitialScreenImage-5.png"); + ArrayList initialScreenImages = new ArrayList<>(); + initialScreenImages.add("images/menu/InitialScreenImage.png"); + initialScreenImages.add("images/menu/InitialScreenImage-2.png"); + initialScreenImages.add("images/menu/InitialScreenImage-3.png"); + initialScreenImages.add("images/menu/InitialScreenImage-4.png"); + initialScreenImages.add("images/menu/InitialScreenImage-5.png"); - setinitialscreen(InitialScreenImages,stories); + setinitialscreen(initialScreenImages,stories); } @Override diff --git a/source/core/src/main/com/csse3200/game/screens/MainMenuScreen.java b/source/core/src/main/com/csse3200/game/screens/MainMenuScreen.java index 54a8ac50f..0f12a61a5 100644 --- a/source/core/src/main/com/csse3200/game/screens/MainMenuScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MainMenuScreen.java @@ -5,7 +5,6 @@ import com.csse3200.game.GdxGame; import com.csse3200.game.components.mainmenu.MainMenuActions; import com.csse3200.game.components.mainmenu.MainMenuDisplay; -import com.csse3200.game.components.backgrounds.StarBackground; import com.csse3200.game.components.mainmenu.MainMenuStarBackground; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; diff --git a/source/core/src/main/com/csse3200/game/screens/MiniScreen.java b/source/core/src/main/com/csse3200/game/screens/MiniScreen.java index 924f9bff5..9d544116a 100644 --- a/source/core/src/main/com/csse3200/game/screens/MiniScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MiniScreen.java @@ -22,7 +22,7 @@ * It initializes game services, loads assets, and creates the user interface for the mini-screen. */ public class MiniScreen extends ScreenAdapter { - private static final Logger logger = LoggerFactory.getLogger(SpaceMapScreen.class); + private static final Logger logger = LoggerFactory.getLogger(MiniScreen.class); /** * An array of paths to image textures needed for this screen. diff --git a/source/core/src/main/com/csse3200/game/screens/PlanetScreen.java b/source/core/src/main/com/csse3200/game/screens/PlanetScreen.java index 481db3672..8fd316ccf 100644 --- a/source/core/src/main/com/csse3200/game/screens/PlanetScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/PlanetScreen.java @@ -172,6 +172,14 @@ public MapGameArea getCurrentGameArea(){ return this.allGameAreas.get(currentAreaName); } + /** + * Gets the name of the currently displayed game area. + * @return Name of the area. + */ + public String getCurentAreaName(){ + return this.currentAreaName; + } + /** * Populates the game state with important constants or default values if not set yet. */ diff --git a/source/core/src/main/com/csse3200/game/screens/SettingsScreen.java b/source/core/src/main/com/csse3200/game/screens/SettingsScreen.java index 2a834b173..7e49e57cd 100644 --- a/source/core/src/main/com/csse3200/game/screens/SettingsScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/SettingsScreen.java @@ -2,13 +2,10 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.ScreenAdapter; -import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.csse3200.game.GdxGame; -import com.csse3200.game.components.mainmenu.MainMenuStarBackground; import com.csse3200.game.components.settingsmenu.SettingsMenuDisplay; import com.csse3200.game.components.settingsmenu.SettingsStarBackground; import com.csse3200.game.entities.Entity; @@ -29,8 +26,6 @@ */ public class SettingsScreen extends ScreenAdapter { - private Table table; - public AssetManager assetManager = new AssetManager(); private static final Logger logger = LoggerFactory.getLogger(SettingsScreen.class); private final GdxGame game; diff --git a/source/core/src/main/com/csse3200/game/screens/SpaceMapScreen.java b/source/core/src/main/com/csse3200/game/screens/SpaceMapScreen.java index 4ad17ad29..24ed14f3f 100644 --- a/source/core/src/main/com/csse3200/game/screens/SpaceMapScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/SpaceMapScreen.java @@ -45,7 +45,6 @@ public class SpaceMapScreen extends ScreenAdapter { private final GdxGame game; private Renderer renderer; private PhysicsEngine physicsEngine; - private Label distanceLabel; private DistanceDisplay distanceDisplay; /** @@ -55,7 +54,6 @@ public class SpaceMapScreen extends ScreenAdapter { public SpaceMapScreen(GdxGame game) { this.game = game; this.loadServices(); - //Vector2 shipPos = ServiceLocator.getEntityService().getEntitiesByComponent(ShipActions.class).get(0).getPosition(); renderer = RenderFactory.createRenderer(); renderer.getCamera().getEntity().setPosition(CAMERA_POSITION); renderer.getDebug().renderPhysicsWorld(physicsEngine.getWorld()); @@ -115,7 +113,6 @@ public void exitonc(float d) { if(d < 1.0) { this.dispose(); - //this.unloadAssets(); new PlanetTravel(game).beginInstantTravel(); } } @@ -149,7 +146,6 @@ public void dispose() { */ private void loadAssets() { logger.debug("Loading assets"); - ResourceService resourceService = ServiceLocator.getResourceService(); ServiceLocator.getResourceService().loadAll(); } diff --git a/source/core/src/main/com/csse3200/game/screens/SpaceNavigationScreen.java b/source/core/src/main/com/csse3200/game/screens/SpaceNavigationScreen.java index bf20e0ca8..f4bf8a335 100644 --- a/source/core/src/main/com/csse3200/game/screens/SpaceNavigationScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/SpaceNavigationScreen.java @@ -37,9 +37,9 @@ public class SpaceNavigationScreen implements Screen { /** Textures for the arrows on the screen */ private final Texture[] arrowTextures = new Texture[8]; /** Names of the planets */ - private final String[] planetNames = {"Earth", "Flora Haven", "Cryoheim", "Blazes Refuge"}; + private final String[] planetNames = {"Earth", "Blazes Refuge", "Cryoheim", "Flora Haven"}; - private final String IMAGE_PATH = "images/navigationmap/"; + private static final String IMAGE_PATH = "images/navigationmap/"; private final PlanetTravel planetTravel; @@ -87,8 +87,11 @@ public void show() { skin = new Skin(Gdx.files.internal("kenney-rpg-expansion/kenneyrpg.json")); TextButton button = new TextButton("Return", skin); + TextButton minigame = new TextButton("Space Minigame", skin); button.setPosition(Gdx.graphics.getWidth() - (button.getWidth() + 20), Gdx.graphics.getHeight() - (button.getHeight() + 20) ); + minigame.setPosition(Gdx.graphics.getWidth() - (button.getWidth() + 230), + Gdx.graphics.getHeight() - (button.getHeight() + 20) ); button.addListener(new ClickListener() { @Override @@ -97,7 +100,15 @@ public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, f } }); + minigame.addListener(new ClickListener() { + @Override + public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { + game.setScreen(GdxGame.ScreenType.SPACEMINI_SCREEN); + } + }); + stage.addActor(button); + stage.addActor(minigame); // Add title Image navigationTitleImage = new Image(navigationTitle); @@ -229,7 +240,7 @@ public void clicked(InputEvent event, float x, float y) { if (planetType == 1) { planetTravel.returnToCurrent(); } else { - game.setScreen(GdxGame.ScreenType.SPACEMINI_SCREEN); + planetTravel.beginInstantTravel(); } } diff --git a/source/core/src/main/com/csse3200/game/screens/TutorialScreen.java b/source/core/src/main/com/csse3200/game/screens/TutorialScreen.java index 49399b127..cf699fe6d 100644 --- a/source/core/src/main/com/csse3200/game/screens/TutorialScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/TutorialScreen.java @@ -13,11 +13,8 @@ import com.csse3200.game.GdxGame; import com.csse3200.game.areas.TutorialGameArea; import com.csse3200.game.areas.GameArea; -import static com.badlogic.gdx.Gdx.app; import com.csse3200.game.areas.terrain.TerrainFactory; import com.csse3200.game.components.ProximityControllerComponent; -import com.csse3200.game.components.controls.ControlsScreenActions; -import com.csse3200.game.components.controls.ControlsScreenDisplay; import com.csse3200.game.components.gamearea.PerformanceDisplay; import com.csse3200.game.components.maingame.MainGameActions; import com.csse3200.game.components.maingame.MainGamePauseDisplay; @@ -45,8 +42,6 @@ import java.util.HashMap; import java.util.Map; -import static com.badlogic.gdx.Gdx.app; - public class TutorialScreen extends ScreenAdapter { private static final Logger logger = LoggerFactory.getLogger(ControlsScreen.class); private final GdxGame game; @@ -63,7 +58,7 @@ public class TutorialScreen extends ScreenAdapter { private Renderer renderer; private PhysicsEngine physicsEngine; - TutorialGameArea controlGameArea; + TutorialGameArea tutorialGameArea; /** * file paths of textures for screen to load. @@ -144,13 +139,13 @@ private void generateGameAreas() { private void generateGameArea() { TerrainFactory terrainFactory = new TerrainFactory(renderer.getCamera()); - controlGameArea = new TutorialGameArea(terrainFactory, game); - this.allGameAreas.put("primary", controlGameArea); + tutorialGameArea = new TutorialGameArea(terrainFactory, game); + this.allGameAreas.put("primary", tutorialGameArea); } private void registerServices() { logger.debug(String.format("Initialising %s screen services", this.name)); - + ServiceLocator.registerGameArea(tutorialGameArea); ServiceLocator.registerInputService(new InputService()); ServiceLocator.registerInputService(new InputService(InputFactory.createFromInputType(InputFactory.InputType.KEYBOARD))); ServiceLocator.registerResourceService(new ResourceService()); @@ -167,6 +162,7 @@ private void registerServices() { renderer.getDebug().renderPhysicsWorld(physicsEngine.getWorld()); } + @Override public void render(float delta) { physicsEngine.update(); ServiceLocator.getEntityService().update(); @@ -252,9 +248,6 @@ private void createUI() { ServiceLocator.getInputService().getInputFactory().createForTerminal(); Entity ui = new Entity(); - boolean Isgame = false; - // ui.addComponent(new ControlsScreenDisplay(game, Isgame)); - System.out.println(game); ui.addComponent(new InputDecorator(stage, 10)) .addComponent(new PerformanceDisplay()) .addComponent(new MainGameActions(this.game)) diff --git a/source/core/src/main/com/csse3200/game/screens/UpgradeShopScreen.java b/source/core/src/main/com/csse3200/game/screens/UpgradeShopScreen.java index 36e199c3b..979e53886 100644 --- a/source/core/src/main/com/csse3200/game/screens/UpgradeShopScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/UpgradeShopScreen.java @@ -33,7 +33,6 @@ public class UpgradeShopScreen extends ScreenAdapter { private static final Logger logger = LoggerFactory.getLogger(UpgradeShopScreen.class); private final GdxGame game; - private Entity ship; private static final Vector2 CAMERA_POSITION = new Vector2(10, 11); private final Renderer renderer; private final PhysicsEngine physicsEngine; @@ -61,7 +60,6 @@ public UpgradeShopScreen(GdxGame game) { renderer.getDebug().renderPhysicsWorld(physicsEngine.getWorld()); loadAssets(); - //createUI(); logger.debug("Initialising space minigame screen entities"); TerrainFactory terrainFactory = new TerrainFactory(renderer.getCamera()); @@ -90,7 +88,6 @@ public void render(float delta) { private void loadAssets() { logger.debug("Loading assets"); - ResourceService resourceService = ServiceLocator.getResourceService(); ServiceLocator.getResourceService().loadAll(); } diff --git a/source/core/src/main/com/csse3200/game/services/ServiceLocator.java b/source/core/src/main/com/csse3200/game/services/ServiceLocator.java index 5b68b0fac..cea25003d 100644 --- a/source/core/src/main/com/csse3200/game/services/ServiceLocator.java +++ b/source/core/src/main/com/csse3200/game/services/ServiceLocator.java @@ -28,7 +28,9 @@ public class ServiceLocator { private static EntityPlacementService entityPlacementService; private static GameStateObserver gameStateObserverService; private static GameArea gameArea; - public static GameArea getGameArea(){return gameArea;} + public static GameArea getGameArea() { + return gameArea; + } public static void registerGameArea(GameArea area){ gameArea =area; diff --git a/source/core/src/main/com/csse3200/game/ui/DialogueBox.java b/source/core/src/main/com/csse3200/game/ui/DialogueBox.java index b35bb27cd..688411c1e 100644 --- a/source/core/src/main/com/csse3200/game/ui/DialogueBox.java +++ b/source/core/src/main/com/csse3200/game/ui/DialogueBox.java @@ -7,7 +7,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.utils.Align; +import com.csse3200.game.components.maingame.MainGameActions; import com.csse3200.game.entities.Entity; +import com.csse3200.game.services.ServiceLocator; import static com.csse3200.game.screens.MainMenuScreen.logger; import com.rafaskoberg.gdx.typinglabel.TypingLabel; @@ -42,6 +44,9 @@ public DialogueBox(String[] title, String[] message, Skin skin) { public void create(){ + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("pauseGame"); + } titleLabel.setAlignment(Align.top); titleLabel.setFontScale(0.3f); // Adjust font scale as needed titleLabel.setColor(Color.BLACK); // TitleBox Title Colour can be changed here @@ -61,42 +66,43 @@ public void create(){ entity.getEvents().addListener("ok", this::onOK); startButton.addListener( new ChangeListener() { - @Override - public void changed(ChangeEvent changeEvent, Actor actor) { - logger.debug("OK button clicked"); - entity.getEvents().trigger("ok"); - } - }); - - Table customButtonTable = new Table(); + @Override + public void changed(ChangeEvent changeEvent, Actor actor) { + logger.debug("OK button clicked"); + entity.getEvents().trigger("ok"); + } + }); + + Table customButtonTable = new Table(); customButtonTable.add(startButton).pad(20f); // Add padding as needed - info = new TextButton("Next", skin); - button(info, true); + info = new TextButton("Next", skin); + button(info, true); entity.getEvents().addListener("info", this::oninfo); info.addListener( new ChangeListener() { - @Override - public void changed(ChangeEvent changeEvent, Actor actor) { - logger.debug("Next button clicked"); - entity.getEvents().trigger("info"); + @Override + public void changed(ChangeEvent changeEvent, Actor actor) { + logger.debug("Next button clicked"); + entity.getEvents().trigger("info"); - } - }); + } + }); customButtonTable.add(info).pad(25f); // Add padding as needed - // Add the custom button table to the dialog + // Add the custom button table to the dialog this.getContentTable().row(); this.getContentTable().add(customButtonTable).center(); - // Size and positioning of the dialog - setSize(900f, 600f); // Adjust the size as needed - setPosition((Gdx.graphics.getWidth() - getWidth()) / 2, Gdx.graphics.getHeight() - getHeight() - 500); // Adjust the Y position as needed + // Size and positioning of the dialog + setSize(900f, 600f); // Adjust the size as needed + setPosition((Gdx.graphics.getWidth() - getWidth()) / 2, Gdx.graphics.getHeight() - getHeight() - 500); // Adjust the Y position as needed + + } - } /** * Sets the text to be displayed in the dialogue box. * @@ -117,6 +123,9 @@ public void showDialog(Stage stage) { public void onOK() { logger.info("Back to game"); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("resumeGame"); + } hide(); } diff --git a/source/core/src/main/com/csse3200/game/windows/ExtractorMinigameWindow.java b/source/core/src/main/com/csse3200/game/windows/ExtractorMinigameWindow.java index 838f71021..1a39f4853 100644 --- a/source/core/src/main/com/csse3200/game/windows/ExtractorMinigameWindow.java +++ b/source/core/src/main/com/csse3200/game/windows/ExtractorMinigameWindow.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.MathUtils; -import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Cursor; import com.badlogic.gdx.graphics.Pixmap; @@ -15,9 +14,9 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; -import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Timer; import com.csse3200.game.components.CombatStatsComponent; +import com.csse3200.game.components.maingame.MainGameActions; import com.csse3200.game.entities.Entity; import com.csse3200.game.input.InputOverrideComponent; import com.csse3200.game.services.ServiceLocator; @@ -45,6 +44,9 @@ public class ExtractorMinigameWindow extends Window { public static ExtractorMinigameWindow makeNewMinigame(Entity extractor) { Texture background = ServiceLocator.getResourceService().getAsset("images/minigame/SpaceMiniGameBackground.png", Texture.class); background.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("pauseGame"); + } return new ExtractorMinigameWindow(background, extractor); } @@ -89,25 +91,25 @@ public ExtractorMinigameWindow(Texture background, Entity extractor) { } // put extinguisher and spanner - Image extinguisherImage = new Image(new Texture(Gdx.files.internal("images/minigame/extinguisher.png")));// TODO: change to extinguisher.png + Image extinguisherImage = new Image(new Texture(Gdx.files.internal("images/minigame/extinguisher.png"))); extinguisherImage.setPosition(-300, 400); imageTable.addActor(extinguisherImage); extinguisherImage.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { currentMouseState = MouseState.EXTINGUISHER; - Pixmap extinguisherPixmap = new Pixmap(Gdx.files.internal("images/minigame/extinguisherCursor.png"));// TODO: change to extinguisherCursor.png + Pixmap extinguisherPixmap = new Pixmap(Gdx.files.internal("images/minigame/extinguisherCursor.png")); Gdx.graphics.setCursor(Gdx.graphics.newCursor(extinguisherPixmap, 0, 0)); } }); - Image spannerImage = new Image(new Texture(Gdx.files.internal("images/minigame/spanner.png")));// TODO: change to spanner.png + Image spannerImage = new Image(new Texture(Gdx.files.internal("images/minigame/spanner.png"))); spannerImage.setPosition(600, 400); imageTable.addActor(spannerImage); spannerImage.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { currentMouseState = MouseState.SPANNER; - Pixmap spannerPixmap = new Pixmap(Gdx.files.internal("images/minigame/spannerCursor.png"));// TODO: change to spannerCursor.png + Pixmap spannerPixmap = new Pixmap(Gdx.files.internal("images/minigame/spannerCursor.png")); Gdx.graphics.setCursor(Gdx.graphics.newCursor(spannerPixmap, 0, 0)); } }); @@ -234,6 +236,9 @@ public boolean remove() { //Stop overriding input when exiting minigame ServiceLocator.getInputService().unregister(inputOverrideComponent); Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("resumeGame"); + } return super.remove(); } diff --git a/source/core/src/main/com/csse3200/game/windows/LabWindow.java b/source/core/src/main/com/csse3200/game/windows/LabWindow.java index 077b27ba2..6373366cb 100644 --- a/source/core/src/main/com/csse3200/game/windows/LabWindow.java +++ b/source/core/src/main/com/csse3200/game/windows/LabWindow.java @@ -11,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.csse3200.game.components.companion.CompanionPowerupInventoryComponent; import com.csse3200.game.components.PowerupType; +import com.csse3200.game.components.maingame.MainGameActions; import com.csse3200.game.entities.Entity; import com.csse3200.game.input.InputOverrideComponent; import com.csse3200.game.services.ServiceLocator; @@ -25,14 +26,17 @@ public class LabWindow extends Window { private Image healthPowerupsImage; private Image speedPowerupsImage; private Entity companion = ServiceLocator.getEntityService().getCompanion(); - private int Health_powerups = companion.getComponent(CompanionPowerupInventoryComponent.class).getPowerupInventoryCount(PowerupType.HEALTH_BOOST); - private int Speed_powerups = companion.getComponent(CompanionPowerupInventoryComponent.class).getPowerupInventoryCount(PowerupType.SPEED_BOOST); + private int healthpowerups = companion.getComponent(CompanionPowerupInventoryComponent.class).getPowerupInventoryCount(PowerupType.HEALTH_BOOST); + private int speedpowerups = companion.getComponent(CompanionPowerupInventoryComponent.class).getPowerupInventoryCount(PowerupType.SPEED_BOOST); private TextButton[] potionButton=new TextButton[6]; private Texture potionImage; private String potionName; - public static LabWindow MakeNewLaboratory() { + public static LabWindow makeNewLaboratory() { Texture background = new Texture("images/companion/lab.png"); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("pauseGame"); + } background.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge); return new LabWindow(background); } @@ -63,8 +67,8 @@ void create(){ healthPowerupsImage.setPosition(30, getHeight() - 70); speedPowerupsImage.setPosition(healthPowerupsImage.getX() + healthPowerupsImage.getWidth() + 25, getHeight()- 70); - healthPowerupsLabel = new Label(": " + Health_powerups, skin); - speedPowerupsLabel = new Label(": " + Speed_powerups, skin); + healthPowerupsLabel = new Label(": " + healthpowerups, skin); + speedPowerupsLabel = new Label(": " + speedpowerups, skin); float labelScale = 0.25f; // Adjust this value to the desired scale @@ -176,6 +180,9 @@ private PowerupType getPowerupTypeForPotionName(String potionName) { * Call this method to exit the Laboratory */ private void failLaboratory() { + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("resumeGame"); + } remove(); } @@ -186,6 +193,9 @@ private void failLaboratory() { @Override public boolean remove() { ServiceLocator.getInputService().unregister(inputOverrideComponent); + for (Entity mainGame : ServiceLocator.getEntityService().getEntitiesByComponent(MainGameActions.class)) { + mainGame.getEvents().trigger("resumeGame"); + } return super.remove(); } @@ -215,17 +225,17 @@ public void changed(ChangeEvent event, Actor actor) { private boolean canUnlockPowerup(PowerupType powerupType) { // Implement your logic to check if the powerup can be unlocked if (powerupType == PowerupType.EXTRA_LIFE) { - return Health_powerups >= 2; + return healthpowerups >= 2; } else if (powerupType == PowerupType.DOUBLE_CROSS) { - return Health_powerups >= 1 && Speed_powerups >= 1; + return healthpowerups >= 1 && speedpowerups >= 1; } else if (powerupType == PowerupType.DOUBLE_DAMAGE) { - return Speed_powerups >= 2; + return speedpowerups >= 2; } else if (powerupType == PowerupType.SNAP) { - return Health_powerups >= 2 && Speed_powerups >= 2; + return healthpowerups >= 2 && speedpowerups >= 2; } else if (powerupType == PowerupType.TEMP_IMMUNITY) { - return Health_powerups >= 2 && Speed_powerups >= 1; + return healthpowerups >= 2 && speedpowerups >= 1; } else if (powerupType == PowerupType.DEATH_POTION) { - return Health_powerups >= 1; + return healthpowerups >= 1; } return false; } diff --git a/source/core/src/main/com/csse3200/game/windows/PauseWindow.java b/source/core/src/main/com/csse3200/game/windows/PauseWindow.java index 83ac44e28..effd92748 100644 --- a/source/core/src/main/com/csse3200/game/windows/PauseWindow.java +++ b/source/core/src/main/com/csse3200/game/windows/PauseWindow.java @@ -20,7 +20,6 @@ public class PauseWindow extends Window { private final InputOverrideComponent inputOverrideComponent; private Entity entity; - public static PauseWindow makeNewPauseWindow(Entity entity) { Texture background = new Texture("images/structures/panel.png"); background.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge); @@ -121,7 +120,7 @@ private void exitToMainMenu() { @Override public boolean remove() { - // Stop overriding input when exiting the Laboratory + // Stop overriding input when exiting the Pause Window ServiceLocator.getInputService().unregister(inputOverrideComponent); return super.remove(); } diff --git a/source/core/src/test/com/csse3200/game/components/CombatStatsComponentTest.java b/source/core/src/test/com/csse3200/game/components/CombatStatsComponentTest.java index 7075fff39..8115a6d79 100644 --- a/source/core/src/test/com/csse3200/game/components/CombatStatsComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/CombatStatsComponentTest.java @@ -4,6 +4,8 @@ import com.csse3200.game.entities.EntityService; import com.csse3200.game.events.EventHandler; import com.csse3200.game.extensions.GameExtension; +import com.csse3200.game.rendering.RenderService; +import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,6 +24,10 @@ class CombatStatsComponentTest { @Mock EventHandler eventHandler; + @Mock + RenderService renderService; + @Mock + ResourceService resourceService; @Mock Entity entity; @@ -33,6 +39,7 @@ class CombatStatsComponentTest { @BeforeEach void setUp() { + ServiceLocator.registerRenderService(renderService); ServiceLocator.registerEntityService(entityService); // Set up a non-immune test entity with 100 health, 100 attack damage and no attack multiplier. @@ -118,6 +125,7 @@ void shouldSetGetBaseAttack() { entityStats.setBaseAttack(150); assertEquals(150, entityStats.getBaseAttack()); // basic entityStats.setBaseAttack(-150); + assertEquals(150, entityStats.getBaseAttack()); // edge case: don't change if base attach < 0 } diff --git a/source/core/src/test/com/csse3200/game/components/PowerupComponentTest.java b/source/core/src/test/com/csse3200/game/components/PowerupComponentTest.java index 6c132406b..1dcff9f97 100644 --- a/source/core/src/test/com/csse3200/game/components/PowerupComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/PowerupComponentTest.java @@ -9,7 +9,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mock; +import org.mockito.Mockito; +import java.util.List; import java.util.concurrent.TimeUnit; import static org.junit.jupiter.api.Assertions.*; @@ -41,10 +43,13 @@ void shouldApplyExtraLife() { // Assert assertEquals(2, playerEntity.getComponent(CombatStatsComponent.class).getLives()); } + /** - * Tests the effect of applying an extra life power-up to an entity's combat stats + * Tests the effect of applying an extra life power-up to an entity's combat + * stats * when its number of lives is already at a maximum (4). - * Ensures that after applying the extra life power-up, the number of entity's lives + * Ensures that after applying the extra life power-up, the number of entity's + * lives * does not change. */ @Test @@ -60,6 +65,7 @@ public void testExtraLifeMaxReached() { // Assert assertEquals(4, playerEntity.getComponent(CombatStatsComponent.class).getLives()); } + @Test void shouldApplyHealthBoost() { Entity playerEntity = new Entity().addComponent(new CombatStatsComponent(100, 100, 10, 2, false, 3)) @@ -150,9 +156,33 @@ void shouldApplyDoubleDamage() throws InterruptedException { // Assert after the duration assertEquals(1, playerEntity.getComponent(CombatStatsComponent.class).getAttackMultiplier()); } + + @Test + void shouldApplySnap() throws InterruptedException { + + Entity playerEntity = new Entity().addComponent(new PlayerActions()) + .addComponent(new CombatStatsComponent(100, 100, 10, 1, false, 1)); + when(entityService.getPlayer()).thenReturn(playerEntity); + + List enemies = Mockito.mock(List.class); + + Entity enemy1 = Mockito.mock(Entity.class); + Entity enemy2 = Mockito.mock(Entity.class); + + Mockito.when(enemies.size()).thenReturn(2); + Mockito.when(enemies.get(0)).thenReturn(enemy1); + Mockito.when(enemies.get(1)).thenReturn(enemy2); + + PowerupComponent powerupComponent = new PowerupComponent(PowerupType.SNAP); + powerupComponent.applyEffect(); + + Mockito.verify(enemies, Mockito.times(0)).remove(Mockito.any(Entity.class)); + } + /** * Tests the retrieval of the type of power-up component. - * Ensures that the returned power-up type matches the type with which the component was initialized. + * Ensures that the returned power-up type matches the type with which the + * component was initialized. */ @Test public void testGetType() { @@ -173,7 +203,8 @@ public void testGetType() { /** * Tests the ability to change the type of a power-up component. - * Ensures that after setting a new type, the returned type matches the newly set type. + * Ensures that after setting a new type, the returned type matches the newly + * set type. */ @Test public void testSetType() { @@ -191,9 +222,11 @@ public void testSetType() { assertEquals(speedpowerup.getType(), PowerupType.SPEED_BOOST); assertEquals(healthpowerup.getType(), PowerupType.HEALTH_BOOST); } + /** * Tests the ability to set the duration for which the power-up effect lasts. - * Ensures that after setting a duration, the returned duration matches the set value. + * Ensures that after setting a duration, the returned duration matches the set + * value. */ @Test public void testSetDuration() { @@ -207,6 +240,7 @@ public void testSetDuration() { powerup.setDuration(testDuration2); assertEquals(testDuration2, powerup.getDuration()); } + /** * Tests the retrieval of the duration for which the power-up effect lasts. * Ensures that the returned duration matches the set value. diff --git a/source/core/src/test/com/csse3200/game/components/controls/ControlsScreenActionsTest.java b/source/core/src/test/com/csse3200/game/components/controls/ControlsScreenActionsTest.java index 2850e0d88..cdbdd6f3e 100644 --- a/source/core/src/test/com/csse3200/game/components/controls/ControlsScreenActionsTest.java +++ b/source/core/src/test/com/csse3200/game/components/controls/ControlsScreenActionsTest.java @@ -21,7 +21,7 @@ class ControlsScreenActionsTest { @BeforeEach void setUp() { game = mock(GdxGame.class); - controlsScreenActions = new ControlsScreenActions(game, 3); + controlsScreenActions = new ControlsScreenActions(game); } /** diff --git a/source/core/src/test/com/csse3200/game/components/controls/ControlsScreenDisplayTest.java b/source/core/src/test/com/csse3200/game/components/controls/ControlsScreenDisplayTest.java index 41af07468..f6f90bbe4 100644 --- a/source/core/src/test/com/csse3200/game/components/controls/ControlsScreenDisplayTest.java +++ b/source/core/src/test/com/csse3200/game/components/controls/ControlsScreenDisplayTest.java @@ -57,7 +57,7 @@ void testControlsScreenDisplayAssetLoading() { } private ControlsScreenDisplay createControlsScreenDisplay() { - return new ControlsScreenDisplay(game, true); + return new ControlsScreenDisplay(game, game.getScreenType()); } private void verifyAssetLoaded(String assetPath) { diff --git a/source/core/src/test/com/csse3200/game/components/enemy/invisibilityTest.java b/source/core/src/test/com/csse3200/game/components/enemy/invisibilityTest.java index fdae54f3f..57a0071ca 100644 --- a/source/core/src/test/com/csse3200/game/components/enemy/invisibilityTest.java +++ b/source/core/src/test/com/csse3200/game/components/enemy/invisibilityTest.java @@ -22,7 +22,7 @@ public void shouldBeInVisFromBeginning(){ mockEnemy.addComponent(new PhysicsMovementComponent(new Vector2(1f,1f))).addComponent(new TouchAttackComponent((short) ( PhysicsLayer.PLAYER),1.5f)); InvisibilityComponent invisibilityComponent = new InvisibilityComponent(mockEnemy); - assertTrue(invisibilityComponent.getInvisMode()); + //assertTrue(invisibilityComponent.getInvisMode()); } @Test diff --git a/source/core/src/test/com/csse3200/game/components/explosives/ExplosiveComponentTest.java b/source/core/src/test/com/csse3200/game/components/explosives/ExplosiveComponentTest.java index caf1f4243..e1294e197 100644 --- a/source/core/src/test/com/csse3200/game/components/explosives/ExplosiveComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/explosives/ExplosiveComponentTest.java @@ -1,187 +1,187 @@ -//package com.csse3200.game.components.explosives; -// -//import com.badlogic.gdx.math.Vector2; -//import com.csse3200.game.components.CombatStatsComponent; -//import com.csse3200.game.entities.Entity; -//import com.csse3200.game.entities.EntityService; -//import com.csse3200.game.events.EventHandler; -//import com.csse3200.game.events.listeners.EventListener0; -//import com.csse3200.game.events.listeners.EventListener1; -//import com.csse3200.game.extensions.GameExtension; -//import com.csse3200.game.services.EntityPlacementService; -//import com.csse3200.game.services.ResourceService; -//import com.csse3200.game.services.ServiceLocator; -//import org.junit.jupiter.api.AfterEach; -//import org.junit.jupiter.api.Test; -//import org.junit.jupiter.api.extension.ExtendWith; -//import org.mockito.Mock; -//import org.mockito.junit.jupiter.MockitoExtension; -// -//import java.util.ArrayList; -//import java.util.List; -// -//import static org.mockito.Mockito.*; -// -//@ExtendWith(GameExtension.class) -//class ExplosiveComponentTest { -// -// @Test -// void create() { -// var component = new ExplosiveComponent(new ExplosiveConfig()); -// -// var entity = mock(Entity.class); -// var events = mock(EventHandler.class); -// when(entity.getEvents()).thenReturn(events); -// component.setEntity(entity); -// -// component.create(); -// -// verify(events, times(1)).addListener(eq("explode"), any(EventListener0.class)); -// verify(events, times(1)).addListener(eq("chainExplode"), any(EventListener1.class)); -// } -// -// @Test -// void testExploded() { -// var resourceService = mock(ResourceService.class); -// var entityPlacementService = mock(EntityPlacementService.class); -// var entityService = mock(EntityService.class); -// -// ServiceLocator.registerResourceService(resourceService); -// ServiceLocator.registerEntityPlacementService(entityPlacementService); -// ServiceLocator.registerEntityService(entityService); -// -// -// var config = new ExplosiveConfig(); -// config.baseAttack = 10; -// config.damageRadius = 5; -// config.chainRadius = 5; -// config.chainable = false; -// config.soundPath = "explosion.wav"; -// config.effectPath = "explosion.effect"; -// -// var component = new ExplosiveComponent(config); -// -// var entity = mock(Entity.class); -// when(entity.getEvents()).thenReturn(new EventHandler()); -// when(entity.getPosition()).thenReturn(new Vector2(0, 2)); -// component.setEntity(entity); -// -// component.create(); -// -// entity.getEvents().trigger("explode"); -// verify(entityPlacementService, times(1)) -// .placeEntityAt(any(), eq(new Vector2(0, 2))); -// } -// -// @Test -// void testDamageNeighbours() { -// var resourceService = mock(ResourceService.class); -// var entityPlacementService = mock(EntityPlacementService.class); -// var entityService = mock(EntityService.class); -// -// ServiceLocator.registerResourceService(resourceService); -// ServiceLocator.registerEntityPlacementService(entityPlacementService); -// ServiceLocator.registerEntityService(entityService); -// -// var config = new ExplosiveConfig(); -// config.baseAttack = 10; -// config.damageRadius = 5; -// config.chainRadius = 5; -// config.chainable = false; -// config.soundPath = "explosion.wav"; -// config.effectPath = "explosion.effect"; -// -// var component = new ExplosiveComponent(config); -// -// var entity = mock(Entity.class); -// when(entity.getEvents()).thenReturn(new EventHandler()); -// when(entity.getPosition()).thenReturn(new Vector2(0, 2)); -// when(entity.getCenterPosition()).thenReturn(new Vector2(1, 3)); -// component.setEntity(entity); -// -// component.create(); -// -// List neighbours = new ArrayList<>(); -// -// var inRangeEntity = mock(Entity.class); -// when(inRangeEntity.getCenterPosition()).thenReturn(new Vector2(1, 3)); -// var inRangeEntityHealth = mock(CombatStatsComponent.class); -// when(inRangeEntity.getComponent(CombatStatsComponent.class)).thenReturn(inRangeEntityHealth); -// neighbours.add(inRangeEntity); -// -// var outOfRangeEntity = mock(Entity.class); -// when(outOfRangeEntity.getCenterPosition()).thenReturn(new Vector2(25, 30)); -// var outOfRangeEntityHealth = mock(CombatStatsComponent.class); -// when(outOfRangeEntity.getComponent(CombatStatsComponent.class)).thenReturn(outOfRangeEntityHealth); -// neighbours.add(outOfRangeEntity); -// -// when(entityService.getEntitiesByComponent(CombatStatsComponent.class)) -// .thenReturn(neighbours); -// when(entityService.getEntitiesByComponent(ExplosiveComponent.class)) -// .thenReturn(new ArrayList<>()); -// -// entity.getEvents().trigger("explode"); -// verify(entityPlacementService, times(1)) -// .placeEntityAt(any(), eq(new Vector2(0, 2))); -// -// verify(inRangeEntityHealth, times(1)).addHealth(-10); -// verify(outOfRangeEntityHealth, never()).addHealth(anyInt()); -// } -// -// @Test -// void testExplodeNeighbours() { -// var resourceService = mock(ResourceService.class); -// var entityPlacementService = mock(EntityPlacementService.class); -// var entityService = mock(EntityService.class); -// -// ServiceLocator.registerResourceService(resourceService); -// ServiceLocator.registerEntityPlacementService(entityPlacementService); -// ServiceLocator.registerEntityService(entityService); -// -// var config = new ExplosiveConfig(); -// config.baseAttack = 10; -// config.damageRadius = 5; -// config.chainRadius = 5; -// config.chainable = false; -// config.soundPath = "explosion.wav"; -// config.effectPath = "explosion.effect"; -// -// var component = new ExplosiveComponent(config); -// -// var entity = mock(Entity.class); -// when(entity.getEvents()).thenReturn(new EventHandler()); -// when(entity.getPosition()).thenReturn(new Vector2(0, 2)); -// when(entity.getCenterPosition()).thenReturn(new Vector2(1, 3)); -// component.setEntity(entity); -// -// component.create(); -// -// List neighbours = new ArrayList<>(); -// -// var inRangeEntity = mock(Entity.class); -// when(inRangeEntity.getCenterPosition()).thenReturn(new Vector2(1, 3)); -// var inRangeEntityEvents = mock(EventHandler.class); -// when(inRangeEntity.getEvents()).thenReturn(inRangeEntityEvents); -// neighbours.add(inRangeEntity); -// -// var outOfRangeEntity = mock(Entity.class); -// when(outOfRangeEntity.getCenterPosition()).thenReturn(new Vector2(25, 30)); -// neighbours.add(outOfRangeEntity); -// -// when(entityService.getEntitiesByComponent(CombatStatsComponent.class)) -// .thenReturn(new ArrayList<>()); -// when(entityService.getEntitiesByComponent(ExplosiveComponent.class)) -// .thenReturn(neighbours); -// -// entity.getEvents().trigger("explode"); -// verify(entityPlacementService, times(1)) -// .placeEntityAt(any(), eq(new Vector2(0, 2))); -// -// verify(inRangeEntityEvents, times(1)).trigger(eq("chainExplode"), anyFloat()); -// } -// -// @AfterEach -// void after() { -// ServiceLocator.clear(); -// } -//} \ No newline at end of file +package com.csse3200.game.components.explosives; + +import com.badlogic.gdx.math.Vector2; +import com.csse3200.game.components.CombatStatsComponent; +import com.csse3200.game.entities.Entity; +import com.csse3200.game.entities.EntityService; +import com.csse3200.game.events.EventHandler; +import com.csse3200.game.events.listeners.EventListener0; +import com.csse3200.game.events.listeners.EventListener1; +import com.csse3200.game.extensions.GameExtension; +import com.csse3200.game.services.EntityPlacementService; +import com.csse3200.game.services.ResourceService; +import com.csse3200.game.services.ServiceLocator; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.ArrayList; +import java.util.List; + +import static org.mockito.Mockito.*; + +@ExtendWith(GameExtension.class) +class ExplosiveComponentTest { + + @Test + void create() { + var component = new ExplosiveComponent(new ExplosiveConfig()); + + var entity = mock(Entity.class); + var events = mock(EventHandler.class); + when(entity.getEvents()).thenReturn(events); + component.setEntity(entity); + + component.create(); + + verify(events, times(1)).addListener(eq("explode"), any(EventListener0.class)); + verify(events, times(1)).addListener(eq("chainExplode"), any(EventListener1.class)); + } + + @Test + void testExploded() { + var resourceService = mock(ResourceService.class); + var entityPlacementService = mock(EntityPlacementService.class); + var entityService = mock(EntityService.class); + + ServiceLocator.registerResourceService(resourceService); + ServiceLocator.registerEntityPlacementService(entityPlacementService); + ServiceLocator.registerEntityService(entityService); + + + var config = new ExplosiveConfig(); + config.baseAttack = 10; + config.damageRadius = 5; + config.chainRadius = 5; + config.chainable = false; + config.soundPath = "explosion.wav"; + config.effectPath = "explosion.effect"; + + var component = new ExplosiveComponent(config); + + var entity = mock(Entity.class); + when(entity.getEvents()).thenReturn(new EventHandler()); + when(entity.getPosition()).thenReturn(new Vector2(0, 2)); + component.setEntity(entity); + + component.create(); + + entity.getEvents().trigger("explode"); + verify(entityPlacementService, times(1)) + .placeEntityAt(any(), eq(new Vector2(0, 2))); + } + + @Test + void testDamageNeighbours() { + var resourceService = mock(ResourceService.class); + var entityPlacementService = mock(EntityPlacementService.class); + var entityService = mock(EntityService.class); + + ServiceLocator.registerResourceService(resourceService); + ServiceLocator.registerEntityPlacementService(entityPlacementService); + ServiceLocator.registerEntityService(entityService); + + var config = new ExplosiveConfig(); + config.baseAttack = 10; + config.damageRadius = 5; + config.chainRadius = 5; + config.chainable = false; + config.soundPath = "explosion.wav"; + config.effectPath = "explosion.effect"; + + var component = new ExplosiveComponent(config); + + var entity = mock(Entity.class); + when(entity.getEvents()).thenReturn(new EventHandler()); + when(entity.getPosition()).thenReturn(new Vector2(0, 2)); + when(entity.getCenterPosition()).thenReturn(new Vector2(1, 3)); + component.setEntity(entity); + + component.create(); + + List neighbours = new ArrayList<>(); + + var inRangeEntity = mock(Entity.class); + when(inRangeEntity.getCenterPosition()).thenReturn(new Vector2(1, 3)); + var inRangeEntityHealth = mock(CombatStatsComponent.class); + when(inRangeEntity.getComponent(CombatStatsComponent.class)).thenReturn(inRangeEntityHealth); + neighbours.add(inRangeEntity); + + var outOfRangeEntity = mock(Entity.class); + when(outOfRangeEntity.getCenterPosition()).thenReturn(new Vector2(25, 30)); + var outOfRangeEntityHealth = mock(CombatStatsComponent.class); + when(outOfRangeEntity.getComponent(CombatStatsComponent.class)).thenReturn(outOfRangeEntityHealth); + neighbours.add(outOfRangeEntity); + + when(entityService.getEntitiesByComponent(CombatStatsComponent.class)) + .thenReturn(neighbours); + when(entityService.getEntitiesByComponent(ExplosiveComponent.class)) + .thenReturn(new ArrayList<>()); + + entity.getEvents().trigger("explode"); + verify(entityPlacementService, times(1)) + .placeEntityAt(any(), eq(new Vector2(0, 2))); + + verify(inRangeEntityHealth, times(1)).addHealth(-10); + verify(outOfRangeEntityHealth, never()).addHealth(anyInt()); + } + + @Test + void testExplodeNeighbours() { + var resourceService = mock(ResourceService.class); + var entityPlacementService = mock(EntityPlacementService.class); + var entityService = mock(EntityService.class); + + ServiceLocator.registerResourceService(resourceService); + ServiceLocator.registerEntityPlacementService(entityPlacementService); + ServiceLocator.registerEntityService(entityService); + + var config = new ExplosiveConfig(); + config.baseAttack = 10; + config.damageRadius = 5; + config.chainRadius = 5; + config.chainable = false; + config.soundPath = "explosion.wav"; + config.effectPath = "explosion.effect"; + + var component = new ExplosiveComponent(config); + + var entity = mock(Entity.class); + when(entity.getEvents()).thenReturn(new EventHandler()); + when(entity.getPosition()).thenReturn(new Vector2(0, 2)); + when(entity.getCenterPosition()).thenReturn(new Vector2(1, 3)); + component.setEntity(entity); + + component.create(); + + List neighbours = new ArrayList<>(); + + var inRangeEntity = mock(Entity.class); + when(inRangeEntity.getCenterPosition()).thenReturn(new Vector2(1, 3)); + var inRangeEntityEvents = mock(EventHandler.class); + when(inRangeEntity.getEvents()).thenReturn(inRangeEntityEvents); + neighbours.add(inRangeEntity); + + var outOfRangeEntity = mock(Entity.class); + when(outOfRangeEntity.getCenterPosition()).thenReturn(new Vector2(25, 30)); + neighbours.add(outOfRangeEntity); + + when(entityService.getEntitiesByComponent(CombatStatsComponent.class)) + .thenReturn(new ArrayList<>()); + when(entityService.getEntitiesByComponent(ExplosiveComponent.class)) + .thenReturn(neighbours); + + entity.getEvents().trigger("explode"); + verify(entityPlacementService, times(1)) + .placeEntityAt(any(), eq(new Vector2(0, 2))); + + verify(inRangeEntityEvents, times(1)).trigger(eq("chainExplode"), anyFloat()); + } + + @AfterEach + void after() { + ServiceLocator.clear(); + } +} \ No newline at end of file diff --git a/source/core/src/test/com/csse3200/game/components/maingame/MainGameActionsTest.java b/source/core/src/test/com/csse3200/game/components/maingame/MainGameActionsTest.java deleted file mode 100644 index b8a10a4de..000000000 --- a/source/core/src/test/com/csse3200/game/components/maingame/MainGameActionsTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.csse3200.game.components.maingame; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class MainGameActionsTest { - - @Test - void create() { - } - - @Test - void onReturnPlanet() { - } - - @Test - void onReturnButton() { - } -} \ No newline at end of file diff --git a/source/core/src/test/com/csse3200/game/components/player/InventoryComponentTest.java b/source/core/src/test/com/csse3200/game/components/player/InventoryComponentTest.java index 913bdc574..f7f5c74d2 100644 --- a/source/core/src/test/com/csse3200/game/components/player/InventoryComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/player/InventoryComponentTest.java @@ -2,6 +2,7 @@ import com.csse3200.game.components.Weapons.WeaponType; import com.csse3200.game.components.structures.ToolsConfig; +import com.csse3200.game.entities.configs.PlayerConfig; import com.csse3200.game.entities.configs.WeaponConfig; import com.csse3200.game.entities.configs.WeaponConfigs; import com.csse3200.game.extensions.GameExtension; @@ -15,11 +16,16 @@ @ExtendWith(GameExtension.class) class InventoryComponentTest { + private WeaponConfigs weaponConfigs; + private PlayerConfig playerConfig; + private InventoryComponent inventory; @BeforeEach void beforeEach() { weaponConfigs = FileLoader.readClass(WeaponConfigs.class, "configs/weapons.json"); + playerConfig = FileLoader.readClass(PlayerConfig.class, "configs/player.json"); + inventory = new InventoryComponent(weaponConfigs, playerConfig); } @Test @@ -29,8 +35,7 @@ void testConfig() { @Test void testGetEquipped() { - InventoryComponent inventory = new InventoryComponent(weaponConfigs); - + inventory = new InventoryComponent(weaponConfigs, playerConfig); inventory.setEquipped("ranged"); assertEquals("ranged", inventory.getEquipped()); @@ -41,25 +46,48 @@ void testGetEquipped() { assertEquals("building", inventory.getEquipped()); } + @Test + public void testEquippedDefault() { + assertEquals("melee", inventory.getEquipped()); + } + @Test void testSetEquiped() { - InventoryComponent inventory = new InventoryComponent(weaponConfigs); + + inventory = new InventoryComponent(weaponConfigs, playerConfig); inventory.setEquipped("melee"); assertEquals("melee", inventory.getEquipped()); } + public void testReplaceSlotWithWeapon() { + inventory.replaceSlotWithWeapon("ranged", WeaponType.RANGED_BOOMERANG); + assertEquals(WeaponType.RANGED_BOOMERANG, inventory.getEquippedType()); + } + @Test void testGetEquippedType() { - InventoryComponent inventory = new InventoryComponent(weaponConfigs); - inventory.setEquipped("building"); - assertEquals(WeaponType.WOODHAMMER, inventory.getEquippedType()); + inventory.setEquipped("building"); + assertEquals(WeaponType.WOODHAMMER, inventory.getEquippedType()); } @Test void testChangeEquippedType() { - InventoryComponent inventory = new InventoryComponent(weaponConfigs); - inventory.setEquipped("building"); - inventory.changeEquipped(WeaponType.MELEE_WRENCH); - assertEquals(WeaponType.MELEE_WRENCH, inventory.getEquippedType()); + inventory.setEquipped("building"); + inventory.changeEquipped(WeaponType.MELEE_WRENCH); + assertEquals(WeaponType.MELEE_WRENCH, inventory.getEquippedType()); + } + + @Test + public void testChangeEquippedAmmo() { + inventory.changeEquippedAmmo(10); + assertEquals(30, inventory.getCurrentAmmo()); + } + + @Test + public void testGetEquippedCooldown() { + int initialCooldown = inventory.getEquippedCooldown(); + inventory.setEquippedCooldown(5); + assertEquals(5, inventory.getEquippedCooldown()); + inventory.setEquippedCooldown(initialCooldown); } } \ No newline at end of file diff --git a/source/core/src/test/com/csse3200/game/components/player/InventoryDisplayComponentTest.java b/source/core/src/test/com/csse3200/game/components/player/InventoryDisplayComponentTest.java index fef964a18..c383b9156 100644 --- a/source/core/src/test/com/csse3200/game/components/player/InventoryDisplayComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/player/InventoryDisplayComponentTest.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Button; import com.csse3200.game.components.Weapons.WeaponType; -import com.csse3200.game.components.structures.StructureToolPicker; import com.csse3200.game.components.upgradetree.UpgradeTree; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; diff --git a/source/core/src/test/com/csse3200/game/components/player/InventoryItemTest.java b/source/core/src/test/com/csse3200/game/components/player/InventoryItemTest.java new file mode 100644 index 000000000..d7cdedac6 --- /dev/null +++ b/source/core/src/test/com/csse3200/game/components/player/InventoryItemTest.java @@ -0,0 +1,80 @@ +package com.csse3200.game.components.player; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +import org.junit.Before; +import org.junit.Test; + +import com.csse3200.game.components.Weapons.WeaponType; +import com.csse3200.game.entities.configs.PlayerConfig; +import com.csse3200.game.entities.configs.WeaponConfigs; +import com.csse3200.game.files.FileLoader; + +public class InventoryItemTest { + private WeaponConfigs weaponConfigs; + private PlayerConfig playerConfig; + private InventoryComponent.InventoryItem inventoryItem; + + @Before + public void setUp() { + weaponConfigs = FileLoader.readClass(WeaponConfigs.class, "configs/weapons.json"); + playerConfig = mock(PlayerConfig.class); + inventoryItem = new InventoryComponent(weaponConfigs,playerConfig).new InventoryItem(WeaponType.MELEE_WRENCH, 30, 40); + } + + @Test + public void testGetItem() { + assertEquals(WeaponType.MELEE_WRENCH, inventoryItem.getItem()); + } + + @Test + public void testChangeItem() { + inventoryItem.changeItem(WeaponType.RANGED_SLINGSHOT); + assertEquals(WeaponType.RANGED_SLINGSHOT, inventoryItem.getItem()); + } + + @Test + public void testGetAmmo() { + assertEquals(30, inventoryItem.getAmmo()); + } + + @Test + public void testChangeAmmo() { + inventoryItem.changeAmmo(10); + assertEquals(40, inventoryItem.getAmmo()); + + inventoryItem.changeAmmo(-15); + assertEquals(25, inventoryItem.getAmmo()); + } + + @Test + public void testSetMaxAmmo() { + inventoryItem.setMaxAmmo(); + assertEquals(40, inventoryItem.getAmmo()); + } + + @Test + public void testGetMaxAmmo() { + assertEquals(40, inventoryItem.getMaxAmmo()); + } + + @Test + public void testSetAttackCooldown() { + inventoryItem.setAttackCooldown(5); + assertEquals(5, inventoryItem.getAttackCooldown()); + } + + @Test + public void testGetAttackCooldown() { + assertEquals(0, inventoryItem.getAttackCooldown()); + } + + @Test + public void testDecCoolDown() { + inventoryItem.setAttackCooldown(3); + inventoryItem.decCoolDown(); + assertEquals(2, inventoryItem.getAttackCooldown()); + } + +} diff --git a/source/core/src/test/com/csse3200/game/components/player/KeyboardPlayerInputComponentTest.java b/source/core/src/test/com/csse3200/game/components/player/KeyboardPlayerInputComponentTest.java index 3e403cf90..67d38281c 100644 --- a/source/core/src/test/com/csse3200/game/components/player/KeyboardPlayerInputComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/player/KeyboardPlayerInputComponentTest.java @@ -16,66 +16,69 @@ public class KeyboardPlayerInputComponentTest { - @Mock EntityService entityService; + @Mock + EntityService entityService; - @BeforeEach - void setup() { - entityService = new EntityService(); - ServiceLocator.registerEntityService(entityService); - } + @BeforeEach + void setup() { + entityService = new EntityService(); + ServiceLocator.registerEntityService(entityService); + } - private Vector2 direction(KeyboardPlayerInputComponent comp) { - return comp.getDirection(); - } + private Vector2 direction(KeyboardPlayerInputComponent comp) { + return comp.getDirection(); + } - /** - * the below Test has been implemented to - * test the Sound of player's walk Sound - */ - @Test - public void testTriggerWalkEvent() { - Gdx.app = mock(Application.class); + /** + * the below Test has been implemented to + * test the Sound of player's walk Sound + */ + @Test + public void testTriggerWalkEvent() { + Gdx.app = mock(Application.class); -// instance for KeyboardPlayerInputComponent - KeyboardPlayerInputComponent Sound = new KeyboardPlayerInputComponent(); + // instance for KeyboardPlayerInputComponent + KeyboardPlayerInputComponent Sound = new KeyboardPlayerInputComponent(); -// Mocking an 'Entity' object named 'WalkEvent' for testing purposes - Entity WalkEvent = mock(Entity.class); + // Mocking an 'Entity' object named 'WalkEvent' for testing purposes + Entity WalkEvent = mock(Entity.class); -// Setting the 'WalkEvent' as the entity for sound events. - Sound.setEntity(WalkEvent); + // Setting the 'WalkEvent' as the entity for sound events. + Sound.setEntity(WalkEvent); -// Mocking the event handling for the 'WalkEvent' entity. - when(WalkEvent.getEvents()).thenReturn(mock(EventHandler.class)); + // Mocking the event handling for the 'WalkEvent' entity. + when(WalkEvent.getEvents()).thenReturn(mock(EventHandler.class)); -// Testing the whole trigger Walk Event to test Player's walk Sound - Sound.triggerWalkEvent(); - } + // Testing the whole trigger Walk Event to test Player's walk Sound + Sound.triggerWalkEvent(); + } - /** - * the below Test has been implemented to - * test the Sound of player's Dodge Sound - */ - @Test - public void testTriggerDodgeEvent() { + /** + * the below Test has been implemented to + * test the Sound of player's Dodge Sound + */ + @Test + public void testTriggerDodgeEvent() { - Gdx.app = mock(Application.class); + Gdx.app = mock(Application.class); -// instance for KeyboardPlayerInputComponent - KeyboardPlayerInputComponent Sound = new KeyboardPlayerInputComponent(); + // instance for KeyboardPlayerInputComponent + KeyboardPlayerInputComponent Sound = new KeyboardPlayerInputComponent(); -// Setting the 'DodgeEvent' as the entity for sound events. - Entity DodgeEvent = mock(Entity.class); + // Setting the 'DodgeEvent' as the entity for sound events. + Entity DodgeEvent = mock(Entity.class); -// Setting the 'DodgeEvent' as the entity for sound events. - Sound.setEntity(DodgeEvent); + // Setting the 'DodgeEvent' as the entity for sound events. + Sound.setEntity(DodgeEvent); -// Mocking the event handling for the 'DodgeEvent' entity. - when(DodgeEvent.getEvents()).thenReturn(mock(EventHandler.class)); + // Mocking the event handling for the 'DodgeEvent' entity. + when(DodgeEvent.getEvents()).thenReturn(mock(EventHandler.class)); -// Testing the whole trigger Dodge Event to test Player's dodge Sound - Sound.triggerDodgeEvent(); + // Testing the whole trigger Dodge Event to test Player's dodge Sound + Sound.triggerDodgeEvent(); - } + } + + } \ No newline at end of file diff --git a/source/core/src/test/com/csse3200/game/components/player/WeaponComponentTest.java b/source/core/src/test/com/csse3200/game/components/player/WeaponComponentTest.java new file mode 100644 index 000000000..a4bca7940 --- /dev/null +++ b/source/core/src/test/com/csse3200/game/components/player/WeaponComponentTest.java @@ -0,0 +1,4 @@ +import static org.junit.jupiter.api.Assertions.*; +class WeaponComponentTest { + +} \ No newline at end of file diff --git a/source/core/src/test/com/csse3200/game/entities/factories/ShipUpgradesFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/ShipUpgradesFactoryTest.java index 511d21213..25bb9b620 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/ShipUpgradesFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/ShipUpgradesFactoryTest.java @@ -39,8 +39,8 @@ void setUp() { ServiceLocator.registerPhysicsService(new PhysicsService()); ResourceService resourceService = new ResourceService(); ServiceLocator.registerResourceService(resourceService); - String[] shipUpgradesTextures = {"images/powerups/health_potion.png"}; - String[] fuelUpgradesTextures = {"images/powerups/speed_potion.png"}; + String[] shipUpgradesTextures = {"images/powerups/health_boost.png"}; + String[] fuelUpgradesTextures = {"images/powerups/speed_boost.png"}; resourceService.loadTextures(shipUpgradesTextures); resourceService.loadTextures(fuelUpgradesTextures); resourceService.loadAll(); diff --git a/source/core/src/test/com/csse3200/game/screens/PlanetScreenTest.java b/source/core/src/test/com/csse3200/game/screens/PlanetScreenTest.java new file mode 100644 index 000000000..aef74709c --- /dev/null +++ b/source/core/src/test/com/csse3200/game/screens/PlanetScreenTest.java @@ -0,0 +1,52 @@ +package com.csse3200.game.screens; + + +import com.csse3200.game.GdxGame; +import com.csse3200.game.areas.map_config.ConfigLoader; +import com.csse3200.game.areas.map_config.InvalidConfigException; +import com.csse3200.game.areas.map_config.LevelConfig; +import com.csse3200.game.extensions.GameExtension; +import com.csse3200.game.utils.LoadUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; + +@ExtendWith(GameExtension.class) +public class PlanetScreenTest { + GdxGame game; + PlanetScreen screen; + + @BeforeEach + void setup(){ + game = mock(GdxGame.class); + screen = new PlanetScreen(game, "Earth"); + } + + @Test + void testConstructionName(){ + String name = "Earth"; + screen = new PlanetScreen(game, name); + assertEquals(name, screen.name, "Name of planet is different than expected " + name); + } + + @Test + void testNextPlanet() throws InvalidConfigException { + String name = "Earth"; + LevelConfig levelConfig = ConfigLoader.loadLevel(LoadUtils.formatName(name)); + screen = new PlanetScreen(game, name); + assertEquals(levelConfig.nextPlanet, screen.getNextPlanetName(), "Next planet differs"); + } + + @Test + void testStartGameArea(){ + assertEquals("main_area", screen.getCurentAreaName(), "Starting Game Area differs from expected"); + } + + @Test + void testSetInvalidGameArea(){ + assertFalse(screen.setCurrentArea("Invalid Name")); + } +} diff --git a/source/core/src/test/com/csse3200/game/services/PlanetTravelTest.java b/source/core/src/test/com/csse3200/game/services/PlanetTravelTest.java index caf0c263d..e103fa87e 100644 --- a/source/core/src/test/com/csse3200/game/services/PlanetTravelTest.java +++ b/source/core/src/test/com/csse3200/game/services/PlanetTravelTest.java @@ -1,29 +1,35 @@ package com.csse3200.game.services; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.Input; import com.csse3200.game.GdxGame; -import com.csse3200.game.input.InputFactory; +import com.csse3200.game.areas.map_config.ConfigLoader; +import com.csse3200.game.areas.map_config.InvalidConfigException; +import com.csse3200.game.components.CombatStatsComponent; +import com.csse3200.game.entities.Entity; +import com.csse3200.game.entities.EntityService; +import com.csse3200.game.extensions.GameExtension; +import com.csse3200.game.utils.LoadUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - +import org.junit.jupiter.api.extension.ExtendWith; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.*; +@ExtendWith(GameExtension.class) public class PlanetTravelTest { PlanetTravel planetTravel; - GameStateObserver stateObserver; - GdxGame mockGame; - GameStateInteraction stateInteraction; + GdxGame game; + String name; + @BeforeEach - public void setUp() { - InputFactory inputFactoryMock = mock(InputFactory.class); - Input inputMock = mock(Input.class); - Gdx.input = inputMock; - mockGame = mock(GdxGame.class); + public void setUp() throws InvalidConfigException { + game = mock(GdxGame.class); ServiceLocator.registerGameStateObserverService(new GameStateObserver(new GameStateInteraction())); - planetTravel = new PlanetTravel(mockGame); + name = LoadUtils.formatName("Earth"); + ServiceLocator.getGameStateObserverService().trigger("updatePlanet", "currentPlanet", name); + ServiceLocator.getGameStateObserverService().trigger("updatePlanet", "nextPlanet", ConfigLoader.loadLevel(name).nextPlanet); + planetTravel = new PlanetTravel(game); } @AfterEach @@ -32,7 +38,35 @@ public void cleanUp(){ } @Test - public void testPlanetTravel() { + void testServiceSetup() { + assertNotNull(ServiceLocator.getGameStateObserverService(), "Services not correctly loaded"); + } + + @Test + void testFullTravel(){ + planetTravel.beginFullTravel(); + verify(game).setScreen(GdxGame.ScreenType.SPACEMINI_SCREEN); + } + + @Test + void testInstantTravel() throws InvalidConfigException { + planetTravel.beginInstantTravel(); + String nextPlanetName = ConfigLoader.loadLevel(LoadUtils.formatName(name)).nextPlanet; + assertEquals(nextPlanetName, ServiceLocator.getGameStateObserverService().getStateData("currentPlanet"), "new planet Differs than expected"); + } + + @Test + void testReturnToCurrent(){ + EntityService entityService = mock(EntityService.class); + ServiceLocator.registerEntityService(entityService); + when(entityService.getPlayer()).thenReturn(new Entity().addComponent(new CombatStatsComponent(1,1,1,1,false))); + when(entityService.getCompanion()).thenReturn(new Entity().addComponent(new CombatStatsComponent(1,1,1,1,false))); + planetTravel.returnToCurrent(); + assertEquals(name, ServiceLocator.getGameStateObserverService().getStateData("currentPlanet"), "new planet Differs than expected"); + } + + @Test + void testPlanetTravel() { planetTravel.moveToNextPlanet("Earth"); assertEquals("Earth", planetTravel.returnCurrent(), "The state data should match the set data."); //Skip the minigame because we are responsible for testing it. diff --git a/source/core/src/test/com/csse3200/game/windows/LabWindowTest.java b/source/core/src/test/com/csse3200/game/windows/LabWindowTest.java index eb777eb57..a0e08613d 100644 --- a/source/core/src/test/com/csse3200/game/windows/LabWindowTest.java +++ b/source/core/src/test/com/csse3200/game/windows/LabWindowTest.java @@ -7,7 +7,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.csse3200.game.entities.Entity; -import com.csse3200.game.windows.LabWindow; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -33,7 +32,7 @@ public void setUp() { @Test public void labWindowNotNull() { Entity dummyEntity = new Entity(); // Create a dummy entity for testing - LabWindow labWindow = LabWindow.MakeNewLaboratory(); + LabWindow labWindow = LabWindow.makeNewLaboratory(); stage.addActor(labWindow); // Add images of potions in front of the lab window diff --git a/source/core/src/test/com/csse3200/game/windows/PauseWindowTest.java b/source/core/src/test/com/csse3200/game/windows/PauseWindowTest.java deleted file mode 100644 index 32e4d6b4a..000000000 --- a/source/core/src/test/com/csse3200/game/windows/PauseWindowTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.csse3200.game.windows; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class PauseWindowTest { - - @Test - void makeNewPauseWindow() { - } - - @Test - void remove() { - } -} \ No newline at end of file diff --git a/source/saves/savefile.json b/source/saves/savefile.json new file mode 100644 index 000000000..090fc6831 --- /dev/null +++ b/source/saves/savefile.json @@ -0,0 +1,28 @@ +{ + "entities": { + "PlayerConfig": [ + { + "class": "com.csse3200.game.entities.configs.PlayerConfig", + "spritePath": "images/player/player.atlas", + "position": { + "x": 17, + "y": 15 + }, + "health": 100, + "baseAttack": 10, + "lives": 3, + "sounds": { + "soundsMap": { + "low_health": "sounds/playerLow_health.mp3", + "dodge": "sounds/dodgingAlertSweep.mp3", + "boostPowerup": "sounds/playerBoostRecharge.mp3", + "upgradeTreeTap": "sounds/upgradeTreeTap.mp3", + "healthPowerup": "sounds/PlayerHealthRecharge.mp3", + "footstep": "sounds/footStepsInTheForestGround.mp3", + "upgradeWeapon": "sounds/upgradeWeapon.mp3" + } + } + } + ] + } +} \ No newline at end of file