Java Code Examples for com.badlogic.gdx.utils.Array

The following examples show how to use com.badlogic.gdx.utils.Array. These examples are extracted from open source projects. 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 Project: libgdx-snippets   Source File: SHA1FileTable.java    License: MIT License 6 votes vote down vote up
/**
 * Saves the file/hash table as .sha1sum text file. The output format is compatible to the *NIX 'sha1sum'
 * command line tool.
 */
public void save(FileHandle sha1sumFile) throws IOException {

	BufferedWriter writer = new BufferedWriter(new FileWriter(sha1sumFile.file()));

	Array<Entry> sortedValues = entries.values().toArray();
	sortedValues.sort((value1, value2) -> value1.filePath.compareTo(value2.filePath));

	for (Entry entry : sortedValues) {

		writer.write(entry.sha1.toString());
		writer.write("  ");
		writer.write(entry.filePath);
		writer.write("\n");

	}

	writer.flush();
	writer.close();
}
 
Example 2
Source Project: ud406   Source File: Assets.java    License: MIT License 6 votes vote down vote up
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
Example 3
Source Project: gdx-ai   Source File: BulletFollowPathTest.java    License: Apache License 2.0 6 votes vote down vote up
/** Creates a random path which is bound by rectangle described by the min/max values */
private static Array<Vector3> createRandomPath (int numWaypoints, float minX, float minY, float maxX, float maxY, float height) {
	Array<Vector3> wayPoints = new Array<Vector3>();

	float midX = (maxX + minX) / 2f;
	float midY = (maxY + minY) / 2f;

	float smaller = Math.min(midX, midY);

	float spacing = MathUtils.PI2 / numWaypoints;

	for (int i = 0; i < numWaypoints; i++) {
		float radialDist = MathUtils.random(smaller * 0.2f, smaller);
		tmpVector2.set(radialDist, 0.0f);

		// rotates the specified vector angle rads around the origin
		// init and rotate the transformation matrix
		tmpMatrix3.idt().rotateRad(i * spacing);
		// now transform the object's vertices
		tmpVector2.mul(tmpMatrix3);

		wayPoints.add(new Vector3(tmpVector2.x, height, tmpVector2.y));
	}

	return wayPoints;
}
 
Example 4
Source Project: gdx-gltf   Source File: GLTFDemo.java    License: Apache License 2.0 6 votes vote down vote up
private void loadModelIndex() 
{
	rootFolder = Gdx.files.internal(samplesPath);	
	
	String indexFilename = Gdx.app.getType() == ApplicationType.WebGL || Gdx.app.getType() == ApplicationType.Android ? "model-index-web.json" : "model-index.json";
	
	FileHandle file = rootFolder.child(indexFilename);
	
	entries = new Json().fromJson(Array.class, ModelEntry.class, file);
	
	ui.entrySelector.setItems(entries);
	
	if(AUTOLOAD_ENTRY != null && AUTOLOAD_VARIANT != null){
		for(int i=0 ; i<entries.size ; i++){
			ModelEntry entry = entries.get(i);
			if(entry.name.equals(AUTOLOAD_ENTRY)){
				ui.entrySelector.setSelected(entry);
				// will be auto select if there is only one variant.
				if(entry.variants.size != 1){
					ui.variantSelector.setSelected(AUTOLOAD_VARIANT);
				}
				break;
			}
		}
	}
}
 
Example 5
Source Project: gdx-vr   Source File: SplitViewport.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Used to calculate either the width or height.
 * 
 * @param subViews
 *            The row informations or column informations of a certain row.
 * @param index
 *            The index of the element to be calculated.
 * @param totalSize
 *            The total size, either the viewport width or height.
 */
private float calculateSize(Array<SubView> subViews, int index, float totalSize) {
	SubView subView = subViews.get(index);
	switch (subView.sizeInformation.sizeType) {
	case ABSOLUTE:
		return subView.sizeInformation.size;
	case RELATIVE:
		return subView.sizeInformation.size * totalSize;
	case REST:
		int rests = countRest(subViews);
		float usedSize = calculateUsedSize(subViews, totalSize);
		return (totalSize - usedSize) / rests;
	default:
		throw new IllegalArgumentException(subView.sizeInformation.sizeType + " could not be handled.");
	}
}
 
