Shop überarbeitet

This commit is contained in:
Sosch 2014-11-11 14:25:46 +01:00
parent 04944e0391
commit b034e68138
9 changed files with 121 additions and 30 deletions

BIN
res/images/shopTest01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
res/images/shopTest02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -18,14 +18,14 @@ public class Player extends ShootingEntity implements KeyboardListener {
super(x, y);
this.setImage("images/ship.png");
this.setPrimaryShotImage("images/shots/laser_blue.png");
this.setShootDamage(PlayerStatus.ShootDamage);
this.setShootDamage(StaticValue.ShootDamage);
this.setShootDelay(20);
this.setShootSpawn(50, 16);
this.setShootDirection(Shot.RIGHT);
this.setShootSpeed(10);
this.setCollisionDamage(10);
this.setShieldPoints(100);
this.setHealthPoints(PlayerStatus.HealthPoints);
this.setShieldPoints(StaticValue.ShieldPoints);
this.setHealthPoints(StaticValue.HealthPoints);
this.registerOnKeyboard(Keyboard.getInstance());
}

View File

@ -1,11 +0,0 @@
package de.teamteamteam.spacescooter.entity;
public class PlayerStatus {
/**
* Status values for the player
*/
public static int ShootDamage = 5;
public static int HealthPoints = 100;
}

View File

@ -0,0 +1,18 @@
package de.teamteamteam.spacescooter.entity;
public class StaticValue {
/**
* Values for the player
*/
public static int ShootDamage = 5;
public static int HealthPoints = 100;
public static int ShieldPoints = 100;
/**
* Values for the Shop
*/
public static int schaden = 0;
public static int schild = 0;
public static int leben = 0;
}

View File

@ -12,6 +12,5 @@ public class Credits {
public static void setCredits(int credits) {
Credits.credits = credits;
System.out.println(credits);
}
}

View File

@ -0,0 +1,51 @@
package de.teamteamteam.spacescooter.gui;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import de.teamteamteam.spacescooter.entity.Entity;
public class ShopOffer extends Entity{
private String offer;
private int gekauft;
private int max;
public ShopOffer(int x, int y, int max, int gekauft, String offer) {
super(x, y);
this.offer = offer;
this.gekauft = gekauft;
this.max = max;
for (int i = 0; i<max; i++){
if(i<gekauft){
new ShopOfferValue(x + 100 + i*35, y, "images/shopTest02.png");
}else{
new ShopOfferValue(x + 100 + i*35, y, "images/shopTest01.png");
}
}
}
@Override
public void paint(Graphics2D g) {
g.setFont(new Font("Monospace", 0, 20));
g.setColor(new Color(255, 255, 255));
g.drawString(offer, this.getX(), this.getY()+20);
}
public void update() {}
public void buy(){
new ShopOfferValue(this.getX() + 100 + gekauft*35, this.getY(), "images/shopTest02.png");
gekauft++;
}
public int getGekauft() {
return gekauft;
}
public int getMax() {
return max;
}
}

View File

@ -0,0 +1,13 @@
package de.teamteamteam.spacescooter.gui;
import de.teamteamteam.spacescooter.entity.Entity;
public class ShopOfferValue extends Entity{
public ShopOfferValue(int x, int y, String filename) {
super(x, y);
setImage(filename);
}
public void update(){}
}

View File

