Esempio n. 1
0
 /** n-ter Spieler im Uhrzeigersinn vom Geber ausgehend =REST(A2-1+$B$1;4)+1 */
 private Player getPlayerLeftFrom(Player pp, int step) throws Exception {
   final int nextPosition = ((pp.getPosition() - 1 + step) % player.size()) + 1;
   for (Player p : player) {
     if (p.getPosition() == nextPosition) return p;
   }
   throw new Exception("next player not found(1)");
 }
Esempio n. 2
0
 /**
  * Updates movement for this local player. The difference between this method and the other player
  * method is that this will make use of sector 2,3 to place the player in a specific position
  * while sector 2,3 is not present in updating of other players (it simply flags local list
  * removal instead).
  *
  * @param player the player to update movement for.
  * @param out the packet to write to.
  */
 public static void updateLocalPlayerMovement(Player player, PacketBuffer.WriteBuffer out) {
   boolean updateRequired = player.getFlags().isUpdateRequired();
   if (player.isNeedsPlacement()) { // Do they need placement?
     out.writeBit(true); // Yes, there is an update.
     int posX = player.getPosition().getLocalX(player.getCurrentRegion());
     int posY = player.getPosition().getLocalY(player.getCurrentRegion());
     appendPlacement(
         out,
         posX,
         posY,
         player.getPosition().getZ(),
         player.isResetMovementQueue(),
         updateRequired);
     // player.setNeedsPlacement(false);
   } else { // No placement update, check for movement.
     int pDir = player.getPrimaryDirection();
     int sDir = player.getSecondaryDirection();
     if (pDir != -1) { // If they moved.
       out.writeBit(true); // Yes, there is an update.
       if (sDir != -1) { // If they ran.
         appendRun(out, pDir, sDir, updateRequired);
       } else { // Movement but no running - they walked.
         appendWalk(out, pDir, updateRequired);
       }
     } else { // No movement.
       if (updateRequired) { // Does the state need to be updated?
         out.writeBit(true); // Yes, there is an update.
         appendStand(out);
       } else { // No update whatsoever.
         out.writeBit(false);
       }
     }
   }
 }
Esempio n. 3
0
  /**
   * Adds a player to the local player list of another player.
   *
   * @param out the packet to write to.
   * @param player the host player.
   * @param other the player being added.
   */
  public static void addPlayer(PacketBuffer.WriteBuffer out, Player player, Player other) {
    out.writeBits(11, other.getSlot()); // Server slot.
    out.writeBit(true); // Yes, an update is required.
    out.writeBit(true); // Discard walking queue(?)

    // Write the relative position.
    Position delta = Misc.delta(player.getPosition(), other.getPosition());
    out.writeBits(5, delta.getY());
    out.writeBits(5, delta.getX());
  }
Esempio n. 4
0
  public void advanceToPlayer() {

    player = getPlayer();

    if (body.getPosition().x < player.getPosition().x - OBJECT_PROXIMITY_TOLERANCE) {
      moveRight();
    } else if (body.getPosition().x > player.getPosition().x + OBJECT_PROXIMITY_TOLERANCE) {
      moveLeft();
    } else {

    }
  }
Esempio n. 5
0
  /**
   * Alle Punkte merken, für Team 1+2 aufsummieren: <br>
   * Team 1: Spieler 1 + 3 <br>
   * Team 2: Spieler 2 + 4 <br>
   */
  private void createGameHistoryRecord() {
    final GameHistory h =
        new GameHistory(
            this.partieNr.get(),
            this.rundenNr.get(),
            this.spielNr.get(),
            this.start,
            this.end,
            this.geber,
            this.trumpfPlayer,
            this.trumpfFarbe,
            this.beet);

    int teamPoints1 = 0, teamPoints2 = 0;
    for (Player p : player) {
      if (p.getPosition() == 1) {
        int pts = sumPoints(p);
        h.setPlayerName1(p.getUsername());
        h.setPlayerPoints1(pts);
        teamPoints1 += pts;
      } else if (p.getPosition() == 2) {
        int pts = sumPoints(p);
        h.setPlayerName2(p.getUsername());
        h.setPlayerPoints2(pts);
        teamPoints2 += pts;
      } else if (p.getPosition() == 3) {
        int pts = sumPoints(p);
        h.setPlayerName3(p.getUsername());
        h.setPlayerPoints3(pts);
        teamPoints1 += pts;
      } else if (p.getPosition() == 4) {
        int pts = sumPoints(p);
        h.setPlayerName4(p.getUsername());
        h.setPlayerPoints4(pts);
        teamPoints2 += pts;
      }
    }
    h.setTeamPoints1(teamPoints1);
    h.setTeamPoints2(teamPoints2);
    // Team 1 hat gespielt
    if (this.trumpfPlayer.getTeamId() == 1) {
      if (teamPoints1 > teamPoints2) h.setTeamGew1(1);
      else h.setTeamGew2(2); // TODO: Bei Kontra 4 !!
    }
    // Team 2 hat gespielt
    else if (this.trumpfPlayer.getTeamId() == 2) {
      if (teamPoints2 > teamPoints1) h.setTeamGew2(1);
      else h.setTeamGew1(2); // TODO: Bei Kontra 4 !!
    }
    this.gameHistory.add(h);
  }
Esempio n. 6
0
File: Map.java Progetto: twhscs/game
 public void setPlayer(Player player) {
   this.player = player;
   player.setMap(this);
   System.out.println(DIMENSIONS);
   player.setPosition(Position.round(new Vector2f(DIMENSIONS.x / 2, DIMENSIONS.y / 2)));
   System.out.println(player.getPosition());
 }
