Example #1
0
  private void cancelTaskAndSubmitNew(Player actor, TileCell targetCell) {
    AStar lastFindPath = findPathTaskMap.get(actor.getId());
    // 如果终点和当前任务查找的终点一样就不重新再找了
    if (lastFindPath != null && lastFindPath.isEnd(targetCell)) {
      return;
    }

    Future<?> lastfindPathTask = findPathFutureMap.get(actor.getId());
    if (lastfindPathTask != null && !lastfindPathTask.isDone() && lastfindPathTask.cancel(true)) {
      System.out.println("cancel——" + lastfindPathTask);
    }

    AStar task = actor.newFindPathTask(map, targetCell);
    Future<?> findPathFuture = executor.submit(task);
    findPathFutureMap.put(actor.getId(), findPathFuture);
    findPathTaskMap.put(actor.getId(), task);
    System.out.println("init——" + findPathFutureMap.get(actor.getId()));
  }
Example #2
0
 private TileMap actorsMap() {
   Player player = actors.iterator().next();
   AStar astart = findPathTaskMap.get(player.getId());
   return astart == null ? this.map : astart.getMap();
 }