当前位置: 首页>>代码示例>>Java>>正文


Java IntMap.put方法代码示例

本文整理汇总了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();
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:18,代码来源:DiscoverySystem.java


示例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;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:17,代码来源:IntMapJsonSerializer.java


示例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;
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:12,代码来源:ColorMapper.java


示例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();
}
 
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:31,代码来源:Entity.java


示例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;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:28,代码来源:IntMapSerializer.java


示例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;
}
 
开发者ID:unlimitedggames,项目名称:gdxjam-ugg,代码行数:12,代码来源:InputController.java


示例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;
}
 
开发者ID:unlimitedggames,项目名称:gdxjam-ugg,代码行数:10,代码来源:Player.java


示例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;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:48,代码来源:Inventory.java


示例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);
}
 
开发者ID:Dakror,项目名称:Vloxlands,代码行数:40,代码来源:Chunk.java


示例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;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:11,代码来源:IntMapJsonSerializer.java


示例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;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:12,代码来源:IntMapCloner.java


示例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;

}
 
开发者ID:Rubentxu,项目名称:GDX-Logic-Bricks,代码行数:14,代码来源:BaseTest.java


示例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++;
    }
  }
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:40,代码来源:SimpleTileAtlas.java


示例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);
		}
	}

}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:75,代码来源:RenderContextAccumulator.java


示例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;
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:11,代码来源:WorldGenerator.java



注:本文中的com.badlogic.gdx.utils.IntMap.put方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。