use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class VisibilityCondition method check.
@Override
public boolean check(Ref ref) {
if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
return false;
}
DC_Obj match = (DC_Obj) ref.getObj(KEYS.MATCH);
boolean result = false;
if (this.match == null && this.source == null) {
if (p_vision != null) {
PLAYER_VISION playerVision = match.getActivePlayerVisionStatus();
if (game.getManager().getActiveObj().isMine() != ref.getSourceObj().isMine()) {
if (ref.getSourceObj().isMine()) {
playerVision = match.getPlayerVisionStatus(false);
} else {
// TODO for enemy unit on player's unit...
}
}
if (playerVision == p_vision) {
return true;
}
}
UNIT_VISION visionStatus = match.getUnitVisionStatus();
if (!ref.getSourceObj().isActiveSelected()) {
visionStatus = match.getGame().getVisionMaster().getSightMaster().getUnitVisibilityStatus(match, (Unit) ref.getSourceObj());
}
return visionStatus.isSufficient(u_vision);
}
if (p_vision != null) {
Unit unit = (Unit) ref.getObj(source);
result = unit.getActivePlayerVisionStatus() == p_vision;
} else if (u_vision != null) {
match = (DC_Obj) ref.getObj(this.match);
// if (((DC_Game) game).getManager().isAI_Turn()) { what's the idea?
Unit activeObj = (Unit) ref.getObj(source);
result = ((DC_Game) game).getVisionMaster().getUnitVisibilityStatus(match, activeObj).isSufficient(u_vision);
// }
}
return result;
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class DamageCalculator method getBonusDamageList.
public static List<Damage> getBonusDamageList(Ref ref, DAMAGE_CASE CASE) {
List<Damage> list = new ArrayList<>();
// TODO make BonusDamage all add to source?
DC_Obj obj = (DC_Obj) ref.getSourceObj();
for (DAMAGE_CASE e : obj.getBonusDamage().keySet()) {
if (e == CASE) {
list.addAll(obj.getBonusDamage().get(e));
}
}
obj = (DC_Obj) ref.getObj(KEYS.ACTIVE);
for (DAMAGE_CASE e : obj.getBonusDamage().keySet()) {
if (e == CASE) {
list.addAll(obj.getBonusDamage().get(e));
}
}
if (obj instanceof DC_ActiveObj) {
obj = ((DC_ActiveObj) obj).getActiveWeapon();
if (obj != null) {
for (DAMAGE_CASE e : obj.getBonusDamage().keySet()) {
if (e == CASE) {
list.addAll(obj.getBonusDamage().get(e));
}
}
}
}
return list;
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class TimeRule method checkTime.
public boolean checkTime(DC_ActiveObj action, int time_used) {
DC_Obj unitObj = action.getOwnerObj();
Integer prevTime = timeMap.get(unitObj);
if (prevTime == null) {
prevTime = 0;
}
int time = prevTime + time_used;
timeMap.put(unitObj, time);
if (time > maxTime) {
maxTime = time;
int delta = getTimeRemaining() - (baseTime - time);
float percent = new Float(delta) / baseTime;
if (game.getDungeonMaster().getExplorationMaster() != null)
game.getDungeonMaster().getExplorationMaster().getAiMaster().tryMoveAiTurnBased(percent);
// % of time spent...
timeRemaining = baseTime - time;
game.getLogManager().log(LOG.GAME_INFO, "*** Time remaining for this round: " + timeRemaining, ENTRY_TYPE.ACTION);
}
return timeRemaining <= 0;
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class LE_MouseMaster method mouseClicked.
public void mouseClicked(MouseEvent e) {
// info click!
DC_Obj obj;
coordinates = null;
boolean right = SwingUtilities.isRightMouseButton(e);
CellComp cellComp = getGrid().getCompByPoint(e.getPoint());
previousCoordinate = coordinates;
coordinates = cellComp.getCoordinates();
obj = cellComp.getTopObjOrCell();
obj.setCoordinates(coordinates);
lastClicked = obj;
if (!right) {
selectedObj = obj;
}
if (right) {
setMode(null);
}
if (checkEventConsumed(obj, right)) {
getGrid().getPanel().repaint();
return;
}
LevelEditor.getGrid().setDirty(true);
handleClick(e, right);
if (LevelEditor.getGrid().isDirty()) {
LevelEditor.getGrid().refresh();
}
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class Level method addObj.
public void addObj(Unit obj, Coordinates c, boolean stack) {
Chronos.mark("adding " + obj);
obj.setZ(location.getZ());
if (stack) {
if (obj.isLandscape()) {
stack = false;
}
}
// if (!obj.isOverlaying())
// getTopObjMap().put(c, obj);
// if (obj instanceof Entrance) {
// if (location.getMainEntrance() == null) {
// location.setMainEntrance((Entrance) obj);
// location.getPlan().setEntranceLayout(
// DungeonLevelMaster.getLayout(location.getPlan(), c));
// LogMaster.log(1, "Main Entrance: " + obj + "; initComps = "
// + location.getPlan().getEntranceLayout());
// } else if (location.getMainExit() == null) {
// location.setMainExit((Entrance) obj);
// location.getPlan().setExitLayout(DungeonLevelMaster.getLayout(location.getPlan(), c));
// LogMaster.log(1, "Main Exit: " + obj + "; initComps = "
// + location.getPlan().getExitLayout());
// }
// location.getEntrances().add((Entrance) obj);
//
// }
cache();
// overwrite
if (!obj.isOverlaying() && !stack && initialized) {
// for (DC_Obj o : mapObjects)
// if (o.getCoordinates().equals(obj.getCoordinates())) {
List<DC_Obj> objects = getObjects(null, c);
objects.remove(obj);
removeObjects(objects);
}
MapBlock b = getBlockForCoordinate(c, false);
if (b != null) {
if (obj.isLandscape() && obj.getType().getName().equalsIgnoreCase(b.getZone().getFillerType())) {
b.getCoordinates().remove(c);
} else if (initialized) {
b.addObject(obj, c);
}
// TODO
} else {
if (!obj.isLandscape()) {
getWallObjects().add(obj);
}
}
Chronos.logTimeElapsedForMark("adding " + obj);
}
Aggregations