From 827eee5c0fc65112bdcbebd3fd706b241c33b1da Mon Sep 17 00:00:00 2001 From: Aaron <rudkowsk@uni-bremen.de> Date: Wed, 1 Jul 2020 17:25:06 +0100 Subject: [PATCH] some ui trader stuff --- .../galaxytruckerreloaded/Main.java | 19 --- .../Model/Map/Planet.java | 2 +- .../Buttons/InGameButtons/ShopSellButton.java | 41 +++++ .../View/Screen/GamePlay.java | 150 +++++++++++++----- .../View/UI/Events/EventGUI.java | 24 ++- .../View/UI/Events/ShopElement.java | 75 +++++++-- .../View/UI/Events/ShopSellElement.java | 116 ++++++++++++++ .../View/UI/Events/ShopUI.java | 127 +++++++++++++-- .../View/UI/Map/MapUI.java | 7 +- .../View/UI/Ship/ShipView.java | 39 +++-- .../View/UI/ShipInformation/WeaponUI.java | 1 - 11 files changed, 481 insertions(+), 120 deletions(-) create mode 100644 core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/ShopSellButton.java create mode 100644 core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopSellElement.java diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Main.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Main.java index a61d99e1..fdaeae6d 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/Main.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Main.java @@ -18,24 +18,14 @@ public class Main extends Game { public static final int HEIGHT = 1080; public static final String TITLE = "Galaxy Trucker"; - - private GameStateManager gsm; /** * Sprite batch */ public SpriteBatch batch; - /** - * Orthographic camera - */ - private OrthographicCamera camera; - @Override public void create() { batch = new SpriteBatch(); - //gsm = new GameStateManager(); - //this.camera = new OrthographicCamera(); - //gsm.push(new MainMenu(gsm)); setScreen(new MainMenu(this)); } @@ -60,15 +50,6 @@ public class Main extends Game { return this.batch; } - /** - * Get the orthographic camera - * - * @return the orthographic camera - */ - public OrthographicCamera getCamera() { - return this.camera; - } - public void setFullscreen() { Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Model/Map/Planet.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Model/Map/Planet.java index f7a276bd..cf54603a 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/Model/Map/Planet.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Model/Map/Planet.java @@ -43,7 +43,7 @@ public class Planet implements Serializable { * Ereignis dass auf diesem Planeten eintrifft */ @NonNull - private Enum<PlanetEvent> event; + private PlanetEvent event; /** * If already discovered set to true diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/ShopSellButton.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/ShopSellButton.java new file mode 100644 index 00000000..e2a8f02e --- /dev/null +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/ShopSellButton.java @@ -0,0 +1,41 @@ +package com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons; + +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.ImButton; +import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.ShopElement; +import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.ShopSellElement; + +public class ShopSellButton extends ImButton { + /** + * Click sound effect + */ + private Sound clickSound; + + /** + * the ui this button is on + */ + private ShopSellElement shop; + + /** + * Constructor + * + * @param ui the ui this button is on + */ + public ShopSellButton(float x, float y, float width, float height, ShopSellElement ui) { + super(new Texture("sell_buy_on.png"), x, y, width, height); + shop = ui; + this.addListener(new ClickListener() { + public void clicked(InputEvent event, float x, float y) { + leftClick(); + } + }); + } + + public void leftClick() + { + shop.sell(); + } +} diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java index 86ad3aae..fd72b4cd 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java @@ -10,6 +10,7 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.Viewport; +import com.galaxytrucker.galaxytruckerreloaded.Controller.TraderController; import com.galaxytrucker.galaxytruckerreloaded.Main; import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew; import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Overworld; @@ -56,16 +57,6 @@ public class GamePlay implements Screen { */ private Sound clickSound; - /** - * single Player active - */ - private boolean singlePlayer; - - /** - * the map for this game - */ - private Overworld map; - /** * ship of the player */ @@ -101,14 +92,6 @@ public class GamePlay implements Screen { */ private VideoUI videoUI; - /** - * Gets the current open OptionUI - * @return current OptionUI - */ - public OptionUI getOptionUI() { - return optionUI; - } - /** * the ingame options ui, if existing */ @@ -124,24 +107,19 @@ public class GamePlay implements Screen { */ public Stage stage; - public Stage pauseStage; - - private Viewport viewport; - /** - * Pausemenu Object. + * the stage for the buttons of the pause menu */ - private PauseMenu pauseMenu; - + private Stage pauseStage; /** - * Gets the current PauseMenu. - * @return current PauseMenuUI + * the viewport */ - public PauseMenuUI getPauseMenuUI() { - return pauseMenuUI; - } + private Viewport viewport; + /** + * the pause menu ui, if existing + */ private PauseMenuUI pauseMenuUI; /** @@ -153,8 +131,6 @@ public class GamePlay implements Screen { this.main = main; background = new Texture("1080p.png"); - pauseMenu = new PauseMenu(main); - viewport = new FitViewport(main.WIDTH, main.HEIGHT); stage = new Stage(viewport); pauseStage = new Stage(viewport); @@ -221,8 +197,8 @@ public class GamePlay implements Screen { player.render(); - if(shopUI != null) { shopUI.render(); } - else if(eventGUI != null) { eventGUI.render(); } + if(eventGUI != null) { eventGUI.render(); } + else if(shopUI != null) { shopUI.render(); } else if(gameOverUI != null) { gameOverUI.render(); } else if(videoUI != null) { videoUI.render(); } else if(generalUI != null) { generalUI.render(); } @@ -269,23 +245,102 @@ public class GamePlay implements Screen { eventGUI = new EventGUI(main, event, stage, this); } + /** + * remove the event ui from the screen + */ public void deleteEvent() { eventGUI = null; } + /** + * travel to a planet + * call to travelController + * + * if valid request, travel to new planet with execution of event etc + * if not, error message? + * + * @param planet the target planet + * @return whether or not it is a valid request + */ + public boolean travel(Planet planet) { + boolean success = true; //TODO call to controller + if(success) { + createEvent(planet.getEvent()); + if(planet.getEvent() == PlanetEvent.SHOP) { + createShop(planet.getTrader()); + } + } + return success; + } + /** * shop ui pops up */ - public void createShop() { - shopUI = new ShopUI(main, stage, this); - } + public void createShop(Trader trader) { + shopUI = new ShopUI(main, stage, this, trader, null, 0); + } //TODO public void deleteShop() { shopUI = null; } - public void buy(int item) { //TODO still not sure how that is gonna work - //call controller + /** + * buy a weapon from the trader + * call to controller + * @param weapon the weapon + */ + public boolean buyWeapon(Weapon weapon) { + return false; + } + + /** + * buy a crew member from the trader + * call to controller + * @param crew the crew member + */ + public boolean buyCrew(Crew crew) { + return false; + } + + /** + * buy fuel from the trader + * call to controller + * @param amount the amount of fuel + */ + public boolean buyFuel(int amount) { + return false; + } + + /** + * buy missiles from the trader + * call to controller + * @param amount the amount of missiles + */ + public boolean buyMissiles(int amount) { + return false; + } + + /** + * sell missiles to the trader + * @param amount the amount of missiles + * @return successfull? call to controller + */ + public boolean sellMissiles(int amount) { return false; } + + /** + * sell weapon to trader + * @param weapon the weapon + * @return successfull? call to controller + */ + public boolean sellWeapon(Weapon weapon) { return false; } + + /** + * buy hp from the trader + * call to controller + * @param amount the amount of hp + */ + public boolean buyHp(int amount) { + return false; } public void createGameOver(boolean won) { @@ -433,7 +488,7 @@ public class GamePlay implements Screen { @Override public void pause() { - pauseMenu.render(1); + } @Override @@ -455,6 +510,19 @@ public class GamePlay implements Screen { this.background = background; } + /** + * Gets the current open OptionUI + * @return current OptionUI + */ + public OptionUI getOptionUI() { + return optionUI; + } - + /** + * Gets the current PauseMenu. + * @return current PauseMenuUI + */ + public PauseMenuUI getPauseMenuUI() { + return pauseMenuUI; + } } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/EventGUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/EventGUI.java index b3893e32..32df8e1e 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/EventGUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/EventGUI.java @@ -41,10 +41,11 @@ public class EventGUI { */ private Texture backgroundTexture; + /** + * the main class extending game + */ private Main main; - private Stage stage; - /** * the current page */ @@ -64,7 +65,6 @@ public class EventGUI { */ public EventGUI(Main main, PlanetEvent event, Stage stage, GamePlay game) { this.main = main; - this.stage = stage; this.event = event; this.game = game; @@ -100,7 +100,8 @@ public class EventGUI { eventPages.add(currentPage); } else { //VOID - disposeEventGUI(); //TODO was hier? + currentPage = new EventPage(main, null, "this planet is empty", 0, 0); + eventPages.add(currentPage); } } @@ -110,6 +111,9 @@ public class EventGUI { public void disposeEventGUI() { backgroundTexture.dispose(); nextPage.remove(); + for(EventPage p : eventPages) { + p.disposePage(); + } game.deleteEvent(); } @@ -119,7 +123,7 @@ public class EventGUI { */ public void render() { main.batch.begin(); - main.batch.draw(backgroundTexture, 0, 0, 15, 15); //TODO whxy + main.batch.draw(backgroundTexture, 0, 0, 15, 15); main.batch.end(); currentPage.render(); } @@ -137,18 +141,10 @@ public class EventGUI { currentPage = eventPages.remove(0); } else { - done(); + disposeEventGUI(); } } - /** - * call controller to tell that player is done going through the pages - * meaning possible planet event (shop, fight, ...) can start now - */ - private void done() { - - } - /** * Setup called after initialisation diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopElement.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopElement.java index bd0ad3de..cbefb982 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopElement.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopElement.java @@ -3,42 +3,72 @@ package com.galaxytrucker.galaxytruckerreloaded.View.UI.Events; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.scenes.scene2d.Stage; import com.galaxytrucker.galaxytruckerreloaded.Main; +import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew; +import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.ShopBuyButton; public class ShopElement { + /** + * the main class extending game + */ private Main main; - private Stage stage; - - private int id; - + /** + * the button with which to buy something + */ private ShopBuyButton button; + /** + * the texture of this element + */ private Texture texture; + /** + * the position on the screen + */ private float x, y; /** - * the shop ui this button is on + * the weapon, if this is a weapon + */ + private Weapon weapon; + + /** + * the crew member, if this is a crew member + */ + private Crew crew; + + /** + * the amount, if this is fuel, hp or missiles + */ + private int amount; + + /** + * the name (fuel, hp, or missiles) if this is one of those + */ + private String type; + + /** + * the shop ui this element is on */ private ShopUI shop; /** * constructor * @param main the main game class - * @param stage the stage for buttons - * @param id the id of this element * @param texture the texture for this element */ - public ShopElement(Main main, Stage stage, int id, Texture texture, float x, float y, ShopUI shop) { + public ShopElement(Main main, Stage stage, Texture texture, float x, float y, ShopUI shop, Weapon weapon, Crew crew, int amount, String type) { this.main = main; - this.stage = stage; - this.id = id; this.texture = texture; this.x = x; this.y = y; this.shop = shop; + this.weapon = weapon; + this.crew = crew; + this.amount = amount; + this.type = type; button = new ShopBuyButton(0, 0, 10, 10, this); //TODO whxy stage.addActor(button); @@ -59,12 +89,35 @@ public class ShopElement { public void disposeShopElement() { texture.dispose(); button.remove(); + shop.removeBuyElement(this); } /** * button was clicked, this item is to be bought */ public void buy() { - shop.buy(id); + boolean success = false; + if(weapon != null) { + success = shop.buyWeapon(weapon); + } + else if(crew != null) { + success = shop.buyCrew(crew); + } + else if(type != null) { + switch (type) { + case "missiles": + success = shop.buyMissiles(amount); + break; + case "fuel": + success = shop.buyFuel(amount); + break; + case "hp": + success = shop.buyHp(amount); + break; + } + } + if(success) { + disposeShopElement(); + } } } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopSellElement.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopSellElement.java new file mode 100644 index 00000000..83cb1ce8 --- /dev/null +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopSellElement.java @@ -0,0 +1,116 @@ +package com.galaxytrucker.galaxytruckerreloaded.View.UI.Events; + +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.galaxytrucker.galaxytruckerreloaded.Main; +import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon; +import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.ShopSellButton; +import lombok.Getter; + +@Getter +public class ShopSellElement { + + /** + * the main class extending game + */ + private Main main; + + /** + * the button with which to buy something + */ + private ShopSellButton button; + + /** + * the texture of this element + */ + private Texture texture; + + /** + * the position on the screen + */ + private float x, y; + + /** + * the weapon, if this is a weapon + */ + private Weapon weapon; + + /** + * the amount, if this is fuel, hp or missiles + */ + private int amount; + + /** + * the shop ui this element is on + */ + private ShopUI shop; + + /** + * the constructor + * @param main the main class + * @param stage the stage for buttons + * @param texture the texture for this element + * @param x the position + * @param y the position + * @param shop the shop this is on + * @param weapon the weapon if this represents a weapon + * @param amount the amount, if this represents missiles + */ + public ShopSellElement(Main main, Stage stage, Texture texture, float x, float y, ShopUI shop, Weapon weapon, int amount) { + this.main = main; + this.texture = texture; + this.x = x; + this.y = y; + this.shop = shop; + this.weapon = weapon; + this.amount = amount; + + button = new ShopSellButton(0, 0, 10, 10, this); + stage.addActor(button); + } + + /** + * dispose of the shop sell element + */ + public void disposeShopSellElement() { + shop.removeSellElement(this); + texture.dispose(); + button.remove(); + } + + public void render() { + main.batch.begin(); + main.batch.draw(texture, 0, 0, 10, 10); + main.batch.end(); + } + + /** + * buy something + */ + public void sell() { + boolean success = false; + if(weapon != null) { + success = sellWeapon(); + } + else { + success = sellMissiles(); + } + if(success) { + disposeShopSellElement(); + } + } + + /** + * sell a weapon + */ + private boolean sellWeapon() { + return shop.sellWeapon(weapon); + } + + /** + * sell missiles + */ + private boolean sellMissiles() { + return shop.sellMissiles(amount); + } +} diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopUI.java index 6b85f500..76cc4f21 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Events/ShopUI.java @@ -4,6 +4,9 @@ package com.galaxytrucker.galaxytruckerreloaded.View.UI.Events; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.scenes.scene2d.Stage; import com.galaxytrucker.galaxytruckerreloaded.Main; +import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew; +import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Trader; +import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.InventoryCloseButton; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.ShopBuyButton; import com.galaxytrucker.galaxytruckerreloaded.View.Screen.GamePlay; @@ -35,23 +38,64 @@ public class ShopUI { */ private List<ShopElement> elements; - private Main main; + /** + * the items that can be sold + */ + private List<ShopSellElement> sellElements; - private Stage stage; + /** + * the main class extending game + */ + private Main main; + /** + * the screen all of this is on, for the buy/sell methods that need to communicate with the controllers + */ private GamePlay game; /** * constructor * @param main the main class - * TODO wie werden hier die objekte die zum verkauf stehen übergeben? */ - public ShopUI(Main main, Stage stage, GamePlay game) { + public ShopUI(Main main, Stage stage, GamePlay game, Trader trader, List<Weapon> shipWeapons, int shipMissiles) { this.main = main; - this.stage = stage; this.game = game; + // add all the items the trader has to offer to the ui elements = new LinkedList<>(); + //crew stock + for(Crew c : trader.getCrewStock()) { + Texture t; + if(c.getName().equals("ana")) { + t = new Texture("crew/anaerobic.png"); + } + else if(c.getName().equals("battle")) { + t = new Texture("crew/battle.png"); + } + else { + t = new Texture("crew/energy.png"); //TODO wie sieht das mit namen aus? + } + elements.add(new ShopElement(main, stage, t, 0, 0, this, null, c, 0, null)); + } + //weapon stock + for(Weapon w : trader.getWeaponStock()) { + elements.add(new ShopElement(main, stage, new Texture("laser.png"), 0, 0, this, w, null, 0, null)); + } + //fuel + elements.add(new ShopElement(main, stage, new Texture("fuel.png"), 0, 0, this, null, null, trader.getFuelStock(), "fuel")); + //hp + elements.add(new ShopElement(main, stage, new Texture("hp.png"), 0, 0, this, null, null, trader.getHpStock(), "hp")); + //missiles/rockets + elements.add(new ShopElement(main, stage, new Texture("missiles.png"), 0, 0, this, null, null, trader.getMissileStock(), "missiles")); + + //add all the items that can be sold TODO geldanzeige immer ändern + sellElements = new LinkedList<>(); + //missiles + sellElements.add(new ShopSellElement(main, stage, new Texture("missiles.png"), 0, 0, this, null, shipMissiles)); + //weapons + for(Weapon w : shipWeapons) { + sellElements.add(new ShopSellElement(main, stage, new Texture("laser.png"), 0, 0, this, w, 0)); + } closeButton = new InventoryCloseButton(0, 0, 10, 10, this, null); stage.addActor(closeButton); @@ -60,12 +104,60 @@ public class ShopUI { } /** - * an item is bought - * called by button - * @param item the item (index in the list) + * buy a weapon from the trader + * @param weapon the weapon */ - public void buy(int item) { - game.buy(item); + boolean buyWeapon(Weapon weapon) { + return game.buyWeapon(weapon); + } + + /** + * buy a crew member from the trader + * @param crew the crew member + */ + boolean buyCrew(Crew crew) { + return game.buyCrew(crew); + } + + /** + * buy fuel from the trader + * @param amount the amount of fuel + */ + boolean buyFuel(int amount) { + return game.buyFuel(amount); + } + + /** + * buy missiles from the trader + * @param amount the amount of missiles + */ + boolean buyMissiles(int amount) { + return game.buyMissiles(amount); + } + + /** + * buy hp from the trader + * @param amount the amount of hp + */ + boolean buyHp(int amount) { + return game.buyHp(amount); + } + + /** + * sell missiles to the trader + * @param amount the amount + * @return successful? + */ + boolean sellMissiles(int amount) { + return game.sellMissiles(amount); + } + + /** + * sell weapon to trader + * @param weapon the weapon + */ + boolean sellWeapon(Weapon weapon) { + return game.sellWeapon(weapon); } /** @@ -80,6 +172,21 @@ public class ShopUI { game.deleteShop(); } + /** + * remove a buyable element + */ + public void removeBuyElement(ShopElement e) { + elements.remove(e); //TODO add to the list of sellable, if weapon/missiles + } + + /** + * remove a sellable element + * @param e the element + */ + public void removeSellElement(ShopSellElement e) { + sellElements.remove(e); //TODO add to the list of buyable items + } + /** * render without stage stuff */ diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Map/MapUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Map/MapUI.java index 41d7bcc4..2bf3cf9f 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Map/MapUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Map/MapUI.java @@ -73,7 +73,6 @@ public class MapUI { } shipView.deleteMap(); - } /** @@ -82,8 +81,10 @@ public class MapUI { * @param planet the new planet */ public void moveToPlanet(Planet planet) { - //call the controller - disposeMapUI(); + boolean success = shipView.travel(planet); + if(success) { + disposeMapUI(); + } } /** diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Ship/ShipView.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Ship/ShipView.java index 9731464b..9cb9da5d 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Ship/ShipView.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Ship/ShipView.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.scenes.scene2d.Stage; import com.galaxytrucker.galaxytruckerreloaded.Main; import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Overworld; +import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Planet; import com.galaxytrucker.galaxytruckerreloaded.Model.Ship; import com.galaxytrucker.galaxytruckerreloaded.Model.ShipLayout.Room; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.AutofireButton; @@ -55,11 +56,6 @@ public class ShipView extends AbstractShip { */ private MoveButton moveButton; - /** - * the weapon autofire button - */ - private AutofireButton weaponAutofire; - /** * the background texture of the ship */ @@ -93,7 +89,6 @@ public class ShipView extends AbstractShip { /** * Constructor - * TODO methods to access all shipinformation stuff * @param main - the main class for SpriteBatch */ public ShipView(Main main, Ship ship, Stage stage, Overworld map, GamePlay game) { @@ -108,9 +103,8 @@ public class ShipView extends AbstractShip { //TODO wie system das zu raum gehört? dann sys id als key, roomui als value } - weaponAutofire = new AutofireButton(1020, 130, 248, 50, this); - moveButton = new MoveButton(850, main.HEIGHT - 90, 150, 92, this); //TODO same here - inventory = new ShipButton(750,main.HEIGHT - 80, 50, 92, this); //TODO warum ändert sich die größe nicht + moveButton = new MoveButton(850, main.HEIGHT - 90, 150, 92, this); + inventory = new ShipButton(750,main.HEIGHT - 80, 50, 92, this); money = new ScrapUI(main, ship.getCoins()); hull = new HullUI(main, ship.getHp()); @@ -120,7 +114,6 @@ public class ShipView extends AbstractShip { shipRoomBackground = new Texture("ship/anaerobic/an2floor.png"); weaponGeneralBackground = new Texture("shipsys/weapon/generalbox.png"); - stage.addActor(weaponAutofire); stage.addActor(inventory); stage.addActor(moveButton); } @@ -133,7 +126,7 @@ public class ShipView extends AbstractShip { public void render() { main.batch.begin(); - main.batch.draw(shipBackground, main.WIDTH -1730, main.HEIGHT/2 - shipBackground.getHeight()/2 - 200, 1000, 1000); //TODO xywh + main.batch.draw(shipBackground, main.WIDTH -1730, main.HEIGHT/2 - shipBackground.getHeight()/2 - 200, 1000, 1000); main.batch.draw(shipRoomBackground, main.WIDTH -1500, main.HEIGHT/2 - shipRoomBackground.getHeight()/2 - 100, 550, 550); main.batch.draw(weaponGeneralBackground, 700, 100, 328, 90); main.batch.end(); @@ -169,7 +162,6 @@ public class ShipView extends AbstractShip { game.deleteShip(); inventory.remove(); moveButton.remove(); - weaponAutofire.remove(); for(RoomUI r : rooms.values()) { r.disposeRoomUI(); } @@ -216,6 +208,21 @@ public class ShipView extends AbstractShip { } + /** + * travel to a planet + * + * send to gameplay, through that to travelcontroller, which declares whether this jump is possible + * + * if possible, travel to new planet (with execution of event etc) + * if not, error message?? + * + * @param planet the target planet + * @return whether travel valid + */ + public boolean travel(Planet planet) { + return game.travel(planet); + } + public void deleteInventory() { inventoryUI = null; } @@ -283,14 +290,6 @@ public class ShipView extends AbstractShip { public void weaponShot(int weaponid, Room room) { game.weaponShot(weaponid, room);} - /** - * autofire - * called by autofire button - */ - public void autofire() { - //controller call - } - /** * Ship hop animation */ diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/WeaponUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/WeaponUI.java index 337a3a6c..30423312 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/WeaponUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/WeaponUI.java @@ -13,7 +13,6 @@ import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.Weapon /** * shows the weapons of the ship */ -//TODO als subklasse zu subsystemui sobald gemergt mit master public class WeaponUI extends SubsystemUI { /** Weapon coolDown */ -- GitLab