use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class DC_SoundMaster method bindEvents.
public static void bindEvents() {
GuiEventManager.bind(GuiEventType.ANIMATION_STARTED, p -> {
Anim anim = (Anim) p.get();
DC_ActiveObj activeObj = (DC_ActiveObj) anim.getActive();
try {
// TODO ON SEPARATE THREAD!!!!
playAnimStartSound(activeObj, anim.getPart());
} catch (Exception e) {
// main.system.ExceptionMaster.printStackTrace(e);
}
});
GuiEventManager.bind(GuiEventType.COMPOSITE_ANIMATION_STARTED, p -> {
CompositeAnim anim = (CompositeAnim) p.get();
DC_ActiveObj activeObj = (DC_ActiveObj) anim.getActive();
try {
playActionStartSound(activeObj);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
});
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class RollMaster method roll.
/**
* @return true if {failure} formula rolls more, false otherwise
*/
public static boolean roll(ROLL_TYPES roll_type, String success, String fail, Ref ref, String logAppendix, String rollSource, Boolean logged) {
Obj source = ref.getSourceObj();
Obj target = ref.getTargetObj();
// if (roll == null)
roll = new Roll(roll_type, success, fail, 0);
if (StringMaster.isEmpty(fail)) {
fail = initStdFail(roll_type);
}
Formula failFormula = new Formula(fail);
if (source != null) {
failFormula.applyFactor(getFailFactor(roll_type));
}
Boolean result;
int max1 = failFormula.getInt(ref);
if (StringMaster.isEmpty(success)) {
success = initStdSuccess(roll_type);
}
Formula successFormula = new Formula(success);
successFormula.applyFactor(getSuccessFactor(roll_type));
int max2 = successFormula.getInt(ref);
int min1 = MathMaster.applyMod(max1, DEFAULT_MIN_ROLL_PERC);
int min2 = MathMaster.applyMod(max2, DEFAULT_MIN_ROLL_PERC);
if (min1 >= max2) {
return true;
}
if (min2 >= max1) {
return false;
}
// per die?
rolledValue = RandomWizard.getRandomIntBetween(min1, max1);
rolledValue2 = RandomWizard.getRandomIntBetween(min2, max2);
roll.setRolledValue(rolledValue);
roll.setRolledValue2(rolledValue2);
result = rolledValue > rolledValue2;
if (target == null) {
target = ref.getEvent().getRef().getTargetObj();
}
// TODO display roll formulas if FULL_INFO is on!
if (rollSource == null) {
rollSource = rolledValue + " out of " + max1;
} else {
rollSource += StringMaster.wrapInParenthesis(rolledValue + " out of " + max1);
}
String rollTarget = rolledValue2 + " out of " + max2;
logString = target.getName() + ((result) ? " fails" : " wins") + " a " + roll_type.getName() + " roll with " + rollTarget + " vs " + source.getName() + "'s " + rollSource;
if (logAppendix != null) {
if (isAppendixAdded(logAppendix, result)) {
logString = logString + logAppendix.replace(getSuccessAppendixIdentifier(), "");
}
}
if (logged == null) {
logged = checkRollLogged(roll_type, result);
}
if (logged) {
ref.getGame().getLogManager().log(logString);
}
ref.getGame().getLogManager();
ref.getGame().getLogManager();
if (!ref.isAnimationDisabled()) {
PhaseAnimation anim = null;
if (ref.getActive() != null) {
// else ?
anim = ((DC_ActiveObj) ref.getActive()).getAnimation();
}
if (anim != null) {
anim.addPhaseArgs(PHASE_TYPE.ROLL, roll);
}
}
roll.setResult(result);
roll.setLogAppendix(logAppendix);
roll.setRollSource(rollSource);
roll.setRollTarget(rollTarget);
return result;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class AnimationConstructor method getBuffAnim.
public BuffAnim getBuffAnim(BuffObj buff) {
BuffAnim anim = new BuffAnim(buff);
DC_ActiveObj active = null;
if (buff.getActive() instanceof DC_ActiveObj) {
active = (DC_ActiveObj) buff.getActive();
}
initAnim(anim.getData(), active, anim.getPart(), anim);
if (!isValid(anim)) {
return null;
}
return anim;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class FloatingTextMaster method createFloatingText.
public void createFloatingText(TEXT_CASES CASE, String arg, Entity entity) {
FloatingText text;
try {
text = getFloatingText(entity, CASE, arg);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
return;
}
if (entity instanceof BattleFieldObject) {
Vector2 v = GridMaster.getCenteredPos(((BattleFieldObject) entity).getCoordinates());
text.setPosition(v);
} else {
if (entity instanceof DC_ActiveObj) {
Vector2 v = GridMaster.getCenteredPos(((DC_ActiveObj) entity).getOwnerObj().getCoordinates());
text.setPosition(v);
}
}
GuiEventManager.trigger(GuiEventType.ADD_FLOATING_TEXT, text);
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class ActivesConstructor method getSingleTargeting.
public static Targeting getSingleTargeting(DC_ActiveObj obj) {
List<ActiveObj> actives = obj.getActives();
if (actives == null) {
return null;
}
if (actives.size() < 1) {
return null;
}
if (actives.get(0) == null) {
return null;
}
Targeting targeting;
try {
targeting = ((AbilityObj) actives.get(0)).getType().getAbilities().getTargeting();
} catch (Exception e) {
targeting = getDefaultSingleTargeting(obj);
}
return targeting;
}
Aggregations