From d12d00d1b2caa5781d2bea9b52f5edbc1edcebe0 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Tue, 9 Dec 2014 13:45:52 +0100 Subject: [PATCH] Rename attributes of PlayerSession. --- .../spacescooter/brain/PlayerSession.java | 84 +++++++++---------- .../spacescooter/entity/Player.java | 12 +-- .../entity/item/ItemIncreaseDamage.java | 9 +- .../spacescooter/screen/ShopScreen.java | 18 ++-- 4 files changed, 65 insertions(+), 58 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/brain/PlayerSession.java b/src/de/teamteamteam/spacescooter/brain/PlayerSession.java index 458d0b2..56d9787 100644 --- a/src/de/teamteamteam/spacescooter/brain/PlayerSession.java +++ b/src/de/teamteamteam/spacescooter/brain/PlayerSession.java @@ -21,34 +21,34 @@ public class PlayerSession { * Damage value of the normal Shots the ship fires. * This can be changed by upgrades in the shop. */ - private static int shipShotDamage; + private static int baseShotDamage; /** * The ships default maximum shield points. * This can be changed by upgrades in the shop. */ - private static int shipShieldPoints; + private static int baseShieldPoints; /** * The ships default maximum health points. * This can be changed by upgrades in the shop. */ - private static int shipHealthPoints; + private static int baseHealthPoints; /** * The number of health upgrades the player bought for the ship. */ - private static int shipHealthUpgadesBought; + private static int baseHealthUpgadesBought; /** * The number of shield upgrades the player bought for the ship. */ - private static int shipShieldUpgadesBought; + private static int baseShieldUpgadesBought; /** * The number of shot damage upgrades the player bought for the ship. */ - private static int shipShotUpgadesBought; + private static int baseShotUpgadesBought; /** * The secondary weapon of the ship. @@ -126,106 +126,106 @@ public class PlayerSession { /** * Get the ships maximum health points. */ - public static int getShipHealthPoints() { - return PlayerSession.shipHealthPoints; + public static int getBaseHealthPoints() { + return PlayerSession.baseHealthPoints; } /** * Set the ships maximum health points. */ - public static void setShipHealthPoints(int shipHealthPoints) { - PlayerSession.shipHealthPoints = shipHealthPoints; + public static void setBaseHealthPoints(int baseHealthPoints) { + PlayerSession.baseHealthPoints = baseHealthPoints; } /** * Add to the ships maximum health points. */ - public static void addShipHealthPoints(int shipHealthPoints) { - PlayerSession.shipHealthPoints += shipHealthPoints; + public static void addBaseHealthPoints(int baseHealthPoints) { + PlayerSession.baseHealthPoints += baseHealthPoints; } /** * Get the ships maximum shield points. */ - public static int getShipShieldPoints() { - return PlayerSession.shipShieldPoints; + public static int getBaseShieldPoints() { + return PlayerSession.baseShieldPoints; } /** * Set the ships maximum shield points. */ - public static void setShipShieldPoints(int shipShieldPoints) { - PlayerSession.shipShieldPoints = shipShieldPoints; + public static void setBaseShieldPoints(int baseShieldPoints) { + PlayerSession.baseShieldPoints = baseShieldPoints; } /** * Add to the ships maximum shield points. */ - public static void addShipShieldPoints(int shipShieldPoints) { - PlayerSession.shipShieldPoints += shipShieldPoints; + public static void addBaseShieldPoints(int baseShieldPoints) { + PlayerSession.baseShieldPoints += baseShieldPoints; } /** * Get the ships shot damage value. */ - public static int getShipShotDamage() { - return PlayerSession.shipShotDamage; + public static int getBaseShotDamage() { + return PlayerSession.baseShotDamage; } /** * Set the ships shot damage value. */ - public static void setShipShotDamage(int shipShotDamage) { - PlayerSession.shipShotDamage = shipShotDamage; + public static void setBaseShotDamage(int baseShotDamage) { + PlayerSession.baseShotDamage = baseShotDamage; } /** * Add to the ships shot damage value. */ - public static void addShipShotDamage(int shipShotDamage) { - PlayerSession.shipShotDamage += shipShotDamage; + public static void addBaseShotDamage(int shipShotDamage) { + PlayerSession.baseShotDamage += shipShotDamage; } /** * Get the number of ship health upgrades the player bought in the shop. */ - public static int getShipHealthUpgradesBought() { - return PlayerSession.shipHealthUpgadesBought; + public static int getBaseHealthUpgradesBought() { + return PlayerSession.baseHealthUpgadesBought; } /** * Increment the number of ship health upgrades the player bought. */ - public static void incrementShipHealthUpgradesBought() { - PlayerSession.shipHealthUpgadesBought++; + public static void incrementBaseHealthUpgradesBought() { + PlayerSession.baseHealthUpgadesBought++; } /** * Get the number of ship shield upgrades the player bought in the shop. */ - public static int getShipShieldUpgradesBought() { - return PlayerSession.shipShieldUpgadesBought; + public static int getBaseShieldUpgradesBought() { + return PlayerSession.baseShieldUpgadesBought; } /** * Increment the number of ship shield upgrades the player bought. */ - public static void incrementShipShieldUpgradesBought() { - PlayerSession.shipShieldUpgadesBought++; + public static void incrementBaseShieldUpgradesBought() { + PlayerSession.baseShieldUpgadesBought++; } /** * Get the number of ship shot upgrades the player bought in the shop. */ - public static int getShipShotUpgradesBought() { - return PlayerSession.shipShotUpgadesBought; + public static int getBaseShotUpgradesBought() { + return PlayerSession.baseShotUpgadesBought; } /** * Increment the number of ship shot upgrades the player bought. */ - public static void incrementShipShotUpgradesBought() { - PlayerSession.shipShotUpgadesBought++; + public static void incrementBaseShotUpgradesBought() { + PlayerSession.baseShotUpgadesBought++; } /** @@ -267,12 +267,12 @@ public class PlayerSession { PlayerSession.score = 0; PlayerSession.secondaryWeapon = 1; PlayerSession.credits = 0; - PlayerSession.shipHealthPoints = GameConfig.initialPlayerHealthPoints; - PlayerSession.shipShieldPoints = GameConfig.initialPlayerShieldPoints; - PlayerSession.shipShotDamage = GameConfig.initialPlayerShotDamage; - PlayerSession.shipHealthUpgadesBought = 0; - PlayerSession.shipShieldUpgadesBought = 0; - PlayerSession.shipShotUpgadesBought = 0; + PlayerSession.baseHealthPoints = GameConfig.initialPlayerHealthPoints; + PlayerSession.baseShieldPoints = GameConfig.initialPlayerShieldPoints; + PlayerSession.baseShotDamage = GameConfig.initialPlayerShotDamage; + PlayerSession.baseHealthUpgadesBought = 0; + PlayerSession.baseShieldUpgadesBought = 0; + PlayerSession.baseShotUpgadesBought = 0; } } diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index 721ca0f..79a5e63 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -66,11 +66,11 @@ public class Player extends ShootingEntity implements KeyboardListener { this.setShootSpeed(10); this.setCollisionDamage(5); this.setScore(0); - this.setHealthPoints(PlayerSession.getShipHealthPoints()); - this.setMaximumHealthPoints(PlayerSession.getShipHealthPoints()); - this.setShieldPoints(PlayerSession.getShipShieldPoints()); - this.setMaximumShieldPoints(PlayerSession.getShipShieldPoints()); - this.setShootDamage((PlayerSession.getShipShotDamage())/2); + this.setHealthPoints(PlayerSession.getBaseHealthPoints()); + this.setMaximumHealthPoints(PlayerSession.getBaseHealthPoints()); + this.setShieldPoints(PlayerSession.getBaseShieldPoints()); + this.setMaximumShieldPoints(PlayerSession.getBaseShieldPoints()); + this.setShootDamage(PlayerSession.getBaseShotDamage()); this.registerOnKeyboard(Keyboard.getInstance()); } @@ -175,7 +175,7 @@ public class Player extends ShootingEntity implements KeyboardListener { } super.remove(); } - + /** * keyPressed method, comes in handy when a key on the keyboard is pressed */ diff --git a/src/de/teamteamteam/spacescooter/entity/item/ItemIncreaseDamage.java b/src/de/teamteamteam/spacescooter/entity/item/ItemIncreaseDamage.java index 06240e8..e39bbb0 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/ItemIncreaseDamage.java +++ b/src/de/teamteamteam/spacescooter/entity/item/ItemIncreaseDamage.java @@ -10,9 +10,16 @@ public class ItemIncreaseDamage extends Item { this.setImage("images/items/item.png"); } + /** + * Increase shoot damage of Player if not above 25. + */ @Override public void itemCollected(Player player) { - player.setShootDamage(player.getShootDamage()+5); + if(player.getShootDamage() > 25) { + return; + } else { + player.setShootDamage(player.getShootDamage()+5); + } } } diff --git a/src/de/teamteamteam/spacescooter/screen/ShopScreen.java b/src/de/teamteamteam/spacescooter/screen/ShopScreen.java index 418a332..6bc9d03 100644 --- a/src/de/teamteamteam/spacescooter/screen/ShopScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/ShopScreen.java @@ -35,9 +35,9 @@ public class ShopScreen extends Screen { super(parent); this.img = Loader.getBufferedImageByFilename("images/shopbackground.png"); new Button(GameConfig.windowWidth/2-125, 500); - damage = new ShopOffer(100, 150, 15, PlayerSession.getShipShotUpgradesBought(), "Schaden 5C"); - shield = new ShopOffer(100, 225, 15, PlayerSession.getShipShieldUpgradesBought(), "Schild 10C"); - life = new ShopOffer(100, 300, 15, PlayerSession.getShipHealthUpgradesBought(), "Leben 10C"); + damage = new ShopOffer(100, 150, 15, PlayerSession.getBaseShotUpgradesBought(), "Schaden 5C"); + shield = new ShopOffer(100, 225, 15, PlayerSession.getBaseShieldUpgradesBought(), "Schild 10C"); + life = new ShopOffer(100, 300, 15, PlayerSession.getBaseHealthUpgradesBought(), "Leben 10C"); new ImageEntity(GameConfig.windowWidth / 2 - 120, 365, "images/shop/shoprocket.png"); new ImageEntity(GameConfig.windowWidth / 2 + 30, 365, "images/shop/shopbeam.png"); if(PlayerSession.getSecondsecondaryWeapon() == 1){ @@ -106,24 +106,24 @@ public class ShopScreen extends Screen { case 0: if(PlayerSession.getCredits() >= 5 && damage.getBought() < damage.getMax()){ damage.buy(); - PlayerSession.addShipShotDamage(5); - PlayerSession.incrementShipShotUpgradesBought(); + PlayerSession.addBaseShotDamage(5); + PlayerSession.incrementBaseShotUpgradesBought(); PlayerSession.removeCredits(5); } break; case 1: if(PlayerSession.getCredits() >= 10 && shield.getBought() < shield.getMax()){ shield.buy(); - PlayerSession.addShipShieldPoints(10); - PlayerSession.incrementShipShieldUpgradesBought(); + PlayerSession.addBaseShieldPoints(10); + PlayerSession.incrementBaseShieldUpgradesBought(); PlayerSession.removeCredits(10); } break; case 2: if(PlayerSession.getCredits() >= 10 && life.getBought() < life.getMax()){ life.buy(); - PlayerSession.addShipHealthPoints(10); - PlayerSession.incrementShipHealthUpgradesBought(); + PlayerSession.addBaseHealthPoints(10); + PlayerSession.incrementBaseHealthUpgradesBought(); PlayerSession.removeCredits(10); } break;