Esempio n. 7
0
 private void sendPlayerMsg(final Player p, final String message) {
   final PlayerCommand pc = new PlayerCommand();
   pc.setPlayerId(p.getId());
   pc.setGameId(gameId);
   pc.setCommandCode(CommandCode.say);
   final MessageInfo mi = new MessageInfo(p.getPosition(), message);
   pc.setMessageInfo(mi);
   this.commandListener.toPlayer(pc);
 }
Esempio n. 8
0
 /**
  * constructor
  *
  * @param data : game data
  * @param enemy : the player who shoot
  */
 public PlayerLaser(GameData data, Player player) {
   super(data, player);
   p = player;
   position =
       new Point(
           (player.getPosition().x + player.image.getWidth() / 2) - 2,
           (player.getPosition().y - player.image.getHeight() / 2) - 2);
   moveDriver.setStrategy(new MoveStrategyStraightLine(position, new Point(position.x, 0), 25));
 }
Esempio n. 9
0
  public void movePlayer(PositionSwitcher movement) {
    Position newPlayerPos = movement.change(player.getPosition());
    Box box = boxIn(newPlayerPos);
    if (canMoveBoxAt(movement, box)) {
      box.move(movement);
      player.move(movement);

    } else if (isEmpty(newPlayerPos)) {
      player.move(movement);
    }
  }
Esempio n. 10
0
File: Map.java Progetto: twhscs/game
  @Override
  public void draw(RenderTarget renderTarget, RenderStates renderStates) {
    int adjustedFrame =
        Math.round((animationFrame * ANIMATION_FRAMES) / (ANIMATION_FRAMES * ANIMATION_SPEED));
    // TODO: Improve efficiency if required. There is no use in looping through tiles immediately
    // adjacent to the
    // start of the chunk.
    // Apply the tile sheet to the tiles.
    RenderStates states = new RenderStates(TILE_SHEET);
    // Get the player's current position.
    Vector2f playerPosition = player.getPosition();
    // Get the window's current size.
    Vector2i windowSize = WINDOW.getSize();

    // Determine how many tiles fit the window horizontally and vertically taking zoom into account,
    // then halve
    // both values.
    int xDistance = (int) Math.ceil(windowSize.x / (TILE_SIZE * 2 / ZOOM));
    int yDistance = (int) Math.ceil(windowSize.y / (TILE_SIZE * 2 / ZOOM));
    Vector2f distance = new Vector2f(xDistance + 1, yDistance + 1);

    // Create a rectangle representing the positions currently viewable by the player.
    FloatRect visibleArea =
        new FloatRect(
            playerPosition.x - distance.x,
            playerPosition.y - distance.y,
            distance.x * 2,
            distance.y * 2);
    // Create a set to keep track of the already rendered chunks.
    Set<Integer> renderedChunks = new HashSet<Integer>();
    // Loop through every position currently in view.
    for (float i = visibleArea.left; i <= visibleArea.left + visibleArea.width; i++) {
      for (float j = visibleArea.top; j <= visibleArea.top + visibleArea.height; j++) {
        // Convert the current position to a chunk ID.
        int chunkID = positionToChunkID(new Vector2f(i, j));
        // If the chunk is valid and hasn't been drawn yet, draw it.
        if (isValidChunkID(chunkID) && !renderedChunks.contains(chunkID)) {
          // Draw the chunk vertex array with the tile sheet.
          VERTEX_ARRAYS[chunkID][0].draw(renderTarget, states);
          if (adjustedFrame > 0) {
            VERTEX_ARRAYS[chunkID][adjustedFrame].draw(renderTarget, states);
          }
          // Add the drawn chunk ID to the set to check against in order to save resources by not
          // drawing
          // it twice.
          renderedChunks.add(chunkID);
        }
      }
    }
  }
 public void applyAction() {
   Player currentPlayer = GameMaster.instance().getCurrentPlayer();
   Cell currentPosition = currentPlayer.getPosition();
   int newCell = GameMaster.instance().getGameBoard().queryCellIndex(destination);
   int currentCell =
       GameMaster.instance().getGameBoard().queryCellIndex(currentPosition.getName());
   int diceValue = 0;
   if (currentCell > newCell) {
     diceValue = (GameMaster.instance().getGameBoard().getCellNumber() + (newCell - currentCell));
   } else if (currentCell <= newCell) {
     diceValue = newCell - currentCell;
   }
   System.out.println(diceValue);
   GameMaster.instance().movePlayer(currentPlayer, diceValue);
 }
Esempio n. 12
0
 private PlayerInfo buildPlayerInfo(final Player p) {
   final PlayerInfo info = new PlayerInfo();
   final Stich r = getCurrentStich();
   info.setAufspieler(r != null ? r.getStarter().getUsername() : "");
   info.setGeber(geber != null ? geber.getUsername() : "");
   info.setActive(p.equals(this.activePlayer));
   info.setKarten(buildCardInfo());
   info.setPlayerId(p.getId());
   info.setPosition(p.getPosition());
   info.setKleinesHolz(0);
   info.setGrossesHolz(0);
   info.setPunkte(sumPoints(p));
   info.setName(p.getUsername());
   info.setRunde(r == null ? 0 : r.getStichNr());
   info.setTrumpf(trumpfFarbe);
   return info;
 }
 public boolean validatePlayer(Player player) {
   if (player.getFirstName() == null) return false;
   if (player.getFirstName().trim().equals("")) return false;
   if (player.getFirstName().matches(".*\\d.*")) return false;
   if (player.getLastName() == null) return false;
   if (player.getLastName().trim().equals("")) return false;
   if (player.getLastName().matches(".*\\d.*")) return false;
   if (player.getAge() == null) return false;
   if (player.getAge() < 20) return false;
   if (player.getAge() > 30) return false;
   if (player.getCountryOfBirth() == null) return false;
   if (player.getCountryOfBirth().trim().equals("")) return false;
   if (player.getCountryOfBirth().matches(".*\\d.*")) return false;
   if (player.getAnnualSalary() == null) return false;
   if (player.getAnnualSalary().getAmount() == null) return false;
   if (!validatePosition(player.getPosition())) return false;
   if (!validateStatistics(player.getStatistics())) return false;
   return true;
 }
 public void updateItem(Player player) {
   if (player.getPosition().equals(currentItem.getPosition())) {
     currentItem.setTaken(player.getPosition());
   }
 }
