@Override public void render( float delta, OrthographicCamera camera, GDXRenderer gdxRenderer, ShapeRenderer renderer) { if (!screen.isLive()) { renderer.setProjectionMatrix(camera.combined); renderer.begin(ShapeType.Line); for (GDXPath object : screen.getLevel().getPaths()) renderNodeList(object.getNodes(), renderer, Color.GRAY); if (pathWindow != null) renderNodeList(pathWindow.getNodes(), renderer, Color.DARK_GRAY); renderer.end(); } };
@Override public boolean touchDown(int x, int y, int x1, int y1) { super.touchDown(x, y, x1, y1); Gdx.app.debug("PathMode.touchDown", "x=" + x + " y=" + y); GDXPath path = screen.getLevel().getClosestPath(coordinates.x, coordinates.y); if (Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || path == null || path.getClosestNode(coordinates.x, coordinates.y).dst(coordinates.x, coordinates.y) > LevelEditorScreen.getNodeRadius()) path = new GDXPath(); if (pathWindow == null) screen.getStage().addActor(pathWindow = new PathWindow(screen.getSkin(), this, path)); if (path.getNodes().isEmpty()) pathWindow.add(coordinates.cpy()); return false; }
protected jbt.execution.core.ExecutionTask.Status internalTick() { Log.debug(this.getClass().getCanonicalName(), "ticked"); GDXPath objective = (GDXPath) getContext().getVariable(AIFieldEnum.OBJECTIVE.name()); NPC self = (NPC) getContext().getVariable(AIFieldEnum.SELF.name()); if (objective != null && !objective.getNodes().isEmpty()) { Vector2 target = objective.getNodes().get(0); getContext().setVariable("CurrentObjectiveTarget", new float[] {target.x, target.y}); if (objective.getNodes().get(0).dst(self.getPosition()) < 1) objective.getNodes().remove(0); if (objective.getNodes().isEmpty()) { switch (objective.getCompletionCriteria()) { case END: getContext().clearVariable(AIFieldEnum.OBJECTIVE.name()); break; case REPEAT: getContext().setVariable(AIFieldEnum.OBJECTIVE.name(), self.getPath().clone()); break; case REVERSE: boolean reversed = getContext().getVariable("PATH_REVERSED") == null || (boolean) getContext().getVariable("PATH_REVERSED"); GDXPath clone = (GDXPath) self.getPath().clone(); if (!reversed) clone.reverse(); getContext().setVariable("PATH_REVERSED", !reversed); getContext().setVariable(AIFieldEnum.OBJECTIVE.name(), clone); break; } } return Status.SUCCESS; } else { getContext().clearVariable("CurrentObjectiveTarget"); self.stopMovement(); return Status.FAILURE; } }
public void removePath(GDXPath path) { Gdx.app.log("PathMode.removePath", path.toString()); screen.getLevel().getPaths().remove(path); }
public void addPath(GDXPath path) { Gdx.app.log("PathMode.addPath", path.toString()); if (!screen.getLevel().getPaths().contains(path)) screen.getLevel().getPaths().add(path); }