示例#1
0
  public void updateAsScheduled(int numUpdates) {
    commerce.updateCommerce(numUpdates);
    paving.distribute(BuildConstants.ALL_PROVISIONS);
    dangerMap.updateVals();
    for (Mission mission : missions) mission.updateMission();
    //
    //  Once per day, iterate across all personnel to get a sense of citizen
    //  mood, and compute community spirit.  (This declines as your settlement
    //  gets bigger.)
    if (numUpdates % World.STANDARD_DAY_LENGTH == 0) {
      final Tile t = world.tileAt(0, 0);
      int numResidents = 0;
      averageMood = 0.5f;

      for (Object o : world.presences.matchesNear(this, t, -1)) {
        if (!(o instanceof Venue)) continue;
        final Venue v = (Venue) o;
        for (Actor resident : v.personnel.residents()) {
          numResidents++;
          averageMood += resident.health.moraleLevel();
        }
      }

      averageMood /= (numResidents + 1);
      communitySpirit = 1f / (1 + (numResidents / 100f));
      communitySpirit = (communitySpirit + averageMood) / 2f;
    }
  }
示例#2
0
  /** Rendering and interface methods- */
  public void renderFor(Rendering rendering) {
    final Viewport port = rendering.port;

    for (Mission mission : missions) {
      final Sprite flag = mission.flagSprite();
      if (!port.intersects(flag.position, 2)) continue;
      rendering.addClient(flag);
    }
  }
示例#3
0
 public Mission pickedMission(BaseUI UI, Viewport port) {
   Mission closest = null;
   float minDist = Float.POSITIVE_INFINITY;
   for (Mission mission : missions) {
     final Sprite flag = mission.flagSprite();
     float dist = port.isoToScreen(new Vec3D().setTo(flag.position)).z;
     if (port.mouseIntersects(flag.position, 0.5f, UI)) {
       if (dist < minDist) {
         minDist = dist;
         closest = mission;
       }
     }
   }
   return closest;
 }