Esempio n. 15
0
  public Sky(GameStateManager gsm) {
    super(gsm);
    cam.setToOrtho(false, OwlCityTribute.WIDTH, OwlCityTribute.HEIGHT);
    player =
        new Player(
            OwlCityTribute.WIDTH,
            OwlCityTribute.HEIGHT,
            OwlCityTribute.HEIGHT,
            -OwlCityTribute.HEIGHT * .1f);
    player.getPosition().y = -OwlCityTribute.HEIGHT * .1f;
    background = new Texture("skybg.png");
    vignette = new Texture("vignette.png");
    cloud = new Texture("cloud.png");
    pauseButton = new Texture("pause.png");
    // playerXOffset = OwlCityTribute.WIDTH*.4f;
    textCount = 3;
    note =
        new FluctuatingObject(
            (int) (player.getPosition().x + cam.viewportWidth), 2f, 200, 50, -250);
    noteAnim = new Animation(new TextureRegion(new Texture("paper.png")), 9, .5f);
    planeRegion = new TextureRegion(player.getPlane());

    clouds = new Array<FluctuatingObject>();
    clouds.add(
        new FluctuatingObject(
            (int) (player.getPosition().x - cam.viewportWidth * .1),
            0f,
            -(int) (OwlCityTribute.HEIGHT * .1f),
            0,
            -1));
    clouds.add(
        new FluctuatingObject(
            (int) (player.getPosition().x + cam.viewportWidth * .7),
            0f,
            -(int) (OwlCityTribute.HEIGHT * .1f),
            0,
            -1));
    sr = new ShapeRenderer();
    noteRotation = 0f;
    for (int i = 0; i < 5; i++) this.sceneText.add(new ArrayList<String>());
    sceneText.get(0).add("I dreamt we were");
    sceneText.get(0).add("above the blue.");

    sceneText.get(1).add("and I was right beside you");
    sceneText.get(1).add("floating away.");

    sceneText.get(2).add("The Earth didn't care");
    sceneText.get(2).add("that we were up there.");

    sceneText.get(3).add("The world looked brighter");
    sceneText.get(3).add("from that high altitude.");

    sceneText.get(4).add("We could go anywhere.");

    parameter.size = 20;
    parameter.characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.";

    font = generator.generateFont(parameter);
    generator.dispose();
    textBox = new TextBox();
    sr = new ShapeRenderer();
    waiting = false;
    whiteValue = 1f;
    whiteOverlay = .99f;
    // readyToFadeBlack = false;
    boxInitialized = false;

    random = new Random(System.currentTimeMillis());
    // Shimmers
    shimmers = new Array<Shimmer>();
    for (int i = 0; i < NUM_SHIMMERS; i++) {
      shimmers.add(
          new Shimmer(
              random.nextInt(OwlCityTribute.WIDTH),
              random.nextInt((int) (OwlCityTribute.HEIGHT * .5f - OwlCityTribute.HEIGHT * .3f))
                  + OwlCityTribute.HEIGHT * .3f,
              random.nextInt((int) (OwlCityTribute.WIDTH * .0025f) + 1),
              random.nextInt(Shimmer.MAX_LIFE) + 50));
    }
    fallen = false;
    noteScale = 1f;
    shrinking = false;
    intro = true;
  }
Esempio n. 16
0
 private void checkFormationStillValidAfterAdding(Player player) {
   if (currentCountOf(player.getPosition()) == player.getPosition().maxQuantityPerTeam()) {
     throw new InvalidTeamFormationException(player.getPosition());
   }
 }
Esempio n. 17
0
 public float getDistanceToPlayer() {
   player = getPlayer();
   return body.getPosition().dst(player.getPosition());
 }
