本文整理汇总了Java中com.badlogic.gdx.utils.IntMap类的典型用法代码示例。如果您正苦于以下问题:Java IntMap类的具体用法?Java IntMap怎么用?Java IntMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntMap类属于com.badlogic.gdx.utils包,在下文中一共展示了IntMap类的40个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: Basic
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public Basic(Matrix4 transform, double speeed, int hp, int health, int range, float coolDown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionWorld world, IntMap<Entity> entities, List<Vector3> path, Map<String, Sound> sounds) {
super(transform, speeed, hp, health, range, coolDown, types, effects, instance, new btCompoundShape(), world, entities, ATTACK_ANIMATION, ATTACK_OFFSET, path, sounds);
((btCompoundShape)shape).addChildShape(new Matrix4(new Vector3(0, 30, 0), new Quaternion().setEulerAngles(0, 0, 0), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(75, 30, 90)));
//System.out.println(getModelInstance().getAnimation("Spider_Armature|walk_ani_vor").id);
listener = new AnimationController.AnimationListener() {
@Override
public void onEnd(AnimationController.AnimationDesc animationDesc) {
}
@Override
public void onLoop(AnimationController.AnimationDesc animationDesc) {
}
};
//animation.setAnimation("Spider_Armature|walk_ani_vor");
//animation.animate("Spider_Armature|walk_ani_vor", -1);
//animation.action("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
//animation.animate("Spider_Armature|Attack", 0, 1000, 1, 1, listener, 0);
//animation.queue("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
}
示例2: tick
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public void tick(float delta, GameScreen screen) {
if (!started && screen.isPaused()) {
started = true;
prevTime = System.currentTimeMillis();
}
if (spawns != null && enemyIndex < spawns.size() && System.currentTimeMillis() > prevTime + spawns.get(enemyIndex).getDelay()) {
prevTime = System.currentTimeMillis();
String name = spawns.get(enemyIndex).getName();
ModelInstance instance;
try {
Class<?> c = enemyClasses.get(name);
Constructor constructor = c.getConstructor(Matrix4.class, Map.class, btCollisionWorld.class, IntMap.class, List.class, Map.class);
enemies.add((Enemy) constructor.newInstance(new Matrix4().setToTranslation(pos), models, world, entity, path, sounds));
} catch (Exception e) {
Gdx.app.log("EnemySpawner spawn enemy", e.toString());
}
enemyIndex++;
}
//for (Enemy enemy : enemies)
// enemy.tick(delta, path);
}
示例3: update
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
protected void update(float delta) {
if (!paused && !isLoading) {
/*for (IntMap.Entry<Entity> entry : entities.entries()) {
entry.value.tick(delta);
if (entry.value.isDead) {
entry.value.destroy();
}
}*/
Iterator<IntMap.Entry<Entity>> iterator = entities.entries().iterator();
while (iterator.hasNext()) {
IntMap.Entry<Entity> entry = iterator.next();
entry.value.tick(delta);
if (entry.value.isDead) {
iterator.remove();
}
}
enemies.tick(delta, this);
collisionWorld.performDiscreteCollisionDetection();
camHandler.update(delta);
}
}
示例4: write
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public void write (Kryo kryo, Output output, IntMap map) {
int length = map.size;
output.writeVarInt(length, true);
output.writeBoolean(false); // whether type is written (in case future version of IntMap supports type awareness)
Serializer valueSerializer = null;
if (valueGenericType != null) {
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueGenericType);
valueGenericType = null;
}
for (Iterator iter = map.iterator(); iter.hasNext();) {
IntMap.Entry entry = (IntMap.Entry)iter.next();
output.writeInt(entry.key);
if (valueSerializer != null) {
kryo.writeObjectOrNull(output, entry.value, valueSerializer);
} else
kryo.writeClassAndObject(output, entry.value);
}
}
示例5: SystemInputHandler
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public SystemInputHandler(InputProxy inputProxy, InputMultiplexer inputMultiplexer, Array<NhgInput> systemInputArray) {
this.inputProxy = inputProxy;
vec0 = new Vector2();
keyboardButtonInputs = new IntMap<>();
mouseButtonInputs = new IntMap<>();
touchInputs = new IntMap<>();
activeKeyboardButtonInputs = new Array<>();
activeMouseButtonInputs = new Array<>();
activeTouchInputs = new Array<>();
mapSystemInput(systemInputArray);
handleSystemInput(inputMultiplexer);
}
示例6: copyAllItemsTo
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
/**
* Copies all items from this inventory into the destination inventory
*/
public void copyAllItemsTo(Inventory destinationInventory) {
for (BagType bag : BagType.values()) {
IntMap<InventoryItem> sourceBag = getBag(bag);
for (Entry<InventoryItem> slot : sourceBag.entries()) {
InventoryItem item = slot.value;
if (item != null) {
InventoryItem newCopy = item.createNewInstance();
if (item.getStackSize() > 1) {
for (int i = 1; i < item.getStackSize(); ++i) {
newCopy.addToStack(newCopy.createNewInstance());
}
}
destinationInventory.addToBag(bag, newCopy, slot.key);
}
}
}
}
示例7: removeFromBag
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
/**
* Removes the item in the supplied slot from the bag and returns it. If the
* slot was empty, null is returned.
*
* If the item was stackable and removeWholeStack is false, its stack is
* decreased and the item removed from the stack is returned.
*
* @param bagType
* @param slot
* @param removeWholeStack
* - if true, the whole stack is removed at once
* @return
*/
public InventoryItem removeFromBag(BagType bagType, Integer slot,
boolean removeWholeStack) {
IntMap<InventoryItem> bag = bags.get(bagType);
InventoryItem existingItem = bag.get(slot);
if (existingItem == null) {
return null;
}
if (existingItem.isInfinite() || (!removeWholeStack && existingItem.getStackSize() > 1)) {
existingItem = existingItem.removeFromStack();
} else {
bag.remove(slot);
}
existingItem.setInventory(null);
onItemRemove(existingItem, bagType);
return existingItem;
}
示例8: processTouch
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
public void processTouch(IntMap<Int2> touch) {
int deltaX, deltaY;
for(IntMap.Entry entry:touch.entries()) {
Int2 value = (Int2)entry.value;
Int2 xy = InputHandler.getXY(entry.key);
deltaX = value.x-xy.x;
deltaY = value.y-xy.y;
if(value.x < InputHandler.vWidth/2) {
player.axisInput(-deltaX/100f,deltaY/100f);
} else {
if(player.setRot(deltaX,deltaY)) {
value.x = xy.x;
value.y = xy.y;
player.jumpCount();
}
}
}
}
示例9: disposeShader
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
boolean disposeShader(ShaderProgram shaderProgram){
if (shaderProgram == null)
return false;
for (IntMap.Entry<UniqueShader> entry : blurPassShaderPrograms.entries()){
UniqueShader uniqueShader = entry.value;
if (uniqueShader.shaderProgram == shaderProgram){
uniqueShader.refCount--;
if (uniqueShader.refCount < 1){
shaderProgram.dispose();
blurPassShaderPrograms.remove(entry.key);
return true;
} else {
return false;
}
}
}
//not found!
shaderProgram.dispose();
return true;
}
示例10: gatherControllers
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
private void gatherControllers(boolean sendEvent) {
// gather all joysticks and gamepads, remove any disconnected ones
IntMap<AndroidController> removedControllers = new IntMap<AndroidController>();
removedControllers.putAll(controllerMap);
for(int deviceId: InputDevice.getDeviceIds()) {
InputDevice device = InputDevice.getDevice(deviceId);
AndroidController controller = controllerMap.get(deviceId);
if(controller != null) {
removedControllers.remove(deviceId);
} else {
addController(deviceId, sendEvent);
}
}
for(Entry<AndroidController> entry: removedControllers.entries()) {
removeController(entry.key);
}
}
示例11: getNeighbors
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
private Iterable<Entity> getNeighbors(Entity empire) {
IntMap<Entity> neighbors = new IntMap<>();
// collect entities we have relations with
for (Entity e : relations.get(empire).relations.keySet())
neighbors.put(e.getId(), e);
// collect entities we share influence with
for (MapPosition p : influences.get(empire).influencedTiles)
for (Entry inf : map.getInfluenceAt(p))
if (inf.key != empire.getId() && !neighbors.containsKey(inf.key)
// may be pending insertion into world if just revolted
&& world.getEntityManager().isActive(inf.key))
neighbors.put(inf.key, world.getEntity(inf.key));
return neighbors.values();
}
示例12: setUp
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
public void setUp() {
if (!allLoaded) {
int npairs = ids.size;
if (lines == null) {
lines = new IPosition[npairs][];
}
IntMap<IPosition> hipMap = sg.getStarMap();
allLoaded = true;
for (int i = 0; i < npairs; i++) {
int[] pair = ids.get(i);
IPosition s1, s2;
s1 = hipMap.get(pair[0]);
s2 = hipMap.get(pair[1]);
if (lines[i] == null && s1 != null && s2 != null) {
lines[i] = new IPosition[] { s1, s2 };
} else {
allLoaded = false;
}
}
}
}
示例13: deserialize
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
public IntMap<T> deserialize (JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonArray jsonArray = json.getAsJsonArray();
IntMap<T> intMap = new IntMap<>(jsonArray.size());
for (JsonElement element : jsonArray) {
JsonObject object = element.getAsJsonObject();
Entry<String, JsonElement> entry = object.entrySet().iterator().next();
int mapKey = Integer.parseInt(entry.getKey());
Class<?> mapObjectClass = GsonUtils.readClassProperty(object, context);
intMap.put(mapKey, context.deserialize(entry.getValue(), mapObjectClass));
}
return intMap;
}
示例14: filterCollisionSensors
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
private Array<CollisionSensor> filterCollisionSensors(Entity entity) {
Array<CollisionSensor> collisionSensors = new Array<CollisionSensor>();
CollisionSensorComponent collisionSensorComponent = entity.getComponent(CollisionSensorComponent.class);
if (collisionSensorComponent != null) {
IntMap.Values<ObjectSet<CollisionSensor>> values = collisionSensorComponent.sensors.values();
while (values.hasNext()) {
for (CollisionSensor sensor : values.next()) {
if (sensor.targetTag != null) {
collisionSensors.add(sensor);
}
}
}
}
return collisionSensors;
}
示例15: entityAdded
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
public void entityAdded(Entity entity) {
Log.debug(tag, "EntityAdded add RaySensors");
RigidBodiesComponents rigidBodiesComponent = entity.getComponent(RigidBodiesComponents.class);
RaySensorComponent raySensorComponent = entity.getComponent(RaySensorComponent.class);
if (raySensorComponent != null) {
IntMap.Values<ObjectSet<RaySensor>> values = raySensorComponent.sensors.values();
while (values.hasNext()) {
for (RaySensor sensor : values.next()) {
if (sensor.attachedRigidBody == null)
sensor.attachedRigidBody = rigidBodiesComponent.rigidBodies.first();
}
}
}
}
示例16: entityAdded
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
public void entityAdded(Entity entity) {
MouseSensorComponent mouseComponent = entity.getComponent(MouseSensorComponent.class);
if (mouseComponent != null) {
IntMap.Values<ObjectSet<MouseSensor>> values = mouseComponent.sensors.values();
while (values.hasNext()) {
for (MouseSensor sensor : values.next()) {
ObjectSet eventSensors;
if (mouseSensors.containsKey(sensor.mouseEvent)) {
eventSensors = mouseSensors.get(sensor.mouseEvent);
} else {
eventSensors = new ObjectSet<MouseSensor>();
mouseSensors.put(sensor.mouseEvent, eventSensors);
}
eventSensors.add(sensor);
}
}
}
}
示例17: Game
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public Game(LogicBricksEngine engine, World physics) {
this.engine = engine;
this.physics = physics;
renderingSystem = new RenderingSystem();
engine.addSystem(renderingSystem);
levelFactories = new IntMap<LevelFactory>();
categoryBitsManager = new CategoryBitsManager();
//engine.update(0);
Gdx.input.setInputProcessor(engine.getInputs());
physics.setContactListener(this);
Gdx.app.setLogLevel(Settings.DEBUG_LEVEL);
}
示例18: DefaultMusicSystem
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public DefaultMusicSystem(Level level) {
this.level = level;
for (IntMap.Entry<Music> entry : Musics.playing) {
if (entry.key < 1 || entry.key > 3) {
Musics.set(entry.key, null);
}
}
musics = new Music[] {
Musics.set(1, "main_1"),
Musics.set(2, "main_2"),
Musics.set(-2, "main_night_2"),
Musics.set(3, "main_3")
};
musics[0].setVolume(1f);
for (int i = 1; i < musics.length; i++) {
musics[i].setVolume(0f);
}
for (int i = 1; i < musics.length; i++) {
musics[i].setPosition(musics[i-1].getPosition());
}
for (int i = 0; i < musics.length; i++) {
musics[i].play();
}
}
示例19: map
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
private static IntMap<BlockPair> map(Object...objects){
IntMap<BlockPair> colors = new IntMap<>();
for(int i = 0; i < objects.length/2; i ++){
colors.put(Color.rgba8888(Color.valueOf((String)objects[i*2])), (BlockPair)objects[i*2+1]);
pairs.add((BlockPair)objects[i*2+1]);
}
for(Entry<BlockPair> e : colors.entries()){
reverseColors.put(e.value.wall == Blocks.air ? e.value.floor : e.value.wall, e.key);
}
return colors;
}
示例20: AttackingEntity
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public AttackingEntity(Matrix4 transform, int hp, int health, int range, EnumSet<Types> types, EnumSet<Effects> effects, float coolDown, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, String attackAnimation, Vector3 attackOffset, Map<String, Sound> sounds){
super(transform, hp, health, types, effects, instance, shape, world, entities, sounds);
this.coolDown = coolDown;
this.range = range;
this.attackAnimation = attackAnimation;
this.attackOffset = attackOffset;
callback = new ClosestRayResultCallback(new Vector3(), new Vector3());
}
示例21: Entity
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public Entity(Matrix4 transform, int hp, int health, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, Map<String, Sound> sounds){
this.instance = instance;
this.transform = transform;
this.hp = hp;
this.types = types;
this.health = health;
this.effects = effects;
this.sounds = sounds;
animation = new AnimationController(instance);
this.instance.transform.set(transform);
this.shape = shape;
body = new btCollisionObject();
body.setCollisionShape(shape);
body.setWorldTransform(this.instance.transform);
this.world = world;
tempVector = new Vector3();
tempVector2 = new Vector3();
this.entities = entities;
tempQuaternion = new Quaternion();
quaternion = new Quaternion();
if(this instanceof Enemy || this instanceof Projectile)
body.setCollisionFlags(body.getCollisionFlags());
int index = getNextIndex();
entities.put(index, this);
body.setUserValue(index);
world.addCollisionObject(body);
boundingBox = instance.calculateBoundingBox(new BoundingBox());
//for(Node node: instance.nodes)
//System.out.println();
}
示例22: Gun
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public Gun(Matrix4 transform, int hp, int health, int range, float cooldown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, String attack, EntityTemplate<Bullet> projectile, Vector3 attackOffset, Map<String, Sound> sounds) {
super(transform, hp, health, range, cooldown, types, effects, instance, shape, world, entities, attack, projectile, attackOffset, sounds);
nodes = new HashMap<String, Node>();
/*for(Node node: instance.model.nodes) {
System.out.println(node.id);
if (node.id.startsWith("Leg")) {
legs.add(node);
}
}*/
//legs.get(0).rotation.setEulerAngles(100, 0, 0);
for(Node node: instance.getNode("Gun_root").getChildren())
nodes.put(node.id, node);
}
示例23: EnemySpawner
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public EnemySpawner(Vector3 pos, Map<String, Class<?>> enemyClasses, List<Spawn> spawns, Map<String, Model> models, List<Enemy> enemies, List<Vector3> path, btCollisionWorld world, IntMap<Entity> entities, Map<String, Sound> sounds) {
this.enemies = enemies;
this.pos = pos;
this.enemyClasses = enemyClasses;
this.models = models;
this.spawns = spawns;
this.path = path;
this.world = world;
this.entity = entities;
this.sounds = sounds;
System.out.println(spawns);
}
示例24: Projectile
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public Projectile(Matrix4 transform, Vector3 velocity, int hp, int health, float speed, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance model, btCollisionShape shape, boolean isTower, btCollisionWorld world, IntMap<Entity> entities, float lifetime, Map<String, Sound> sounds) {
super(transform, hp, health, types, effects, model, shape, world, entities, sounds);
this.isTower = isTower;
this.velocity = velocity;
this.velocity.scl(speed);
this.lifetime = lifetime;
}
示例25: read
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public IntMap read (Kryo kryo, Input input, Class<IntMap> type) {
int length = input.readVarInt(true);
input.readBoolean(); // currently unused
IntMap map = new IntMap(length);
Class valueClass = null;
Serializer valueSerializer = null;
if (valueGenericType != null) {
valueClass = valueGenericType;
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
valueGenericType = null;
}
kryo.reference(map);
for (int i = 0; i < length; i++) {
int key = input.readInt();
Object value;
if (valueSerializer != null) {
value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
} else
value = kryo.readClassAndObject(input);
map.put(key, value);
}
return map;
}
示例26: hasPendingChanges
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public boolean hasPendingChanges () {
State pending = this.pending;
State current = this.current;
if (pending.depthMasking != current.depthMasking) return true;
if (pending.depthTesting != current.depthTesting) return true;
if (pending.depthTesting && pending.depthFunc != current.depthFunc) return true;
if (pending.blending != current.blending) return true;
if (pending.blending) {
if (pending.blendSrcFuncColor != current.blendSrcFuncColor || pending.blendDstFuncColor != current.blendDstFuncColor
|| pending.blendSrcFuncAlpha != current.blendSrcFuncAlpha || pending.blendDstFuncAlpha != current.blendDstFuncAlpha)
return true;
if (pending.blendEquationColor != current.blendEquationColor || pending.blendEquationAlpha != current.blendEquationAlpha)
return true;
}
IntMap<GLTexture> actualTextureUnits = current.textureUnits;
for (IntMap.Entry<GLTexture> entry : pending.textureUnits) {
if (actualTextureUnits.get(entry.key) != entry.value) return true;
}
return false;
}
示例27: touchDragged
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
for (IntMap.Entry<Touch> entry : pointers) {
entry.value.update(screenX, screenY);
}
eventTouch.dispatch(null);
return true;
}
示例28: InputController
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public InputController(Stage playStage, Stage guiStage){
this.playStage = playStage;
this.guiStage = guiStage;
this.inputMultiplexer = new InputMultiplexer(guiStage, playStage);
this.commandManager = new CommandManager();
this.players = new IntMap<>();
this.mappedKeysForPlayer = new ObjectMap<>();
}
示例29: mapKeyToCommand
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public <T extends Command> InputController mapKeyToCommand(int playerId, InputPeripheralType peripheralType, int key, Class<T> commandClass){
Player targetPlayer = this.players.get(playerId);
targetPlayer.mapCommand(peripheralType, key, commandClass);
IntMap<Player> mappedKeys = this.mappedKeysForPlayer.get(peripheralType);
if(mappedKeys == null){
mappedKeys = new IntMap<>();
this.mappedKeysForPlayer.put(peripheralType, mappedKeys);
}
mappedKeys.put(key, targetPlayer);
return this;
}
示例30: getTargetPlayerForKey
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
private Player getTargetPlayerForKey(int key, InputPeripheralType peripheralType){
IntMap<Player> mappedKeys = this.mappedKeysForPlayer.get(peripheralType);
if(mappedKeys == null)
return null;
else
return mappedKeys.get(key);
}
示例31: assignComponents
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
public void assignComponents(GameEntity gameEntity) {
ParticleTypesComponent particleC = gameEntity.addComponent(ParticleTypesComponent.class);
for(IntMap.Entry<ParticleType> entry : particleTypes){
particleC.particleTypes.put(entry.key, entry.value);
}
}
示例32: mapCommand
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public <T extends Command> Player mapCommand(InputPeripheralType peripheralType, int key, Class<T> commandClass){
IntMap<Class> mappedByPeripheral = mappedCommands.get(peripheralType);
if(mappedByPeripheral == null) {
mappedByPeripheral = new IntMap<>();
mappedCommands.put(peripheralType, mappedByPeripheral);
}
mappedByPeripheral.put(key, commandClass);
return this;
}
示例33: getCommandClass
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public <T extends Command> Class<T> getCommandClass(InputPeripheralType peripheralType, int key){
IntMap<Class> mappedByPeripheral = mappedCommands.get(peripheralType);
if(mappedByPeripheral != null){
Class<T> command = mappedByPeripheral.get(key);
if(command != null) {
return command;
}else{
Logger.getInstance().error("No command found for key [" + key + "] and peripheral [" + peripheralType + "]");
}
}else{
Logger.getInstance().log("No commands found for peripheral [" + peripheralType + "]");
}
return null;
}
示例34: OpenALAudio
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
this.deviceBufferSize = deviceBufferSize;
this.deviceBufferCount = deviceBufferCount;
registerSound("ogg", Ogg.Sound.class);
registerMusic("ogg", Ogg.Music.class);
registerSound("wav", Wav.Sound.class);
registerMusic("wav", Wav.Music.class);
registerSound("mp3", Mp3.Sound.class);
registerMusic("mp3", Mp3.Music.class);
try {
AL.create();
} catch (LWJGLException ex) {
noDevice = true;
ex.printStackTrace();
return;
}
allSources = new IntArray(false, simultaneousSources);
for (int i = 0; i < simultaneousSources; i++) {
int sourceID = alGenSources();
if (alGetError() != AL_NO_ERROR) break;
allSources.add(sourceID);
}
idleSources = new IntArray(allSources);
soundIdToSource = new LongMap<Integer>();
sourceToSoundId = new IntMap<Long>();
FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6)
.put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip();
alListener(AL_ORIENTATION, orientation);
FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
alListener(AL_VELOCITY, velocity);
FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
alListener(AL_POSITION, position);
recentSounds = new OpenALSound[simultaneousSources];
}
示例35: onInventoryClose
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
@Override
public void onInventoryClose() {
super.onInventoryClose();
if (shouldBeRemoved) {
GameMap map = getMap();
map.removeGameObject(ItemPile.this);
IntMap<InventoryItem> backPack = getBag(BagType.BACKPACK);
if (backPack.size == 1) {
InventoryItem lastItem = backPack.values().next();
Tile tile = position().tile();
new PickableGameObject(lastItem, tile.getX(), tile.getY(), map);
backPack.clear();
}
}
}
示例36: Inventory
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
public Inventory(InventoryContainer ic) {
bags = new ObjectMap<BagType, IntMap<InventoryItem>>();
for (BagType bag : BagType.values()) {
bags.put(bag, new IntMap<InventoryItem>());
}
this.parentContainer = ic;
}
示例37: getItem
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
/**
* Returns the item with the specified id from this Inventory, or null if
* such item cannot be found.
*
* The item is not actually removed from the intenvory when returned!
*
* @param id
* @return
*/
public InventoryItem getItem(String id) {
id = id.toLowerCase(Locale.ENGLISH);
for (BagType bagType : BagType.values()) {
IntMap<InventoryItem> bag = bags.get(bagType);
for (InventoryItem item : bag.values()) {
if (id.equals(item.getId())) {
return item;
}
}
}
return null;
}
示例38: addToBag
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
/**
* Adds the supplied InventoryItem to the supplied slot in the bag. If the
* slot is already occupied, and the item there is not stackable, the item
* there will be replaced by the new one and returned by this method.
*
* Otherwise the new item is just added to the stack and null is returned.
*
* If the supplied item already belonged to a different inventory, it will
* be removed from there.
*
* @param bagType
* @param item
* @param slot
* - if it is null, the first empty slot is used
* @return
*/
public InventoryItem addToBag(BagType bagType, InventoryItem item,
Integer slot) {
IntMap<InventoryItem> bag = bags.get(bagType);
InventoryItem existingItem = null;
// remove from previous owner if we had one
removeFromPreviousInventry(item);
if (slot == null) {
slot = findAcceptableSlot(bag, item);
}
if (bag.containsKey(slot)) {
existingItem = bag.get(slot);
}
if (existingItem != null && existingItem.isStackable(item)) {
existingItem.addToStack(item);
existingItem = null;
} else {
item.setSlot(slot);
item.setInventory(this);
item.setInventoryBag(bagType);
bag.put(slot, item);
if (existingItem != null) {
existingItem.setInventory(null);
onItemRemove(existingItem, bagType);
}
}
onItemAdd(item, bagType);
return existingItem;
}
示例39: findAcceptableSlot
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
private int findAcceptableSlot(IntMap<InventoryItem> bag, InventoryItem item) {
int slot = 0;
// first check for occupied slot that's stackable with the item
for (Entry<InventoryItem> entry: bag.entries()) {
if (entry.value.isStackable(item)) {
return entry.key;
}
}
// then search for an embty slot
while (bag.containsKey(slot)) {
++slot;
}
return slot;
}
示例40: clear
import com.badlogic.gdx.utils.IntMap; //导入依赖的package包/类
/**
* Removes all items from all bags of this inventory.
*/
public void clear() {
for (ObjectMap.Entry<BagType, IntMap<InventoryItem>> bag : bags.entries()) {
Iterator<Entry<InventoryItem>> iterator = bag.value.iterator();
while (iterator.hasNext()) {
InventoryItem item = iterator.next().value;
item.setInventory(null);
onItemRemove(item, bag.key);
iterator.remove();
}
}
}
注:本文中的com.badlogic.gdx.utils.IntMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。