Package civquest.group

Examples of civquest.group.Group


        this.map = map;
    }

    public void actionPerformed(FunctionActionEvent e) {
        if (this.map.getGameData() != null) {
            Group group = this.map.getActiveGroup();
            Coordinate wf = this.map.getWorkingFieldPos();
            int x = wf.x;
            int y = wf.y;
           
            Vector<Coordinate> coords = new Vector();
            Vector<Coordinate> temp = new Vector();
           
            //no loop here because I want to change the order a bit...
            temp.add(new Coordinate(x-1, y-1));
            temp.add(new Coordinate(x, y-1));
            temp.add(new Coordinate(x+1, y-1));
            temp.add(new Coordinate(x-1, y));
            temp.add(new Coordinate(x+1, y));
            temp.add(new Coordinate(x-1, y+1));
            temp.add(new Coordinate(x, y+1));
            temp.add(new Coordinate(x+1, y+1));
            temp.add(wf);

            MapData mapData = Game.getMapData();
            for (int i = 0; i < temp.size(); i++) {
                Coordinate coord = temp.get(i);
                if (mapData.isOnMap(coord)) {
                    coords.add(coord);
                }
            }
            Long[] fieldIDs = new Long[temp.size()];
            for (int i = 0; i < coords.size(); i++) {
                fieldIDs[i] = mapData.getFieldID(coords.get(i));
            }

            if (group.getFields().contains(wf)) {
                //unmark fields
                UnmarkField unmarkField = new UnmarkField(group, coords, fieldIDs);
                unmarkField.execute();
            } else {
                //mark fields
View Full Code Here


      bufferManager.paintBuffers(graphics, view, viewportPosition);
    }

    if (fmPainter != null) {
      Group group = this.getActiveGroup();
            if (group != null) {
                Iterator<Coordinate> markedFieldsIterator = group.getFieldIterator();
                while (markedFieldsIterator.hasNext()) {
                    fmPainter.paintFieldAsMarked(graphics, painter, properties,
                            markedFieldsIterator.next());
                }
      }
View Full Code Here

  private Set<Unit> getOwnActiveUnits() {
    Set<Unit> retSet = new HashSet<Unit>();

    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);
      }
View Full Code Here

  }

  private void calculateMovePaths() {

    if (workingField != null) {
      Group group = getActiveGroup();

      // We want a MovePath to dest, unless there are foreign units
      // (we would attack them instead)
      boolean wantToDest = true;
     
     
      if (config.displayMovePaths && group.containsUnits() && wantToDest) {
        Set<Long> markedOwnUnits = getMarkedOwnUnits();
       
        Set<Set<Long>> unitGroups
          = MoveCalculator.constructUnitGroups(gameDataAccessor,
                             markedOwnUnits);
View Full Code Here

  }

  public Set<Long> getMarkedOwnUnits() {
    // for now, this function returns also foreign marked units!
   
    Group group = getActiveGroup();
    Iterator<Long> unitIterator = group.getUnitIterator();
    Set<Long> markedOwnUnits = new HashSet<Long>();
    while (unitIterator.hasNext()) {
      Long currID = unitIterator.next();
      markedOwnUnits.add(currID);
    }   
View Full Code Here

        } else if (this.infoMode == InfoMode.MARKED_MODE) {
            for (Long unitID : unitIDs) {
                if (this.markedFieldUnits.containsKey(unitID) ||
                        this.activeUnits.containsKey(unitID)) {
                    //unitInfo displayed
                    Group group = mainMapView.getActiveGroup();
                    boolean removeUnitInfo = true;
                    UnitInfoComponent unitInfo = null;

                    if (this.activeUnits.containsKey(unitID)) {
                        if (!group.getUnits().contains(unitID)) {
                            //remove unit from activeUnits as it isn't active
                            //any more
                            unitInfo = this.activeUnits.get(unitID);
                            this.activeUnits.remove(unitID);
                        } else {
                            removeUnitInfo = false;
                        }
                    }
                    if (this.markedFieldUnits.containsKey(unitID)) {
                        if (!group.getUnitsOnFields().contains(unitID)) {
                            //remove unit from markedUnits if it isn't on a
                            //marked field any more
                            unitInfo = this.markedFieldUnits.get(unitID);
                            this.markedFieldUnits.remove(unitID);
                        } else {
                            removeUnitInfo = false;
                        }
                    }
                    if (removeUnitInfo) {
                        this.markedInfoPanel.remove(unitInfo);
                    }
                } else {
                    //unitInfo not displayed
                    Group group = mainMapView.getActiveGroup();
                    if (group.getUnits().contains(unitID) ||
                            group.getUnitsOnFields().contains(unitID)) {
                        //add unit to markedUnits if it is marked now
                        UnitInfoComponent unitInfo = new UnitInfoComponent(unitID,
                                this.unitInfoRuleset, false, this.gameData);
                        this.addUnitComponent(this.markedInfoPanel, unitInfo,
                                this.dummyMarkedPanel);
                        if (group.getUnits().contains(unitID)) {
                            this.activeUnits.put(unitID, unitInfo);
                        }
                        if (group.getUnitsOnFields().contains(unitID)) {
                            this.markedFieldUnits.put(unitID, unitInfo);
                        }
                    }
                }
            }
View Full Code Here

  }

  public void markOnlyField() {
    // We may assume that we are active - otherwise, the function couldn't be called
    if (gameData != null) {
      Group group = quadMap.getActiveGroup();
      if (group.getFields().contains(position)) {
                UnmarkField unmarkField = new UnmarkField(group, position);
                unmarkField.execute();
            } else {
                MarkField markField = new MarkField(group, position);
                markField.execute();
View Full Code Here

      Set<Long> newUnits = SetOperations.minus(realUnitIDs, units);
      units.addAll(0, newUnits);

      // Move marked units to the head of the list, their order with respect
      // to each other remains unchanged
      Group activeGroup = quadMap.getActiveGroup();

      Iterator<Long> markedUnitsIterator = activeGroup.getUnitIterator();
      Set<Long> markedUnitsOnField = filterForPos(moReader, markedUnitsIterator,
                            position);

      if (!markedUnitsOnField.isEmpty()) {
        // Update listening-setup
View Full Code Here

    } else {
      // Fetch the unit we want to paint
      Long topUnitID = units.get(0);

      // Determine wether it is marked (marked units blink)
      Group activeGroup = quadMap.getActiveGroup();
      blinking = activeGroup.containsUnit(topUnitID);

      // Fetch unit-image
      Section imageSection = ruleset.getSection("unitimages");
     
      MapObjectReader moReader = gameData.getMapObjectReader();
View Full Code Here

        if (this.units.size() < 1) {
            //there are no units...
            return;
        }
       
        Group group = this.quadMap.getActiveGroup();
        MapObjectReader moReader = gameData.getMapObjectReader();

        Set<Long> markedUnitsOnField = filterForPos(moReader,
                group.getUnitIterator(), position);

        List<Long> prevMarked
            = SetOperations.listRestrictedToSet(units, markedUnitsOnField);
        List<Long> prevNotMarked
            = SetOperations.listWithoutSet(units, markedUnitsOnField);
View Full Code Here

TOP

Related Classes of civquest.group.Group

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.