public void update(double dt) { CrewUpdateEvent event = new CrewUpdateEvent(dt, this); if (homeShip != null) { FTLGame.instance().getShip(homeShip).EVENT_BUS.post(event); } if (state == CrewStates.WALKING) { pathfinder.update(dt, this); posX = pathfinder.getX(); posY = pathfinder.getY(); if (pathfinder.state == 0) { state = CrewStates.IDLE; } } else if (state == CrewStates.REPAIRING) { AbstractShipSystem system = room.getSystem(); if (system != null) { system.repair(dt, this); if (system.getDamage() == 0) { state = CrewStates.IDLE; } } } else if (state == CrewStates.MANNING) { AbstractShipSystem system = room.getSystem(); if (system.getDamage() > 0) { system.unmann(); state = CrewStates.REPAIRING; } else if (!system.isPowered()) { system.unmann(); state = CrewStates.IDLE; } } else if (state == CrewStates.FIGHTING) { // TODO: Fight } else if (state == CrewStates.IDLE) { AbstractShipSystem system = room.getSystem(); // System.out.println(name + " " + system.isPowered()); if (system != null && system.getDamage() > 0) { state = CrewStates.REPAIRING; } else if (system != null && system.canMann() && !system.isManned() && system.isPowered()) { int stationX = system.getStationX(); int stationY = system.getStationY(); if (stationX + getRoom().getX() == getX() && stationY + getRoom().getY() == getY()) { system.mann(this); state = CrewStates.MANNING; } else { if (!room.getTile(stationX, stationY).getProperties().containsValue("crew")) move(getRoom(), stationX, stationY); } } } }
public void jump(int star) { if (ftlDriveCharge == 1) { game.shipJump(this, star); } }
public void render(SpriteBatch batch, Door door, int shipOffsetX, int shipOffsetY) { Texture texture = TextureRegistry.getTexture("doors"); if (spriteState < 4 && (door.open || door.forceOpen || (door.getLink() != null && door.getLink().open))) { spriteState++; if (spriteState > 4) spriteState = 4; } if (spriteState > 0 && !(door.open || door.forceOpen || (door.getLink() != null && door.getLink().open))) { spriteState--; if (spriteState < 0) spriteState = 0; } int u = spriteState; int v = 0; v = door.room1.getShip().getSystem("doors").getPower() - 1; TextureRegion region = new TextureRegion(texture, u * 35, v * 35, 35, 35); int mouseX = Gdx.input.getX() - shipOffsetX; int mouseY = (Gdx.graphics.getHeight() - Gdx.input.getY()) - shipOffsetY; boolean hover = false; int shrinkH = 5; int shrinkV = 10; float doorAlpha = 0.75f; if (FTLGame.instance().getPlayer() != null && FTLGame.instance().getPlayer().getName().equals(door.room1.getShip().getName())) { if (door.direction == Direction.RIGHT || door.direction == Direction.LEFT) if (mouseX > door.getX() * 35 - 35 / 2 + shrinkV && mouseX < door.getX() * 35 + 35 / 2 - shrinkV && mouseY > door.getY() * 35 + shrinkH && mouseY < door.getY() * 35 + 35 - shrinkH) hover = true; if (door.direction == Direction.UP || door.direction == Direction.DOWN) if (mouseX > door.getX() * 35 + shrinkH && mouseX < door.getX() * 35 + 35 - shrinkH && mouseY > door.getY() * 35 - 35 / 2 + shrinkV && mouseY < door.getY() * 35 + 35 / 2 - shrinkV) hover = true; } if (FTLView.inputHandler.selected != null) hover = false; Texture doorHighlight = TextureRegistry.getTexture("door_highlight"); if (door.direction == Direction.LEFT) { if (hover) { batch.setColor(1, 1, 1, doorAlpha); batch.draw( doorHighlight, shipOffsetX + (float) (door.getX() - 0.5) * 35 + 1, shipOffsetY + (float) (door.getY()) * 35); batch.setColor(1, 1, 1, 1); } batch.draw( region, shipOffsetX + (float) (door.getX() - 0.5) * 35 + 1, shipOffsetY + (float) (door.getY()) * 35); } if (door.direction == Direction.RIGHT) { if (hover) { batch.setColor(1, 1, 1, doorAlpha); if (door.getLink() == null) batch.draw( doorHighlight, shipOffsetX + (float) (door.getX() - 0.5) * 35 + 1, shipOffsetY + (float) (door.getY()) * 35); batch.setColor(1, 1, 1, 1); } batch.draw( region, shipOffsetX + (float) (door.getX() - 0.5) * 35 + 1, shipOffsetY + (float) (door.getY()) * 35); } if (door.direction == Direction.DOWN) { if (hover) { batch.setColor(1, 1, 1, doorAlpha); batch.draw( new TextureRegion(doorHighlight), shipOffsetX + (float) (door.getX()) * 35 - 1, shipOffsetY + (float) (door.getY() - 0.5) * 35 + 1, 36 / 2, 36 / 2, 35, 35, 1, 1, 90); batch.setColor(1, 1, 1, 1); } batch.draw( region, shipOffsetX + (float) (door.getX()) * 35 - 1, shipOffsetY + (float) (door.getY() - 0.5) * 35 + 1, 36 / 2, 36 / 2, 35, 35, 1, 1, 90); } if (door.direction == Direction.UP) { if (hover) { batch.setColor(1, 1, 1, doorAlpha); if (door.getLink() == null) batch.draw( new TextureRegion(doorHighlight), shipOffsetX + (float) (door.getX()) * 35 - 1, shipOffsetY + (float) (door.getY() - 0.5) * 35 + 1, 36 / 2, 36 / 2, 35, 35, 1, 1, 90); batch.setColor(1, 1, 1, 1); } batch.draw( region, shipOffsetX + (float) (door.getX()) * 35 - 1, shipOffsetY + (float) (door.getY() - 0.5) * 35 + 1, 36 / 2, 36 / 2, 35, 35, 1, 1, 90); } }
public void setPlayer(boolean value) { if (value == true) FTLGame.instance().setPlayer(this); isPlayer = value; }