use of de.gg.game.model.World in project ProjektGG by eskalon.
the class GameBallotScreen method onNewBallot.
@Subscribe
private void onNewBallot(NewBallotEvent ev) {
if (ev.getNewBallot() == null) {
application.getScreenManager().pushScreen("map", "circle_open");
return;
}
World world = application.getClient().getSession().getWorld();
Player localPlayer = application.getClient().getLocalPlayer();
optionTable.clear();
voterTable.clear();
buttons.clear();
infoText.setText(ev.getNewBallot().getInfoText());
// Display the voters
voterTable.add(new Label(Lang.get("screen.vote.voters"), skin, "title")).padBottom(12).row();
for (short s : ev.getNewBallot().getVoters()) {
// PositionType posT = world.getCharacter(s).getPosition();
boolean isLocalPlayer = s == application.getClient().getLocalPlayer().getCurrentlyPlayedCharacterId();
voterTable.add(new CharacterComponent(skin, world.getCharacter(s), isLocalPlayer ? -1 : application.getClient().getOpinionOfOtherCharacter(s))).left().padBottom(25).row();
}
// Display the options (if the player can vote)
if (ev.getNewBallot().getVoters().contains(localPlayer.getCurrentlyPlayedCharacterId())) {
for (BallotOption option : ev.getNewBallot().getOptions()) {
ImageTextButton button = new OffsettableImageTextButton(Lang.get(option), skin, 5);
button.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
application.getClient().getActionHandler().castVote(option.getValue());
for (Button b : buttons) {
b.setDisabled(true);
b.setTouchable(Touchable.disabled);
}
}
});
buttons.add(button);
if (option.isCharacter() && option.getValue() != application.getClient().getLocalPlayer().getCurrentlyPlayedCharacterId()) {
// PositionType posT = world.getCharacters()
// .get((short) option.getValue()).getPosition();
optionTable.add(new CharacterComponent(skin, world.getCharacter((short) option.getValue()), application.getClient().getOpinionOfOtherCharacter((short) option.getValue()))).right().padBottom(8).row();
}
optionTable.add(button).right().padBottom(15).row();
}
}
}
use of de.gg.game.model.World in project ProjektGG by eskalon.
the class GameTownHallInteriorScreen method setUIValues.
@Override
protected void setUIValues() {
World world = application.getClient().getSession().getWorld();
// Building b =
// world.getBuildingSlots()[(short)pushParams[0]].getBuilding();
short playerCharId = application.getClient().getLocalPlayer().getCurrentlyPlayedCharacterId();
// Buy citizenship
if (world.getCharacter(playerCharId).getStatus() == SocialStatus.NON_CITIZEN && application.getClient().getLocalPlayer().getFortune(world) >= SocialStatus.NON_CITIZEN.getFortuneRequirement()) {
applyForCitizenshipButton.setDisabled(false);
} else {
applyForCitizenshipButton.setDisabled(true);
}
// Apply for position
// TODO check whether positions aer available
}
use of de.gg.game.model.World in project ProjektGG by eskalon.
the class GameMapScreen method setUIValues.
@Override
protected void setUIValues() {
GameSession session = application.getClient().getSession();
World world = session.getWorld();
Player player = application.getClient().getLocalPlayer();
if (pushParams != null) {
// Is a new game
gameRenderer.resetCamera();
selectionInputController.setWorld(world);
gameSpeedInputProcessor.setClientActionHandler(application.getClient().getActionHandler());
iconButton.getStyle().imageUp = skin.getDrawable(player.getIcon().getShieldDrawableName());
}
selectionInputController.resetSelection();
movementInputController.resetInput();
dateLabel.setText(Lang.get("screen.map.time", GameClock.getSeason(session.getCurrentRound()), GameClock.getYear(session.getCurrentRound())));
}
use of de.gg.game.model.World in project ProjektGG by eskalon.
the class GameLoadingScreen method onFinishedLoading.
@Override
protected void onFinishedLoading() {
GameSession session = ((ProjektGGApplication) application).getClient().getSession();
World world = session.getWorld();
// Create the ModelInstances
for (BuildingSlot s : world.getBuildingSlots()) {
if (s.isBuiltOn()) {
s.getBuilding().setRenderData(new SelectableRenderData(application.getAssetManager().get(s.getBuilding().getType().getModelPath(), Model.class)));
// FIXME siehe AuthoritativeSession#init(...)
s.getBuilding().getRenderData().transform.translate(s.getPosX(), 0, s.getPosZ());
s.getBuilding().getRenderData().transform.rotate(Y_AXIS, s.getRotationToStreet());
// TODO Use _one_ scene for all models?
// new SelectableRenderData(scene,
// building1.getType().getNodeName(), true);
}
}
Model skyboxModel = application.getAssetManager().get(session.getSessionSetup().getMap().getSkyboxPath(), Model.class);
for (Material m : skyboxModel.materials) {
// fixes a bug related to changes in gdx 1.9.9, see
// https://github.com/libgdx/libgdx/issues/5529
m.remove(ColorAttribute.Emissive);
}
world.setSkybox(new ModelInstance(skyboxModel));
Log.info("Client", "Game assets loaded");
if (((ProjektGGApplication) application).isHost()) {
((ProjektGGApplication) application).getServer().startMatch();
Log.info("Server", "Game started!");
}
application.getScreenManager().pushScreen("round_end", "simple_zoom", 1);
}
use of de.gg.game.model.World in project ProjektGG by eskalon.
the class GameSession method init.
/**
* Sets the game up by initializing the world, the game entities and the
* processing systems.
* <p>
* After the initialization the session can be updated via calling
* {@link #update()}. To resume the game after a round ended
* {@link #startNextRound()} has to get called.
*
* @param players
* A hashmap of all players in this session.
* @param savedGame
* <i>Not</i> <code>null</code> if this is a loaded game state.
*/
public synchronized void init(HashMap<Short, LobbyPlayer> players, @Nullable SavedGame savedGame) {
if (savedGame == null) {
this.world = new World();
this.world.generate(sessionSetup, players);
} else {
this.world = savedGame.world;
this.currentRound = savedGame.currentRound;
// Switch player IDs when loading game
if (savedGame != null) {
for (Entry<Short, LobbyPlayer> newE : players.entrySet()) {
for (Entry<Short, String> oldE : savedGame.clientIdentifiers.entrySet()) {
if (newE.getValue().getHostname().equals(oldE.getValue())) {
// Change all mentions of the saved player id to the
// new one
// Use negative numbers so there are no collisions
Player p = world.getPlayers().remove(oldE.getKey());
world.getPlayers().put((short) -newE.getKey(), p);
}
}
}
// Revert the IDs back to positive numbers
for (short s : savedGame.world.getPlayers().keySet()) {
Player p = world.getPlayers().remove(s);
world.getPlayers().put((short) -s, p);
}
}
// TODO in den Konstruktoren die Setups setzen
// TODO in der Lobby das Setup disablen
}
// Add and initialize the smp system(s)
this.roundEndSystem = new RoundEndSystem(localNetworkId);
this.roundEndSystem.init(world);
// Init the tick counter
this.tickCounter = new TickCounter(new TickHandler() {
@Override
public void onTick() {
fixedUpdate();
}
@Override
public int getDeltaMultiplier() {
return gameSpeed.getDeltaTimeMultiplied();
}
}, TICKS_PER_ROUND, TICK_DURATION, savedGame == null ? 0 : savedGame.lastProcessedTick);
this.initialized = true;
}
Aggregations