Esempio n. 18
0
  public Grassland(GameStateManager gsm) {
    super(gsm);
    cam.setToOrtho(false, OwlCityTribute.WIDTH, OwlCityTribute.HEIGHT);
    player =
        new Player(
            OwlCityTribute.WIDTH,
            OwlCityTribute.HEIGHT,
            OwlCityTribute.HEIGHT,
            -OwlCityTribute.HEIGHT * .1f);
    player.getPosition().y = OwlCityTribute.HEIGHT;
    background = new Texture("grass.png");
    vignette = new Texture("vignette.png");
    cloud = new Texture("cloud.png");
    pauseButton = new Texture("pause.png");
    balloon = new Texture("balloon.png");
    brush = new Texture("brush.png");

    textCount = -1;
    note =
        new FluctuatingObject(
            (int) (player.getPosition().x + cam.viewportWidth), 2f, 200, 50, -250);
    noteAnim = new Animation(new TextureRegion(new Texture("paper.png")), 9, .5f);
    planeRegion = new TextureRegion(player.getPlane());

    clouds = new Array<FluctuatingObject>();
    clouds.add(
        new FluctuatingObject(
            (int) (player.getPosition().x - cam.viewportWidth * .1),
            0f,
            (int) (OwlCityTribute.HEIGHT * .8f),
            0,
            -1));
    clouds.add(
        new FluctuatingObject(
            (int) (player.getPosition().x + cam.viewportWidth * .7),
            0f,
            (int) (OwlCityTribute.HEIGHT * .8f),
            0,
            -1));
    sr = new ShapeRenderer();
    noteRotation = 0f;
    for (int i = 0; i < 4; i++) this.sceneText.add(new ArrayList<String>());

    sceneText.get(0).add("The open summer breeze swept");
    sceneText.get(0).add("us through the hills.");

    sceneText.get(1).add("There was endless sky with");
    sceneText.get(1).add("the evening around us");

    sceneText.get(2).add("Everywhere we looked we saw");
    sceneText.get(2).add("green, scenic sublime");

    sceneText.get(3).add("And cold nostalgia chilled");
    sceneText.get(3).add("us in the warm air");

    parameter.size = 20;
    parameter.characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.,";

    font = generator.generateFont(parameter);
    generator.dispose();

    textBox = new TextBox();
    sr = new ShapeRenderer();
    waiting = false;
    whiteValue = 0f;
    // readyToFadeBlack = false;
    boxInitialized = false;

    random = new Random(System.currentTimeMillis());
    // Shimmers
    shimmers = new Array<Shimmer>();
    for (int i = 0; i < NUM_SHIMMERS; i++) {
      shimmers.add(
          new Shimmer(
              random.nextInt(OwlCityTribute.WIDTH),
              random.nextInt((int) (OwlCityTribute.HEIGHT * .5f - OwlCityTribute.HEIGHT * .3f))
                  + OwlCityTribute.HEIGHT * .3f,
              random.nextInt((int) (OwlCityTribute.WIDTH * .0025f) + 1),
              random.nextInt(Shimmer.MAX_LIFE) + 50));
    }
    fallen = false;
    noteScale = 1f;
    shrinking = false;

    balloonFluctuation =
        new FluctuatingObject(
            (int) (OwlCityTribute.WIDTH * .75),
            .75f,
            (int) (OwlCityTribute.HEIGHT * .8f),
            (int) (OwlCityTribute.HEIGHT * .025),
            0);

    brushmoving = new Array<FluctuatingObject>();
    for (int i = 0; i < 3; i++) {
      brushmoving.add(
          new FluctuatingObject(
              i * brush.getWidth()
                  + (int) (player.getPosition().x - cam.viewportWidth / 2 + player.xOffset),
              0,
              -(int) (OwlCityTribute.HEIGHT * .15),
              0,
              0));
    }
  }
Esempio n. 19
0
  @Override
  public void render(SpriteBatch sb) {
    float leftEdge = player.getPosition().x - cam.viewportWidth / 2 + player.xOffset;
    sb.setProjectionMatrix(cam.combined);
    sb.begin();
    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);
    sb.draw(
        background,
        player.getPosition().x - cam.viewportWidth / 2 + player.xOffset,
        0,
        cam.viewportWidth,
        cam.viewportHeight);
    sb.end();

    Gdx.gl.glEnable(GL20.GL_BLEND);

    sr.setProjectionMatrix(cam.combined);
    sr.begin(ShapeRenderer.ShapeType.Filled);
    // Draw sparkles
    for (int i = 0; i < NUM_SHIMMERS; i++) {
      sr.setColor(
          whiteValue,
          whiteValue,
          whiteValue,
          Math.abs((float) Math.sin(Math.PI * shimmers.get(i).life / Shimmer.MAX_LIFE)));
      sr.circle(
          shimmers.get(i).x + player.getPosition().x - cam.viewportWidth / 2 + player.xOffset,
          shimmers.get(i).y,
          (float) Math.abs(Math.sin(Math.PI * shimmers.get(i).life / Shimmer.MAX_LIFE))
              * shimmers.get(i).size);
    }
    sr.end();
    sb.begin();
    // Draw pause
    sb.draw(
        pauseButton,
        cam.position.x - cam.viewportWidth / 2 + cam.viewportWidth * .05f,
        cam.viewportHeight * .95f - pauseButton.getHeight());

    // Draw balloon
    sb.draw(
        balloon,
        cam.position.x
            - cam.viewportWidth / 2
            + balloonFluctuation.getPosition().x
            - balloon.getWidth() / 2,
        balloonFluctuation.getPosition().y - balloon.getHeight() / 2);

    // Draw text
    if (!textBox.finished) {
      sb.end();
      Gdx.gl.glEnable(GL20.GL_BLEND);
      sr.setProjectionMatrix(cam.combined);
      sr.setAutoShapeType(true);
      sr.begin();
      sr.set(ShapeRenderer.ShapeType.Filled);
      sr.setColor(1f, 1f, 1f, (textBox.alpha > .4f) ? .4f : textBox.alpha);
      // Vert
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2 - textBox.padding / 2,
          textBox.y - textBox.height / 2,
          textBox.width + textBox.padding,
          textBox.height);
      // Horiz
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2,
          textBox.y + textBox.height / 2,
          textBox.width,
          textBox.padding / 2);
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2,
          textBox.y - textBox.height / 2,
          textBox.width,
          -textBox.padding / 2);
      sr.end();
      sb.begin();
      if (textBox.boxOpened) {
        font.setColor(1f, 1f, 1f, textBox.alpha);
        // First line
        font.draw(
            sb,
            textBox.firstLineBuffer,
            (leftEdge + textBox.x - (textBox.width / 2)),
            textBox.y + textBox.height / 2);
        // Second line
        font.draw(
            sb,
            textBox.secondLineBuffer,
            (leftEdge + textBox.x - (textBox.width / 2)),
            textBox.y
                + textBox.height / 2
                - font.getBounds(sceneText.get(textCount).get(0)).height * 1.5f);
      }
    }

    // clouds
    sb.setColor(whiteValue, whiteValue, whiteValue, .75f);
    sb.draw(cloud, clouds.get(0).getPosition().x, clouds.get(0).getPosition().y);
    sb.draw(cloud, clouds.get(1).getPosition().x, clouds.get(1).getPosition().y);

    // draw note
    sb.setColor(whiteValue, whiteValue * (230f / 255f), whiteValue, 1f);
    sb.draw(
        noteAnim.getFrame(),
        note.getPosition().x,
        note.getPosition().y,
        noteAnim.getFrame().getRegionWidth() / 2,
        noteAnim.getFrame().getRegionHeight() / 2,
        noteAnim.getFrame().getRegionWidth(),
        noteAnim.getFrame().getRegionHeight(),
        noteScale,
        noteScale,
        noteRotation);

    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);
    // Draw player
    sb.draw(
        planeRegion,
        player.getPosition().x,
        player.getPosition().y,
        planeRegion.getRegionWidth() / 2,
        planeRegion.getRegionHeight() / 2,
        player.getPlane().getWidth() * .75f,
        player.getPlane().getHeight() * .75f,
        1,
        1,
        player.rotation);

    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);

    // draw brush
    for (FluctuatingObject f : brushmoving) {
      sb.draw(brush, f.getPosition().x, f.getPosition().y);
    }

    sb.end();
    // HUD
    Matrix4 uiMatrix = cam.combined.cpy();
    uiMatrix.setToOrtho2D(0, 0, OwlCityTribute.WIDTH, OwlCityTribute.HEIGHT);

    sb.setProjectionMatrix(uiMatrix);
    sb.begin();
    sb.draw(vignette, 0, 0, cam.viewportWidth, cam.viewportHeight);
    sb.end();
    sr.begin(ShapeRenderer.ShapeType.Filled);
    Gdx.gl.glEnable(GL20.GL_BLEND);

    sr.setColor(1f, 1f, 1f, whiteOverlay);
    sr.setProjectionMatrix(cam.combined);
    sr.rect(leftEdge, 0, cam.viewportWidth, cam.viewportHeight);
    sr.end();
  }
