@Override public boolean pinch( Vector2 initialFirstPointer, Vector2 initialSecondPointer, Vector2 firstPointer, Vector2 secondPointer) { if (!(initialFirstPointer.equals(oldInitialFirstPointer) && initialSecondPointer.equals(oldInitialSecondPointer))) { oldInitialFirstPointer = initialFirstPointer.cpy(); oldInitialSecondPointer = initialSecondPointer.cpy(); oldScale = gameScreen.getCameraZoom(); } Vector3 center = new Vector3( (firstPointer.x + initialSecondPointer.x) / 2, (firstPointer.y + initialSecondPointer.y) / 2, 0); gameScreen.zoomCamera( center, oldScale * initialFirstPointer.dst(initialSecondPointer) / firstPointer.dst(secondPointer)); return true; }
public void processTouch(Vector2 v) { int touchPositionY = (int) v.y; // check for pressed menu if (touchPositionY >= 0 && touchPositionY <= gameScreen.getMenuHeight()) { setMenuUtilities((int) v.x); } else if (v.x > 1600 && v.x < 1900 && v.y > 250 && v.y < 350 && gameScreen.getGameLogic().isAfterHours()) { processTouch(new Vector2(200, 400)); int index = gameScreen .getGameLogic() .getVenueManager() .getVenueList() .indexOf(gameScreen.getCurrentVenue()); Venue ev = gameScreen.getGameLogic().resetVenue(index); gameScreen.setVenue(ev); gameScreen.setReportSummaryOpen(false); } }
@Override public boolean pan(float x, float y, float deltaX, float deltaY) { gameScreen.moveCamera(deltaX, deltaY); return true; }
@Override public boolean tap(float x, float y, int count, int button) { Vector2 actualTouch = gameScreen.menuUnproject(x, y); processTouch(actualTouch); return false; }
@Override public boolean scrolled(int amount) { Vector3 mouse = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0); gameScreen.zoomCamera(mouse, gameScreen.getCameraZoom() - (amount * SCROLL_SCALE)); return false; }
public void setMenuUtilities(int x) { float unit = 1920 / (gameScreen.getMenuBarItems().size() + 1); for (int i = 0; i < gameScreen.getMenuBarItems().size(); i++) { float centerX = gameScreen.getMenuBarItems().get(i).getRight() * unit; String name = gameScreen.getMenuBarItems().get(i).getLeft(); Texture tx = gameScreen.getResourceManager().textures.get("menu_" + name); float leftX = centerX - (tx.getWidth() / 2); float rightX = centerX + (tx.getWidth() / 2); if (x > leftX && x < rightX && name.equals("stock")) { menuStack.push(new StockMenu(gameScreen)); gameScreen.getGameLogic().setPaused(true); } else if (x > leftX && x < rightX && name.equals("menu")) { menuStack.push(new DishMenu(gameScreen)); gameScreen.getGameLogic().setPaused(true); } else if (x > leftX && x < rightX && name.equals("market")) { menuStack.push(new MarketMenu(gameScreen)); gameScreen.getGameLogic().setPaused(true); } else if (x > leftX && x < rightX && name.equals("staff")) { menuStack.push(new StaffMenu(gameScreen)); gameScreen.getGameLogic().setPaused(true); } else if (x > leftX && x < rightX && name.equals("estate")) { // menuStack.push(new EstateMenu(gameScreen)); if (venue) { gameScreen.setVenue(gameScreen.getGameLogic().getVenueManager().getVenueList().get(1)); venue = false; } else { gameScreen.setVenue(gameScreen.getGameLogic().getVenueManager().getVenueList().get(0)); venue = true; } } else if (x > leftX && x < rightX && name.equals("advertisement")) { menuStack.push(new AdvertisementMenu(gameScreen)); gameScreen.getGameLogic().setPaused(true); } else if (x > leftX && x < rightX && name.equals("reports")) { menuStack.push(new ReportsMenu(gameScreen)); gameScreen.getGameLogic().setPaused(true); } else if (x > leftX && x < rightX && name.equals("friends")) { menuStack.push(new FriendsMenu(gameScreen)); gameScreen.getGameLogic().setPaused(true); } if (!menuStack.isEmpty()) { InputProcessor ip = menuStack.peek().getMenuController(); gameScreen.setInputProcessor(ip); } } }