Search in sources :

Example 51 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class CoordinateTargeting method select.

public boolean select(Ref ref) {
    DC_Obj obj = (DC_Obj) ref.getObj(key);
    DIRECTION used_direction = direction;
    if (unitDirection != null) {
        Unit unit = (Unit) obj;
        used_direction = DirectionMaster.getDirectionByFacing(unit.getFacing(), unitDirection);
    }
    Coordinates coordinate = obj.getCoordinates().getAdjacentCoordinate(used_direction);
    List<BattleFieldObject> objects = obj.getGame().getMaster().getObjectsOnCoordinate(coordinate, false);
    if (objects.size() == 0) {
        ref.setTarget(obj.getGame().getCellByCoordinate(coordinate).getId());
    } else if (objects.size() == 1) {
        ref.setTarget(objects.get(0).getId());
    } else {
        ref.setGroup(new GroupImpl(new ArrayList<>(objects)));
    }
    return true;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) UNIT_DIRECTION(main.game.bf.Coordinates.UNIT_DIRECTION) DIRECTION(main.game.bf.Coordinates.DIRECTION) Coordinates(main.game.bf.Coordinates) GroupImpl(main.entity.group.GroupImpl) Unit(eidolons.entity.obj.unit.Unit)

Example 52 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class GridPanel method createUnitsViews.

