Search in sources :

Example 1 with World

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();
        }
    }
}
Also used : Player(de.gg.game.model.entities.Player) OffsettableImageTextButton(de.gg.engine.ui.components.OffsettableImageTextButton) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Button(com.badlogic.gdx.scenes.scene2d.ui.Button) OffsettableImageTextButton(de.gg.engine.ui.components.OffsettableImageTextButton) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) ButtonClickListener(de.gg.game.input.ButtonClickListener) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) CharacterComponent(de.gg.game.ui.components.CharacterComponent) BallotOption(de.gg.game.model.votes.BallotOption) OffsettableImageTextButton(de.gg.engine.ui.components.OffsettableImageTextButton) World(de.gg.game.model.World) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with World

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
}
Also used : World(de.gg.game.model.World)

Example 3 with World

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())));
}
Also used : GameSession(de.gg.game.session.GameSession) Player(de.gg.game.model.entities.Player) World(de.gg.game.model.World)

Example 4 with World

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);
}
Also used : GameSession(de.gg.game.session.GameSession) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) Model(com.badlogic.gdx.graphics.g3d.Model) Material(com.badlogic.gdx.graphics.g3d.Material) ProjektGGApplication(de.gg.game.core.ProjektGGApplication) World(de.gg.game.model.World) SelectableRenderData(de.gg.game.ui.rendering.SelectableRenderData) BuildingSlot(de.gg.game.model.entities.BuildingSlot)

Example 5 with World

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;
}
Also used : TickCounter(de.gg.engine.misc.TickCounter) LobbyPlayer(de.gg.game.network.LobbyPlayer) Player(de.gg.game.model.entities.Player) World(de.gg.game.model.World) LobbyPlayer(de.gg.game.network.LobbyPlayer) RoundEndSystem(de.gg.game.systems.smp.RoundEndSystem) TickHandler(de.gg.engine.misc.TickCounter.TickHandler)

Aggregations

World (de.gg.game.model.World)5 Player (de.gg.game.model.entities.Player)3 GameSession (de.gg.game.session.GameSession)2 Material (com.badlogic.gdx.graphics.g3d.Material)1 Model (com.badlogic.gdx.graphics.g3d.Model)1 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)1 Button (com.badlogic.gdx.scenes.scene2d.ui.Button)1 ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 Subscribe (com.google.common.eventbus.Subscribe)1 TickCounter (de.gg.engine.misc.TickCounter)1 TickHandler (de.gg.engine.misc.TickCounter.TickHandler)1 OffsettableImageTextButton (de.gg.engine.ui.components.OffsettableImageTextButton)1 ProjektGGApplication (de.gg.game.core.ProjektGGApplication)1 ButtonClickListener (de.gg.game.input.ButtonClickListener)1 BuildingSlot (de.gg.game.model.entities.BuildingSlot)1 BallotOption (de.gg.game.model.votes.BallotOption)1 LobbyPlayer (de.gg.game.network.LobbyPlayer)1 RoundEndSystem (de.gg.game.systems.smp.RoundEndSystem)1 CharacterComponent (de.gg.game.ui.components.CharacterComponent)1