Esempio n. 20
0
  @Override
  public void update(float dt) {
    if (!paused) {
      handleInput();
      if (!readyToFadeWhite) player.update(dt); // So player can be controlled upward from Sky
      else {
        // Lift player
        whiteOverlay += .3f * dt;
        player.getVelocity().add(0, -player.gravity / 2);
        player.getVelocity().scl(dt);
        player.getPosition().add(player.movement * dt, player.getVelocity().y);
        player.getVelocity().scl(1 / dt);
        float temp =
            player.normalize(
                -450, 200, (float) -Math.PI / 4f, (float) Math.PI / 4f, player.getVelocity().y);
        player.rotation = 25 * (float) Math.sin(temp);
        if (whiteOverlay > 1f) {
          dispose();
          Preferences p = Gdx.app.getPreferences(OwlCityTribute.GAME_PREFS);
          p.putInteger("level", 5);
          if (p.getInteger("maxlevel") < 5) {
            p.putInteger("maxlevel", 5);
          }
          p.flush();
          gsm.currentState = GameStateManager.SKY;
          this.gsm.setState(new Sky(this.gsm));
        }
      }
      fallen = player.getPosition().y == -OwlCityTribute.HEIGHT * .1f;

      if (!loss && fallen) {
        loss = true;
        gsm.push(new UponLoss(gsm));
      }

      note.update(dt);
      noteAnim.update(dt);
      noteRotation += 100f * dt;
      if (noteRotation > 360) noteRotation = 0;

      balloonFluctuation.update(dt);

      cam.position.x = player.getPosition().x + player.xOffset;
      float leftEdge = player.getPosition().x - (cam.viewportWidth / 2) + player.xOffset;

      // Check if note is hit
      if (!shrinking
          && Math.sqrt(
                  Math.pow(
                          (player.getPosition().x + player.getPlane().getWidth() * .75f)
                              - note.getPosition().x,
                          2)
                      + Math.pow(
                          (player.getPosition().y + (player.getPlane().getHeight() * .75f) / 2)
                              - (note.getPosition().y + noteAnim.getFrame().getRegionHeight() / 2),
                          2))
              < 40) {
        // Open textbox
        textCount++;
        textBox.prepare(
            sceneText.get(textCount).get(0),
            (sceneText.get(textCount).size() == 1) ? "" : sceneText.get(textCount).get(1),
            .1f);
        boxInitialized = true;

        // Set bounds
        int w = (int) font.getBounds(sceneText.get(textCount).get(0)).width;
        // int h = (int)(font.getBounds(sceneText.get(textCount).get(0)).height*2.5);
        int h =
            (int)
                (font.getBounds(sceneText.get(textCount).get(0)).height
                    * sceneText.get(textCount).size()
                    * 1.5);
        textBox.setBounds(
            w,
            h,
            (int) (OwlCityTribute.WIDTH * .65) - w / 2,
            (int) (OwlCityTribute.HEIGHT * .875) - h / 2);
        waiting = true;
        shrinking = true;
      } else if (note.getPosition().x < leftEdge - noteAnim.getFrame().getRegionWidth()
          && !waiting
          && textCount < sceneText.size() - 1
          && player.movement > player.maxMovement * .75) {
        note.getPosition().x = player.getPosition().x + cam.viewportWidth;
        note.setyOffset((int) (Math.random() * 100) + 200);
      }

      if (shrinking) {
        noteScale -= 2.5 * dt;
        if (noteScale < 0) {
          shrinking = false;
          noteScale = 1f;
          note.getPosition().x -= cam.viewportWidth;
        }
      }

      if (textBox.readyToUpdate) {
        if (!textBox.update(dt)) waiting = true;
        else {
          waiting = false;
          if (textCount < sceneText.size() - 1 && player.movement > player.maxMovement * .75) {
            note.getPosition().x = player.getPosition().x + cam.viewportWidth;
            note.setyOffset((int) (Math.random() * 100) + 200);
          }
        }
      }

      if (!fallen && boxInitialized && textCount == sceneText.size() - 1 && textBox.finished) {
        readyToFadeWhite = true;
      }

      // clouds
      for (int i = 0; i < clouds.size; i++) {
        clouds.get(i).update(dt);
        if (clouds.get(i).getPosition().x < leftEdge - cloud.getWidth()) {
          int index = (i == 0) ? clouds.size - 1 : i - 1;
          clouds.get(i).getPosition().x =
              (float) (clouds.get(index).getPosition().x + cam.viewportWidth * .8);
          clouds.get(i).yOffset =
              random.nextInt((int) (OwlCityTribute.HEIGHT * .1f))
                  + (int) (OwlCityTribute.HEIGHT * .75f);
        }
      }

      //        if(readyToFadeBlack){
      //            whiteValue  = (whiteValue > 0) ? whiteValue - .2f*dt : 0f;
      //            if(whiteValue == 0f){
      //                if(player.getPosition().y == -OwlCityTribute.HEIGHT*.1f){
      //                    dispose();
      //                    this.gsm.setState(new Sky(this.gsm));
      //                }
      //            }
      //        }
      // else{
      whiteValue = (whiteValue < 1f) ? whiteValue + .4f * dt : 1f;
      // }

      // Shimmer update
      for (int i = 0; i < NUM_SHIMMERS; i++) {
        shimmers.get(i).update(dt);
      }

      // Check brush
      for (int i = 0; i < brushmoving.size; i++) {
        brushmoving.get(i).MOVEMENT = -(player.movement / 5);
        brushmoving.get(i).update(dt);
        if (brushmoving.get(i).getPosition().x < leftEdge - brush.getWidth() * 1.5) {
          int index = (i == 0) ? brushmoving.size - 1 : i - 1;
          brushmoving.get(i).getPosition().x =
              brushmoving.get(index).getPosition().x + brush.getWidth();
          break;
        }
      }

      cam.update();
    }
  }
