use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class DrawMaster method drawSpecialIcons.
private void drawSpecialIcons(Unit obj) {
// obj.getEngagementTarget();
/*
* when drawing stacked objects, draw a red arrow/sword towards the ET
*/
Unit engageShowUnit = obj.getGame().getManager().getInfoUnit();
if (engageShowUnit == null) {
engageShowUnit = obj.getGame().getManager().getActiveObj();
} else if (engageShowUnit.isBfObj()) {
engageShowUnit = obj.getGame().getManager().getActiveObj();
}
Image overlay = null;
if (engageShowUnit.getEngagementTarget() == obj) {
overlay = STD_IMAGES.ENGAGEMENT_TARGET.getImage();
}
if (obj.getGame().getRules().getEngagedRule().getEngagers(engageShowUnit).contains(obj)) {
{
overlay = STD_IMAGES.ENGAGER.getImage();
}
}
if (overlay != null) {
BufferedImage image = ImageManager.getNewBufferedImage(getObjCompWidth(), getObjCompHeight());
Graphics g = image.getGraphics();
drawImage(g, overlay, 24, 24);
BfGridComp.getOverlayMap().put(new XLine(obj.getCoordinates(), new Coordinates(getOffsetX(obj), getOffsetY(obj))), image);
}
if (obj.isUnconscious()) {
// drawImage(g,
// ImageManager.getRandomBloodOverlay(GuiManager.getObjSize()), 0,
// 0);
// darkening/bloody overlay! perhaps on the cell frame as well,
// blood stains/dripping
// drawImage(g, image, x, y);
// black'n'white?
}
}
use of eidolons.entity.obj.unit.Unit 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 eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class DrawMasterStatic method drawWatchInfo.
public static void drawWatchInfo(int zoom, Graphics g) {
DC_Obj info = DC_Game.game.getManager().getInfoObj();
if (info instanceof Unit) {
java.util.List<DC_Obj> watchedObjects = WatchRule.getWatchersMap().get(info);
if (watchedObjects != null) {
drawWatchVisuals(watchedObjects, (Unit) info, g, zoom, watchedObjects, false, true);
drawWatchVisuals(watchedObjects, (Unit) info, g, zoom, watchedObjects, false, false);
}
} else {
Unit active = DC_Game.game.getManager().getActiveObj();
if (active.isMine()) {
java.util.List<DC_Obj> watchedObjects = WatchRule.getWatchersMap().get(active);
if (watchedObjects != null) {
drawWatchVisuals(watchedObjects, active, g, zoom, watchedObjects, true, true);
drawWatchVisuals(watchedObjects, active, g, zoom, watchedObjects, true, false);
}
}
}
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class BfMouseListener method mouseClicked.
@Override
public void mouseClicked(MouseEvent e) {
if (checkAnimationClick(e)) {
return;
}
if (checkDynamicButtonClick(e)) {
return;
}
point = e.getPoint();
cellComp = gridComp.getCompByPoint(e.getPoint());
Point relativePoint = new Point(point.x % gridComp.getCellWidth(), point.y % gridComp.getCellHeight());
objClicked = null;
for (Rectangle rect : cellComp.getMouseMap().keySet()) {
if (rect.contains(relativePoint)) {
Object object = cellComp.getMouseMap().get(rect);
if (object instanceof INTERACTIVE_ELEMENT) {
INTERACTIVE_ELEMENT element = (INTERACTIVE_ELEMENT) object;
switch(element) {
case STACK:
// if (CoreEngine.isLevelEditor())
objClicked = DialogMaster.objChoice("Which object?", cellComp.getObjects().toArray(new DC_Obj[cellComp.getObjects().size()]));
break;
case AP:
break;
case COUNTERS:
break;
case ITEMS:
Collection<? extends Obj> droppedItems = cellComp.getGame().getDroppedItemManager().getDroppedItems(cellComp.getTerrainObj());
break;
case LOCKS:
break;
case TRAPS:
break;
}
// break ;
} else if (object instanceof Obj) {
if (object instanceof Unit) {
if (objClicked != null) {
int index = cellComp.getObjects().indexOf(objClicked);
int index2 = cellComp.getObjects().indexOf(object);
LogMaster.log(1, objClicked + "'s " + index + " vs " + object + "'s " + index2);
if (index > index2) // TODO so we need to keep this always sorted...
{
continue;
}
}
Unit unit = (Unit) object;
if (unit.isOverlaying()) {
// corpseClicked(unit);
if (unit.getVisibilityLevel() == VisionEnums.VISIBILITY_LEVEL.CONCEALED) {
continue;
}
objClicked = unit;
break;
} else {
objClicked = unit;
continue;
}
} else if (object instanceof DC_Cell) {
if (e.isAltDown()) {
objClicked = (DC_Obj) object;
break;
} else if (objClicked == null) {
objClicked = (DC_Obj) object;
}
// ?
continue;
}
}
// if (objClicked == null)
// return; // ??
}
}
if (objClicked == null) {
objClicked = cellComp.getTopObjOrCell();
}
if (CoreEngine.isLevelEditor()) {
if (objClicked instanceof DC_Cell) {
return;
}
}
boolean right = SwingUtilities.isRightMouseButton(e);
if (right) {
objClicked.invokeRightClicked();
// gridComp.getGame().getManager().rightClicked(objClicked);
} else {
gridComp.getGame().getManager().objClicked(objClicked);
}
boolean debugMode = gridComp.getGame().isDebugMode();
if (debugMode) {
gridComp.getGame().getDebugMaster().setArg(objClicked);
}
if (e.isAltDown()) {
if (debugMode) {
invokeAltClick(right);
} else {
new Thread(new Runnable() {
public void run() {
gridComp.getGame().getMovementManager().moveTo(objClicked);
}
}, "moveTo thread").start();
}
}
if (e.isShiftDown()) {
invokeShiftClick(right);
}
if (e.isControlDown()) {
invokeControlClick(right);
}
}
use of eidolons.entity.obj.unit.Unit 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();
}
Aggregations