Search in sources :

Example 1 with TargetRunnable

use of eidolons.libgdx.bf.TargetRunnable in project Eidolons by IDemiurge.

the class DC_GameManager method select.

@Override
public Integer select(Set<Obj> selectingSet, Ref ref) {
    Pair<Set<Obj>, TargetRunnable> p = new ImmutablePair<>(selectingSet, (t) -> {
        if (ref.getActive() instanceof DC_ActiveObj) {
            // TODO CLICK ON ANY OTHER OBJ MUST RESULT IN SELECTION STOP!
            // ((DC_ActiveObj) ref.getActive()).activateOn(t);
            // WaitMaster.receiveInput(WAIT_OPERATIONS.SELECT_BF_OBJ, t.getId());
            t.invokeClicked();
        }
    });
    GuiEventManager.trigger(SELECT_MULTI_OBJECTS, p);
    for (Obj obj : new ArrayList<>(selectingSet)) {
        if (obj instanceof DC_Obj) {
            DC_Obj unit = (DC_Obj) obj;
            if (getActiveObj() != null) {
                if (getActiveObj().getZ() != unit.getZ()) {
                    selectingSet.remove(unit);
                }
            }
        }
    }
    this.selectingSet = selectingSet;
    if (selectingSet.isEmpty()) {
        // getGame().getToolTipMaster().addTooltip(SCREEN_POSITION.ACTIVE_UNIT_BOTTOM,
        // "No targets available!");
        DC_SoundMaster.playStandardSound(STD_SOUNDS.ACTION_CANCELLED);
        return null;
    }
    setSelecting(true);
    for (Obj obj : selectingSet) {
        DrawMasterStatic.getObjImageCache().remove(obj);
    }
    Integer id = selectAwait();
    if (id == null) {
        if (ref.getTarget() != null) {
            return ref.getTarget();
        }
    }
    return id;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Set(java.util.Set) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) MicroObj(main.entity.obj.MicroObj) ActiveObj(main.entity.obj.ActiveObj) BuffObj(main.entity.obj.BuffObj) Obj(main.entity.obj.Obj) PassiveAbilityObj(main.ability.PassiveAbilityObj) ArrayList(java.util.ArrayList) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) TargetRunnable(eidolons.libgdx.bf.TargetRunnable)

Example 2 with TargetRunnable

use of eidolons.libgdx.bf.TargetRunnable in project Eidolons by IDemiurge.

the class PartyManager method chooseMainHero.

protected String chooseMainHero() {
    if (party.getMembers().size() == 1) {
        return party.getLeader().getName();
    }
    // return ListChooser.chooseObj(party.getMembers(), SELECTION_MODE.SINGLE);
    if (!WaitMaster.isComplete(WAIT_OPERATIONS.GUI_READY)) {
        Object result = WaitMaster.waitForInput(WAIT_OPERATIONS.GUI_READY, 4000);
        if (result == null)
            return ListChooser.chooseObj(party.getMembers(), SELECTION_MODE.SINGLE);
    }
    Set<Obj> selectingSet = new HashSet<>(party.getMembers());
    Pair<Set<Obj>, TargetRunnable> p = new ImmutablePair<>(selectingSet, (t) -> {
        WaitMaster.receiveInput(WAIT_OPERATIONS.SELECT_BF_OBJ, t);
    });
    party.getMembers().forEach(hero -> {
        GuiEventManager.trigger(ADD_FLOATING_TEXT, FloatingTextMaster.getInstance().getFloatingText(hero, TEXT_CASES.BATTLE_COMMENT, hero.getName()));
    });
    GuiEventManager.trigger(SELECT_MULTI_OBJECTS, p);
    Unit unit = (Unit) WaitMaster.waitForInput(WAIT_OPERATIONS.SELECT_BF_OBJ, 15000);
    if (unit == null) {
        // List<JButton> pics = party.getMembers().stream().map(hero ->
        // new JButton(ImageManager.getIcon(hero.getImagePath().replace(" 128", "")))).collect(Collectors.toList());
        // int i = DialogMaster.optionChoice(pics.toArray(), "Choose a hero to control...");
        // if (i==-1)
        // i=0;
        String hero = // party.getMembers().get(i).getName();
        ListChooser.chooseObj(party.getMembers(), SELECTION_MODE.SINGLE);
        return hero;
    }
    return unit.getName();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Obj(main.entity.obj.Obj) Unit(eidolons.entity.obj.unit.Unit) HashSet(java.util.HashSet) TargetRunnable(eidolons.libgdx.bf.TargetRunnable)

Aggregations

TargetRunnable (eidolons.libgdx.bf.TargetRunnable)2 Set (java.util.Set)2 Obj (main.entity.obj.Obj)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)2 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 Unit (eidolons.entity.obj.unit.Unit)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 PassiveAbilityObj (main.ability.PassiveAbilityObj)1 ActiveObj (main.entity.obj.ActiveObj)1 BuffObj (main.entity.obj.BuffObj)1 MicroObj (main.entity.obj.MicroObj)1