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


Java ObjectIntMap.get方法代码示例

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


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

示例1: setPotions

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
public void setPotions(ObjectIntMap<Ability> potionCount) {
    potions.clear();
    for (Ability potion : potionCount.keys()) {
        int currentCount = potions.get(potion, 0);
        int newCount = potionCount.get(potion, 0);
        if (currentCount != newCount) {
            potions.put(potion, newCount);
            onPotionCountChanged.dispatch(potion);
        }
    }
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:12,代码来源:UserData.java

示例2: canWithdraw

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
public boolean canWithdraw(ObjectIntMap<Item> items) {
    for (Item item : items.keys()) {
        int count = items.get(item, 0);
        if (count > this.items.get(item, 0))
            return false;
    }
    return true;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:9,代码来源:UserData.java

示例3: countComparator

import com.badlogic.gdx.utils.ObjectIntMap; //导入方法依赖的package包/类
public static Comparator<? super Ability> countComparator(UserData userData) {
    final ObjectIntMap<Ability> counts = new ObjectIntMap<Ability>();
    for (Die die : userData.dice()) {
        for (ObjectIntMap.Entry<Ability> e : die.inventory)
            counts.getAndIncrement(e.key, e.value, e.value);
        for (Ability ability : die.abilities)
            if (ability != null) counts.getAndIncrement(ability, 0, 1);
    }
    return new Comparator<Ability>() {
        @Override public int compare(Ability o1, Ability o2) {
            return counts.get(o1, 0) - counts.get(o2, 0);
        }
    };
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:15,代码来源:Ability.java

示例4: 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.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。