use of eidolons.libgdx.gui.panels.dc.unitinfo.datasource.ResourceSourceImpl in project Eidolons by IDemiurge.
the class GridPanel method onIngameEvent.
private EventCallback onIngameEvent() {
return param -> {
Event event = (Event) param.get();
Ref ref = event.getRef();
boolean caught = false;
if (event.getType() == STANDARD_EVENT_TYPE.EFFECT_HAS_BEEN_APPLIED) {
GuiEventManager.trigger(GuiEventType.EFFECT_APPLIED, event.getRef());
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_CHANGED_FACING || event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_TURNED_CLOCKWISE || event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_TURNED_ANTICLOCKWISE) {
BattleFieldObject hero = (BattleFieldObject) ref.getObj(KEYS.TARGET);
// if (hero.isMainHero()) TODO this is an experiment (insane) feature...
// if (hero.isMine()) {
// turnField(event.getType());
// }
BaseView view = viewMap.get(hero);
if (view != null && view instanceof GridUnitView) {
GridUnitView unitView = ((GridUnitView) view);
unitView.updateRotation(hero.getFacing().getDirection().getDegrees());
// SoundController.getCustomEventSound(SOUND_EVENT.UNIT_TURNS, );
if (hero instanceof Unit)
DC_SoundMaster.playTurnSound((Unit) hero);
}
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_FALLEN_UNCONSCIOUS) {
GuiEventManager.trigger(UNIT_GREYED_OUT_ON, ref.getSourceObj());
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_RECOVERED_FROM_UNCONSCIOUSNESS) {
GuiEventManager.trigger(UNIT_GREYED_OUT_OFF, ref.getSourceObj());
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED) {
GuiEventManager.trigger(UNIT_GREYED_OUT_OFF, ref.getSourceObj());
if (!DeathAnim.isOn() || ref.isDebug()) {
GuiEventManager.trigger(DESTROY_UNIT_MODEL, ref.getTargetObj());
}
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_BEING_MOVED) {
if (// || AnimMaster.isAnimationOffFor(ref.getSourceObj(), viewMap.get(ref.getSourceObj())))
!MoveAnimation.isOn())
removeUnitView((BattleFieldObject) ref.getSourceObj());
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_FINISHED_MOVING) {
if (!MoveAnimation.isOn() || AnimMaster.isAnimationOffFor(ref.getSourceObj(), viewMap.get(ref.getSourceObj())))
moveUnitView((BattleFieldObject) ref.getSourceObj());
caught = true;
} else if (event.getType().name().startsWith("PARAM_BEING_MODIFIED")) {
caught = true;
} else if (event.getType().name().startsWith("PROP_")) {
caught = true;
} else if (event.getType().name().startsWith("ABILITY_")) {
caught = true;
} else if (event.getType().name().startsWith("EFFECT_")) {
caught = true;
} else if (event.getType().name().startsWith("PARAM_MODIFIED")) {
if (GuiEventManager.isParamEventAlwaysFired(event.getType().getArg())) {
UnitView view = (UnitView) getViewMap().get(event.getRef().getSourceObj());
if (view != null)
if (view.isVisible())
if (view.getHpBar() != null)
// if (view.getHpBar( ).getDataSource().canHpBarBeVisible())
view.resetHpBar(new ResourceSourceImpl((BattleFieldObject) event.getRef().getSourceObj()));
}
caught = true;
}
if (!caught) {
/* System.out.println("catch ingame event: " + event.getType() + " in " + event.getRef());
*/
}
};
}
use of eidolons.libgdx.gui.panels.dc.unitinfo.datasource.ResourceSourceImpl in project Eidolons by IDemiurge.
the class UnitViewFactory method create.
public static GridUnitView create(BattleFieldObject bfObj) {
UnitViewOptions options = new UnitViewOptions(bfObj);
GridUnitView view = new GridUnitView(options);
if (VisionMaster.isLastSeenOn()) {
LastSeenView lsv = new LastSeenView(options, view);
view.setLastSeenView(lsv);
new LastSeenTooltipFactory().add(lsv, bfObj);
}
view.setOutlinePathSupplier(() -> {
OUTLINE_TYPE type = null;
// if (bfObj instanceof Unit) {
// if (!VisionManager.checkVisible(bfObj)) {
// type = OUTLINE_TYPE.DARK_OUTLINE;
// }
// }
// if (type == null)
type = bfObj.getOutlineTypeForPlayer();
if (type == null)
return null;
String path = Eidolons.game.getVisionMaster().getVisibilityMaster().getImagePath(type, bfObj);
return (path);
});
view.createHpBar((new ResourceSourceImpl(bfObj)));
if (bfObj instanceof Unit) {
view.getInitiativeQueueUnitView().getHpBar().setTeamColor(options.getTeamColor());
}
view.getHpBar().setTeamColor(options.getTeamColor());
final UnitViewTooltip tooltip = new UnitViewTooltip(view);
tooltip.setUserObject(UnitViewTooltipFactory.create(bfObj));
view.setToolTip(tooltip);
ClickListener listener = createListener(bfObj);
view.addListener(listener);
view.getInitiativeQueueUnitView().addListener(listener);
return view;
}
Aggregations