private void createUnitsViews(DequeImpl<BattleFieldObject> units) {
    // lightingManager = new LightingManager(units, rows, cols);
    Map<Coordinates, List<BattleFieldObject>> map = new HashMap<>();
    for (BattleFieldObject object : units) {
        Coordinates c = object.getCoordinates();
        if (c == null)
            continue;
        if (!map.containsKey(c)) {
            map.put(c, new ArrayList<>());
        }
        List<BattleFieldObject> list = map.get(c);
        list.add(object);
    }
    for (Coordinates coordinates : map.keySet()) {
        List<BaseView> views = new ArrayList<>();
        List<OverlayView> overlays = new ArrayList<>();
        if (map.get(coordinates) == null) {
            continue;
        }
        for (BattleFieldObject object : map.get(coordinates)) {
            if (!object.isOverlaying()) {
                final BaseView baseView = createUnitView(object);
                views.add(baseView);
            } else {
                final OverlayView overlay = UnitViewFactory.createOverlay(object);
                if (!isVisibleByDefault(object))
                    overlay.setVisible(false);
                viewMap.put(object, overlay);
                Vector2 v = GridMaster.getVectorForCoordinate(object.getCoordinates(), false, false, this);
                overlay.setPosition(v.x, v.y - GridMaster.CELL_H);
                addOverlay(overlay);
            }
        }
        final GridCellContainer gridCellContainer = cells[coordinates.getX()][rows - 1 - coordinates.getY()];
        views.forEach(gridCellContainer::addActor);
    }
    shadowMap = new ShadowMap(this);
    wallMap = new WallMap();
    addActor(wallMap);
    GuiEventManager.bind(SHOW_MODE_ICON, obj -> {
        List list = (List) obj.get();
        UnitView view = (UnitView) getViewMap().get(list.get(0));
        view.updateModeImage((String) list.get(1));
    });
    if (DC_Engine.isAtbMode()) {
        GuiEventManager.bind(INITIATIVE_CHANGED, obj -> {
            Pair<Unit, Pair<Integer, Float>> p = (Pair<Unit, Pair<Integer, Float>>) obj.get();
            GridUnitView uv = (GridUnitView) viewMap.get(p.getLeft());
            if (uv == null) {
                addUnitView(p.getLeft());
                uv = (GridUnitView) viewMap.get(p.getLeft());
            }
            if (uv != null) {
                uv.getInitiativeQueueUnitView().setTimeTillTurn(p.getRight().getRight());
                uv.getInitiativeQueueUnitView().updateInitiative(p.getRight().getLeft());
            }
        });
    } else
        GuiEventManager.bind(INITIATIVE_CHANGED, obj -> {
            Pair<Unit, Integer> p = (Pair<Unit, Integer>) obj.get();
            GridUnitView uv = (GridUnitView) viewMap.get(p.getLeft());
            if (uv == null) {
                addUnitView(p.getLeft());
                uv = (GridUnitView) viewMap.get(p.getLeft());
            }
            if (uv != null)
                uv.getInitiativeQueueUnitView().updateInitiative(p.getRight());
        });
    GuiEventManager.bind(UNIT_CREATED, p -> {
        addUnitView((BattleFieldObject) p.get());
    });
    GuiEventManager.bind(VALUE_MOD, p -> {
        FloatingTextMaster.getInstance().createAndShowParamModText(p.get());
    });
    WaitMaster.receiveInput(WAIT_OPERATIONS.GUI_READY, true);
    WaitMaster.markAsComplete(WAIT_OPERATIONS.GUI_READY);
}
Also used : StrPathBuilder(main.system.auxiliary.StrPathBuilder) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) LastSeenMaster(eidolons.game.battlecraft.logic.battlefield.vision.LastSeenMaster) GuiEventType(main.system.GuiEventType) MapMaster(main.system.auxiliary.data.MapMaster) Entrance(eidolons.game.module.dungeoncrawl.dungeon.Entrance) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) DungeonScreen(eidolons.libgdx.screens.DungeonScreen) Ref(main.entity.Ref) Pair(org.apache.commons.lang3.tuple.Pair) Vector2(com.badlogic.gdx.math.Vector2) GdxMaster(eidolons.libgdx.GdxMaster) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) OptionsMaster(eidolons.system.options.OptionsMaster) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) HpBar(eidolons.libgdx.bf.overlays.HpBar) OUTLINE_TYPE(main.content.enums.rules.VisionEnums.OUTLINE_TYPE) MoveAnimation(eidolons.libgdx.anims.std.MoveAnimation) TextureManager(eidolons.libgdx.texture.TextureManager) DC_Obj(eidolons.entity.obj.DC_Obj) ActorMaster(eidolons.libgdx.anims.ActorMaster) Event(main.game.logic.event.Event) FadeOutAction(eidolons.libgdx.anims.actions.FadeOutAction) Align(com.badlogic.gdx.utils.Align) DC_Game(eidolons.game.core.game.DC_Game) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ShadowMap(eidolons.libgdx.bf.light.ShadowMap) HelpMaster(eidolons.system.text.HelpMaster) List(java.util.List) OutlineMaster(eidolons.game.battlecraft.logic.battlefield.vision.OutlineMaster) Keys(com.badlogic.gdx.Input.Keys) Coordinates(main.game.bf.Coordinates) WallMap(eidolons.libgdx.bf.overlays.WallMap) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) java.util(java.util) DequeImpl(main.system.datatypes.DequeImpl) DeathAnim(eidolons.libgdx.anims.std.DeathAnim) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener) AnimMaster(eidolons.libgdx.anims.AnimMaster) EVENT_TYPE(main.game.logic.event.Event.EVENT_TYPE) Gdx(com.badlogic.gdx.Gdx) Batch(com.badlogic.gdx.graphics.g2d.Batch) WaitMaster(main.system.threading.WaitMaster) GuiEventManager(main.system.GuiEventManager) StringMaster(main.system.auxiliary.StringMaster) DC_Engine(eidolons.game.battlecraft.DC_Engine) OverlaysManager(eidolons.libgdx.bf.overlays.OverlaysManager) PanelActionsDataSource(eidolons.libgdx.gui.panels.dc.actionpanel.datasource.PanelActionsDataSource) GRAPHIC_OPTION(eidolons.system.options.GraphicsOptions.GRAPHIC_OPTION) VisionManager(eidolons.game.battlecraft.logic.battlefield.vision.VisionManager) LogMaster(main.system.auxiliary.log.LogMaster) EventCallback(main.system.EventCallback) KEYS(main.entity.Ref.KEYS) AnimationConstructor(eidolons.libgdx.anims.AnimationConstructor) FloatingTextMaster(eidolons.libgdx.anims.text.FloatingTextMaster) ResourceSourceImpl(eidolons.libgdx.gui.panels.dc.unitinfo.datasource.ResourceSourceImpl) Group(com.badlogic.gdx.scenes.scene2d.Group) StyleHolder(eidolons.libgdx.StyleHolder) TEXT_CASES(eidolons.libgdx.anims.text.FloatingTextMaster.TEXT_CASES) eidolons.libgdx.bf(eidolons.libgdx.bf) WAIT_OPERATIONS(main.system.threading.WaitMaster.WAIT_OPERATIONS) java.awt(java.awt) TextureCache(eidolons.libgdx.texture.TextureCache) Eidolons(eidolons.game.core.Eidolons) Unit(eidolons.entity.obj.unit.Unit) DC_SoundMaster(eidolons.system.audio.DC_SoundMaster) SHADE_LIGHT(eidolons.libgdx.bf.light.ShadowMap.SHADE_LIGHT) Unit(eidolons.entity.obj.unit.Unit) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) ShadowMap(eidolons.libgdx.bf.light.ShadowMap) Coordinates(main.game.bf.Coordinates) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Vector2(com.badlogic.gdx.math.Vector2) WallMap(eidolons.libgdx.bf.overlays.WallMap)

Aggregations

BattleFieldObject (eidolons.entity.obj.BattleFieldObject)52 Unit (eidolons.entity.obj.unit.Unit)24 Coordinates (main.game.bf.Coordinates)22 DC_Obj (eidolons.entity.obj.DC_Obj)12 Ref (main.entity.Ref)12 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)10 Obj (main.entity.obj.Obj)9 DequeImpl (main.system.datatypes.DequeImpl)8 Event (main.game.logic.event.Event)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 DIRECTION (main.game.bf.Coordinates.DIRECTION)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 Vector2 (com.badlogic.gdx.math.Vector2)4 Align (com.badlogic.gdx.utils.Align)4 Eidolons (eidolons.game.core.Eidolons)4 Gdx (com.badlogic.gdx.Gdx)3 Keys (com.badlogic.gdx.Input.Keys)3 Batch (com.badlogic.gdx.graphics.g2d.Batch)3 Group (com.badlogic.gdx.scenes.scene2d.Group)3