@ -8,9 +8,10 @@ import java.awt.image.BufferedImage;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.entity.Player;
import de.teamteamteam.spacescooter.entity.PlayerStatus;
import de.teamteamteam.spacescooter.entity.StaticValue;
import de.teamteamteam.spacescooter.gui.Button;
import de.teamteamteam.spacescooter.gui.Credits;
import de.teamteamteam.spacescooter.gui.ShopOffer;
import de.teamteamteam.spacescooter.utility.GameConfig;
import de.teamteamteam.spacescooter.utility.Loader;
@ -22,14 +23,18 @@ public class ShopScreen extends Screen {
private boolean keyPressed = false;
private Player player;
private int animationStatus = 0; //0 = Animation noch nicht gestartet, 1 = Animation laeuft, 2 = Animation beendet
private ShopOffer schaden;
private ShopOffer schild;
private ShopOffer leben;
public ShopScreen(Screen parent) {
super(parent);
this.img = Loader.getBufferedImageByFilename("images/testbackground.png");
new Button(GameConfig.windowWidth/2-125, 250);
new Button(GameConfig.windowWidth/2-125, 350);
new Button(GameConfig.windowWidth/2-125, 450);
player = new Player(GameConfig.windowWidth/2-170, 259);
schaden = new ShopOffer(100, 160, 15, StaticValue.schaden, "Schaden");
schild = new ShopOffer(100, 260, 15, StaticValue.schild, "Schild");
leben = new ShopOffer(100, 360, 15, StaticValue.leben, "Leben");
player = new Player(50, 159);
player.setCanMove(false);
player.setCanShoot(false);
}
@ -43,43 +48,59 @@ public class ShopScreen extends Screen {
}
g.setFont(new Font("Monospace", 0, 20));
g.setColor(new Color(255, 255, 255));
g.drawString("Credits: " + String.valueOf(Credits.getCredits()), GameConfig.windowWidth/2-30, 200);
g.drawString("Credits: " + String.valueOf(Credits.getCredits()), GameConfig.windowWidth/2-30, 100);
g.setColor(new Color(0, 0, 0));
g.drawString("Schaden", GameConfig.windowWidth/2-30, 282);
g.drawString("Leben", GameConfig.windowWidth/2-50, 382);
g.drawString("Hauptmen\u00fc", GameConfig.windowWidth/2-50, 482);
g.drawString("Hauptmen\u00fc", GameConfig.windowWidth/2-55, 482);
}
@Override
protected void update() {
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN) && !this.keyPressed && this.animationStatus == 0) {
this.keyPressed = true;
if(this.menuPoint<2){
if(this.menuPoint<3){
this.menuPoint++;
this.player.setPosition(this.player.getX(), 259+(this.menuPoint*100));
if(menuPoint == 3){
this.player.setPosition(GameConfig.windowWidth/2-170, this.player.getY());
}
this.player.setPosition(this.player.getX(), 159+(this.menuPoint*100));
}
}else if(Keyboard.isKeyDown(KeyEvent.VK_UP) && !this.keyPressed && this.animationStatus == 0) {
this.keyPressed = true;
if(this.menuPoint>0) {
this.menuPoint--;
this.player.setPosition(this.player.getX(), 259+(this.menuPoint*100));
this.player.setPosition(50, this.player.getY());
this.player.setPosition(this.player.getX(), 159+(this.menuPoint*100));
}
}else if(Keyboard.isKeyDown(KeyEvent.VK_ENTER) && !this.keyPressed && this.animationStatus == 0) {
this.keyPressed = true;
///////////////////////////////////////////////////////////////
switch (this.menuPoint) {
case 0:
if(Credits.getCredits() >= 5){
PlayerStatus.ShootDamage += 5;
if(Credits.getCredits() >= 5 && schaden.getGekauft() < schaden.getMax()){
schaden.buy();
StaticValue.ShootDamage += 5;
StaticValue.schaden++;
Credits.setCredits(Credits.getCredits() - 5);
System.out.println(schaden.getGekauft());
}
break;
case 1:
if(Credits.getCredits() >= 10){
PlayerStatus.HealthPoints += 10;
if(Credits.getCredits() >= 10 && schild.getGekauft() < schild.getMax()){
schild.buy();
StaticValue.ShieldPoints += 10;
StaticValue.schild++;
Credits.setCredits(Credits.getCredits() - 10);
}
break;
case 2:
if(Credits.getCredits() >= 10 && leben.getGekauft() < leben.getMax()){
leben.buy();
StaticValue.HealthPoints += 10;
StaticValue.leben++;
Credits.setCredits(Credits.getCredits() - 10);
}
break;
case 3:
this.animationStatus = 1;
break;
}