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


Java ObjectIntMap.put方法代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.ObjectIntMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectIntMap.put方法的具体用法?Java ObjectIntMap.put怎么用?Java ObjectIntMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.utils.ObjectIntMap的用法示例。


在下文中一共展示了ObjectIntMap.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calcResult

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
private IActionResult calcResult(Creature creature, Grid2D.Coordinate cell) {
    Vector2 position = tmp.set(cell.x(), cell.y());
    ObjectIntMap<Creature> targets = new ObjectIntMap<Creature>();
    for (int i = cell.x() - MathUtils.ceil(radius); i <= cell.x() + radius; i++) {
        for (int j = cell.y() - MathUtils.ceil(radius); j <= cell.y() + radius; j++) {
            if (position.dst(i, j) <= radius) {
                WorldObject object = creature.world.get(i, j);
                if (object instanceof Creature
                    && ((Creature) object).get(Attribute.canBeSelected)
                    && !((Creature) object).get(Attribute.frozen)) {
                    targets.put((Creature) object, i == cell.x() && j == cell.y() ? epicenterTurns : turns);
                }
            }
        }
    }

    return new IceStormResult(owner, creature, cell, targets);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:19,代码来源:IceStorm.java

示例2: read

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
public ObjectIntMap read (Kryo kryo, Input input, Class<ObjectIntMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    ObjectIntMap map = create(length);

    Class keyClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        int value = input.readInt();
        map.put(key, value);
    }
    return map;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:28,代码来源:ObjectIntMapSerializer.java

示例3: fetchAttributes

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
private void fetchAttributes () throws Exception {
    IntBuffer params = $getValue__params();
    IntBuffer type = $getValue__type();
    int program = $getValue__program();
    ObjectIntMap<String> attributes = $getValue__attributes();
    ObjectIntMap<String> attributeTypes = $getValue__attributeTypes();
    ObjectIntMap<String> attributeSizes = $getValue__attributeSizes();

    params.clear();
    Gdx.gl20.glGetProgramiv(program, GL20.GL_ACTIVE_ATTRIBUTES, params);
    int numAttributes = params.get(0);

    String[] attributeNames = new String[numAttributes];

    for (int i = 0; i < numAttributes; i++) {
        params.clear();
        params.put(0, 1);
        type.clear();
        String name = Gdx.gl20.glGetActiveAttrib(program, i, params, type);
        int location = Gdx.gl20.glGetAttribLocation(program, name);
        attributes.put(name, location);
        attributeTypes.put(name, type.get(0));
        attributeSizes.put(name, params.get(0));
        attributeNames[i] = name;
    }

    $setValue_attributeNames(attributeNames);
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:29,代码来源:GeometryShaderProgram.java

示例4: fetchUniforms

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
private void fetchUniforms () throws Exception {
    IntBuffer params = $getValue__params();
    IntBuffer type = $getValue__type();
    int program = $getValue__program();
    ObjectIntMap<String> uniforms = $getValue__uniforms();
    ObjectIntMap<String> uniformTypes = $getValue__uniformTypes();
    ObjectIntMap<String> uniformSizes = $getValue__uniformSizes();

    params.clear();
    Gdx.gl20.glGetProgramiv(program, GL20.GL_ACTIVE_UNIFORMS, params);
    int numUniforms = params.get(0);

    String[] uniformNames = new String[numUniforms];

    for (int i = 0; i < numUniforms; i++) {
        params.clear();
        params.put(0, 1);
        type.clear();
        String name = Gdx.gl20.glGetActiveUniform(program, i, params, type);
        int location = Gdx.gl20.glGetUniformLocation(program, name);
        uniforms.put(name, location);
        uniformTypes.put(name, type.get(0));
        uniformSizes.put(name, params.get(0));
        uniformNames[i] = name;
    }
    $setValue_uniformNames(uniformNames);
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:28,代码来源:GeometryShaderProgram.java

示例5: calcResult

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
private IActionResult calcResult(Creature creature, Grid2D.Coordinate cell) {
    Vector2 position = tmp.set(cell.x(), cell.y());
    Array<Creature> underAttack = new Array<Creature>();
    Array<Creature> killed = new Array<Creature>();
    ObjectIntMap<Creature> expResults = new ObjectIntMap<Creature>();
    for (int i = cell.x() - MathUtils.ceil(radius); i <= cell.x() + radius; i++) {
        for (int j = cell.y() - MathUtils.ceil(radius); j <= cell.y() + radius; j++) {
            if (position.dst(i, j) <= radius) {
                WorldObject object = creature.world.get(i, j);
                if (object instanceof Creature && ((Creature) object).get(Attribute.canBeSelected)) {
                    underAttack.add((Creature) object);
                }
            }
        }
    }
    for (Creature c : underAttack) {
        int attackLevel = (c.getX() == cell.x() && c.getY() == cell.y()) ? this.epicenterAttackLevel : this.attackLevel;
        int defenceLevel = c.get(Attribute.defenceFor(attackType));
        if (attackLevel > defenceLevel) {
            killed.add(c);
            if (creature.inRelation(Creature.CreatureRelation.enemy, c)) {
                expResults.getAndIncrement(creature, 0, ExpHelper.expForKill(creature, c));
            }
        } else {
            if (creature.inRelation(Creature.CreatureRelation.enemy, c)) {
                expResults.put(c, ExpHelper.expForDefence(creature, c));
            } else {
                expResults.put(c, ExpHelper.MIN_EXP);
            }
        }
    }
    return new FirestormResult(creature, owner, underAttack, killed, expResults, cell);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:34,代码来源:Firestorm.java

示例6: getTargetInfluence

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
/**
 * Compute the target influence on all tiles around the starting position.
 * <p>
 * Note: resulting target can be negative. It stops on tiles where there is no
 * influence from source AND target is not positive.
 */
private ObjectIntMap<Influence> getTargetInfluence(Entity source, MapPosition startPos, int startingPower) {
  Map<Terrain, Integer> costs = terrainCosts(source);
  Queue<Pos> frontier = new PriorityQueue<>();
  frontier.add(new Pos(startPos, startingPower));
  ObjectIntMap<Influence> targets = new ObjectIntMap<>();
  targets.put(map.getInfluenceAt(startPos), startingPower);

  while (!frontier.isEmpty()) {
    Pos current = frontier.poll();

    for (MapPosition next : map.getNeighbors(current.pos)) {
      Influence inf = map.getInfluenceAt(next);
      if (!inf.terrain.moveBlock()) {
        int newTarget = current.target - costs.get(inf.terrain);
        int oldTarget = targets.get(inf, Integer.MIN_VALUE);
        if (newTarget > oldTarget) {
          targets.put(inf, newTarget);
          /*
           * Increase only one tile from already influenced tiles. Decreases
           * wherever we have some influence (makes no sense to decrease
           * elsewhere.
           */
          if (inf.hasInfluence(source))
            frontier.offer(new Pos(next, newTarget));
        }
      }
    }
  }
  return targets;
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:37,代码来源:InfluenceSystem.java


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