com.badlogic.gdx.ai.msg.Telegram Java Examples
The following examples show how to use
com.badlogic.gdx.ai.msg.Telegram.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultStateMachine.java From gdx-ai with Apache License 2.0 | 6 votes |
/** Handles received telegrams. The telegram is first routed to the current state. If the current state does not deal with the * message, it's routed to the global state's message handler. * * @param telegram the received telegram * @return true if telegram has been successfully handled; false otherwise. */ @Override public boolean handleMessage (Telegram telegram) { // First see if the current state is valid and that it can handle the message if (currentState != null && currentState.onMessage(owner, telegram)) { return true; } // If not, and if a global state has been implemented, send // the message to the global state if (globalState != null && globalState.onMessage(owner, telegram)) { return true; } return false; }
Example #2
Source File: GameStage.java From GdxDemo3D with Apache License 2.0 | 6 votes |
@Override public boolean handleMessage(Telegram telegram) { switch (telegram.message) { case Constants.MSG_GUI_SET_DOG_BUTTON_TO_WHISTLE: setDogButton(whistleButton, (HumanCharacter) telegram.extraInfo); return true; case Constants.MSG_GUI_SET_DOG_BUTTON_TO_THROW: setDogButton(throwButton, (HumanCharacter) telegram.extraInfo); return true; case Constants.MSG_GUI_CLEAR_DOG_BUTTON: clearDogButton((HumanCharacter) telegram.extraInfo); return true; case Constants.MSG_GUI_UPDATE_DOG_BUTTON: updateDogButton((HumanCharacter) telegram.extraInfo); return true; } return false; }
Example #3
Source File: InterruptibleFlatTiledAStarTest.java From gdx-ai with Apache License 2.0 | 6 votes |
@Override public boolean handleMessage (Telegram telegram) { switch (telegram.message) { case PF_RESPONSE: // PathFinderQueue will call us directly, no need to register for this message MyPathFinderRequest pfr = (MyPathFinderRequest)telegram.extraInfo; if (PathFinderRequestControl.DEBUG) { @SuppressWarnings("unchecked") PathFinderQueue<FlatTiledNode> pfQueue = (PathFinderQueue<FlatTiledNode>)telegram.sender; System.out.println("pfQueue.size = " + pfQueue.size() + " executionFrames = " + pfr.executionFrames); } // Swap double buffer workPath = activePath; activePath = (TiledSmoothableGraphPath<FlatTiledNode>)pfr.resultPath; isActivePathSmoothed = pfr.smoothEnabled; // Release the request requestPool.free(pfr); break; } return true; }
Example #4
Source File: TelegramProviderTest.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public boolean handleMessage (Telegram msg) { // build a new house if (houses.size <= 10) { houses.add(new House(this)); } return false; }
Example #5
Source File: TelegramProviderTest.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public boolean handleMessage (Telegram msg) { if (citizens.size < 3) { // new child Gdx.app.log(toString(), "We're having a baby!"); citizens.add(new Citizen(this)); } return false; }
Example #6
Source File: LevelAudioProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleMessage(final Telegram msg) { if (msg.message == MessageType.GAME_OVER.code()) { theme.stop(); gameOverMusic.play(); } else if (msg.message == MessageType.EXIT.code()) { theme.stop(); exitMusic.play(); } return true; }
Example #7
Source File: TelegramProviderTest.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public boolean handleMessage (Telegram msg) { Citizen citizen = (Citizen)msg.extraInfo; // greet only if not in the same house if (this.house.id != citizen.house.id) { Gdx.app.log(toString(), "Hi " + citizen + ", I'm your new neighbour"); } return false; }
Example #8
Source File: NinjaRabbitGame.java From ninja-rabbit with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleMessage(final Telegram msg) { if (msg.message == MessageType.RESET.code()) { reset(); } else if (msg.message == MessageType.DEAD.code()) { restartCurrentLevel(); } else if (msg.message == MessageType.BEGIN_LEVEL.code()) { beginNextLevel(); } return false; }
Example #9
Source File: NinjaRabbitPlayerStatusProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleMessage(final Telegram msg) { if (msg.message == MessageType.COLLECTED.code()) { getStatus().setCollectibles((short) (getStatus().getCollectibles() + 1)); getStatus().setScore(getStatus().getScore() + COLLECTIBLE_POINTS); } else if (msg.message == MessageType.DEAD.code()) { if (getStatus().getLives() > 0) { getStatus().setLives((short) (getStatus().getLives() - 1)); } System.out.println("Dead received!"); } return true; }
Example #10
Source File: LevelPlayerStatusProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleMessage(final Telegram msg) { getStatus().setLevel((byte) (getStatus().getLevel() + 1)); getStatus().setTime(PlayerStatus.DEFAULT_TIME); MessageManager.getInstance().dispatchMessage(this, MessageType.BEGIN_LEVEL.code()); return true; }
Example #11
Source File: MessageTimerTest.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public boolean handleMessage (Telegram msg) { this.msgCounter = (Integer)msg.extraInfo; this.msgTimestamp = msg.getTimestamp(); if (timerEnabledButton.isChecked()) { float lag = GdxAI.getTimepiece().getTime() - msg.getTimestamp(); lag -= (int)lag; // take the decimal part only (in case the lag is > 1) float delay = 1f - lag; sendMessage(delay, msgCounter + 1); } return true; }
Example #12
Source File: NinjaRabbitGraphicsProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleMessage(final Telegram msg) { Entity character = (Entity) msg.extraInfo; character.getBody().setTransform(RESPAWN_POSITION, character.getBody().getAngle()); character.changeState(NinjaRabbitState.IDLE); character.setDirection(Direction.RIGHT); return true; }
Example #13
Source File: InterruptibleHierarchicalTiledAStarTest.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public boolean handleMessage (Telegram telegram) { switch (telegram.message) { case PF_RESPONSE: // PathFinderQueue will call us directly, no need to register for this message if (PathFinderRequestControl.DEBUG) { @SuppressWarnings("unchecked") PathFinderQueue<HierarchicalTiledNode> pfQueue = (PathFinderQueue<HierarchicalTiledNode>)telegram.sender; System.out.println("pfQueue.size = " + pfQueue.size()); } MyPathFinderRequest pfr = (MyPathFinderRequest)telegram.extraInfo; TiledSmoothableGraphPath<HierarchicalTiledNode> path = paths[pfr.pathIndex]; int n = path.getCount(); if (n > 0 && pfr.pathFound && pfr.endNode != path.get(n - 1)) { pfr.startNode = path.get(n - 1); if(pfr.pathIndex + 1 < paths.length) { pfr.pathIndex++; } pfr.resultPath = paths[pfr.pathIndex]; pfr.changeStatus(PathFinderRequest.SEARCH_NEW); numPaths = pfr.pathIndex; } else { requestPool.free(pfr); numPaths = pfr.pathIndex + 1; } break; } return true; }
Example #14
Source File: DogCharacter.java From GdxDemo3D with Apache License 2.0 | 5 votes |
@Override public boolean handleMessage(Telegram telegram) { switch (telegram.message) { case Constants.MSG_DOG_LETS_PLAY: humanWantToPlay = true; stickThrown = false; break; case Constants.MSG_DOG_LETS_STOP_PLAYING: humanWantToPlay = false; break; case Constants.MSG_DOG_HUMAN_IS_DEAD: humanIsDead = true; humanWantToPlay = false; alreadyCriedForHumanDeath = false; break; case Constants.MSG_DOG_HUMAN_IS_RESURRECTED: humanIsDead = false; alreadyCriedForHumanDeath = false; break; case Constants.MSG_DOG_STICK_THROWN: stickThrown = true; break; } // Update GUI buttons if the dog's owner is selected if (this.human != null && this.human.selected) { MessageManager.getInstance().dispatchMessage(Constants.MSG_GUI_UPDATE_DOG_BUTTON, this.human); } return true; }
Example #15
Source File: PathFinderQueue.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public boolean handleMessage (Telegram telegram) { @SuppressWarnings("unchecked") PathFinderRequest<N> pfr = (PathFinderRequest<N>)telegram.extraInfo; pfr.client = telegram.sender; // set the client to be notified once the request has completed pfr.status = PathFinderRequest.SEARCH_NEW; // Reset status pfr.statusChanged = true; // Status has just changed pfr.executionFrames = 0; // Reset execution frames counter requestQueue.store(pfr); return true; }
Example #16
Source File: Elsa.java From gdx-ai with Apache License 2.0 | 4 votes |
@Override public boolean handleMessage (Telegram msg) { return stateMachine.handleMessage(msg); }
Example #17
Source File: Bob.java From gdx-ai with Apache License 2.0 | 4 votes |
@Override public boolean handleMessage (Telegram msg) { return stateMachine.handleMessage(msg); }
Example #18
Source File: PlayerAgent.java From Pacman_libGdx with MIT License | 4 votes |
@Override public boolean handleMessage(Telegram msg) { return stateMachine.handleMessage(msg); }
Example #19
Source File: NinjaRabbitAudioProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 4 votes |
@Override public boolean handleMessage(final Telegram msg) { assets.get(Assets.LIFE_LOST_FX).play(); return true; }
Example #20
Source File: NinjaRabbitInputProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 4 votes |
@Override public boolean handleMessage(final Telegram msg) { Gdx.input.setInputProcessor(null); return true; }
Example #21
Source File: LevelGraphicsProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 4 votes |
@Override public boolean handleMessage(final Telegram msg) { renderGameOver = msg.message == MessageType.GAME_OVER.code(); return true; }
Example #22
Source File: CollectibleRenderer.java From ninja-rabbit with GNU General Public License v2.0 | 4 votes |
@Override public boolean handleMessage(final Telegram msg) { Collectible collectible = (Collectible) msg.extraInfo; removed.add(collectible); return true; }
Example #23
Source File: HumanCharacter.java From GdxDemo3D with Apache License 2.0 | 4 votes |
@Override public boolean onMessage(HumanCharacter entity, Telegram telegram) { return false; }
Example #24
Source File: Zombie.java From riiablo with Apache License 2.0 | 4 votes |
@Override public boolean onMessage(Integer entityId, Telegram telegram) { return false; }
Example #25
Source File: Fallen.java From riiablo with Apache License 2.0 | 4 votes |
@Override public boolean onMessage(Integer entityId, Telegram telegram) { return false; }
Example #26
Source File: QuillRat.java From riiablo with Apache License 2.0 | 4 votes |
@Override public boolean onMessage(Integer entity, Telegram telegram) { return false; }
Example #27
Source File: GhostAgent.java From Pacman_libGdx with MIT License | 4 votes |
@Override public boolean handleMessage(Telegram msg) { return stateMachine.handleMessage(msg); }
Example #28
Source File: StateMachine.java From gdx-ai with Apache License 2.0 | 2 votes |
/** Handles received telegrams. * <p> * Implementation classes should first route the telegram to the current state. If the current state does not deal with the * message, it should be routed to the global state. * </p> * @param telegram the received telegram * @return true if telegram has been successfully handled; false otherwise. */ public boolean handleMessage (Telegram telegram);
Example #29
Source File: State.java From gdx-ai with Apache License 2.0 | 2 votes |
/** This method executes if the {@code entity} receives a {@code telegram} from the message dispatcher while it is in this * state. * * @param entity the entity that received the message * @param telegram the message sent to the entity * @return true if the message has been successfully handled; false otherwise. */ public boolean onMessage (E entity, Telegram telegram);