本文整理汇总了Java中com.badlogic.gdx.utils.IntIntMap类的典型用法代码示例。如果您正苦于以下问题:Java IntIntMap类的具体用法?Java IntIntMap怎么用?Java IntIntMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntIntMap类属于com.badlogic.gdx.utils包,在下文中一共展示了IntIntMap类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributeLocations
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
protected final int[] getAttributeLocations(Renderable renderable) {
final IntIntMap attributes = new IntIntMap();
final VertexAttributes attrs = renderable.meshPart.mesh.getVertexAttributes();
final int c = attrs.size();
for (int i = 0; i < c; i++) {
final VertexAttribute attr = attrs.get(i);
final int location = program.getAttributeLocation(attr.alias);
if (location >= 0)
attributes.put(attr.getKey(), location);
}
tempArray.clear();
final int n = attrs.size();
for (int i = 0; i < n; i++) {
tempArray.add(attributes.get(attrs.get(i).getKey(), -1));
}
return tempArray.items;
}
示例2: updateTileInfluence
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
private void updateTileInfluence(int x, int y) {
Influence tile = map.getInfluenceAt(x, y);
float shift = 0f;
for (IntIntMap.Entry e : tile.getDelta()) {
if (e.value != 0) {
Entity empire = world.getEntity(e.key);
String text = abs(e.value) > 4 ? (e.value > 0 ? "+" + e.value : Integer.toString(e.value))
: DELTA_STR[e.value + 4];
EntityFactory.createFadingTileLabel(world, text, data.get(empire).color, x, y + shift, 1f);
shift += 0.2;
}
}
tile.computeNewInfluence();
// do not forget to update the main source
Entity main = tile.getMainInfluenceSource(world);
if (main != null)
sources.get(main).influencedTiles.add(map.getPositionAt(x, y));
}
示例3: getNeighboringSources
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
/** Neighbors from the nicest to the worst. */
private List<Entity> getNeighboringSources(Entity entity) {
IntIntMap neighbors = new IntIntMap(16);
MapPosition pos = positions.get(entity);
for (int i = 1; i < 10; i++) {
// TODO really search for all tiles
addInfluencer(neighbors, entity, pos.x + i, pos.y + i);
addInfluencer(neighbors, entity, pos.x - i, pos.y + i);
addInfluencer(neighbors, entity, pos.x + i, pos.y - i);
addInfluencer(neighbors, entity, pos.x - i, pos.y - i);
}
List<Entry> entries = new ArrayList<>();
neighbors.entries().forEach(e -> entries.add(e));
entries.sort((e1, e2) -> Integer.compare(e1.value, e2.value));
List<Entity> res = new ArrayList<>(entries.size());
entries.forEach(e -> res.add(world.getEntity(e.key)));
return res;
}
示例4: addInfluences
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
private Influence addInfluences(MapPosition tile) {
Influence influence = map.getInfluenceAt(tile);
int mainSource = influence.getMainInfluenceSource();
StringBuilder sb = new StringBuilder("[BLACK]Influence: ");
for (IntIntMap.Entry e : influence) {
Entity source = world.getEntity(e.key);
Empire empire = source.getComponent(Empire.class);
sb.append("\n ").append(markup(empire.color)).append(source.getComponent(Name.class).name).append("[]: ")
.append(100 * e.value / InfluenceSystem.INITIAL_POWER).append('%').append(' ')
.append(number(100 * influence.getDelta(source) / InfluenceSystem.INITIAL_POWER)).append('%');
// ignore == 0
if (e.key == mainSource)
sb.append(" (main)");
}
selectionMenu.addColoredLabel(sb.toString());
return influence;
}
示例5: write
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
public void write (Kryo kryo, Output output, IntIntMap map) {
int length = map.size;
output.writeVarInt(length, true);
for (Iterator iter = map.iterator(); iter.hasNext();) {
IntIntMap.Entry entry = (IntIntMap.Entry)iter.next();
output.writeInt(entry.key);
output.writeInt(entry.value);
}
}
示例6: read
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
public IntIntMap read (Kryo kryo, Input input, Class<IntIntMap> type) {
int length = input.readVarInt(true);
IntIntMap map = new IntIntMap(length);
for (int i = 0; i < length; i++) {
int key = input.readInt();
int value = input.readInt();
map.put(key, value);
}
return map;
}
示例7: getButtonAmount
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
public int getButtonAmount () {
try {
switch (Gdx.app.getType()) {
case Android:
Field androidButtons = ClassReflection
.getDeclaredField(ClassReflection.forName("com.badlogic.gdx.controllers.android.AndroidController"), "buttons");
androidButtons.setAccessible(true);
return ((IntIntMap)androidButtons.get(gamePad)).size;
case Desktop:
Field desktopButtons = ClassReflection.getDeclaredField(
ClassReflection.forName("com.badlogic.gdx.controllers.lwjgl3.Lwjgl3Controller"), "buttonState");
desktopButtons.setAccessible(true);
return ((boolean[])desktopButtons.get(gamePad)).length;
case HeadlessDesktop:
return 0;
case WebGL:
Field gwtButtons = ClassReflection
.getDeclaredField(ClassReflection.forName("com.badlogic.gdx.controllers.gwt.GwtController"), "buttons");
gwtButtons.setAccessible(true);
return ((IntFloatMap)gwtButtons.get(gamePad)).size;
case iOS:
return 0;
default:
break;
}
} catch (Exception ex) {
ex.printStackTrace();
}
return 0;
}
示例8: FetlarRulesEngine
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
public FetlarRulesEngine() {
blackLegalMoves = new Array<Move>();
whiteLegalMoves = new Array<Move>();
kingLegalMoves = new Array<Move>();
boardConfigHistory = new IntArray();
configurationCounter = new IntIntMap();
random = new Random();
shuffleArray = new Move[Constants.GameConstants.MAX_NUMBER_OF_MOVES];
}
示例9: getDelta
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
public Iterable<IntIntMap.Entry> getDelta() {
return influenceDelta;
}
示例10: addInfluencer
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
private void addInfluencer(IntIntMap neighbors, Entity capital, int x, int y) {
Influence inf = map.getInfluenceAt(x, y);
if (inf != null && !inf.isMainInfluencer(capital) && inf.hasMainInfluence())
neighbors.getAndIncrement(inf.getMainInfluenceSource(), 0, 1);
}
示例11: DefaultGameModel
import com.badlogic.gdx.utils.IntIntMap; //导入依赖的package包/类
public DefaultGameModel() {
super();
playerRefIdToShipRefIdMap = new IntIntMap();
}