mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Add Chaos Wheel for Planar Conquest
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1339,6 +1339,7 @@ forge-gui-mobile/src/forge/screens/online/OnlineChatScreen.java -text
|
||||
forge-gui-mobile/src/forge/screens/online/OnlineLobbyScreen.java -text
|
||||
forge-gui-mobile/src/forge/screens/online/OnlineMenu.java -text
|
||||
forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java -text
|
||||
forge-gui-mobile/src/forge/screens/planarconquest/ConquestChaosWheel.java -text
|
||||
forge-gui-mobile/src/forge/screens/planarconquest/ConquestCollectionScreen.java -text
|
||||
forge-gui-mobile/src/forge/screens/planarconquest/ConquestCommandersScreen.java -text
|
||||
forge-gui-mobile/src/forge/screens/planarconquest/ConquestDeckEditor.java -text
|
||||
@@ -17973,6 +17974,7 @@ forge-gui/res/skins/dark_ascension/bg_splash.png -text
|
||||
forge-gui/res/skins/dark_ascension/bg_texture.jpg -text
|
||||
forge-gui/res/skins/dark_ascension/font1.ttf -text
|
||||
forge-gui/res/skins/dark_ascension/sprite_icons.png -text
|
||||
forge-gui/res/skins/default/bg_chaos_wheel.png -text
|
||||
forge-gui/res/skins/default/bg_draft_deck.png -text
|
||||
forge-gui/res/skins/default/bg_match.jpg -text
|
||||
forge-gui/res/skins/default/bg_space.png -text
|
||||
|
||||
@@ -592,6 +592,9 @@ public class Graphics {
|
||||
public void drawRotatedImage(Texture image, float x, float y, float w, float h, float originX, float originY, float rotation) {
|
||||
drawRotatedImage(image, x, y, w, h, originX, originY, 0, 0, image.getWidth(), image.getHeight(), rotation);
|
||||
}
|
||||
public void drawRotatedImage(TextureRegion image, float x, float y, float w, float h, float originX, float originY, float rotation) {
|
||||
drawRotatedImage(image.getTexture(), x, y, w, h, originX, originY, image.getRegionX(), image.getRegionY(), image.getRegionWidth(), image.getRegionHeight(), rotation);
|
||||
}
|
||||
public void drawRotatedImage(Texture image, float x, float y, float w, float h, float originX, float originY, int srcX, int srcY, int srcWidth, int srcHeight, float rotation) {
|
||||
batch.draw(image, adjustX(x), adjustY(y, h), originX - x, h - (originY - y), w, h, 1, 1, rotation, srcX, srcY, srcWidth, srcHeight, false, false);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import forge.properties.ForgeConstants;
|
||||
public enum FSkinTexture implements FImage {
|
||||
BG_TEXTURE(ForgeConstants.TEXTURE_BG_FILE, true),
|
||||
BG_MATCH(ForgeConstants.MATCH_BG_FILE, false),
|
||||
BG_SPACE(ForgeConstants.SPACE_BG_FILE, false);
|
||||
BG_SPACE(ForgeConstants.SPACE_BG_FILE, false),
|
||||
BG_CHAOS_WHEEL(ForgeConstants.CHAOS_WHEEL_IMG_FILE, false);
|
||||
|
||||
private final String filename;
|
||||
private final boolean repeat;
|
||||
@@ -74,4 +75,8 @@ public enum FSkinTexture implements FImage {
|
||||
g.drawImage(texture, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawRotated(Graphics g, float x, float y, float w, float h, float rotation) {
|
||||
g.drawRotatedImage(texture, x, y, w, h, getWidth() / 2, getHeight() / 2, rotation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package forge.screens.planarconquest;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.animation.ForgeAnimation;
|
||||
import forge.assets.FSkinTexture;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.PhysicsObject;
|
||||
import forge.util.ThreadUtil;
|
||||
|
||||
public class ConquestChaosWheel extends FOverlay {
|
||||
private final WheelSpinAnimation animation = new WheelSpinAnimation();
|
||||
|
||||
public ConquestChaosWheel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible0) {
|
||||
if (this.isVisible() == visible0) { return; }
|
||||
|
||||
super.setVisible(visible0);
|
||||
|
||||
if (visible0) { //delay spin animation briefly
|
||||
ThreadUtil.delay(250, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
animation.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOverlay(Graphics g) {
|
||||
float padding = FOptionPane.PADDING;
|
||||
float wheelSize = getWidth() - 2 * padding;
|
||||
FSkinTexture.BG_CHAOS_WHEEL.drawRotated(g, padding, (getHeight() - wheelSize) / 2, wheelSize, wheelSize, animation.getWheelRotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLayout(float width, float height) {
|
||||
}
|
||||
|
||||
private class WheelSpinAnimation extends ForgeAnimation {
|
||||
private final PhysicsObject rotationManager;
|
||||
|
||||
private WheelSpinAnimation() {
|
||||
float initialPosition = Aggregates.randomInt(1, 8) * 45f - 22.5f; //-22.5f because wheel image slightly rotated initially
|
||||
float initialVelocity = Aggregates.randomInt(50, 100);
|
||||
float acceleration = Aggregates.randomInt(50, 100) * -1f;
|
||||
rotationManager = new PhysicsObject(new Vector2(initialPosition, 0), new Vector2(initialVelocity, 0), new Vector2(acceleration, 0), false);
|
||||
}
|
||||
|
||||
private float getWheelRotation() {
|
||||
return rotationManager.getPosition().x;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean advance(float dt) {
|
||||
rotationManager.advance(dt);
|
||||
Vector2 pos = rotationManager.getPosition();
|
||||
while (pos.x > 360f) { //loop back around
|
||||
pos.x -= 360f;
|
||||
}
|
||||
return rotationManager.isMoving();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnd(boolean endingAll) {
|
||||
ThreadUtil.delay(1000, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
forge-gui/res/skins/default/bg_chaos_wheel.png
Normal file
BIN
forge-gui/res/skins/default/bg_chaos_wheel.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 342 KiB |
@@ -87,6 +87,7 @@ public final class ForgeConstants {
|
||||
public static final String MATCH_BG_FILE = "bg_match.jpg";
|
||||
public static final String TEXTURE_BG_FILE = "bg_texture.jpg";
|
||||
public static final String SPACE_BG_FILE = "bg_space.png";
|
||||
public static final String CHAOS_WHEEL_IMG_FILE = "bg_chaos_wheel.png";
|
||||
public static final String DRAFT_DECK_IMG_FILE = "bg_draft_deck.png";
|
||||
|
||||
// data tree roots
|
||||
|
||||
Reference in New Issue
Block a user