• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ObjectIntMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: write

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
public void write (Kryo kryo, Output output, ObjectIntMap map) {
    int length = map.size;
    output.writeVarInt(length, true);
    output.writeBoolean(false); // whether type is written (in case future version of ObjectIntMap supports type awareness)

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

    for (Iterator iter = map.iterator(); iter.hasNext();) {
        ObjectIntMap.Entry entry = (ObjectIntMap.Entry)iter.next();
        if (keySerializer != null) {
            kryo.writeObject(output, entry.key, keySerializer);
        } else
            kryo.writeClassAndObject(output, entry.key);
        output.writeInt(entry.value);
    }
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:21,代码来源:ObjectIntMapSerializer.java


示例2: 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


示例3: 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


示例4: 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


示例5: 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


示例6: if

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
public com.badlogic.gdx.utils.ObjectIntMap $getValue__uniforms() throws Exception {
    if($gen_uniforms == null) {
        $gen_uniforms = com.badlogic.gdx.graphics.glutils.ShaderProgram.class.getDeclaredField("uniforms");
        net.ncguy.argent.utils.ReflectionUtils.setCompletelyAccessible($gen_uniforms);
    }
    return (com.badlogic.gdx.utils.ObjectIntMap)$gen_uniforms.get(this);
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:8,代码来源:GeometryShaderProgram.java


示例7: LevelResult

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
public LevelResult(ObjectIntMap<Die> addedExperience,
                   ObjectMap<Fraction, Player> players,
                   Player viewer) {
    this.addedExperience = addedExperience;
    this.players = players;
    this.viewer = viewer;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:8,代码来源:LevelResult.java


示例8: visualize

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
@Override public IFuture<Void> visualize(final IceStormResult result) {
    final Future<Void> future = new Future<Void>();
    final ParticleActor particleActor = new ParticleActor("ability-" + result.ability.name).freeOnComplete();
    particleActor.getColor().a = 0;
    final Vector2 position = tmp.set(result.coordinate.x() + 0.5f, result.coordinate.y() + 0.5f).scl(ViewController.CELL_SIZE);
    particleActor.setPosition(position.x, position.y + 160);
    visualizer.viewController.effectLayer.addActor(particleActor);
    SoundManager.instance.playSound("ability-fireball");
    visualizer.viewController.scroller.centerOn(result.coordinate.x(), result.coordinate.y());
    particleActor.addAction(alpha(1f, 0.5f));
    particleActor.addAction(sequence(
        moveTo(position.x, position.y, 1f),
        run(new Runnable() {
            @Override public void run() {
                particleActor.effect.allowCompletion();
                final ParticleActor hitActor = new ParticleActor("ability-" + result.ability.name + "-hit").freeOnComplete();
                hitActor.setPosition(position.x, position.y);
                visualizer.viewController.spawnLayer.addActor(hitActor);
                SoundManager.instance.playSound("ability-freeze-hit");
                visualizer.viewController.world.stage.addAction(Actions.delay(0.5f, Actions.run(future)));
                if (result.targets.size == 0)
                    return;
                for (ObjectIntMap.Entry<Creature> e : result.targets) {
                    showFreeze(e.key);
                }
            }
        })
    ));
    return future;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:31,代码来源:IceStormVisualizer.java


示例9: 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


示例10: 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


示例11: potionsCount

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
public int potionsCount() {
    int r = 0;
    ObjectIntMap.Values v = potions.values();
    while (v.hasNext()) {
        r += v.next();
    }
    return r;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:9,代码来源:UserData.java


示例12: itemsCount

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
public int itemsCount(Item.Type type) {
    int r = 0;
    for (ObjectIntMap.Entry<Item> e : items.entries()) {
        if (e.key.type == type) r += e.value;
    }
    return r;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:8,代码来源:UserData.java


示例13: Die

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
public Die(ProfessionDescription profession, String name, int exp, Array<Ability> abilities, ObjectIntMap<Ability> inventory) {
    this.profession = profession;
    this.name = name;
    this.exp = exp;
    this.abilities = abilities;
    this.inventory = inventory;
    Iterator<Ability> it = abilities.iterator();
    while (it.hasNext()) {
        Ability ability = it.next();
        if (ability != null && !profession.ignoreRequirements && (!ability.requirement.isSatisfied(this))) {
            inventory.getAndIncrement(ability, 0, 1);
            it.remove();
        }
    }
    int used = getUsedSkill();
    int total = getTotalSkill();
    if (used > total) {
        System.out.print(name + " has skill overdraft, " + used + " > " + total + ", inventory = ");
    }
    while (abilities.size > 0 && getUsedSkill() > getTotalSkill()) {
        Ability popped = abilities.pop();
        if (popped != null) inventory.getAndIncrement(popped, 0, 1);
    }
    if (used > total)
        System.out.println(inventory);

    while (abilities.size < 6)
        abilities.add(null);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:30,代码来源:Die.java


示例14: 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


示例15: calcResult

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
private IActionResult calcResult(Creature creature, Grid2D.Coordinate coordinate) {
    ProfessionDescription profession = Config.professions.get(professionName);

    Array<Ability> abilities = new Array<Ability>();
    for (String abilityName : abilityNames) {
        abilities.add(Config.abilities.get(abilityName));
    }

    Die die = new Die(profession, summonedName, 10000000, abilities, new ObjectIntMap<Ability>());
    Creature summoned = new Creature(die, creature.player, creature.player.fraction + "@s-" + creature.player.nextSummonedId());
    summoned.set(Attribute.canBeResurrected, Boolean.FALSE);
    return new SummonResult(owner, creature, coordinate, summoned);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:14,代码来源:Summon.java


示例16: ChainLightningResult

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
public ChainLightningResult(Creature caster, Ability ability, Array<Creature> chain, Array<Creature> killed, ObjectIntMap<Creature> addedExp) {
    super();
    this.caster = caster;
    this.ability = ability;
    this.chain = chain;
    this.killed = killed;
    this.addedExp = addedExp;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:9,代码来源:ChainLightningResult.java


示例17: FirestormResult

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
public FirestormResult(Creature caster, Ability ability, Array<Creature> underAttack, Array<Creature> killed, ObjectIntMap<Creature> addedExp, Grid2D.Coordinate cell) {
    super();
    this.caster = caster;
    this.ability = ability;
    this.underAttack = underAttack;
    this.killed = killed;
    this.addedExp = addedExp;
    this.cell = cell;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:10,代码来源:FirestormResult.java


示例18: 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


示例19: awaitSpawning

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
private void awaitSpawning(final PvpPlayState state) {
    Logger.debug("server: await for spawning of other clients"/*, new RuntimeException()*/);
    final ObjectMap<IParticipant, Spawned> data = new ObjectMap<IParticipant, Spawned>();
    register(SpawnedToServer.class, new IMessageProcessor<SpawnedToServer>() {
        int toSpawn = session.getAll().size;
        @Override public void receive(IParticipant from, SpawnedToServer message) {
            Player player = state.participantsToPlayers.get(from);
            data.put(from, new Spawned(message.dice, message.potions, player.fraction));
            ObjectIntMap<Item> rolled = session.getMode().metaLevel.drop.roll();
            applyDrop(rolled, message.dice);
            if (data.size == toSpawn) {
                for (ObjectMap.Entry<String, ? extends IParticipant> entry : session.getAll().entries()) {
                    IParticipant spawnedParticipant = entry.value;
                    Spawned spawned = data.get(spawnedParticipant);
                    for (IParticipant toNotify : session.getAll().values()) {
                        if (spawnedParticipant == toNotify) continue;
                        Logger.debug("server: notify " + toNotify + " about spawned " + spawned);
                        sendTo(toNotify, spawned);
                    }
                }
                Array<? extends Creature> creatures = state.world.byType(Creature.class);
                creatures.sort(Ability.INITIATIVE_COMPARATOR);
                unregister(SpawnedToServer.class);
                Logger.debug("server: start!");
                awaitRestart();
                sendToAll(new Start(creatures));
            }
        }
    });
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:31,代码来源:ServerMessageListener.java


示例20: updateResult

import com.badlogic.gdx.utils.ObjectIntMap; //导入依赖的package包/类
private void updateResult() {
    if (outputResult != null) {
        outputResult.remove();
        outputResult = null;
    }
    res.clear();
    for (ItemIcon i : inputs.values()) {
        if (i != null) {
            res.getAndIncrement(i.item, 0, 1);
        }
    }
    Ability ability = null;
    for (Ability check : recipes) {
        ObjectIntMap<Item> cost = check.ingredients;
        if (inputMatches(res, cost)) {
            ability = check;
            break;
        }
    }
    if (ability != null) {
        outputResult = new AbilityIcon(ability);
        addActor(outputResult);
        outputResult.setPosition(
            output.getX() + (output.getWidth() - outputResult.getWidth()) * 0.5f,
            output.getY() + (output.getHeight() - outputResult.getHeight()) * 0.5f
        );
    }
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:29,代码来源:CraftingPane.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PathIsDirectoryException类代码示例发布时间:2022-05-22
下一篇:
Java CombineValuesIterator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap