Package org.moparscape.msc.gs.model.landscape

Examples of org.moparscape.msc.gs.model.landscape.ActiveTile


            gfx.drawString(labels[label++], x + 10, y + 20);
          }
          continue;
        }
        handleTile(x, y, world.getTileValue(x / 2, y / 2));
        ActiveTile t = world.tiles[x / 2][y / 2];
        if (t != null) {
          if (t.hasNpcs()) {
            fillTile(x, y, RED);
          }
          if (t.hasItems()) {
            fillTile(x, y, PURPLE);
          }
          if (t.hasGameObject()) {
            fillTile(x, y, BLACK);
          }
        }
      }
    }
View Full Code Here


   */
  public ActiveTile getTile(int x, int y) {
    if (!withinWorld(x, y)) {
      return null;
    }
    ActiveTile t = tiles[x][y];
    if (t == null) {
      t = new ActiveTile(x, y);
      tiles[x][y] = t;
    }
    return t;
  }
View Full Code Here

    try {
      if (i.getLoc() == null) {
        delayedEventHandler.add(new DelayedEvent(null, 180000) {

          public void run() {
            ActiveTile tile = getTile(i.getLocation());
            if (tile.hasItem(i)) {
              unregisterItem(i);
            }
            matchRunning = false;
          }
        });
View Full Code Here

  /**
   * adds or removes the given entity from the relivant tiles
   */
  public void setLocation(Entity entity, Point oldPoint, Point newPoint) {
    ActiveTile t;
    if (oldPoint != null) {
      t = getTile(oldPoint);
      t.remove(entity);
    }
    if (newPoint != null) {
      t = getTile(newPoint);
      t.add(entity);
    }
  }
View Full Code Here

    long startTime = getTime();
    int curMemory = (int) (Runtime.getRuntime().totalMemory() - Runtime
        .getRuntime().freeMemory()) / 1000;
    for (int i = 0; i < Instance.getWorld().tiles.length; i++) {
      for (int in = 0; in < Instance.getWorld().tiles[i].length; in++) {
        ActiveTile tile = Instance.getWorld().tiles[i][in];
        if (tile != null) {
          if (!tile.hasGameObject() && !tile.hasItems()
              && !tile.hasNpcs() && !tile.hasPlayers()) {
            Instance.getWorld().tiles[i][in] = null;
          }
        }
      }
    }
View Full Code Here

  public List<GameObject> getGameObjectsInView() {
    List<GameObject> objects = new ArrayList<GameObject>();
    ActiveTile[][] viewArea = getViewedArea(21, 21, 21, 21);
    for (int x = 0; x < viewArea.length; x++) {
      for (int y = 0; y < viewArea[x].length; y++) {
        ActiveTile t = viewArea[x][y];
        if (t != null) {
          if (t.hasGameObject()) {
            objects.add(t.getGameObject());
          }
        }
      }
    }
    return objects;
View Full Code Here

  public List<Item> getItemsInView() {
    List<Item> items = new ArrayList<Item>();
    ActiveTile[][] viewArea = getViewedArea(21, 21, 21, 21);
    for (int x = 0; x < viewArea.length; x++) {
      for (int y = 0; y < viewArea[x].length; y++) {
        ActiveTile t = viewArea[x][y];
        if (t != null) {
          items.addAll(t.getItems());
        }
      }
    }
    return items;
  }
View Full Code Here

  public List<Npc> getNpcsInView() {
    List<Npc> npcs = new ArrayList<Npc>();
    ActiveTile[][] viewArea = getViewedArea(15, 15, 16, 16);
    for (int x = 0; x < viewArea.length; x++)
      for (int y = 0; y < viewArea[x].length; y++) {
        ActiveTile t = viewArea[x][y];
        if (t != null) {
          List<Npc> temp = t.getNpcs();
          if (temp != null) {
            npcs.addAll(temp);
          }
        }
      }
View Full Code Here

  public List<Player> getPlayersInView() {
    List<Player> players = new ArrayList<Player>();
    ActiveTile[][] viewArea = getViewedArea(15, 15, 16, 16);
    for (int x = 0; x < viewArea.length; x++)
      for (int y = 0; y < viewArea[x].length; y++) {
        ActiveTile t = viewArea[x][y];
        if (t != null) {
          List<Player> temp = t.getPlayers();
          if (temp != null) {
            players.addAll(temp);
          }
        }
      }
View Full Code Here

      return;
    }
    player.resetAll();
    Point location = Point.location(p.readShort(), p.readShort());
    int id = p.readShort();
    final ActiveTile tile = world.getTile(location);
    final Item item = getItem(id, tile, player);

    if (item == null) {
      // player.setSuspiciousPlayer(true);
      player.resetPath();
      return;
    }

    if (!item.getDef().canTrade()) {
      if (item.droppedby() != 0
          && org.moparscape.msc.gs.tools.DataConversions
              .usernameToHash(player.getUsername()) != item
              .droppedby()) {
        player.getActionSender().sendMessage(
            "This item is non-tradable.");
        return;
      }
    }

    if (player.isPMod() && !player.isMod())
      return;
    if (item.getDef().isMembers() && !World.isMembers()) {
      player.getActionSender().sendMessage(
          "This feature is only avaliable on a members server");
      return;
    }

    player.setStatus(Action.TAKING_GITEM);
    boolean blocked = false;
    try {
      PathHandler pa = new PathHandler(player);
      for (int i : new int[] { 1, 2, 4, 8 }) {
        if (pa.isBlocking(location.getX(), location.getY(), i)) {
          blocked = true;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    int distance = blocked ? 1 : 0;
    Instance.getDelayedEventHandler().add(
        new WalkToPointEvent(player, location, distance, true) {
          public void arrived() {
            if (owner.isBusy() || owner.isRanging()
                || !tile.hasItem(item) || !owner.nextTo(item)
                || owner.getStatus() != Action.TAKING_GITEM) {
              return;
            }

            if (item.getID() == 23) {
View Full Code Here

TOP

Related Classes of org.moparscape.msc.gs.model.landscape.ActiveTile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.