@Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (selected != null) { Unit selectedUnit = selected; selected = null; Actor actor = getWorldStage().hit(x, y, true); if (actor == null || !(actor instanceof Unit)) { Service.eventQueue().enqueue(new MoveToPositionEvent(selectedUnit, new Vector2(x, y))); return; } Unit unit = (Unit) actor; if (selectedUnit != unit) { // if(unit.city==null && // !unit.getFaction().isFriend(selectedUnit.getFaction())) { // Service.eventQueue().enqueue(new AttackUnitEvent(selectedUnit, // (Unit) actor)); // } // else if(unit.city!=null && // unit.getFaction().isFriend(selectedUnit.getFaction()) && // selectedUnit.development!=null) { // } if (unit.city == null) { Service.eventQueue().enqueue(new AttackUnitEvent(selectedUnit, (Unit) actor)); } else if (unit.city != null && selectedUnit.combat != null) { // selectedUnit.combat.seize(unit); } } } }
@Override public void tap(InputEvent event, float x, float y, int pointer, int button) { Actor actor = getWorldStage().hit(x, y, true); if (actor instanceof Unit) { Unit unit = (Unit) actor; if (unit.city != null) { Service.eventQueue().enqueue(new ShowCityWeaponEvent((Unit) actor, true)); } Service.eventQueue().enqueue(new UnitSelectionEvent((Unit) actor, true)); } if (actor == null) { Service.eventQueue().enqueue(new UnitSelectionEvent((Unit) actor, false)); } }
@Override public void pan(InputEvent event, float x, float y, float deltaX, float deltaY) { Vector2 scrolling = new Vector2(); if (selected != null) { Service.eventQueue() .enqueue( new Event( EventName.SET_DEBUG_RENDERER, new DebugRendererArgument( "direction_" + selected.hashCode(), new DebugRenderer.LineRenderer( selected.getX(Align.center), selected.getY(Align.center), x, y)))); // scrolling = new Vector2(deltaX*0.25f, deltaY*0.25f); } else { scrolling = new Vector2(-deltaX, -deltaY); } Service.eventQueue().enqueue(new Event(EventName.MOVING_CAMERA, scrolling)); }
@Override public void touchDown(InputEvent event, float x, float y, int pointer, int button) { Actor actor = getWorldStage().hit(x, y, true); if (actor instanceof Unit) { Unit unit = (Unit) actor; if (unit.getFaction().isFriend(player.getFaction())) { selected = (Unit) actor; Service.eventQueue().enqueue(new UnitSelectionEvent(selected, true)); } } }