Example 6
Source Project: riiablo   Source File: GameLoadingScreen.java    License: Apache License 2.0 6 votes vote down vote up
public GameLoadingScreen(Map map, Array<AssetDescriptor> dependencies) {
  this.map = map;
  stage = new Stage(Riiablo.defaultViewport, Riiablo.batch);

  Riiablo.assets.load(loadingscreenDescriptor);
  Riiablo.assets.finishLoadingAsset(loadingscreenDescriptor);
  final Animation loadingscreen = Animation.newAnimation(Riiablo.assets.get(loadingscreenDescriptor));
  loadingscreen.setFrameDuration(Float.MAX_VALUE);
  loadingscreenWrapper = new AnimationWrapper(loadingscreen) {
    @Override
    public void act(float delta) {
      super.act(delta);
      for (Animation animation : animations) {
        animation.setFrame((int) (Riiablo.assets.getProgress() * (animation.getNumFramesPerDir() - 1)));
      }
    }
  };
  loadingscreenWrapper.setPosition(
      (stage.getWidth()  / 2) - (loadingscreen.getMinWidth()  / 2),
      (stage.getHeight() / 2) - (loadingscreen.getMinHeight() / 2));
  stage.addActor(loadingscreenWrapper);

  this.dependencies = new Array<>(dependencies);
}
 
Example 7
Source Project: ud406   Source File: Assets.java    License: MIT License 6 votes vote down vote up
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
Example 8
Source Project: dice-heroes   Source File: ClericDefence.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static Array<Creature> findTargets(Creature creature, Creature.CreatureRelation relation, int x, int y, World world, float distance) {
    Vector2 creaturePos = tmp1.set(x, y);
    Array<Creature> result = new Array<Creature>();
    for (WorldObject object : world) {
        if (!(object instanceof Creature))
            continue;
        Creature check = (Creature) object;
        if (!check.get(Attribute.canBeSelected) || !creature.inRelation(relation, check))
            continue;

        Vector2 checkPos = tmp2.set(check.getX(), check.getY());
        if (checkPos.dst(creaturePos) > distance)
            continue;
        result.add(check);
    }
    return result;
}
 
Example 9
Source Project: dice-heroes   Source File: Shot.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static Array<Creature> findTargets(Creature creature, Creature.CreatureRelation relation, int x, int y, World world, float distance) {
    Vector2 creaturePos = tmp1.set(x, y);
    Array<Creature> result = new Array<Creature>();
    for (WorldObject object : world) {
        if (!(object instanceof Creature))
            continue;
        Creature check = (Creature) object;
        if (!check.get(Attribute.canBeSelected) || !creature.inRelation(relation, check))
            continue;
        Vector2 checkPos = tmp2.set(check.getX(), check.getY());
        if (checkPos.dst(creaturePos) > distance)
            continue;
        result.add(check);
    }
    return result;
}
 
