本文整理汇总了Java中com.badlogic.gdx.ai.msg.MessageManager类的典型用法代码示例。如果您正苦于以下问题:Java MessageManager类的具体用法?Java MessageManager怎么用?Java MessageManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageManager类属于com.badlogic.gdx.ai.msg包,在下文中一共展示了MessageManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: update
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
public void update(float deltaTime) {
// Update AI time
GdxAI.getTimepiece().update(deltaTime);
// Dispatch delayed messages
MessageManager.getInstance().update();
// Update Bullet simulation
// On default fixedTimeStep = 1/60, small objects (the stick) will fall through
// the ground (the ground has relatively big triangles).
dynamicsWorld.stepSimulation(deltaTime, 10, 1f / 240f);
for (GameObject object : objectsById.values()) {
if (object != null) {
object.update(deltaTime);
}
}
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:19,代码来源:GameEngine.java
示例2: update
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public void update(HumanCharacter entity) {
if (entity.isMoving()) {
// Keep on updating movement animation
updateAnimation(entity);
} else {
GameScreen.screen.sounds.whistle.play();
// If the entity owns a dog send it a delayed message to emulate reaction time
if (entity.dog != null) {
MessageManager.getInstance().dispatchMessage(MathUtils.randomTriangular(.8f, 2f, 1.2f), null, entity.dog,
Constants.MSG_DOG_LETS_PLAY);
}
// Transition to the appropriate idle state depending on the previous state
HumanState previousState = entity.stateMachine.getPreviousState();
HumanState nextState = HumanState.IDLE_STAND;
if (previousState != null) {
if (previousState.isMovementState()) {
nextState = previousState.idleState;
} else if (previousState.isIdleState()) {
nextState = previousState;
}
}
entity.stateMachine.changeState(nextState);
}
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:26,代码来源:HumanCharacter.java
示例3: enter
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public void enter(HumanCharacter entity) {
// Turn off animation
entity.animations.setAnimation("armature|idle_stand", -1);
entity.animations.paused = true;
// Stop steering and let friction and gravity arrest the entity
entity.stopSteering(false);
// Set ragdoll control
entity.setRagdollControl(true);
// Dog owners inform the dog of the death and clear dog button
if (entity.dog != null) {
MessageManager.getInstance().dispatchMessage(MathUtils.randomTriangular(.8f, 2f, 1.2f), null, entity.dog, Constants.MSG_DOG_HUMAN_IS_DEAD);
MessageManager.getInstance().dispatchMessage(Constants.MSG_GUI_CLEAR_DOG_BUTTON, entity);
}
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:19,代码来源:HumanCharacter.java
示例4: prepareToMove
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
protected void prepareToMove(HumanCharacter entity, float steeringMultiplier) {
entity.moveState = this;
// Apply the multiplier to steering limits
entity.setMaxLinearSpeed(HumanSteerSettings.maxLinearSpeed * steeringMultiplier);
entity.setMaxLinearAcceleration(HumanSteerSettings.maxLinearAcceleration * steeringMultiplier);
entity.setMaxAngularSpeed(HumanSteerSettings.maxAngularSpeed * steeringMultiplier);
entity.setMaxAngularAcceleration(HumanSteerSettings.maxAngularAcceleration * steeringMultiplier);
entity.followPathSteerer.followPathSB.setDecelerationRadius(HumanSteerSettings.decelerationRadius * steeringMultiplier);
// If the entity owns a dog tell him you don't want to play and re-enable whistle
if (entity.dog != null) {
MessageManager.getInstance().dispatchMessage(MathUtils.randomTriangular(.8f, 2f, 1.2f), null, entity.dog, Constants.MSG_DOG_LETS_STOP_PLAYING);
MessageManager.getInstance().dispatchMessage(Constants.MSG_GUI_SET_DOG_BUTTON_TO_WHISTLE, entity);
}
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:18,代码来源:HumanCharacter.java
示例5: CharacterController
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
public CharacterController(TextureAtlas buttonAtlas) {
whistleButton = new CharacterButton(HumanState.WHISTLE, buttonAtlas, "whistle-up", "whistle-down", "whistle-down");
throwButton = new CharacterButton(HumanState.THROW, buttonAtlas, "throw-up", "throw-down", "throw-down");
radioGroup = new ButtonGroup<CharacterButton>(
new CharacterButton(HumanState.MOVE_RUN, buttonAtlas, "run-up", "run-down", "run-down"),
new CharacterButton(HumanState.MOVE_WALK, buttonAtlas, "walk-up", "walk-down", "walk-down"),
new CharacterButton(HumanState.MOVE_CROUCH, buttonAtlas, "crouch-up", "crouch-down", "crouch-down"),
//new CharacterButton(CharacterState.MOVE_CRAWL, buttonAtlas, "crawl-up", "crawl-down", "crawl-down"),
new CharacterButton(HumanState.DEAD, buttonAtlas, "kill-up", "kill-down", "kill-down")
);
// Add whistle button and save the reference to the 1st cell
this.dogCell = add(whistleButton);
// Add radio buttons
for (CharacterButton btn : radioGroup.getButtons()) {
add(btn);
}
// Register this controller's interests
MessageManager.getInstance().addListeners(this,
Constants.MSG_GUI_CLEAR_DOG_BUTTON,
Constants.MSG_GUI_SET_DOG_BUTTON_TO_WHISTLE,
Constants.MSG_GUI_SET_DOG_BUTTON_TO_THROW);
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:27,代码来源:GameStage.java
示例6: clearTarget
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
public static void clearTarget (Entity target) {
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(TargetComponent.class).get());
for (Entity entity : entities) {
TargetComponent targetComp = Components.TARGET.get(entity);
if (targetComp.getTarget() == target) {
targetComp.setTarget(null);
//Dispatch a message to the entites FSM that there target was removed from the engine
if (Components.FSM.has(entity)) {
FSMComponent fsm = Components.FSM.get(entity);
MessageManager.getInstance().dispatchMessage(null, fsm, TelegramMessage.TARGET_REMOVED.ordinal(), target);
}
}
}
}
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:18,代码来源:EntityUtils.java
示例7: clearTarget
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
public void clearTarget (Entity target) {
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(TargetComponent.class, SquadComponent.class).get());
for (Entity squad : entities) {
SquadComponent squadComp = Components.SQUAD.get(squad);
squadComp.untrack(squad, target); //The squad no longer will track the target
TargetComponent targetComp = Components.TARGET.get(squad);
//If we were targeting that squad we remove it from our target
if (targetComp.getTarget() == target) {
targetComp.setTarget(null);
//Dispatch a message to the entites FSM that there target was removed from the engine
if (Components.FSM.has(squad)) {
FSMComponent fsm = Components.FSM.get(squad);
MessageManager.getInstance().dispatchMessage(null, fsm, TelegramMessage.TARGET_REMOVED.ordinal(), target);
}
}
}
}
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:22,代码来源:SquadEntityListener.java
示例8: track
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
public void track (Entity self, Entity target) {
if ((target.flags & EntityCategory.RESOURCE) == EntityCategory.RESOURCE) {
resourcesTracked.add(target);
resourceAgents.add(Components.STEERABLE.get(target));
sortTrackedResources();
MessageManager.getInstance().dispatchMessage(null, Components.FSM.get(self),
TelegramMessage.DISCOVERED_RESOURCE.ordinal());
} else if ((target.flags & EntityCategory.SQUAD) == EntityCategory.SQUAD) {
if (EntityUtils.isSameFaction(self, target)) {
friendliesTracked.add(target);
friendlyAgents.add(Components.STEERABLE.get(target));
} else {
enemiesTracked.add(target);
MessageManager.getInstance().dispatchMessage(null, Components.FSM.get(self), TelegramMessage.DISCOVERED_ENEMY.ordinal());
}
}
}
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:19,代码来源:SquadComponent.java
示例9: render
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public void render(final float delta) {
accumulator += Math.min(delta, 0.25f);
while (accumulator >= TIME_STEP) {
world.step(TIME_STEP, VELOCITY_ITERATIONS, POSITION_ITERATIONS);
accumulator -= TIME_STEP;
}
ninjaRabbit.update(viewport.getCamera());
viewport.getCamera().update();
game.getBatch().setProjectionMatrix(viewport.getCamera().combined);
environment.update(viewport.getCamera());
game.getBatch().begin();
ninjaRabbit.step(game.getBatch());
environment.step(game.getBatch());
game.getBatch().end();
MessageManager.getInstance().update(delta);
hud.render();
}
开发者ID:nfantone,项目名称:ninja-rabbit,代码行数:23,代码来源:LevelScreen.java
示例10: keyDown
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public boolean keyDown(final int keycode) {
switch (keycode) {
case JUMP_KEY:
character.changeState(NinjaRabbitState.JUMP);
break;
case LEFT_KEY:
character.changeState(NinjaRabbitState.LEFT);
break;
case RIGHT_KEY:
character.changeState(NinjaRabbitState.RIGHT);
break;
case DUCK_KEY:
// character.execute(NinjaRabbit.DUCK);
break;
case RESET_KEY:
MessageManager.getInstance().dispatchMessage(null, MessageType.DEAD.code(), character);
break;
default:
break;
}
return super.keyDown(keycode);
}
开发者ID:nfantone,项目名称:ninja-rabbit,代码行数:24,代码来源:NinjaRabbitInputProcessor.java
示例11: render
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public void render () {
float delta = Gdx.graphics.getDeltaTime();
elapsedTime += delta;
// Update time
GdxAI.getTimepiece().update(delta);
if (elapsedTime > 0.8f) {
// Update Bob and his wife
bob.update(elapsedTime);
elsa.update(elapsedTime);
// Dispatch any delayed messages
MessageManager.getInstance().update();
elapsedTime = 0;
}
}
开发者ID:libgdx,项目名称:gdx-ai,代码行数:20,代码来源:StateMachineTest.java
示例12: messageTest
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Test
public void messageTest() {
engine.addEntity(player);
MessageManager.getInstance().dispatchMessage(messageActuator, MessageHandler.getMessageKey(message));
engine.update(1);
assertTrue(sensor.positive);
assertEquals(LogicBrick.BrickMode.BM_ON, sensor.pulseState);
engine.update(1);
assertTrue(sensor.pulseState == LogicBrick.BrickMode.BM_OFF);
assertTrue(sensor.positive);
sensor.managedMessage = true;
engine.update(1);
assertTrue(sensor.pulseState == LogicBrick.BrickMode.BM_ON);
assertFalse(sensor.positive);
}
开发者ID:Rubentxu,项目名称:GDX-Logic-Bricks,代码行数:20,代码来源:MessageSensorSystemTest.java
示例13: update
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public void update(NhgEntry nhgEntry) {
float delta = Gdx.graphics.getDeltaTime();
MessageManager.getInstance().update();
nhgEntry.nhg.assets.update();
nhgEntry.nhg.entities.update(delta);
nhgEntry.onUpdate(delta);
}
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:11,代码来源:EngineStateRunning.java
示例14: update
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public void update(Assets assets) {
if (assets.assetManager.update()) {
assets.fsm.changeState(AssetsStates.IDLE);
MessageManager.getInstance().dispatchMessage(AssetsStates.ASSETS_GC);
assets.assetLoadingFinished();
publishLoadedAssets(assets);
}
}
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:11,代码来源:AssetStateLoading.java
示例15: AssetStateIdle
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
public AssetStateIdle() {
MessageManager.getInstance().addListener(new Telegraph() {
@Override
public boolean handleMessage(Telegram msg) {
startGcTask();
return true;
}
}, AssetsStates.ASSETS_GC);
}
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:10,代码来源:AssetStateIdle.java
示例16: execute
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public Status execute () {
DogCharacter dog = getObject();
HumanCharacter human = dog.human;
if (human.selected && dog.humanWantToPlay) {
int msg = enabled ? Constants.MSG_GUI_SET_DOG_BUTTON_TO_THROW : Constants.MSG_GUI_CLEAR_DOG_BUTTON;
boolean sendTelegram = enabled && dog.humanWantToPlay && !dog.stickThrown;
if (!enabled)
sendTelegram = dog.humanWantToPlay && dog.stickThrown;
if (sendTelegram) {
MessageManager.getInstance().dispatchMessage(msg, human);
}
}
return Status.SUCCEEDED;
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:16,代码来源:SetThrowButtonTask.java
示例17: handleMessage
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@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;
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:30,代码来源:DogCharacter.java
示例18: exit
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
@Override
public void exit(HumanCharacter entity) {
entity.animations.paused = false;
entity.setRagdollControl(false);
// Dog owners inform the dog of the resurrection and enable whistle button
if (entity.dog != null) {
MessageManager.getInstance().dispatchMessage(MathUtils.randomTriangular(.8f, 1.5f), null, entity.dog, Constants.MSG_DOG_HUMAN_IS_RESURRECTED);
MessageManager.getInstance().dispatchMessage(Constants.MSG_GUI_SET_DOG_BUTTON_TO_WHISTLE, entity);
}
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:12,代码来源:HumanCharacter.java
示例19: onStickLanded
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
public void onStickLanded() {
stick.hasLanded = true;
// If the entity owns a dog send it a delayed message to emulate reaction time
if (dog != null) {
MessageManager.getInstance().dispatchMessage(MathUtils.randomTriangular(.3f, 1.2f, .6f), null, dog,
Constants.MSG_DOG_STICK_THROWN);
}
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:9,代码来源:HumanCharacter.java
示例20: constructUnit
import com.badlogic.gdx.ai.msg.MessageManager; //导入依赖的package包/类
public void constructUnit (Entity squad) {
if (resourceSystem.resources >= unitCost) {
resourceSystem.resources -= unitCost;
EntityFactory.createUnit(squad);
MessageManager.getInstance().dispatchMessage(this, Components.FSM.get(squad),
TelegramMessage.CONSTRUCT_UNIT_CONFRIM.ordinal());
} else {
MessageManager.getInstance().dispatchMessage(TelegramMessage.GUI_INSUFFICIENT_RESOURCES.ordinal());
}
}
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:11,代码来源:ConstructionSystem.java
注:本文中的com.badlogic.gdx.ai.msg.MessageManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论