use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class DrawMasterStatic method drawDiagonalJoints.
public static void drawDiagonalJoints(int zoom, Graphics g, int offsetX, int offsetY, int w, int h, Map<Coordinates, java.util.List<Coordinates.DIRECTION>> diagonalJoints) {
for (Coordinates c : diagonalJoints.keySet()) {
boolean darken = false;
Unit obj = DC_Game.game.getUnitByCoordinate(c);
// TODO CHECK WALL
if (obj == null) {
obj = DC_Game.game.getUnitByCoordinate(c);
continue;
}
if (!CoreEngine.isLevelEditor()) {
if (!obj.isDetected()) {
if (!DebugMaster.isOmnivisionOn()) // obj.getPlayerVisionStatus(false) !=
// UNIT_TO_PLAYER_VISION.DETECTED
{
continue;
}
}
}
if (obj != null) {
darken = obj.getVisibilityLevel() != VisionEnums.VISIBILITY_LEVEL.CLEAR_SIGHT;
}
String prefix = darken ? "dark" : "";
int x = w * (c.x - offsetX);
int y = h * (c.y - offsetY);
if (x < 0) {
continue;
}
if (x > GuiManager.getBattleFieldWidth()) {
continue;
}
if (y < 0) {
continue;
}
if (y > GuiManager.getBattleFieldHeight()) {
continue;
}
java.util.List<Coordinates.DIRECTION> list = diagonalJoints.get(c);
for (Coordinates.DIRECTION side : list) {
int x1 = x;
int y1 = y;
boolean flipped = false;
if (side == Coordinates.DIRECTION.DOWN_LEFT) {
y1 += h;
} else if (side == Coordinates.DIRECTION.DOWN_RIGHT) {
x1 += w;
y1 += h;
flipped = true;
} else if (side == Coordinates.DIRECTION.UP_LEFT) {
flipped = true;
} else if (side == Coordinates.DIRECTION.UP_RIGHT) {
x1 += w;
}
// if (list.indexOf(side) > 0) {
// flipped = !flipped;
// }
// getOrCreate the rim for this side
// add offset if necessary
Image image = ImageManager.STD_IMAGES.WALL_CORNER_ALMOND.getPathPrefixedImage(prefix);
if (zoom != 100) {
image = ImageManager.getSizedVersion(image, zoom, true);
}
if (flipped) {
image = ImageTransformer.flipHorizontally(ImageManager.getBufferedImage(image));
}
// TODO scale them!
drawImage(g, image, x1 - image.getWidth(null) / 2, y1 - image.getHeight(null) / 2);
}
}
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class BfGridComp method initCellsAndMap.
private void initCellsAndMap() {
cells = new CellComp[getCellsX()][getCellsY()];
for (int i = 0; i < getCellsX(); i++) {
for (int j = 0; j < getCellsY(); j++) {
DC_Cell cellEntity = new DC_Cell(i, j, game, new Ref(), game.getDungeon());
Coordinates coordinates = new Coordinates(i, j);
cellEntityMap.put(coordinates, cellEntity);
if (!CoreEngine.isLevelEditor())
continue;
CellComp cell = new CellComp(game, coordinates, this);
getMap().put(coordinates, cell);
cells[i][j] = cell;
}
}
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class DC_BattleFieldGrid method resetComponents.
@Deprecated
private void resetComponents() {
int offsetX = getOffsetX();
int offsetY = getOffsetY();
LogMaster.log(0, "resetting grid comps with offsetX = " + offsetX + ";offsetY =" + offsetY);
for (int i = 0; i < getDisplayedCellsX(); i++) {
for (int j = 0; j < getDisplayedCellsY(); j++) {
int x = i + getOffsetX();
int y = j + getOffsetY();
Coordinates c = new Coordinates(x, y);
List<BattleFieldObject> objects = game.getObjectsOnCoordinate(getZ(), c, false, true, false);
List<Unit> overlayingObjects = new ArrayList<>(new DequeImpl(game.getObjectsOnCoordinate(getZ(), c, true, true, false)).getRemoveAll(objects));
// visibility preCheck!
CellComp comp = gridComp.getCells()[x][y];
List<BattleFieldObject> list = new ArrayList<>();
for (BattleFieldObject obj : objects) {
if (VisionManager.checkVisible(obj)) {
list.add(obj);
}
}
comp.setSizeFactor(gridComp.getZoom());
comp.setOverlayingObjects(overlayingObjects);
if (list.size() != 0) {
// comp.setObjects(list);
}
comp.refresh();
}
}
comp.refresh();
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class DC_BattleFieldGrid method noObstacles.
private boolean noObstacles(int xy, int xy1, int xy2, Obj source, boolean x_y) {
int max = xy2;
int min = xy1;
if (xy1 > xy2) {
max = xy1;
min = xy2;
}
for (int i = min + 1; i < max; i++) {
Coordinates c = (x_y) ? new Coordinates(xy, i) : new Coordinates(i, xy);
List<BattleFieldObject> objects = game.getMaster().getObjectsOnCoordinate(getZ(), c, false, false, false);
for (BattleFieldObject obj : objects) {
if (obj.isObstructing(source, game.getCellByCoordinate(c))) {
return false;
}
}
}
return true;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class DC_BattleFieldGrid method noObstaclesOnDiagonal.
@Override
public boolean noObstaclesOnDiagonal(Coordinates c1, Coordinates c2, Obj source) {
boolean above = PositionMaster.isAbove(c1, c2);
boolean left = PositionMaster.isToTheLeft(c1, c2);
int X = c1.x;
int Y = c1.y;
while (X != c2.x || Y != c2.y) {
if (above) {
Y++;
} else {
Y--;
}
if (left) {
X++;
} else {
X--;
}
if (X == c2.x || Y == c2.y) {
break;
}
Coordinates c = new Coordinates(X, Y);
List<BattleFieldObject> objects = game.getMaster().getObjectsOnCoordinate(c, false);
for (BattleFieldObject obj : objects) {
if (obj.isObstructing(source, game.getCellByCoordinate(c))) {
return false;
}
}
}
return true;
}
Aggregations