Example 10
Source Project: ud406   Source File: Assets.java    License: MIT License 6 votes vote down vote up
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
Example 11
Source Project: gdx-gamesvcs   Source File: GpgsClient.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Blocking version of {@link #fetchGameStatesSync()}
 *
 * @return game states
 * @throws IOException
 */
public Array<String> fetchGameStatesSync() throws IOException {

    if (!driveApiEnabled)
        throw new UnsupportedOperationException();

    Array<String> games = new Array<String>();

    FileList l = GApiGateway.drive.files().list()
            .setSpaces("appDataFolder")
            .setFields("files(name)")
            .execute();

    for (File f : l.getFiles()) {
        games.add(f.getName());
    }

    return games;
}
 
Example 12
Source Project: gdx-gltf   Source File: GLTFDemoUI.java    License: Apache License 2.0 6 votes vote down vote up
public void setEntry(ModelEntry entry, FileHandle rootFolder) 
{
	variantSelector.setSelected(null);
	Array<String> variants = entry.variants.keys().toArray(new Array<String>());
	variants.insert(0, "");
	variantSelector.setItems(variants);
	
	if(entry.variants.size == 1){
		variantSelector.setSelectedIndex(1);
	}else{
		variantSelector.setSelectedIndex(0);
	}
	
	
	if(screenshotsTable.getChildren().size > 0){
		Image imgScreenshot = (Image)screenshotsTable.getChildren().first();
		((TextureRegionDrawable)imgScreenshot.getDrawable()).getRegion().getTexture().dispose();
	}
	screenshotsTable.clear();
}
 
Example 13
Source Project: riiablo   Source File: RenderSystem.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * resizes fov -- called rarely (typically only creation or screen resize)
 */
public void resize() {
  updateBounds();
  final int viewBufferLen = tilesX + tilesY - 1;
  final int viewBufferMax = tilesX * 2 - 1; // FIXME: double check when adding support for other aspect ratios, need a ternary operation
  viewBuffer = new int[viewBufferLen];
  int x, y;
  for (x = 0, y = 1; y < viewBufferMax; x++, y += 2)
    viewBuffer[x] = viewBuffer[viewBufferLen - 1 - x] = y;
  while (viewBuffer[x] == 0)
    viewBuffer[x++] = viewBufferMax;
  if (DEBUG_BUFFER) {
    int len = 0;
    for (int i : viewBuffer) len += i;
    Gdx.app.debug(TAG, "viewBuffer[" + len + "]=" + Arrays.toString(viewBuffer));
  }
  dirty = true;

  cache = new Array[viewBufferLen][][];
  for (int i = 0; i < viewBufferLen; i++) {
    int viewBufferRun = viewBuffer[i];
    cache[i] = new Array[viewBufferRun][];
    for (int j = 0; j < viewBufferRun; j++) {
      cache[i][j] = new Array[] {
          new Array<Integer>(Tile.NUM_SUBTILES), // TODO: Really {@code (Tile.SUBTILE_SIZE - 1) * (Tile.SUBTILE_SIZE - 1)}
          new Array<Integer>(1), // better size TBD
          new Array<Integer>(Tile.SUBTILE_SIZE + Tile.SUBTILE_SIZE - 1), // only upper walls
      };
    }
  }
}
 
Example 14
Source Project: uracer-kotd   Source File: Messager.java    License: Apache License 2.0 5 votes vote down vote up
private void update (Position group) {
	Array<Message> msgs = messages.get(group.ordinal());

	for (Message msg : msgs) {
		// any message?
		if (msg == null && (msgs.size > 0 && msgs.first() != null)) {
			// schedule next message to process
			msg = msgs.first();
			msgs.removeValue(msg, true);
		}

		// busy or became busy?
		if (msg != null && !msg.isCompleted()) {
			// start message if needed
			if (!msg.started) {
				msg.started = true;
				msg.startMs = System.currentTimeMillis();
				msg.show();
			}

			// check if finished
			long much = (long)((System.currentTimeMillis() - msg.startMs) /* URacer.timeMultiplier */);
			if (msg.isShowComplete() && much >= msg.durationMs) {
				// message should end
				msg.hide();
			}
		}
	}
}
 
Example 15
Source Project: talos   Source File: BoundEffect.java    License: Apache License 2.0 5 votes vote down vote up
protected Array<String> getEvents() {
    Array<EventData> events = parent.getSkeleton().getData().getEvents();
    Array<String> result = new Array<>();
    result.add("");
    for(EventData eventData: events) {
        result.add(eventData.getName());
    }
    return result;
}
 
Example 16
Source Project: dice-heroes   Source File: Attack.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static void addEnemyOf(Array<Creature> targets, Creature creature, Creature.CreatureRelation relation, World world, int x, int y) {
    WorldObject object = world.get(x, y);
    if (object instanceof Creature) {
        Creature c = (Creature) object;
        if (c.get(Attribute.canBeSelected) && creature.inRelation(relation, c)) {
            targets.add(c);
        }
    }
}
 
Example 17
Source Project: dice-heroes   Source File: CreatureAction.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected final Array<Creature> creatures(World world, int x, int y, Function<Creature, Boolean> filter, float radius) {
    Vector2 creaturePos = tmpVector.set(x, y);
    Array<Creature> result = new Array<Creature>();
    for (WorldObject object : world) {
        if (!(object instanceof Creature))
            continue;
        Creature check = (Creature) object;
        if (!check.get(Attribute.canBeSelected) || !filter.apply(check))
            continue;
        if (creaturePos.dst(check.getX(), check.getY()) > radius)
            continue;
        result.add(check);
    }
    return result;
}
 
Example 18
public static Grid2D.Coordinate selectMoveTarget(Creature creature, Array<Grid2D.Coordinate> coordinates, CellValueCalculator calculator) {
    BinaryHeap<Node> heap = new BinaryHeap<Node>(9, true);
    for (Grid2D.Coordinate c : coordinates) {
        float value = calculator.getValue(creature, c.x(), c.y());
        heap.add(new Node(c.x(), c.y(), value));
    }

    if (heap.size == 0)
        return new Grid2D.Coordinate(creature.getX(), creature.getY());
    Node node = heap.peek();
    return new Grid2D.Coordinate(node.x, node.y);
}
 
Example 19
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public ExplosionAssets(TextureAtlas atlas) {

            Array<AtlasRegion> explosionRegions = new Array<AtlasRegion>();
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_LARGE));
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_MEDIUM));
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_SMALL));

            explosion = new Animation(Constants.EXPLOSION_DURATION / explosionRegions.size,
                    explosionRegions, PlayMode.NORMAL);
        }
 
Example 20
Source Project: xibalba   Source File: BrainComponent.java    License: MIT License 5 votes vote down vote up
/**
 * The brain.
 *
 * @param entity What entity has this brain
 */
