use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class UpkeepRule method apply.
@Override
public void apply(Unit unit) {
// TODO getOrCreate all buffs/units with this SOURCE /summoner
List<Obj> payObjects = new ArrayList<>();
List<Obj> destroyObjects = new ArrayList<>();
boolean destroy = unit.isDead() || unit.isUnconscious();
for (Unit u : game.getUnits()) {
if (destroy || u.isDead() || u.isUnconscious()) {
destroyObjects.add(u);
} else if (u.getRef().getObj(KEYS.SUMMONER) == unit) {
if (checkHasUpkeep(u)) {
payObjects.add(u);
}
}
}
for (Obj buff : game.getObjects(DC_TYPE.BUFFS)) {
try {
Obj spell = (Obj) buff.getRef().getActive();
if (spell == null) {
continue;
}
if (spell.getRef().getSourceObj() == unit) {
// TODO summoner?
if (checkHasUpkeep(buff)) {
payObjects.add(buff);
}
}
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
for (Obj payObj : destroyObjects) {
enactUpkeepFail(getFailAction(payObj), Ref.getSelfTargetingRefCopy(payObj));
}
for (Obj payObj : payObjects) {
if (!checkCanUpkeep(unit, payObj)) {
// positive upkeep?
enactUpkeepFail(getFailAction(payObj), Ref.getSelfTargetingRefCopy(payObj));
} else {
subtractUpkeep(unit, payObj);
}
}
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class CleaveRule method initNextTarget.
private void initNextTarget() {
boolean first = false;
if (clockwise == null) {
// find targets TODO
first = true;
}
// preCheck facing! always try the longest arc first, if
clockwise = true;
// it fails, then short one
DIRECTION direction = DirectionMaster.getRelativeDirection(source, currentTarget);
Obj objectByCoordinate = game.getObjectByCoordinate(source.getCoordinates().getAdjacentCoordinate(DirectionMaster.rotate45(direction, clockwise)), true);
if (objectByCoordinate instanceof Unit) {
currentTarget = (Unit) objectByCoordinate;
} else if (first) {
clockwise = false;
objectByCoordinate = game.getObjectByCoordinate(source.getCoordinates().getAdjacentCoordinate(DirectionMaster.rotate45(direction, clockwise)), true);
if (objectByCoordinate != null) {
currentTarget = (Unit) objectByCoordinate;
}
}
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class LE_MapMaster method loadBlock.
public void loadBlock(MapBlock block) {
if (block == null) {
return;
}
Coordinates c = pickCoordinate();
int offsetX = -CoordinatesMaster.getMinX(block.getCoordinates()) + c.x;
int offsetY = -CoordinatesMaster.getMinY(block.getCoordinates()) + c.y;
List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithOffset(block.getCoordinates(), offsetX, offsetY);
// coordinates=CoordinatesMaster.getCoordinatesWithin(c.x, , c.y, y1);
this.block = new MapBlock(getPlan().getBlocks().size(), block.getType(), getPlan().getZones().get(0), getPlan(), coordinates);
// should add to this.block
clearArea(coordinates);
for (Obj obj : block.getObjects()) {
// beware deadlock
LevelEditor.getCurrentLevel().setInitialized(false);
try {
Coordinates newCoordinates = new Coordinates(obj.getCoordinates().x + offsetX, obj.getCoordinates().y + offsetY);
obj.setCoordinates(newCoordinates);
LevelEditor.getObjMaster().addObj(obj.getType(), obj.getCoordinates());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
LevelEditor.getCurrentLevel().setInitialized(true);
}
}
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class LE_ObjMaster method moveSelectedObj.
public static void moveSelectedObj() {
Coordinates c = LE_MapMaster.pickCoordinate();
Obj selectedObj = LevelEditor.getMouseMaster().getSelectedObj();
int offsetX = c.x - selectedObj.getX();
int offsetY = c.y - selectedObj.getY();
moveObj(selectedObj.getCoordinates(), offsetX, offsetY);
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class LE_TreePlanPanel method getTreeCellRendererComponent.
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value == null) {
return null;
}
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
value = node.getUserObject();
if (value instanceof MapZone) {
return getZoneComponent((MapZone) value, selected);
}
if (value instanceof MapBlock) {
return getBlockComponent((MapBlock) value, selected);
}
if (value instanceof Obj) {
return getObjComponent((Obj) value, selected);
}
// TODO add dungeon icon
JLabel label = new JLabel(value.toString());
label.setForeground(ColorManager.GOLDEN_WHITE);
label.setFont(FontMaster.getFont(FONT.AVQ, 19, Font.PLAIN));
return label;
// new DefaultTreeCellRenderer().getTreeCellRendererComponent(tree,
// value, selected, expanded, leaf, row, hasFocus)
}
Aggregations