Esempio n. 21
0
  public void startGame() throws Exception {

    // PLAYER CHECK
    //
    final int playerCount = player.size();
    {
      if (playerCount < 2) {
        throw new Exception("Zu wenig Spieler für ein Spiel.");
      }
      if (playerCount > MAX_PLAYER) {
        throw new Exception("Zu viele Spieler für ein Spiel.");
      }
      if (playerCount < 2 || playerCount > MAX_PLAYER) {
        throw new Exception("Unpassende Spieleranzahl.");
      }
    }

    // FIRST TIME INITIALIZATION
    //
    Thread.currentThread().setName("Game " + this.gameId);
    this.maxStichNr = 32 / player.size();
    gotoGameState(GameState.G0);

    // LOOP FOR 4 PLAYER !!

    for (; ; ) {

      final GameEvent event = getNextEvent(20000);
      pause(50);

      if (event == null) {
        log.info("State=" + gameState + ", waiting for events");
        continue;
      }
      log.info("State=" + gameState + ", event=" + event);

      if (event.getEvent() == EventType.gostate) {
        gameState = event.getState();
      }

      switch (gameState) {

          // -----------------------------------------------------------
        case G0:
          {
            resetSpiel();
            start = new Date();
            selectGeber();

            // Reset clients
            final PlayerCommand pc = new PlayerCommand();
            sendCommandToAllPlayer(CommandCode.gameReset);

            // Initialize clients
            sendGameInfo();
            // 3 Karten für jeden
            for (int i = 0; i < 3; i++) {
              for (Player p : player) {
                assignFreeCardToPlayer(p, false);
              }
            }
            sendPlayerInfo();
            gotoGameState(GameState.G1);
            break;
          }

          // -----------------------------------------------------------
        case G1:
          {
            // 2 Karten für jeden
            original = null;
            for (int i = 0; i < 2; i++) {
              for (Player p : player) {
                assignFreeCardToPlayer(p, p.getId() == this.geber.getId());
              }
            }
            sendPlayerInfo();
            gotoGameState(GameState.G1a);
            break;
          }
          // -----------------------------------------------------------
        case G1a:
          {
            // 3 Karten für jeden
            for (int i = 0; i < 3; i++) {
              for (Player p : player) {
                assignFreeCardToPlayer(p, false);
              }
            }
            sendPlayerInfo();
            gotoGameState(GameState.G2);
            break;
          }
          // -----------------------------------------------------------
        case G2:
          {
            Player p = getPlayerLeftFromGeber(+1);
            sendPlayerCommand(
                p,
                CommandCode.frageOriginal,
                new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
            gameState = GameState.G3;
            break;
          }
          // -----------------------------------------------------------
        case G3:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.nein) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Weg!");
                Player p = getPlayerLeftFromGeber(+2);
                sendPlayerCommand(
                    p,
                    CommandCode.frageOriginal,
                    new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
                gameState = GameState.G4;
              } else if (response.getResponseCode() == ResponseCode.ja) {
                trumpfPlayer = getPlayerById(response.getPlayerId());
                trumpfFarbe = original.getFarbe();
                originalSelected = true;
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Ich gehe rein");
                gotoGameState(GameState.S0);
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case G4:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.nein) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Weg!");
                Player p = getPlayerLeftFromGeber(+3);
                sendPlayerCommand(
                    p,
                    CommandCode.frageOriginal,
                    new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
                gameState = GameState.G5;
              } else if (response.getResponseCode() == ResponseCode.ja) {
                trumpfPlayer = getPlayerById(response.getPlayerId());
                trumpfFarbe = original.getFarbe();
                originalSelected = true;
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Ich gehe rein");
                gotoGameState(GameState.S0);
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case G5:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.nein) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Weg!");
                Player p = getPlayerLeftFromGeber(+0);
                sendPlayerCommand(
                    p,
                    CommandCode.frageOriginal,
                    new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
                gameState = GameState.G6;
              } else if (response.getResponseCode() == ResponseCode.ja) {
                trumpfPlayer = getPlayerById(response.getPlayerId());
                trumpfFarbe = original.getFarbe();
                originalSelected = true;
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Ich gehe rein");
                gotoGameState(GameState.S0);
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case G6:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.nein) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Weg!");
                Player p = getPlayerLeftFromGeber(+1);
                sendPlayerCommand(
                    p,
                    CommandCode.frageKleines,
                    new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
                gameState = GameState.G7;
              } else if (response.getResponseCode() == ResponseCode.ja) {
                trumpfPlayer = getPlayerById(response.getPlayerId());
                trumpfFarbe = original.getFarbe();
                originalSelected = true;
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Ich gehe rein");
                gotoGameState(GameState.S0);
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case G7:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.nein) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Noch weg!");
                Player p = getPlayerLeftFromGeber(+2);
                sendPlayerCommand(
                    p,
                    CommandCode.frageKleines,
                    new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
                gameState = GameState.G8;
              } else if (response.getResponseCode() == ResponseCode.ja) {
                Player p = getPlayerLeftFromGeber(+1);
                sendPlayerCommand(
                    p, CommandCode.frageTrumpffarbe, new ResponseCode[] {ResponseCode.waehleFarbe});
                gameState = GameState.G11;
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case G8:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.nein) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Noch weg!");
                Player p = getPlayerLeftFromGeber(+3);
                sendPlayerCommand(
                    p,
                    CommandCode.frageKleines,
                    new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
                gameState = GameState.G9;
              } else if (response.getResponseCode() == ResponseCode.ja) {
                Player p = getPlayerLeftFromGeber(+2);
                sendPlayerCommand(
                    p, CommandCode.frageTrumpffarbe, new ResponseCode[] {ResponseCode.waehleFarbe});
                gameState = GameState.G12;
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case G9:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.nein) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Noch weg!");
                Player p = getPlayerLeftFromGeber(+0);
                sendPlayerCommand(
                    p,
                    CommandCode.frageKleines,
                    new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
                gameState = GameState.G10;
              } else if (response.getResponseCode() == ResponseCode.ja) {
                Player p = getPlayerLeftFromGeber(+3);
                sendPlayerCommand(
                    p, CommandCode.frageTrumpffarbe, new ResponseCode[] {ResponseCode.waehleFarbe});
                gameState = GameState.G13;
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case G10:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.nein) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Noch weg!");
                gotoGameState(GameState.G20);
              } else if (response.getResponseCode() == ResponseCode.ja) {
                Player p = getPlayerLeftFromGeber(+0);
                sendPlayerCommand(
                    p, CommandCode.frageTrumpffarbe, new ResponseCode[] {ResponseCode.waehleFarbe});
                gameState = GameState.G14;
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case G11:
        case G12:
        case G13:
        case G14:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.waehleFarbe) {
                trumpfPlayer = getPlayerById(response.getPlayerId());
                trumpfFarbe = response.getFarbe();
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "spiele " + trumpfFarbe);
                gotoGameState(GameState.S0);
              } else {
                throw new Exception(
                    "Unexpected response: state="
                        + gameState
                        + ", response="
                        + response.getResponseCode());
              }
            }
            break;
          }

          // -----------------------------------------------------------
        case S0:
          {
            originalSelected = true;
            if (playerCount == 2 || playerCount == 3) {
              /** Spieler, der die Trumpf 7 hält, kann mit 'Original' tauschen */
              final PlayCard trumpf7 = getCard(trumpfFarbe, Kartenwert.Sieben);
              final Player trumpf7_owner = trumpf7.getOwner();
              if (trumpf7_owner != null && !original.equals(trumpf7)) {
                sendPlayerCommand(
                    trumpf7_owner,
                    CommandCode.tauscheSieben,
                    new ResponseCode[] {ResponseCode.ja, ResponseCode.nein});
                gameState = GameState.X1;
              }
            } else {
              gotoGameState(GameState.S1);
            }
            break;
          }
          // -----------------------------------------------------------
        case S1:
          {
            if (!areCardsAvailable()) {
              gotoGameState(GameState.S4);
            } else {
              // Neue Runde starten
              final Stich newRound = new Stich();
              newRound.setNr(stichNr.getAndIncrement());
              newRound.setCount(0);
              // In der 1. Runde spielt der Nebenmann auf:
              if (newRound.getStichNr() == 1) {
                newRound.setStarter(getPlayerLeftFromGeber(+1));
              } else {
                newRound.setStarter(getCurrentStich().getWinner());
              }
              stiche.add(newRound);
              // Prepare next step and send out game info
              gotoGameState(GameState.S2);
            }
            break;
          }
          // -----------------------------------------------------------
        case S2:
          {
            final Stich r = getCurrentStich();
            // Nächster Spieler im Uhrzeigersinn:
            final Player p = getPlayerLeftFrom(r.getStarter(), r.getCount());
            this.activePlayer = p;
            sendGameInfo(false);
            sendPlayerInfo();
            sendPlayerCommand(p, CommandCode.spieleKarte, new ResponseCode[] {ResponseCode.play});
            gotoGameState(GameState.S3);
            break;
          }
          // -----------------------------------------------------------
        case S3:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.play) {

                final PlayCard c = getCard(response.getGespielteKarte());
                final Player p = getPlayerById(response.getPlayerId());
                final Stich r = getCurrentStich();

                if (c == null)
                  throw new Exception("card not found: " + response.getGespielteKarte());
                if (p == null) throw new Exception("player not found: " + response.getPlayerId());

                c.setBidNr(r.getCount());
                c.setStichNr(r.getStichNr());

                // TODO: Terz check
                // TODO: Bella check ...
                sendPlayerInfo();

                if (r.getCount() >= playerCount - 1) {
                  // Runde ist beendet
                  calculatePointsInRound(r);
                  log.info("Stich Ende: " + r.toString());
                  gotoGameState(GameState.S1);
                } else {
                  // Weiter auf nächste Karte warten
                  r.setCount(r.getCount() + 1);
                  gotoGameState(GameState.S2);
                }
              }
            }
            break;
          }
          // -----------------------------------------------------------
        case S4:
          {

            // Spielende:
            // Gesamtpunkte, Gewinner berechnen.
            createGameHistoryRecord();

            if (this.spielNr.get() == MAX_RUNDEN) {
              sendGameInfo();
              gotoGameState(GameState.GOV);
            } else {
              gotoGameState(GameState.S5);
            }
            break;
          }
          // -----------------------------------------------------------
        case S5:
          {
            log.info("Game finished.");
            for (Player p : player) {
              if ((System.currentTimeMillis() % 5) == p.getPosition()) {
                sendPlayerMsg(p, "Weiter!");
              }
            }
            sendPlayerInfo();
            sendGameInfo(true);

            // Prepare next game:
            spielNr.incrementAndGet();
            /** TODO: prüfe neue Runde? TODO: prüfe Holz, ... */

            // Restart Game:
            pause(1000);
            gotoGameState(GameState.G0);
            break;
          }

          // -----------------------------------------------------------
        case G20:
          {
            log.info("Alle weg, Karten neu verteilen.");
            pause(1000);
            for (Player p : player) {
              if ((System.currentTimeMillis() % 5) == p.getPosition()) {
                sendPlayerMsg(p, "Neue Karten");
              } else if ((System.currentTimeMillis() % 3) == p.getPosition()) {
                sendPlayerMsg(p, "Mischen");
              }
            }
            // Restart Game:
            pause(1000);
            gotoGameState(GameState.G0);
            break;
          }
          // -----------------------------------------------------------
        case GOV:
          {
            end = new Date();
            log.info("GAME OVER.");
            break;
          }
          // -----------------------------------------------------------
        case X1:
          {
            if (event.getEvent() == EventType.player) {
              final PlayerResponse response = event.getPlayerResponse();
              if (response.getResponseCode() == ResponseCode.ja) {
                sendPlayerMsg(getPlayerById(response.getPlayerId()), "Tausche die 7!");
                PlayCard trumpf7 = getCard(trumpfFarbe, Kartenwert.Sieben);
                PlayCard changeCard = getCard(trumpfFarbe, original.getWert());
                changeCard.setOwner(trumpf7.getOwner());
                trumpf7.setOwner(null);
                original = trumpf7.getKarte();
              }
            }
            gotoGameState(GameState.S1);
            break;
          }
          // -----------------------------------------------------------
        case X2:
          {
            break;
          }
      }
    }
  }
