コード例 #1
0
ファイル: Map.java プロジェクト: yanalex981/RTS-Project
  /**
   * Sets this Node to the radius specified, and updates the maxUnitRadius of all the Nodes
   * neighbours
   *
   * @param n The node to set the radius of
   * @param radius The maxUnitRadius to set the Node to
   */
  private void setUnitRadius(Node n, int radius) {
    if (n.getMaxUnitRadius() <= radius) return;

    n.setMaxUnitRadius(radius);

    for (Neighbour neighbour : n.getNeighbours())
      setUnitRadius(neighbour.getNode(), radius + neighbour.getCost());
  }
コード例 #2
0
ファイル: Map.java プロジェクト: yanalex981/RTS-Project
  /**
   * Reverses the maxUnitRadius when unblocking a Node
   *
   * @param n The Node to reset the maxUnitRadius of
   */
  private void setUnblockedUnitRadius(Node n) {
    int previousUnitRadius = n.getMaxUnitRadius();
    n.setMaxUnitRadius(MAX_RADIUS_COST);

    for (Neighbour neighbour : n.getNeighbours()) {
      if (neighbour.getNode().getMaxUnitRadius() == previousUnitRadius + neighbour.getCost())
        setUnblockedUnitRadius(neighbour.getNode());
      else if (neighbour.getNode().getMaxUnitRadius() < previousUnitRadius + neighbour.getCost())
        setUnitRadius(n, neighbour.getNode().getMaxUnitRadius() + neighbour.getCost());
    }
  }