Example #1
0
  private void newEntity(EntityType newType) {

    Position[] posList =
        new Position[_preferences.getEntityHeight(newType) * _preferences.getEntityWidth(newType)];

    int i = 0;

    for (int x = _posSelected.getX();
        x < (_posSelected.getX() + _preferences.getEntityWidth(newType));
        x++)
      for (int y = _posSelected.getY();
          y < (_posSelected.getY() + _preferences.getEntityHeight(newType));
          y++) {

        posList[i] = new Position(x, y);

        i++;
      }

    if (_map.newEntity(
        posList,
        new Entity(newType),
        _preferences.getEntityHeight(newType),
        _preferences.getEntityWidth(newType))) {

      notifyAllSelectChanges();
      notifyNewEntity(posList, newType);
    }
  }
Example #2
0
  public void removeEntity() {

    Position entityPosition = _map.getCell(_posSelected).getPrimaryEntity();

    int entityID = _map.getEntityID(entityPosition);

    EntityType entity = _map.getEntity(entityID).getType();

    Position[] posList =
        new Position[_preferences.getEntityHeight(entity) * _preferences.getEntityWidth(entity)];

    int i = 0;

    for (int x = entityPosition.getX();
        x < (entityPosition.getX() + _preferences.getEntityWidth(entity));
        x++)
      for (int y = entityPosition.getY();
          y < (entityPosition.getY() + _preferences.getEntityHeight(entity));
          y++) {

        posList[i] = new Position(x, y);

        i++;
      }

    if (_map.removeEntity(posList, entityID)) {

      notifyRemoveEntity(posList);
      notifyCellDeSelected();
    }
  }
Example #3
0
  private void notifyNewMapLoaded() {

    notifyCellDeSelected();
    notifyNewMap(_map.getMapWidth(), _map.getMapHeight());

    _posSelected = null;

    Position pos = null;

    for (int x = 0; x < _map.getMapWidth(); x++)
      for (int y = 0; y < _map.getMapHeight(); y++) {

        pos = new Position(x, y);
        notifyCellChanged(pos, _map.getCell(pos).getType());

        int entityID = _map.getCell(pos).getEntity();

        if (entityID != 0) {

          Position entityPos = _map.getCell(pos).getPrimaryEntity();

          EntityType entityType = _map.getEntity(entityID).getType();

          Position[] posList =
              new Position
                  [_preferences.getEntityHeight(entityType)
                      * _preferences.getEntityWidth(entityType)];

          int i = 0;

          for (int xEntity = entityPos.getX();
              xEntity < (entityPos.getX() + _preferences.getEntityWidth(entityType));
              xEntity++)
            for (int yEntity = entityPos.getY();
                yEntity < (entityPos.getY() + _preferences.getEntityHeight(entityType));
                yEntity++) {

              posList[i] = new Position(xEntity, yEntity);
              i++;
            }

          notifyNewEntity(posList, entityType);
        }
      }
  }
Example #4
0
  public boolean deleteEntity() {

    boolean deleted =
        _preferences.deleteEntity(
            new ColorEntity(
                _preferences.getColorTypeEntity((EntityType) _elementSelected),
                (EntityType) _elementSelected,
                _preferences.getEntityHeight((EntityType) _elementSelected),
                _preferences.getEntityWidth((EntityType) _elementSelected)));

    if (deleted) notifyPreferencesChanged();

    return deleted;
  }
Example #5
0
  public void clicked(ElementType type) {

    _painting = true;

    _elementSelected = type;

    _posSelected = null;

    notifyCellDeSelected();

    if (type instanceof EntityType)
      notifyTypeElementSelected(
          type,
          _preferences.getEntityHeight((EntityType) type),
          _preferences.getEntityWidth((EntityType) type));
    else notifyTypeElementSelected(type, 0, 0);
  }