com.badlogic.gdx.utils.Array Java Examples

The following examples show how to use com.badlogic.gdx.utils.Array. 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: GLTFDemo.java    From gdx-gltf with 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 #2
Source File: SHA1FileTable.java    From libgdx-snippets with 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 #3
Source File: Assets.java    From ud406 with 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 #4
Source File: BulletFollowPathTest.java    From gdx-ai with 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 #5
Source File: SplitViewport.java    From gdx-vr with 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 File: GameLoadingScreen.java    From riiablo with 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 File: Assets.java    From ud406 with 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 File: ClericDefence.java    From dice-heroes with 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 File: Shot.java    From dice-heroes with 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 File: Assets.java    From ud406 with 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 File: GpgsClient.java    From gdx-gamesvcs with 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 File: GLTFDemoUI.java    From gdx-gltf with 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 File: Assets.java    From ud406 with 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 #14
Source File: BoundEffect.java    From talos with 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 #15
Source File: Attack.java    From dice-heroes with 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 #16
Source File: CreatureAction.java    From dice-heroes with 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 #17
Source File: CurveWidget.java    From talos with Apache License 2.0 5 votes vote down vote up
private void drawCurve(Batch batch, float parentAlpha) {
    tmp.set(3, 2);
    localToStageCoordinates(tmp);

    shapeRenderer.setColor(lineColor);

    if(curveDataProvider == null) return;

    Array<Vector2> points = curveDataProvider.getPoints();

    if(points == null) return;

    if(points.get(0).x > 0) {
        // draw a line from (0, v) to that point (u, v)
        drawLine(0, points.get(0).y, points.get(0).x, points.get(0).y);
    }

    for(int i = 0; i < points.size - 1; i++) {
        Vector2 from = points.get(i);
        Vector2 to = points.get(i+1);
        drawLine(from.x, from.y, to.x, to.y);
    }

    if(points.get(points.size-1).x < 1f) {
        // draw a line from that point(u,v) to (1, v)
        drawLine(points.get(points.size-1).x, points.get(points.size-1).y, 1f, points.get(points.size-1).y);
    }

    shapeRenderer.setColor(pointColor);
    // draw points
    for(int i = 0; i < points.size; i++) {
        Vector2 point = points.get(i);
        drawPoint(point.x, point.y);
    }
}
 
Example #18
Source File: LinePath.java    From gdx-ai with 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 #19
Source File: BatchConvertDialog.java    From talos with 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 #20
Source File: RenderSystem.java    From riiablo with 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 #21
Source File: AtlasModel.java    From gdx-texture-packer-gui with 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 #22
Source File: Looped.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void startTutorial() {
    current = new Tutorial(tutorialName == null ? "unnamed" : tutorialName, resources, new Array<TutorialTask>(tasks));
    current.start().addListener(new IFutureListener<Tutorial>() {
        @Override public void onHappened(Tutorial tutorial) {
            startTutorial();
        }
    });
}
 
Example #23
Source File: GwtDatabaseQueryTest.java    From gdx-fireapp with Apache License 2.0 5 votes vote down vote up
@Test
public void run() {
    // Given
    ProviderJsFiltering providerJsFiltering = Mockito.mock(ProviderJsFiltering.class);
    ResolverDatabaseReferenceFilter filterResolver = Mockito.mock(ResolverDatabaseReferenceFilter.class);
    ResolverDatabaseReferenceOrderBy orderByResolver = Mockito.mock(ResolverDatabaseReferenceOrderBy.class);
    Mockito.when(providerJsFiltering.createFilterResolver()).thenReturn(filterResolver);
    Mockito.when(providerJsFiltering.createOrderByResolver()).thenReturn(orderByResolver);
    Mockito.when(providerJsFiltering.setFilters(Mockito.any(Array.class))).thenReturn(providerJsFiltering);
    Mockito.when(providerJsFiltering.setOrderByClause(Mockito.any(OrderByClause.class))).thenReturn(providerJsFiltering);
    Mockito.when(providerJsFiltering.setQuery(Mockito.any(DatabaseReference.class))).thenReturn(providerJsFiltering);
    GwtDatabaseQuery gwtDatabaseQuery = new TestQuery(Mockito.mock(Database.class), "/test");
    gwtDatabaseQuery.providerJsFiltering = providerJsFiltering;
    Array<Filter> filters = new Array<>();
    OrderByClause orderByClause = new OrderByClause(OrderByMode.ORDER_BY_KEY, null);
    filters.add(new Filter(FilterType.LIMIT_FIRST, 2));
    gwtDatabaseQuery.with(filters);
    gwtDatabaseQuery.with(orderByClause);

    // When
    gwtDatabaseQuery.applyFilters();
    gwtDatabaseQuery.run();

    // Then
    Mockito.verify(providerJsFiltering, VerificationModeFactory.times(1)).setFilters(Mockito.any(Array.class));
    Mockito.verify(providerJsFiltering, VerificationModeFactory.times(1)).setOrderByClause(Mockito.any(OrderByClause.class));
    Mockito.verify(providerJsFiltering, VerificationModeFactory.times(1)).setQuery(Mockito.nullable(DatabaseReference.class));
    Mockito.verify(providerJsFiltering, VerificationModeFactory.times(1)).applyFiltering();
}
 
Example #24
Source File: SpawnController.java    From dice-heroes with 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 #25
Source File: Assets.java    From ud406 with 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 #26
Source File: Roll.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public Array<RangeItemCount> roll() {
    if (range == null) {
        return dropped;
    }
    Array<RangeItemCount> res = new Array<RangeItemCount>();
    int value = range.getRandomInRange();
    for (RangeItemCount rangeItemCount : dropped) {
        Range r = rangeItemCount.range;
        if (r == null || r.inRange(value)) {
            res.add(rangeItemCount);
        }
    }
    return res;
}
 
Example #27
Source File: PvpMessageListener.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example #28
Source File: Thesaurus.java    From dice-heroes with 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 #29
Source File: PackInputFilesController.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@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 #30
Source File: ArrayHelper.java    From dice-heroes with 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;
}