本文整理匯總了Java中com.badlogic.gdx.utils.IntMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java IntMap.put方法的具體用法?Java IntMap.put怎麽用?Java IntMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.IntMap
的用法示例。
在下文中一共展示了IntMap.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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;
}
示例4: 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();
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: getVertices
import com.badlogic.gdx.utils.IntMap; //導入方法依賴的package包/類
private void getVertices() {
IntMap<TextureFace> faces = new IntMap<TextureFace>();
IntMap<TextureFace> transpFaces = new IntMap<TextureFace>();
int i = 0;
for (int x = 0; x < SIZE; x++) {
for (int y = 0; y < SIZE; y++) {
for (int z = 0; z < SIZE; z++, i++) {
byte voxel = voxels[i];
if (voxel == 0) continue;
Voxel v = Voxel.getForId(voxel);
if (island.isSurrounded(x + pos.x, y + pos.y, z + pos.z, v.isOpaque())) continue;
for (Direction d : Direction.values()) {
byte w = island.get(x + d.dir.x + pos.x, y + d.dir.y + pos.y, z + d.dir.z + pos.z);
Voxel ww = Voxel.getForId(w);
if (w == 0 || (ww == null || !ww.isOpaque()) && w != voxel) {
TextureFace face = new TextureFace(d, new Vector3(x + pos.x, y + pos.y, z + pos.z), Voxel.getForId(voxel).getTextureUV(x, y, z, d));
if (v.isOpaque()) faces.put(face.hashCode(), face);
else transpFaces.put(face.hashCode(), face);
}
}
}
}
}
Mesher.generateGreedyMesh((int) pos.x, (int) pos.y, (int) pos.z, faces);
Mesher.generateGreedyMesh((int) pos.x, (int) pos.y, (int) pos.z, transpFaces);
for (IntMap.Entry<TextureFace> f : faces)
f.value.getVertexData(opaqueMeshData);
IntArray transpKeys = transpFaces.keys().toArray();
transpKeys.sort();
for (int index : transpKeys.toArray())
transpFaces.get(index).getVertexData(transpMeshData);
}
示例10: read
import com.badlogic.gdx.utils.IntMap; //導入方法依賴的package包/類
@Override
public IntMap read (Json json, JsonValue jsonData, Class type) {
IntMap intMap = new IntMap();
for (JsonValue entry = jsonData.child; entry != null; entry = entry.next) {
intMap.put(Integer.parseInt(entry.name), json.readValue(entry.name, null, jsonData));
}
return intMap;
}
示例11: cloneObject
import com.badlogic.gdx.utils.IntMap; //導入方法依賴的package包/類
@Override
protected IntMap cloneObject (IntMap original, IDeepCloner cloner, Map<Object, Object> clones) {
IntMap map = new IntMap(original.size);
for (Object object : original.entries()) {
Entry entry = (Entry) object;
map.put(entry.key, cloner.deepClone(entry.value, clones));
}
return map;
}
示例12: getAnimations
import com.badlogic.gdx.utils.IntMap; //導入方法依賴的package包/類
protected IntMap<Animation> getAnimations() {
IntMap<Animation> animations = new IntMap<Animation>();
Array textureRegion = new Array();
textureRegion.add(Mockito.mock(TextureRegion.class));
textureRegion.add(Mockito.mock(TextureRegion.class));
textureRegion.add(Mockito.mock(TextureRegion.class));
animations.put(0, new Animation(0.2f, textureRegion, Animation.PlayMode.LOOP));
animations.put(1, new Animation(0.2f, textureRegion, Animation.PlayMode.NORMAL));
return animations;
}
示例13: SimpleTileAtlas
import com.badlogic.gdx.utils.IntMap; //導入方法依賴的package包/類
public SimpleTileAtlas(TiledMap paramTiledMap, FileHandle paramFileHandle)
{
Iterator localIterator = paramTiledMap.tileSets.iterator();
while (localIterator.hasNext())
{
TileSet localTileSet = (TileSet)localIterator.next();
Object localObject = new Pixmap(paramFileHandle.child(localTileSet.imageName));
int i = ((Pixmap)localObject).getWidth();
int j = ((Pixmap)localObject).getHeight();
if ((!MathUtils.isPowerOfTwo(i)) || (!MathUtils.isPowerOfTwo(j)))
{
int k = MathUtils.nextPowerOfTwo(i);
int m = MathUtils.nextPowerOfTwo(j);
Pixmap localPixmap = new Pixmap(k, m, ((Pixmap)localObject).getFormat());
localPixmap.drawPixmap((Pixmap)localObject, 0, 0, 0, 0, k, m);
((Pixmap)localObject).dispose();
localObject = localPixmap;
}
Texture localTexture = new Texture((Pixmap)localObject);
((Pixmap)localObject).dispose();
this.textures.add(localTexture);
TextureRegion[][] arrayOfTextureRegion = split(localTexture, i, j, paramTiledMap.tileWidth, paramTiledMap.tileHeight, localTileSet.spacing, localTileSet.margin);
int n = 0;
int i1 = 0;
while (n < arrayOfTextureRegion[0].length)
{
int i2 = 0;
while (i2 < arrayOfTextureRegion.length)
{
IntMap localIntMap = this.regionsMap;
int i3 = i1 + 1;
localIntMap.put(i1 + localTileSet.firstgid, arrayOfTextureRegion[i2][n]);
i2++;
i1 = i3;
}
n++;
}
}
}
示例14: executeChanges
import com.badlogic.gdx.utils.IntMap; //導入方法依賴的package包/類
/** Applies the pending state changes and texture bindings to GL. This must be called in between {@link #begin()} and
* {@link #end()}. */
public void executeChanges () {
State pending = this.pending;
State current = this.current;
if (pending.depthMasking != current.depthMasking) {
Gdx.gl.glDepthMask(pending.depthMasking);
current.depthMasking = pending.depthMasking;
}
if (pending.depthTesting != current.depthTesting) {
if (pending.depthTesting)
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
else
Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
current.depthTesting = pending.depthTesting;
}
if (pending.depthTesting) {
if (pending.depthFunc != current.depthFunc) {
Gdx.gl.glDepthFunc(pending.depthFunc);
current.depthFunc = pending.depthFunc;
}
if (pending.depthRangeNear != current.depthRangeNear || pending.depthRangeFar != current.depthRangeFar) {
Gdx.gl.glDepthRangef(pending.depthRangeNear, pending.depthRangeFar);
current.depthRangeNear = pending.depthRangeNear;
current.depthRangeFar = pending.depthRangeFar;
}
}
if (pending.blending != current.blending) {
if (pending.blending)
Gdx.gl.glEnable(GL20.GL_BLEND);
else
Gdx.gl.glDisable(GL20.GL_BLEND);
current.blending = pending.blending;
}
if (pending.blending) {
if (pending.blendSrcFuncColor != current.blendSrcFuncColor || pending.blendDstFuncColor != current.blendDstFuncColor
|| pending.blendSrcFuncAlpha != current.blendSrcFuncAlpha || pending.blendDstFuncAlpha != current.blendDstFuncAlpha) {
if (pending.blendSrcFuncColor == pending.blendSrcFuncAlpha
&& pending.blendDstFuncColor == pending.blendDstFuncAlpha) {
Gdx.gl.glBlendFunc(pending.blendSrcFuncColor, pending.blendDstFuncColor);
} else {
Gdx.gl.glBlendFuncSeparate(pending.blendSrcFuncColor, pending.blendDstFuncColor, pending.blendSrcFuncAlpha,
pending.blendDstFuncAlpha);
}
current.blendSrcFuncColor = pending.blendSrcFuncColor;
current.blendDstFuncColor = pending.blendDstFuncColor;
current.blendSrcFuncAlpha = pending.blendSrcFuncAlpha;
current.blendDstFuncAlpha = pending.blendDstFuncAlpha;
}
if (pending.blendEquationColor != current.blendEquationColor
|| pending.blendEquationAlpha != current.blendEquationAlpha) {
if (pending.blendEquationColor == pending.blendEquationAlpha)
Gdx.gl.glBlendEquation(pending.blendEquationColor);
else
Gdx.gl.glBlendEquationSeparate(pending.blendEquationColor, pending.blendEquationAlpha);
}
}
IntMap<GLTexture> currentTextureUnits = current.textureUnits;
for (IntMap.Entry<GLTexture> entry : pending.textureUnits) {
if (currentTextureUnits.get(entry.key) != entry.value) {
entry.value.bind(entry.key);
currentTextureUnits.put(entry.key, entry.value);
}
}
}
示例15: map
import com.badlogic.gdx.utils.IntMap; //導入方法依賴的package包/類
private static IntMap<Block> map(Object...objects){
IntMap<Block> out = new IntMap<>();
for(int i = 0; i < objects.length; i += 2){
out.put(Hue.rgb((Color)objects[i]), (Block)objects[i+1]);
}
return out;
}