Java Code Examples for com.badlogic.gdx.utils.Array#pop()
The following examples show how to use
com.badlogic.gdx.utils.Array#pop() .
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: TeleportVisualizer.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
private Array<TextureAtlas.AtlasRegion> compose(String name) { Array<TextureAtlas.AtlasRegion> result = composes.get(name); if (result == null) { result = new Array<TextureAtlas.AtlasRegion>(Config.findRegions(name)); Array<TextureAtlas.AtlasRegion> rev = new Array<TextureAtlas.AtlasRegion>(result); rev.pop(); rev.reverse(); for (int i = 0; i < 1; i++) { result.add(result.get(result.size - 2)); result.add(result.get(result.size - 2)); } result.addAll(rev); composes.put(name, result); } return result; }
Example 2
Source File: SpawnController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") private void autoPlace() { if (placed.size > 0) { ObjectSet<Creature> tmp = Pools.obtain(ObjectSet.class); tmp.addAll(placed); for (Creature c : tmp) { removeFromPlaced(c); } tmp.clear(); Pools.free(tmp); } Array<Grid2D.Coordinate> coordinates = Pools.obtain(Array.class); Set<Map.Entry<Grid2D.Coordinate, Fraction>> spawns = world.level.getElements(LevelElementType.spawn); for (Map.Entry<Grid2D.Coordinate, Fraction> e : spawns) { if (e.getValue() == world.viewer.fraction) { coordinates.add(e.getKey()); } } coordinates.shuffle(); int usedCount = Math.min(creatures.size, coordinates.size); Array<Creature> toPlace = Pools.obtain(Array.class); toPlace.addAll(creatures); toPlace.shuffle(); toPlace.truncate(usedCount); for (Creature creature : toPlace) { Grid2D.Coordinate coordinate = coordinates.pop(); place(creature, coordinate.x(), coordinate.y()); } toPlace.clear(); coordinates.clear(); Pools.free(toPlace); Pools.free(coordinates); }
Example 3
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); }