public BrainComponent(Entity entity) {
  stateMachine = new DefaultStateMachine<>(entity, Brain.SLEEP);

  dna = new Array<>();

  fear = 0f;
}
 
Example 21
Source Project: gdx-ai   Source File: LinePath.java    License: Apache License 2.0 5 votes vote down vote up
/** Creates a {@code LinePath} for the specified {@code waypoints}.
 * @param waypoints the points making up the path
 * @param isOpen a flag indicating whether the path is open or not
 * @throws IllegalArgumentException if {@code waypoints} is {@code null} or has less than two (2) waypoints. */
public LinePath (Array<T> waypoints, boolean isOpen) {
	this.isOpen = isOpen;
	createPath(waypoints);
	nearestPointOnCurrentSegment = waypoints.first().cpy();
	nearestPointOnPath = waypoints.first().cpy();
	tmpB = waypoints.first().cpy();
	tmpC = waypoints.first().cpy();
}
 
Example 22
Source Project: gdx-texture-packer-gui   Source File: AtlasModel.java    License: Apache License 2.0 5 votes vote down vote up
private void generatePages(TextureAtlasData atlasData) {
    this.pages.clear();
    Array<TextureAtlasData.Page> pageDataArray = atlasData.getPages();
    for (int i = 0; i < pageDataArray.size; i++) {
        TextureAtlasData.Page pageData = pageDataArray.get(i);
        PageModel page = new PageModel(this, pageData, i);
        this.pages.add(page);
    }
}
 
Example 23
Source Project: dice-heroes   Source File: SpawnController.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 24
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public ExplosionAssets(TextureAtlas atlas) {

            Array<AtlasRegion> explosionRegions = new Array<AtlasRegion>();
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_LARGE));
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_MEDIUM));
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_SMALL));

            explosion = new Animation(Constants.EXPLOSION_DURATION / explosionRegions.size,
                    explosionRegions, PlayMode.NORMAL);
        }
 
Example 25
@LmlAction("includeSelected") void includeSelected() {
    PackModel pack = getSelectedPack();
    Array<InputFile> selectedNodes = new Array<>(listAdapter.getSelection());

    for (InputFile node : selectedNodes) {
        if (!node.isDirectory() && node.getType() == InputFile.Type.Ignore) {
            InputFile newInputFile = modelUtils.includeInputFile(pack, node);
            if (newInputFile != null) {
                listAdapter.getSelectionManager().select(newInputFile);
            }
        }
    }
}
 
Example 26
Source Project: dice-heroes   Source File: ArrayHelper.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static <T> Array<T> from(Iterable<? extends T> iterable) {
    final Array<T> result = new Array<T>();
    for (T t : iterable) {
        result.add(t);
    }
    return result;
}
 
Example 27
Source Project: gdx-ai   Source File: SchedulerBase.java    License: Apache License 2.0 5 votes vote down vote up
/** Creates a {@code SchedulerBase}.
 * @param dryRunFrames number of frames simulated by the dry run to calculate the phase when adding a schedulable via
 *           {@link #addWithAutomaticPhasing(Schedulable, int)} */
public SchedulerBase (int dryRunFrames) {
	this.schedulableRecords = new Array<T>();
	this.runList = new Array<T>();
	this.phaseCounters = new IntArray();
	this.dryRunFrames = dryRunFrames;
}
 
Example 28
Source Project: talos   Source File: BatchConvertDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void traverseFolder(FileHandle folder, Array<String> fileList, String extension, int depth) {
    for(FileHandle file : folder.list()) {
        if(file.isDirectory() && depth < 10) {
            traverseFolder(file, fileList, extension, depth + 1);
        }
        if(file.extension().equals(extension)) {
            fileList.add(file.path());
        }
    }
}
 
Example 29
Source Project: dice-heroes   Source File: Thesaurus.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static <T> String enumerate(Thesaurus thesaurus, Array<T> elements, Stringifier<T> stringifier) {
    String key = Keys.enumeration(elements.size);
    Params params = Thesaurus.params();
    for (int i = 0, n = elements.size; i < n; i++) {
        params.put(String.valueOf(i), stringifier.toString(elements.get(i)));
    }
    return thesaurus.localize(key, params);
}
 
Example 30
private void checkQueue(IParticipant from) {
    Array<IPvpMessage> messages = queue.get(from);
    if (messages == null || messages.size == 0)
        return;
    int neededIndex = receivedMessagesIndexes.get(from, 0);
    if (messages.first().packetIdx == neededIndex) {
        IPvpMessage m = messages.removeIndex(0);
        receiveMessage(from, m);
        checkQueue(from);
    }
}