/** Returns a triangularly distributed random number between {@code min} (inclusive) and {@code max} (exclusive), where the * {@code mode} argument defaults to the midpoint between the bounds, giving a symmetric distribution. * <p> * This method is equivalent of {@link #randomTriangular(float, float, float) randomTriangular(min, max, (min + max) * .5f)} * @param min the lower limit * @param max the upper limit */ public static float randomTriangular (float min, float max) { return randomTriangular(min, max, (min + max) * 0.5f); }
/** Returns a triangularly distributed random number between {@code min} (inclusive) and {@code max} (exclusive), where the * {@code mode} argument defaults to the midpoint between the bounds, giving a symmetric distribution. * <p> * This method is equivalent of {@link #randomTriangular(float, float, float) randomTriangular(min, max, (min + max) * .5f)} * @param min the lower limit * @param max the upper limit */ public static float randomTriangular (float min, float max) { return randomTriangular(min, max, (min + max) * 0.5f); }
@Override public float nextFloat () { if (-low == high && mode == 0) return MathUtils.randomTriangular(high); // It's faster return MathUtils.randomTriangular(low, high, mode); }
@Override public int nextInt () { float r; if (-low == high && mode == 0) r = MathUtils.randomTriangular(high); // It's faster else r = MathUtils.randomTriangular(low, high, mode); return Math.round(r); }
/** Returns a triangularly distributed random number between {@code min} (inclusive) and {@code max} (exclusive), where the * {@code mode} argument defaults to the midpoint between the bounds, giving a symmetric distribution. * <p> * This method is equivalent of {@link #randomTriangular(float, float, float) randomTriangular(min, max, (min + max) * .5f)} * @param min the lower limit * @param max the upper limit */ public static float randomTriangular (float min, float max) { return randomTriangular(min, max, (min + max) * 0.5f); }
@Override public float nextFloat () { if (-low == high && mode == 0) return MathUtils.randomTriangular(high); // It's faster return MathUtils.randomTriangular(low, high, mode); }
/** Returns a triangularly distributed random number between {@code min} (inclusive) and {@code max} (exclusive), where the * {@code mode} argument defaults to the midpoint between the bounds, giving a symmetric distribution. * <p> * This method is equivalent of {@link #randomTriangular(float, float, float) randomTriangular(min, max, (min + max) * .5f)} * @param min the lower limit * @param max the upper limit */ public static float randomTriangular (float min, float max) { return randomTriangular(min, max, (min + max) * 0.5f); }
@Override public int nextInt () { float r; if (-low == high && mode == 0) r = MathUtils.randomTriangular(high); // It's faster else r = MathUtils.randomTriangular(low, high, mode); return Math.round(r); }
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); } }
if (lastTime > 0) { float delta = now - lastTime; wanderOrientation += MathUtils.randomTriangular(wanderRate * delta);
@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); } } };
@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); } }
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); } }
@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); } }
if (lastTime > 0) { float delta = now - lastTime; wanderOrientation += MathUtils.randomTriangular(wanderRate * delta);