Package civquest.units

Examples of civquest.units.Unit


    System.out.println("before done");
   

    MapData mapData = Game.getMapData();
    Unit unit = mapData.getUnit(unitID);

    // performs all necessary datastructure-upgrades (references
    // Field -> Unit, etc.)
    Game.getGame().remove(unit);
View Full Code Here


   */
  public MoveUnit(Coordinate to, long unitID, int newTime) {
    super(Game.getMapData().getUnit(unitID).getField().getPosition(),
        Game.getMapData().getField(to).getPosition(), unitID);
   
    Unit unit = Game.getMapData().getUnit(unitID);

    assert unit != null : "MoveUnit-Constructor: No unit with unit-ID"
      + unitID + " exists!";

    this.newTime = newTime;
View Full Code Here

    this.to = to;
    this.unitID = unitID;
  }

  public void execute() {
        Unit unit = Game.getMapData().getUnit(unitID);
    this.from = unit.getPosition();

    notifyBefore();

        Field toField = Game.getMapData().getField(to);
    Game.getMapData().moveMapObject(unit, toField);
//         Game.getMapData().setUnitPosition(unit, field);
    unit.setTime(newTime);

    notifyAfter();
  }
View Full Code Here

        Field field = mapData.getField(location);
        Nation nation = game.getNation(owner);

        Iterator<Unit> unitsIt = field.getUnitIterator();
        if (unitsIt.hasNext()) {
            Unit unit = unitsIt.next();
            if (!unit.getOwner().equals(nation)) {
                messages.err("ConstructUnit", "You try to build a unit " +
                        "on a field where another nation's unit is located.");
                return;
            }
        }
        if (field.getCityOnField() != null &&
                !field.getCityOnField().getOwner().equals(nation)) {
            messages.err("ConstructUnit", "You try to build a unit " +
            "on a field where another nation's city is located.");
            return;
        }

//     // for now to make it run
//     UnitModel aModel = nation.getUnitModel("Musketeer");

//     Unit unit = aModel.constructUnit();

    Unit unit = new Musketeer(field);
    Long unitID = unit.getID();
    this.setUnitID(unitID);

    unit.setField(field);
    Game.getGame().add(unit);
    Game.getMapData().setUnitOwner(unit, nation);
//     mapData.addUnit(unit, mapData.getField(location), nation);

    notifyAfter();
View Full Code Here

  private boolean canMoveThisTurn(Game game, Long[] units,
                  int timeForMove) {

    TimeRules timeRules = game.getTimeRules();
    for (Long unit : units) {
      Unit currUnit = game.getMapData().getUnit(unit);
      if (!timeRules.isActionAllowed(timeForMove, currUnit)) {
        return false;
      }
    }
    return true;
View Full Code Here

                        Coordinate to,
                        int[] timeForMove) {
    TimeRules timeRules = game.getTimeRules();
    List<GameChange> retList = new ArrayList<GameChange>();
    for (int n = 0; n < units.length; n++) {
      Unit currUnit = game.getMapData().getUnit(units[n]);
      int newTime = timeRules.getTimeAfterAction(timeForMove[n],
                             currUnit);
      retList.add(new MoveUnit(to, units[n], newTime));
    }
View Full Code Here

  }

  public void execute() {
    notifyBefore();

    Unit unit = Game.getMapData().getUnit(unitID);
    unit.setTime(newTime);

    notifyAfter();
  }
View Full Code Here

  }

  public void execute() {
    notifyBefore();

    Unit unit = Game.getMapData().getUnit(unitID);
    unit.resetTime();

    notifyAfter();
  }
View Full Code Here

        Field field = mapData.getField(location);
        Nation nation = Game.getGame().getNation(ownerNation);

        Iterator<Unit> unitsIt = field.getUnitIterator();
        if (unitsIt.hasNext()) {
            Unit unit = unitsIt.next();
            if (!unit.getOwner().equals(nation)) {
                messages.err("ConstructCity", "You try to build a city " +
                        "on a field where another nation's unit is located.");
                return;
            }
        }
View Full Code Here

    RestrictedToNation resToNation = gameDataAccessor.getRestrictedToNation();
    Group group = getActiveGroup();
    Iterator<Long> unitsIterator = group.getUnitIterator();
    while (unitsIterator.hasNext()) {
      Unit unit = Game.getMapData().getUnit(unitsIterator.next());
      if (unit != null && resToNation.contains(unit.getOwnerID())) {
        retSet.add(unit);
      }
    }
    return retSet;
  }
View Full Code Here

TOP

Related Classes of civquest.units.Unit

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.