Java Code Examples for com.badlogic.gdx.utils.Array#iterator()
The following examples show how to use
com.badlogic.gdx.utils.Array#iterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResurrectionProcessor.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override protected int preProcess(Creature creature, Ability ability) { if (Attack.findTargets(creature).size > 0) return -1; Array<Creature> allies = Shot.findTargets(creature, Creature.CreatureRelation.ally, 1.5f); Iterator<Creature> it = allies.iterator(); while (it.hasNext()) { if (it.next().profession == profession) it.remove(); } if (allies.size > 1) return -1; return 3; }
Example 2
Source File: Die.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
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); }
Example 3
Source File: Freeze.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public IFuture<IActionResult> apply(final Creature creature, World world) { Array<Creature> targets = Shot.findTargets(creature, Creature.CreatureRelation.enemy, creature.getX(), creature.getY(), world, distance); Iterator<Creature> it = targets.iterator(); while (it.hasNext()) { if (it.next().get(Attribute.frozen)) { it.remove(); } } if (targets.size == 0) return Future.completed(IActionResult.NOTHING); else if (targets.size == 1) return Future.<IActionResult>completed(new FreezeResult(owner, creature, targets.first(), turns)); else { final Future<IActionResult> future = new Future<IActionResult>(); world.getController(BehaviourController.class) .get(creature) .request(BehaviourRequest.CREATURE, new AbilityCreatureParams(creature, owner, targets)) .addListener(new IFutureListener<Creature>() { @Override public void onHappened(Creature target) { future.happen(new SequenceResult( new FreezeResult(owner, creature, target, turns), new GiveExpResult(creature, ExpHelper.MIN_EXP) )); } }); return future; } }
Example 4
Source File: CommonUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
/** * Splits a string, and trims each segment. */ public static Array<String> splitAndTrim(String str, String regex) { Array<String> lines = new Array<>(str.split(regex)); // Trim each line for (int i = 0; i < lines.size; i++) { lines.set(i, lines.get(i).trim()); } // Remove empty lines for (Iterator<String> iter = lines.iterator(); iter.hasNext();) { if (iter.next().isEmpty()) { iter.remove(); } } return lines; }