Esempio n. 22
0
  /**
   * Updates the player.
   *
   * @param player the player to update.
   */
  public static void update(Player player) {
    // XXX: The buffer sizes may need to be tuned.
    PacketBuffer.WriteBuffer out = PacketBuffer.newWriteBuffer(16384); // 8192
    PacketBuffer.WriteBuffer block = PacketBuffer.newWriteBuffer(8192); // 4096

    /** Initialize the update packet. */
    out.writeVariableShortPacketHeader(81);
    out.setAccessType(PacketBuffer.AccessType.BIT_ACCESS);

    /** Update this player. */
    PlayerUpdate.updateLocalPlayerMovement(player, out);

    if (player.getFlags().isUpdateRequired()) {
      PlayerUpdate.updateState(player, block, false, true);
    }

    /** Update other local players. */
    out.writeBits(8, player.getPlayers().size());
    for (Iterator<Player> i = player.getPlayers().iterator(); i.hasNext(); ) {
      Player other = i.next();
      if (other.getPosition().isViewableFrom(player.getPosition())
          && other.getSession().getStage() == Session.Stage.LOGGED_IN
          && !other.isNeedsPlacement()
          && other.isVisible()) {
        PlayerUpdate.updateOtherPlayerMovement(other, out);
        if (other.getFlags().isUpdateRequired()) {
          PlayerUpdate.updateState(other, block, false, false);
        }
      } else {
        out.writeBit(true);
        out.writeBits(2, 3);
        i.remove();
      }
    }

    int added = 0;

    /** Update the local player list. */
    for (int i = 0; i < World.getPlayers().getCapacity(); i++) {
      if (added == 15 || player.getPlayers().size() >= 220) {

        /** Player limit has been reached. */
        break;
      }
      Player other = World.getPlayers().get(i);
      if (other == null
          || other == player
          || other.getSession().getStage() != Session.Stage.LOGGED_IN
          || !other.isVisible()) {
        continue;
      }
      if (!player.getPlayers().contains(other)
          && other.getPosition().isViewableFrom(player.getPosition())) {
        added++;
        player.getPlayers().add(other);
        PlayerUpdate.addPlayer(out, player, other);
        PlayerUpdate.updateState(other, block, true, false);
      }
    }

    /** Append the attributes block to the main packet. */
    if (block.getBuffer().position() > 0) {
      out.writeBits(11, 2047);
      out.setAccessType(PacketBuffer.AccessType.BYTE_ACCESS);
      out.writeBytes(block.getBuffer());
    } else {
      out.setAccessType(PacketBuffer.AccessType.BYTE_ACCESS);
    }

    /** Finish the packet and send it. */
    out.finishVariableShortPacketHeader();
    player.getSession().encode(out);
  }
 public boolean hasWon(Player player) {
   return (currentItem.isTaken() && currentMap.getSpawnPosition().equals(player.getPosition()));
 }