update Adventure Matchscreen

This commit is contained in:
Anthony Calosa
2022-12-01 15:06:36 +08:00
parent 43b9add84d
commit c56329206d
11 changed files with 611 additions and 512 deletions

View File

@@ -350,6 +350,9 @@ public class Forge implements ApplicationListener {
try {
FileHandle transitionFile = Config.instance().getFile("ui/transition.png");
FileHandle titleBGFile = Forge.isLandscapeMode() ? Config.instance().getFile("ui/title_bg.png") : Config.instance().getFile("ui/title_bg_portrait.png");
FileHandle vsIcon = Config.instance().getFile("ui/vs.png");
if (vsIcon.exists())
Forge.getAssets().fallback_skins().put(2, new Texture(vsIcon));
if (transitionFile.exists())
Forge.getAssets().fallback_skins().put(1, new Texture(transitionFile));
if (titleBGFile.exists())

View File

@@ -5,6 +5,7 @@ import java.util.Deque;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
@@ -46,6 +47,7 @@ public class Graphics {
private final ShaderProgram shaderRipple = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragRipple);
private final ShaderProgram shaderPixelateWarp = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragPixelateShaderWarp);
private final ShaderProgram shaderChromaticAbberation = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragChromaticAbberation);
private final ShaderProgram shaderHueShift = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragHueShift);
private Texture dummyTexture = null;
@@ -102,6 +104,7 @@ public class Graphics {
public boolean startClip() {
return startClip(0, 0, bounds.width, bounds.height);
}
public boolean startClip(float x, float y, float w, float h) {
batch.flush(); //must flush batch to prevent other things not rendering
@@ -115,22 +118,40 @@ public class Graphics {
float maxY = minY;
tmp.set(clip.x + clip.width, clip.y, 0);
tmp.mul(batch.getTransformMatrix());
if (tmp.x < minX) { minX = tmp.x; }
else if (tmp.x > maxX) { maxX = tmp.x; }
if (tmp.y < minY) { minY = tmp.y; }
else if (tmp.y > maxY) { maxY = tmp.y; }
if (tmp.x < minX) {
minX = tmp.x;
} else if (tmp.x > maxX) {
maxX = tmp.x;
}
if (tmp.y < minY) {
minY = tmp.y;
} else if (tmp.y > maxY) {
maxY = tmp.y;
}
tmp.set(clip.x + clip.width, clip.y + clip.height, 0);
tmp.mul(batch.getTransformMatrix());
if (tmp.x < minX) { minX = tmp.x; }
else if (tmp.x > maxX) { maxX = tmp.x; }
if (tmp.y < minY) { minY = tmp.y; }
else if (tmp.y > maxY) { maxY = tmp.y; }
if (tmp.x < minX) {
minX = tmp.x;
} else if (tmp.x > maxX) {
maxX = tmp.x;
}
if (tmp.y < minY) {
minY = tmp.y;
} else if (tmp.y > maxY) {
maxY = tmp.y;
}
tmp.set(clip.x, clip.y + clip.height, 0);
tmp.mul(batch.getTransformMatrix());
if (tmp.x < minX) { minX = tmp.x; }
else if (tmp.x > maxX) { maxX = tmp.x; }
if (tmp.y < minY) { minY = tmp.y; }
else if (tmp.y > maxY) { maxY = tmp.y; }
if (tmp.x < minX) {
minX = tmp.x;
} else if (tmp.x > maxX) {
maxX = tmp.x;
}
if (tmp.y < minY) {
minY = tmp.y;
} else if (tmp.y > maxY) {
maxY = tmp.y;
}
clip.set(minX, minY, maxX - minX, maxY - minY);
}
@@ -140,12 +161,12 @@ public class Graphics {
}
return true;
}
public void endClip() {
if (failedClipCount == 0) {
batch.flush(); //must flush batch to ensure stuffed rendered during clip respects that clip
ScissorStack.popScissors();
}
else {
} else {
failedClipCount--;
}
}
@@ -159,8 +180,7 @@ public class Graphics {
bounds = new Rectangle(parentBounds.x + displayObj.getLeft(), parentBounds.y + displayObj.getTop(), displayObj.getWidth(), displayObj.getHeight());
if (!Dtransforms.isEmpty()) { //transform screen position if needed by applying transform matrix to rectangle
updateScreenPosForRotation(displayObj);
}
else {
} else {
displayObj.screenPos.set(bounds);
}
@@ -172,8 +192,7 @@ public class Graphics {
if (displayObj.getRotate90()) { //use top-right corner of bounds as pivot point
startRotateTransform(displayObj.getWidth(), 0, -90);
updateScreenPosForRotation(displayObj);
}
else if (displayObj.getRotate180()) { //use center of bounds as pivot point
} else if (displayObj.getRotate180()) { //use center of bounds as pivot point
startRotateTransform(displayObj.getWidth() / 2, displayObj.getHeight() / 2, 180);
//screen position won't change for this object from a 180 degree rotation
}
@@ -201,24 +220,42 @@ public class Graphics {
tmp.set(bounds.x + bounds.width, regionHeight - bounds.y, 0);
tmp.mul(batch.getTransformMatrix());
tmp.y = regionHeight - tmp.y;
if (tmp.x < minX) { minX = tmp.x; }
else if (tmp.x > maxX) { maxX = tmp.x; }
if (tmp.y < minY) { minY = tmp.y; }
else if (tmp.y > maxY) { maxY = tmp.y; }
if (tmp.x < minX) {
minX = tmp.x;
} else if (tmp.x > maxX) {
maxX = tmp.x;
}
if (tmp.y < minY) {
minY = tmp.y;
} else if (tmp.y > maxY) {
maxY = tmp.y;
}
tmp.set(bounds.x + bounds.width, regionHeight - bounds.y - bounds.height, 0);
tmp.mul(batch.getTransformMatrix());
tmp.y = regionHeight - tmp.y;
if (tmp.x < minX) { minX = tmp.x; }
else if (tmp.x > maxX) { maxX = tmp.x; }
if (tmp.y < minY) { minY = tmp.y; }
else if (tmp.y > maxY) { maxY = tmp.y; }
if (tmp.x < minX) {
minX = tmp.x;
} else if (tmp.x > maxX) {
maxX = tmp.x;
}
if (tmp.y < minY) {
minY = tmp.y;
} else if (tmp.y > maxY) {
maxY = tmp.y;
}
tmp.set(bounds.x, regionHeight - bounds.y - bounds.height, 0);
tmp.mul(batch.getTransformMatrix());
tmp.y = regionHeight - tmp.y;
if (tmp.x < minX) { minX = tmp.x; }
else if (tmp.x > maxX) { maxX = tmp.x; }
if (tmp.y < minY) { minY = tmp.y; }
else if (tmp.y > maxY) { maxY = tmp.y; }
if (tmp.x < minX) {
minX = tmp.x;
} else if (tmp.x > maxX) {
maxX = tmp.x;
}
if (tmp.y < minY) {
minY = tmp.y;
} else if (tmp.y > maxY) {
maxY = tmp.y;
}
displayObj.screenPos.set(minX, minY, maxX - minX, maxY - minY);
}
@@ -226,6 +263,7 @@ public class Graphics {
public void drawLine(float thickness, FSkinColor skinColor, float x1, float y1, float x2, float y2) {
drawLine(thickness, skinColor.getColor(), x1, y1, x2, y2);
}
public void drawLine(float thickness, Color color, float x1, float y1, float x2, float y2) {
batch.end(); //must pause batch while rendering shapes
@@ -267,6 +305,7 @@ public class Graphics {
fillCircle(Color.WHITE, x2, y2, arrowThickness / 2);
drawLine(arrowThickness / 3, Color.WHITE, x1, y1, x2, y2);
}
public void drawLineArrow(float thickness, Color color, float x1, float y1, float x2, float y2) {
batch.end(); //must pause batch while rendering shapes
@@ -306,9 +345,11 @@ public class Graphics {
batch.begin();
}
public void drawArrow(float borderThickness, float arrowThickness, float arrowSize, FSkinColor skinColor, float x1, float y1, float x2, float y2) {
drawArrow(borderThickness, arrowThickness, arrowSize, skinColor.getColor(), x1, y1, x2, y2);
}
public void drawArrow(float borderThickness, float arrowThickness, float arrowSize, Color color, float x1, float y1, float x2, float y2) {
batch.end(); //must pause batch while rendering shapes
@@ -381,6 +422,7 @@ public class Graphics {
public void drawRoundRect(float thickness, FSkinColor skinColor, float x, float y, float w, float h, float cornerRadius) {
drawRoundRect(thickness, skinColor.getColor(), x, y, w, h, cornerRadius);
}
public void drawRoundRect(float thickness, Color color, float x, float y, float w, float h, float cornerRadius) {
batch.end(); //must pause batch while rendering shapes
@@ -429,6 +471,7 @@ public class Graphics {
public void fillRoundRect(FSkinColor skinColor, float x, float y, float w, float h, float cornerRadius) {
fillRoundRect(skinColor.getColor(), x, y, w, h, cornerRadius);
}
public void fillRoundRect(Color color, float x, float y, float w, float h, float cornerRadius) {
batch.end(); //must pause batch while rendering shapes
if (alphaComposite < 1) {
@@ -455,6 +498,7 @@ public class Graphics {
public void drawRect(float thickness, FSkinColor skinColor, float x, float y, float w, float h) {
drawRect(thickness, skinColor.getColor(), x, y, w, h);
}
public void drawRect(float thickness, Color color, float x, float y, float w, float h) {
batch.end(); //must pause batch while rendering shapes
@@ -480,6 +524,7 @@ public class Graphics {
batch.begin();
}
public void drawRectLines(float thickness, Color color, float x, float y, float w, float h) {
drawLine(thickness, color, x, y, x + w, y);
drawLine(thickness, color, x + thickness / 2f, y + thickness / 2f, x + thickness / 2f, y + h - thickness / 2f);
@@ -490,6 +535,7 @@ public class Graphics {
public void fillRect(FSkinColor skinColor, float x, float y, float w, float h) {
fillRect(skinColor.getColor(), x, y, w, h);
}
public void fillRect(Color color, float x, float y, float w, float h) {
batch.end(); //must pause batch while rendering shapes
@@ -515,6 +561,7 @@ public class Graphics {
public void drawCircle(float thickness, FSkinColor skinColor, float x, float y, float radius) {
drawCircle(thickness, skinColor.getColor(), x, y, radius);
}
public void drawCircle(float thickness, Color color, float x, float y, float radius) {
batch.end(); //must pause batch while rendering shapes
@@ -544,6 +591,7 @@ public class Graphics {
public void fillCircle(FSkinColor skinColor, float x, float y, float radius) {
fillCircle(skinColor.getColor(), x, y, radius);
}
public void fillCircle(Color color, float x, float y, float radius) {
batch.end(); //must pause batch while rendering shapes
@@ -569,6 +617,7 @@ public class Graphics {
public void fillTriangle(FSkinColor skinColor, float x1, float y1, float x2, float y2, float x3, float y3) {
fillTriangle(skinColor.getColor(), x1, y1, x2, y2, x3, y3);
}
public void fillTriangle(Color color, float x1, float y1, float x2, float y2, float x3, float y3) {
batch.end(); //must pause batch while rendering shapes
@@ -594,12 +643,15 @@ public class Graphics {
public void fillGradientRect(FSkinColor skinColor1, FSkinColor skinColor2, boolean vertical, float x, float y, float w, float h) {
fillGradientRect(skinColor1.getColor(), skinColor2.getColor(), vertical, x, y, w, h);
}
public void fillGradientRect(FSkinColor skinColor1, Color color2, boolean vertical, float x, float y, float w, float h) {
fillGradientRect(skinColor1.getColor(), color2, vertical, x, y, w, h);
}
public void fillGradientRect(Color color1, FSkinColor skinColor2, boolean vertical, float x, float y, float w, float h) {
fillGradientRect(color1, skinColor2.getColor(), vertical, x, y, w, h);
}
public void fillGradientRect(Color color1, Color color2, boolean vertical, float x, float y, float w, float h) {
batch.end(); //must pause batch while rendering shapes
@@ -654,11 +706,15 @@ public class Graphics {
alphaComposite = alphaComposite0;
batch.setColor(new Color(1, 1, 1, alphaComposite));
}
public void resetAlphaComposite() {
alphaComposite = 1;
batch.setColor(Color.WHITE);
}
public float getfloatAlphaComposite() { return alphaComposite; }
public float getfloatAlphaComposite() {
return alphaComposite;
}
public void drawBorderImage(FImage image, Color borderColor, Color tintColor, float x, float y, float w, float h, boolean tint) {
float oldalpha = alphaComposite;
@@ -673,17 +729,20 @@ public class Graphics {
}
setAlphaComposite(oldalpha);
}
public void drawborderImage(Color borderColor, float x, float y, float w, float h) {
float oldalpha = alphaComposite;
fillRoundRect(borderColor, x, y, w, h, (h - w) / 12);
setAlphaComposite(oldalpha);
}
public void drawImage(FImage image, Color borderColor, float x, float y, float w, float h) {
if (image == null)
return;
image.draw(this, x, y, w, h);
fillRoundRect(borderColor, x + 1, y + 1, w - 1.5f, h - 1.5f, (h - w) / 10);//used by zoom let some edges show...
}
public void drawAvatarImage(FImage image, float x, float y, float w, float h, boolean drawGrayscale) {
if (image == null)
return;
@@ -704,6 +763,7 @@ public class Graphics {
batch.begin();
}
}
public void drawCardImage(FImage image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
if (image == null)
return;
@@ -726,6 +786,7 @@ public class Graphics {
batch.begin();
}
}
public void drawCardImage(Texture image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
if (!drawGrayscale) {
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
@@ -746,6 +807,7 @@ public class Graphics {
batch.begin();
}
}
public void drawCardImage(TextureRegion image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
if (image != null) {
if (!drawGrayscale) {
@@ -768,6 +830,7 @@ public class Graphics {
}
}
}
public void drawGrayTransitionImage(FImage image, float x, float y, float w, float h, float percentage) {
if (image == null)
return;
@@ -784,6 +847,7 @@ public class Graphics {
batch.setShader(null);
batch.begin();
}
public void drawGrayTransitionImage(Texture image, float x, float y, float w, float h, boolean withDarkOverlay, float percentage) {
batch.end();
shaderGrayscale.bind();
@@ -798,6 +862,7 @@ public class Graphics {
batch.setShader(null);
batch.begin();
}
public void drawGrayTransitionImage(TextureRegion image, float x, float y, float w, float h, boolean withDarkOverlay, float percentage) {
batch.end();
shaderGrayscale.bind();
@@ -812,6 +877,47 @@ public class Graphics {
batch.setShader(null);
batch.begin();
}
public void drawHueShift(Texture image, float x, float y, float w, float h, Float time) {
if (image == null)
return;
if (time != null) {
batch.end();
shaderHueShift.bind();
shaderHueShift.setUniformf("u_time", time);
batch.setShader(shaderHueShift);
batch.begin();
//draw
batch.draw(image, x, y, w, h);
//reset
batch.end();
batch.setShader(null);
batch.begin();
} else {
drawImage(image, x, y, w, h);
}
}
public void drawHueShift(TextureRegion image, float x, float y, float w, float h, Float time) {
if (image == null)
return;
if (time != null) {
batch.end();
shaderHueShift.bind();
shaderHueShift.setUniformf("u_time", time);
batch.setShader(shaderHueShift);
batch.begin();
//draw
batch.draw(image, x, y, w, h);
//reset
batch.end();
batch.setShader(null);
batch.begin();
} else {
drawImage(image, x, y, w, h);
}
}
public void drawChromatic(TextureRegion image, float x, float y, float w, float h, Float time) {
if (image == null)
return;
@@ -831,6 +937,7 @@ public class Graphics {
drawImage(image, x, y, w, h);
}
}
public void drawRipple(FImage image, float x, float y, float w, float h, Float amount, boolean flipY) {
if (image == null)
return;
@@ -852,6 +959,7 @@ public class Graphics {
drawImage(image, x, y, w, h);
}
}
public void drawPixelated(FImage image, float x, float y, float w, float h, Float amount, boolean flipY) {
if (image == null)
return;
@@ -874,6 +982,7 @@ public class Graphics {
drawImage(image, x, y, w, h);
}
}
public void drawPixelated(TextureRegion image, float x, float y, float w, float h, Float amount, boolean flipY) {
if (image == null)
return;
@@ -896,6 +1005,7 @@ public class Graphics {
drawImage(image, x, y, w, h);
}
}
public void drawPixelatedWarp(TextureRegion image, float x, float y, float w, float h, float amount) {
if (image == null)
return;
@@ -919,6 +1029,7 @@ public class Graphics {
drawImage(image, x, y, w, h);
}
}
public void drawWarpImage(Texture image, float x, float y, float w, float h, float time) {
batch.end();
shaderWarp.bind();
@@ -934,6 +1045,7 @@ public class Graphics {
batch.setShader(null);
batch.begin();
}
public void drawWarpImage(TextureRegion image, float x, float y, float w, float h, float time) {
batch.end();
shaderWarp.bind();
@@ -949,6 +1061,7 @@ public class Graphics {
batch.setShader(null);
batch.begin();
}
public void drawWarpImage(FImage image, float x, float y, float w, float h, float time) {
if (image == null)
return;
@@ -966,6 +1079,7 @@ public class Graphics {
batch.setShader(null);
batch.begin();
}
public void drawUnderWaterImage(FImage image, float x, float y, float w, float h, float time) {
if (image == null)
return;
@@ -984,6 +1098,7 @@ public class Graphics {
batch.setShader(null);
batch.begin();
}
public void drawNightDay(FImage image, float x, float y, float w, float h, Float time) {
if (image == null)
return;
@@ -1003,6 +1118,7 @@ public class Graphics {
drawImage(image, x, y, w, h);
}
}
public void drawUnderWaterImage(TextureRegion image, float x, float y, float w, float h, float time) {
batch.end();
shaderUnderwater.bind();
@@ -1018,9 +1134,11 @@ public class Graphics {
batch.setShader(null);
batch.begin();
}
public void drawImage(FImage image, float x, float y, float w, float h) {
drawImage(image, x, y, w, h, false);
}
public void drawImage(FImage image, float x, float y, float w, float h, boolean withDarkOverlay) {
if (image == null)
return;
@@ -1032,14 +1150,17 @@ public class Graphics {
setAlphaComposite(oldalpha);
}
}
public void drawImage(Texture image, float x, float y, float w, float h) {
if (image != null)
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
}
public void drawImage(TextureRegion image, float x, float y, float w, float h) {
if (image != null)
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
}
public void drawImage(TextureRegion image, TextureRegion glowImageReference, float x, float y, float w, float h, Color glowColor, boolean selected) {
if (image == null || glowImageReference == null)
return;
@@ -1065,6 +1186,7 @@ public class Graphics {
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
}
}
public void drawDeckBox(FImage cardArt, float scale, TextureRegion image, TextureRegion glowImageReference, float x, float y, float w, float h, Color glowColor, boolean selected) {
if (image == null || glowImageReference == null)
return;
@@ -1149,16 +1271,26 @@ 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);
}
public void drawText(String text, BitmapFont bitmapFont, float x, float y, Color color, float alpha) {
if (text == null || bitmapFont == null || text.isEmpty())
return;
bitmapFont.setColor(color.r, color.g, color.b, alpha);
bitmapFont.draw(batch, text, x, y);
}
public void drawText(String text, FSkinFont font, FSkinColor skinColor, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically) {
drawText(text, font, skinColor.getColor(), x, y, w, h, wrap, horzAlignment, centerVertically);
}
public void drawText(String text, FSkinFont font, Color color, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically) {
try {
if (text == null)
@@ -1173,8 +1305,7 @@ public class Graphics {
TextBounds textBounds;
if (wrap) {
textBounds = font.getWrappedBounds(text, w);
}
else {
} else {
textBounds = font.getMultiLineBounds(text);
}
@@ -1185,12 +1316,10 @@ public class Graphics {
font = font.shrink();
if (wrap) {
textBounds = font.getWrappedBounds(text, w);
}
else {
} else {
textBounds = font.getMultiLineBounds(text);
}
}
else {
} else {
needClip = true;
break;
}
@@ -1224,6 +1353,7 @@ public class Graphics {
public void drawOutlinedText(String text, FSkinFont skinFont, Color textColor, Color outlineColor, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically) {
drawOutlinedText(text, skinFont, textColor, outlineColor, x, y, w, h, wrap, horzAlignment, centerVertically, false);
}
public void drawOutlinedText(String text, FSkinFont skinFont, Color textColor, Color outlineColor, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically, boolean shadow) {
if (shadow) {
float oldAlpha = alphaComposite;
@@ -1250,6 +1380,7 @@ public class Graphics {
public float adjustY(float y, float height) {
return regionHeight - y - bounds.y - height; //flip y-axis
}
public Color borderLining(String c) {
if (c == null || c == "")
return Color.valueOf("#fffffd");

View File

@@ -42,6 +42,30 @@ public class Shaders {
" v_texCoords = a_texCoord0;\n" +
" gl_Position = u_projTrans * a_position;\n" +
"}";
public static final String fragHueShift = "#ifdef GL_ES\n" +
"#define LOWP lowp\n" +
"precision mediump float;\n" +
"#else\n" +
"#define LOWP \n" +
"#endif\n" +
"varying vec2 v_texCoords;\n" +
"uniform sampler2D u_texture;\n" +
"uniform float u_time;\n" +
"\n" +
"vec3 hs(vec3 c, float s) {\n" +
" vec3 m=vec3(cos(s),s=sin(s)*.5774,-s);\n" +
" return c*mat3(m+=(1.-m.x)/3.,m.zxy,m.yzx);\n" +
"}\n" +
"\n" +
"void main() {\n" +
"\tvec2 uv = v_texCoords;\n" +
" vec4 orig = texture2D(u_texture, uv);\n" +
" vec3 col = texture2D(u_texture, uv).rgb;\n" +
" vec4 col2 = vec4(hs(col, u_time), 1.);\n" +
" //multiply the original texture alpha to render only opaque shifted colors \n" +
" col2.a *= orig.a;\n" +
" gl_FragColor = col2;\n" +
"}";
public static final String fragRipple = "#ifdef GL_ES\n" +
"#define LOWP lowp\n" +
"precision mediump float;\n" +
@@ -1135,6 +1159,7 @@ public class Shaders {
* {@link com.github.tommyettinger.colorful.rgb.ColorTools#rgb(float, float, float, float)}.
* <br>
* Meant for use with {@link #vertexShader}.
*
* @see #fragmentShaderConfigurableContrast a per-sprite-configurable version of this
*/
public static String fragmentShaderFlatLightness =
@@ -1176,6 +1201,7 @@ public class Shaders {
* the specific way this uses them.
* <br>
* Meant for use with {@link #vertexShader}.
*
* @see #fragmentShaderFlatLightness if you only need one contrast setting and still want to set color tints
*/
public static String fragmentShaderConfigurableContrast =

View File

@@ -1,10 +1,7 @@
package forge.adventure.scene;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.*;
@@ -15,7 +12,6 @@ import forge.Forge;
import forge.adventure.character.EnemySprite;
import forge.adventure.data.ArenaData;
import forge.adventure.data.WorldData;
import forge.adventure.player.AdventurePlayer;
import forge.adventure.stage.GameHUD;
import forge.adventure.stage.IAfterMatch;
import forge.adventure.stage.WorldStage;
@@ -29,8 +25,6 @@ import java.util.Random;
* Displays the rewards of a fight or a treasure
*/
public class ArenaScene extends UIScene implements IAfterMatch {
private FileHandle vsIcon = Config.instance().getFile("ui/vs.png");
private TextureRegion vsTextureRegion = vsIcon.exists() ? new TextureRegion(new Texture(vsIcon)) : null;
private static ArenaScene object;
private final float gridSize;
private ArenaData arenaData;
@@ -59,11 +53,9 @@ public class ArenaScene extends UIScene implements IAfterMatch {
final Sprite edgeWin;
final Sprite edgeWinM;
boolean arenaStarted = false;
private ArenaScene() {
super(Forge.isLandscapeMode() ? "ui/arena.json" : "ui/arena_portrait.json");
TextureAtlas atlas = Config.instance().getAtlas(Paths.ARENA_ATLAS);
fighterSpot = atlas.createSprite("Spot");
lostOverlay = atlas.createSprite("Lost");
@@ -95,11 +87,9 @@ public class ArenaScene extends UIScene implements IAfterMatch {
startButton = ui.findActor("start");
}
private void showAreYouSure() {
Dialog areYouSureDialog = prepareDialog(Forge.getLocalizer().getMessage("lblConcedeTitle"), ButtonYes | ButtonNo, () -> loose());
areYouSureDialog.text(Forge.getLocalizer().getMessage("lblConcedeCurrentGame"));
showDialog(areYouSureDialog);
@@ -113,19 +103,17 @@ public class ArenaScene extends UIScene implements IAfterMatch {
}
private void startButton() {
if(roundsWon ==0)
{
if (roundsWon == 0) {
Dialog startDialog = prepareDialog(Forge.getLocalizer().getMessage("lblStart"), ButtonYes | ButtonNo, () -> startArena());
startDialog.text("Do you want to go into the Arena?");
showDialog(startDialog);
}
else
{
} else {
startRound();
}
}
int roundsWon = 0;
private void startArena() {
goldLabel.setVisible(false);
arenaStarted = true;
@@ -137,37 +125,31 @@ public class ArenaScene extends UIScene implements IAfterMatch {
Current.player().takeGold(arenaData.entryFee);
startRound();
}
@Override
public void setWinner(boolean winner) {
Array<Actor> winners = new Array<>();
Array<EnemySprite> winnersEnemies = new Array<>();
for(int i=0;i<fighters.size-2;i+=2)
{
for (int i = 0; i < fighters.size - 2; i += 2) {
boolean leftWon = rand.nextBoolean();
if(leftWon)
{
if (leftWon) {
winners.add(fighters.get(i));
winnersEnemies.add(enemies.get(i));
moveFighter(fighters.get(i), true);
markLostFighter(fighters.get(i + 1));
}
else
{
} else {
markLostFighter(fighters.get(i));
moveFighter(fighters.get(i + 1), false);
winners.add(fighters.get(i + 1));
winnersEnemies.add(enemies.get(i + 1));
}
}
if(winner)
{
if (winner) {
markLostFighter(fighters.get(fighters.size - 2));
moveFighter(fighters.get(fighters.size - 1), false);
winners.add(fighters.get(fighters.size - 1));
roundsWon++;
}
else
{
} else {
markLostFighter(fighters.get(fighters.size - 1));
moveFighter(fighters.get(fighters.size - 2), true);
winners.add(fighters.get(fighters.size - 2));
@@ -176,8 +158,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
fighters = winners;
enemies = winnersEnemies;
if(roundsWon >=arenaData.rounds )
{
if (roundsWon >= arenaData.rounds) {
arenaStarted = false;
startButton.setDisabled(true);
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
@@ -186,14 +167,12 @@ public class ArenaScene extends UIScene implements IAfterMatch {
}
private void moveFighter(Actor actor, boolean leftPlayer) {
Image spotImg = new Image(upWin);
double stepsToTheSide = Math.pow(2, roundsWon);
float widthDiff = actor.getWidth() - spotImg.getWidth();
spotImg.setPosition(actor.getX() + widthDiff / 2, actor.getY() + gridSize + widthDiff / 2);
arenaPlane.addActor(spotImg);
for(int i=0;i<stepsToTheSide;i++)
{
for (int i = 0; i < stepsToTheSide; i++) {
Image leftImg;
if (i == 0)
leftImg = new Image(leftPlayer ? edgeWin : edgeWinM);
@@ -208,7 +187,6 @@ public class ArenaScene extends UIScene implements IAfterMatch {
}
private void markLostFighter(Actor fighter) {
Image lost = new Image(lostOverlay);
float widthDiff = fighter.getWidth() - lost.getWidth();
lost.setPosition(fighter.getX() + widthDiff / 2, fighter.getY() + widthDiff / 2);
@@ -222,13 +200,11 @@ public class ArenaScene extends UIScene implements IAfterMatch {
Forge.setTransitionScreen(new TransitionScreen(() -> {
duelScene.initDuels(WorldStage.getInstance().getPlayerSprite(), enemy);
Forge.switchScene(duelScene);
}, Forge.takeScreenshot(), true, false, false, false, "", vsTextureRegion, AdventurePlayer.current().avatar(), enemy.getAtlasPath()));
}, Forge.takeScreenshot(), true, false, false, false, "", Current.player().avatar(), enemy.getAtlasPath(), Current.player().getName(), enemy.nameOverride.isEmpty() ? enemy.getData().name : enemy.nameOverride));
});
}
public boolean start() {
return true;
}
@@ -236,13 +212,10 @@ public class ArenaScene extends UIScene implements IAfterMatch {
public boolean done() {
GameHUD.getInstance().getTouchpad().setVisible(false);
Forge.switchToLast();
if(roundsWon !=0)
{
if (roundsWon != 0) {
Array<Reward> data = new Array<>();
for(int i = 0; i< roundsWon; i++)
{
for(int j=0;j<arenaData.rewards[i].length;j++)
{
for (int i = 0; i < roundsWon; i++) {
for (int j = 0; j < arenaData.rewards[i].length; j++) {
data.addAll(arenaData.rewards[i][j].generate(false, null));
}
}
@@ -251,13 +224,13 @@ public class ArenaScene extends UIScene implements IAfterMatch {
}
return true;
}
@Override
public void act(float delta) {
stage.act(delta);
}
Array<EnemySprite> enemies = new Array<>();
Array<Actor> fighters = new Array<>();
Actor player;
@@ -277,8 +250,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
int numberOfEnemies = (int) (Math.pow(2f, data.rounds) - 1);
for(int i=0;i<numberOfEnemies;i++)
{
for (int i = 0; i < numberOfEnemies; i++) {
EnemySprite enemy = new EnemySprite(WorldData.getEnemy(data.enemyPool[rand.nextInt(data.enemyPool.length)]));
enemies.add(enemy);
fighters.add(new Image(enemy.getAvatar()));
@@ -297,16 +269,11 @@ public class ArenaScene extends UIScene implements IAfterMatch {
int gridHeight = data.rounds + 1;
arenaPlane.setSize(gridWidth * gridSize, gridHeight * gridSize * 2);
int fighterIndex = 0;
for(int x=0;x<gridWidth;x++)
{
for(int y=0;y<gridHeight;y++)
{
if(x % Math.pow(2,y+1) == Math.pow(2,y))
{
if(y==0)
{
if(fighterIndex<fighters.size)
{
for (int x = 0; x < gridWidth; x++) {
for (int y = 0; y < gridHeight; y++) {
if (x % Math.pow(2, y + 1) == Math.pow(2, y)) {
if (y == 0) {
if (fighterIndex < fighters.size) {
float widthDiff = gridSize - fighters.get(fighterIndex).getWidth();
fighters.get(fighterIndex).setPosition(x * gridSize + widthDiff / 2, y * gridSize * 2 + widthDiff / 2);
arenaPlane.addActor(fighters.get(fighterIndex));
@@ -317,25 +284,19 @@ public class ArenaScene extends UIScene implements IAfterMatch {
spotImg.setPosition(x * gridSize, y * gridSize * 2);
arenaPlane.addActor(spotImg);
if(y!=gridHeight-1)
{
if (y != gridHeight - 1) {
Image upImg = new Image(up);
upImg.setPosition(x * gridSize, y * gridSize * 2 + gridSize);
arenaPlane.addActor(upImg);
}
if(y!=0)
{
for(int i=0;i<Math.pow(2,(y-1));i++)
{
if (y != 0) {
for (int i = 0; i < Math.pow(2, (y - 1)); i++) {
Image leftImg;
Image rightImg;
if(i==Math.pow(2,(y-1))-1)
{
if (i == Math.pow(2, (y - 1)) - 1) {
leftImg = new Image(edge);
rightImg = new Image(edgeM);
}
else
{
} else {
leftImg = new Image(side);
rightImg = new Image(side);
}
@@ -349,5 +310,4 @@ public class ArenaScene extends UIScene implements IAfterMatch {
}
}
}
}

View File

@@ -55,6 +55,7 @@ public class DuelScene extends ForgeScene {
object = new DuelScene();
return object;
}
//GameLobby lobby;
HostedMatch hostedMatch;
EnemySprite enemy;

View File

@@ -3,7 +3,6 @@ package forge.adventure.scene;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import forge.Forge;
import forge.adventure.character.PlayerSprite;
import forge.adventure.data.BiomeData;
import forge.adventure.stage.MapStage;
import forge.adventure.stage.WorldStage;
@@ -58,15 +57,15 @@ public class GameScene extends HudScene {
super.enter();
WorldStage.getInstance().handlePointsOfInterestCollision();
}
public String getAdventurePlayerLocation(boolean forHeader) {
String location = "";
if (MapStage.getInstance().isInMap()) {
location = forHeader ? TileMapScene.instance().rootPoint.getData().name : TileMapScene.instance().rootPoint.getData().type;
} else {
World world = Current.world();
PlayerSprite player = WorldStage.getInstance().getPlayerSprite();
int currentBiome = World.highestBiome(world.getBiome((int) player.getX() / world.getTileSize(), (int) player.getY() / world.getTileSize()));
List<BiomeData> biomeData = Current.world().getData().GetBiomes();
int currentBiome = World.highestBiome(world.getBiome((int) Current.player().getWorldPosX() / world.getTileSize(), (int) Current.player().getWorldPosY() / world.getTileSize()));
List<BiomeData> biomeData = world.getData().GetBiomes();
try {
BiomeData data = biomeData.get(currentBiome);
location = forHeader ? TextUtil.capitalize(data.name) + " Map" : data.name;

View File

@@ -118,8 +118,7 @@ public class MapStage extends GameStage {
return changes;
}
private MapStage()
{
private MapStage() {
dialog = Controls.newDialog("");
eventTouchDown = new InputEvent();
eventTouchDown.setPointer(-1);
@@ -128,6 +127,7 @@ public class MapStage extends GameStage {
eventTouchUp.setPointer(-1);
eventTouchUp.setType(InputEvent.Type.touchUp);
}
public static MapStage getInstance() {
return instance == null ? instance = new MapStage() : instance;
}
@@ -246,6 +246,7 @@ public class MapStage extends GameStage {
setDialogStage(GameHUD.getInstance());
showDialog();
}
Array<EntryActor> otherEntries = new Array<>();
Array<EntryActor> spawnClassified = new Array<>();
Array<EntryActor> sourceMapMatch = new Array<>();
@@ -281,12 +282,9 @@ public class MapStage extends GameStage {
effect = JSONStringLoader.parse(EffectData.class, map.getProperties().get("dungeonEffect").toString(), "");
effectDialog(effect);
}
if(MP.get("respawnEnemies")!=null&&MP.get("respawnEnemies") instanceof Boolean&&(Boolean)MP.get("respawnEnemies"))
{
if (MP.get("respawnEnemies") != null && MP.get("respawnEnemies") instanceof Boolean && (Boolean) MP.get("respawnEnemies")) {
respawnEnemies = true;
}
else
{
} else {
respawnEnemies = false;
}
if (MP.get("preventEscape") != null) preventEscape = (boolean) MP.get("preventEscape");
@@ -321,11 +319,9 @@ public class MapStage extends GameStage {
int oldSize;
do {
oldSize = collisionRect.size;
for(int i=0;i<collisionRect.size;i++)
{
for (int i = 0; i < collisionRect.size; i++) {
Rectangle r1 = collisionRect.get(i);
for(int j=i+1;j<collisionRect.size;j++)
{
for (int j = i + 1; j < collisionRect.size; j++) {
Rectangle r2 = collisionRect.get(j);
if ((Math.abs(r1.x - (r2.x + r2.width)) < 1 && Math.abs(r1.y - r2.y) < 1 && Math.abs(r1.height - r2.height) < 1)//left edge is the same as right edge
@@ -336,8 +332,7 @@ public class MapStage extends GameStage {
|| (Math.abs(r1.x - r2.x) < 1 && Math.abs(r1.y - (r2.y + r2.height)) < 1 && Math.abs(r1.width - r2.width) < 1)//bottom edge is the same as left edge
|| containsOrEquals(r1, r2) || containsOrEquals(r2, r1)
)
{
) {
r1.merge(r2);
collisionRect.removeIndex(j);
i--;
@@ -358,6 +353,7 @@ public class MapStage extends GameStage {
float yma = ymi + r2.height;
return xmi >= r1.x && xmi <= r1.x + r1.width && xma >= r1.x && xma <= r1.x + r1.width && ymi >= r1.y && ymi <= r1.y + r1.height && yma >= r1.y && yma <= r1.y + r1.height;
}
private void loadCollision(TiledMapTileLayer layer) {
for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) {
@@ -408,15 +404,11 @@ public class MapStage extends GameStage {
!sourceMap.isEmpty() && targetMap.equals(sourceMap);
EntryActor entry = new EntryActor(this, id, prop.get("teleport").toString(), x, y, w, h, prop.get("direction").toString());
if((prop.containsKey("spawn")&& prop.get("spawn").toString().equals("true"))&&spawnPlayerThere)
{
if ((prop.containsKey("spawn") && prop.get("spawn").toString().equals("true")) && spawnPlayerThere) {
spawnClassified.add(entry);
}else if(spawnPlayerThere)
{
} else if (spawnPlayerThere) {
sourceMapMatch.add(entry);
}
else
{
} else {
otherEntries.add(entry);
}
addMapActor(obj, entry);
@@ -484,7 +476,6 @@ public class MapStage extends GameStage {
addMapActor(obj, new OnCollide(() -> Forge.switchScene(SpellSmithScene.instance())));
break;
case "arena":
addMapActor(obj, new OnCollide(() -> {
ArenaData arenaData = JSONStringLoader.parse(ArenaData.class, prop.get("arena").toString(), "");
ArenaScene.instance().loadArenaData(arenaData, WorldSave.getCurrentSave().getWorld().getRandom().nextLong());
@@ -696,7 +687,7 @@ public class MapStage extends GameStage {
if (isInMap && effect != null)
duelScene.setDungeonEffect(effect);
Forge.switchScene(duelScene);
}, Forge.takeScreenshot(), true, false));
}, Forge.takeScreenshot(), true, false, false, false, "", Current.player().avatar(), mob.getAtlasPath(), Current.player().getName(), mob.nameOverride.isEmpty() ? mob.getData().name : mob.nameOverride));
}
});
});
@@ -709,6 +700,7 @@ public class MapStage extends GameStage {
public boolean isInMap() {
return isInMap;
}
public boolean isDialogOnlyInput() {
return dialogOnlyInput;
}
@@ -792,18 +784,16 @@ public class MapStage extends GameStage {
}
}, 0.10f);
}
private void selectNextDialogButton() {
if (dialogButtonMap.size < 2)
return;
if(!(dialogStage.getKeyboardFocus() instanceof Button))
{
if (!(dialogStage.getKeyboardFocus() instanceof Button)) {
dialogStage.setKeyboardFocus(dialogButtonMap.first());
return;
}
for(int i=0;i<dialogButtonMap.size;i++)
{
if(dialogStage.getKeyboardFocus()==dialogButtonMap.get(i))
{
for (int i = 0; i < dialogButtonMap.size; i++) {
if (dialogStage.getKeyboardFocus() == dialogButtonMap.get(i)) {
i += 1;
i %= dialogButtonMap.size;
dialogStage.setKeyboardFocus(dialogButtonMap.get(i));
@@ -811,18 +801,16 @@ public class MapStage extends GameStage {
}
}
}
private void selectPreviousDialogButton() {
if (dialogButtonMap.size < 2)
return;
if(!(dialogStage.getKeyboardFocus() instanceof Button))
{
if (!(dialogStage.getKeyboardFocus() instanceof Button)) {
dialogStage.setKeyboardFocus(dialogButtonMap.first());
return;
}
for(int i=0;i<dialogButtonMap.size;i++)
{
if(dialogStage.getKeyboardFocus()==dialogButtonMap.get(i))
{
for (int i = 0; i < dialogButtonMap.size; i++) {
if (dialogStage.getKeyboardFocus() == dialogButtonMap.get(i)) {
i -= 1;
if (i < 0)
i = dialogButtonMap.size - 1;

View File

@@ -40,7 +40,6 @@ import java.util.Random;
* Stage for the over world. Will handle monster spawns
*/
public class WorldStage extends GameStage implements SaveFileContent {
private static WorldStage instance = null;
protected EnemySprite currentMob;
protected Random rand = MyRandom.getRandom();
@@ -63,9 +62,9 @@ public class WorldStage extends GameStage implements SaveFileContent {
return instance == null ? instance = new WorldStage() : instance;
}
final Rectangle tempBoundingRect = new Rectangle();
final Vector2 enemyMoveVector = new Vector2();
@Override
protected void onActing(float delta) {
if (player.isMoving()) {
@@ -75,8 +74,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
while (it.hasNext()) {
Pair<Float, EnemySprite> pair = it.next();
if(globalTimer>=pair.getKey()+dieTimer)
{
if (globalTimer >= pair.getKey() + dieTimer) {
foregroundSprites.removeActor(pair.getValue());
it.remove();
@@ -84,8 +82,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
}
EnemySprite mob = pair.getValue();
if(!currentModifications.containsKey(PlayerModification.Hide))
{
if (!currentModifications.containsKey(PlayerModification.Hide)) {
enemyMoveVector.set(player.getX(), player.getY()).sub(mob.pos());
enemyMoveVector.setLength(mob.speed() * delta);
tempBoundingRect.set(mob.getX() + enemyMoveVector.x, mob.getY() + enemyMoveVector.y, mob.getWidth(), mob.getHeight() * mob.getCollisionHeight());
@@ -100,20 +97,15 @@ public class WorldStage extends GameStage implements SaveFileContent {
{
mob.moveBy(0, enemyMoveVector.y);
}
}
else
{
} else {
mob.moveBy(enemyMoveVector.x, 0);
}
}
else
{
} else {
mob.moveBy(enemyMoveVector.x, enemyMoveVector.y);
}
}
if (player.collideWith(mob)) {
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
mob.setAnimation(CharacterSprite.AnimationTypes.Attack);
@@ -130,7 +122,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
Forge.setTransitionScreen(new TransitionScreen(() -> {
duelScene.initDuels(player, mob);
Forge.switchScene(duelScene);
}, Forge.takeScreenshot(), true, false));
}, Forge.takeScreenshot(), true, false, false, false, "", Current.player().avatar(), mob.getAtlasPath(), Current.player().getName(), mob.nameOverride.isEmpty() ? mob.getData().name : mob.nameOverride));
currentMob = mob;
WorldSave.getCurrentSave().autoSave();
});
@@ -138,16 +130,14 @@ public class WorldStage extends GameStage implements SaveFileContent {
break;
}
}
} else {
for (Pair<Float, EnemySprite> pair : enemies) {
pair.getValue().setAnimation(CharacterSprite.AnimationTypes.Idle);
}
}
}
private void removeEnemy(EnemySprite currentMob) {
private void removeEnemy(EnemySprite currentMob) {
currentMob.removeAfterEffects();
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
while (it.hasNext()) {
@@ -158,9 +148,9 @@ public class WorldStage extends GameStage implements SaveFileContent {
}
}
}
@Override
public void setWinner(boolean playerIsWinner) {
if (playerIsWinner) {
Current.player().win();
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
@@ -179,12 +169,10 @@ public class WorldStage extends GameStage implements SaveFileContent {
WorldStage.this.removeEnemy(currentMob);
currentMob = null;
});
}
}
}
public void handlePointsOfInterestCollision() {
for (Actor actor : foregroundSprites.getChildren()) {
if (actor.getClass() == PointOfInterestMapSprite.class) {
PointOfInterestMapSprite point = (PointOfInterestMapSprite) actor;
@@ -200,18 +188,17 @@ public class WorldStage extends GameStage implements SaveFileContent {
}
}
}
}
}
}
}
@Override
public boolean isColliding(Rectangle boundingRect)
{
public boolean isColliding(Rectangle boundingRect) {
if (currentModifications.containsKey(PlayerModification.Fly))
return false;
return WorldSave.getCurrentSave().getWorld().collidingTile(boundingRect);
}
public boolean spawn(String enemy)
{
public boolean spawn(String enemy) {
return spawn(WorldData.getEnemy(enemy));
}
@@ -245,18 +232,15 @@ public class WorldStage extends GameStage implements SaveFileContent {
EnemySprite sprite = new EnemySprite(enemyData);
float unit = Scene.getIntendedHeight() / 6f;
Vector2 spawnPos = new Vector2(1, 1);
for(int j=0;j<10;j++)
{
for (int j = 0; j < 10; j++) {
spawnPos.setLength(unit + (unit * 3) * rand.nextFloat());
spawnPos.setAngleDeg(360 * rand.nextFloat());
for(int i=0;i<10;i++)
{
for (int i = 0; i < 10; i++) {
boolean enemyXIsBigger = sprite.getX() > player.getX();
boolean enemyYIsBigger = sprite.getY() > player.getY();
sprite.setX(player.getX() + spawnPos.x + (i * sprite.getWidth() * (enemyXIsBigger ? 1 : -1)));//maybe find a better way to get spawn points
sprite.setY(player.getY() + spawnPos.y + (i * sprite.getHeight() * (enemyYIsBigger ? 1 : -1)));
if(sprite.getData().flying || !WorldSave.getCurrentSave().getWorld().collidingTile(sprite.boundingRect()))
{
if (sprite.getData().flying || !WorldSave.getCurrentSave().getWorld().collidingTile(sprite.boundingRect())) {
enemies.add(Pair.of(globalTimer, sprite));
foregroundSprites.addActor(sprite);
return true;
@@ -287,7 +271,6 @@ public class WorldStage extends GameStage implements SaveFileContent {
@Override
public void enter() {
getPlayerSprite().LoadPos();
getPlayerSprite().setMovementDirection(Vector2.Zero);
for (Actor actor : foregroundSprites.getChildren()) {
@@ -297,10 +280,8 @@ public class WorldStage extends GameStage implements SaveFileContent {
collidingPoint = point;
}
}
}
setBounds(WorldSave.getCurrentSave().getWorld().getWidthInPixels(), WorldSave.getCurrentSave().getWorld().getHeightInPixels());
GridPoint2 pos = background.translateFromWorldToChunk(player.getX(), player.getY());
background.loadChunk(pos.x, pos.y);
handlePointsOfInterestCollision();
@@ -315,15 +296,11 @@ public class WorldStage extends GameStage implements SaveFileContent {
public void load(SaveFileData data) {
try {
clearCache();
List<Float> timeouts = (List<Float>) data.readObject("timeouts");
List<String> names = (List<String>) data.readObject("names");
List<Float> x = (List<Float>) data.readObject("x");
List<Float> y = (List<Float>) data.readObject("y");
for(int i=0;i<timeouts.size();i++)
{
for (int i = 0; i < timeouts.size(); i++) {
EnemySprite sprite = new EnemySprite(WorldData.getEnemy(names.get(i)));
sprite.setX(x.get(i));
sprite.setY(y.get(i));
@@ -331,15 +308,12 @@ public class WorldStage extends GameStage implements SaveFileContent {
foregroundSprites.addActor(sprite);
}
globalTimer = data.readFloat("globalTimer");
}
catch (Exception e)
{
} catch (Exception e) {
}
}
public void clearCache() {
for (Pair<Float, EnemySprite> enemy : enemies)
foregroundSprites.removeActor(enemy.getValue());
enemies.clear();
@@ -354,8 +328,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
List<String> names = new ArrayList<>();
List<Float> x = new ArrayList<>();
List<Float> y = new ArrayList<>();
for(Pair<Float, EnemySprite> enemy:enemies)
{
for (Pair<Float, EnemySprite> enemy : enemies) {
timeouts.add(enemy.getKey());
names.add(enemy.getValue().getData().name);
x.add(enemy.getValue().getX());
@@ -376,23 +349,19 @@ public class WorldStage extends GameStage implements SaveFileContent {
public void removeNearestEnemy() {
float shortestDist = Float.MAX_VALUE;
EnemySprite enemy = null;
for (Pair<Float, EnemySprite> pair : enemies) {
float dist = pair.getValue().pos().sub(player.pos()).len();
if(dist<shortestDist)
{
if (dist < shortestDist) {
shortestDist = dist;
enemy = pair.getValue();
}
}
if(enemy!=null)
{
if (enemy != null) {
enemy.playEffect(Paths.EFFECT_KILL);
removeEnemy(enemy);
player.playEffect(Paths.TRIGGER_KILL);
}
}
}

View File

@@ -229,13 +229,15 @@ public class Controls {
switch (fontName) {
case "blackbig":
case "big":
getSkin().getFont("default").getData().setScale(2, 2);
return getSkin().getFont("default");
return getBitmapFont("default", 2);
default:
getSkin().getFont("default").getData().setScale(1, 1);
return getSkin().getFont("default");
return getBitmapFont("default", 1);
}
}
static public BitmapFont getBitmapFont(String fontName, float scaleXY) {
getSkin().getFont(fontName).getData().setScale(scaleXY, scaleXY);
return getSkin().getFont("default");
}
static public Skin getSkin() {
FileHandle skinFile = Config.instance().getFile(Paths.SKIN);

View File

@@ -1,41 +1,44 @@
package forge.screens;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import forge.Forge;
import forge.Graphics;
import forge.adventure.scene.ArenaScene;
import forge.adventure.util.Config;
import forge.adventure.util.Controls;
import forge.animation.ForgeAnimation;
import forge.assets.FSkin;
import forge.assets.FSkinImage;
import forge.assets.FSkinTexture;
import forge.gui.FThreads;
import forge.gui.GuiBase;
import forge.sound.SoundSystem;
import forge.toolbox.FContainer;
import forge.toolbox.FProgressBar;
import forge.util.MyRandom;
public class TransitionScreen extends FContainer {
private BGAnimation bgAnimation;
private FProgressBar progressBar;
Runnable runnable;
TextureRegion textureRegion, screenUIBackground, playerAvatar, vsTexture;
String enemyAtlasPath;
TextureRegion textureRegion, screenUIBackground, playerAvatar;
Texture vsTexture;
String enemyAtlasPath, playerAvatarName, enemyAvatarName;
private String message = "";
boolean matchTransition, isloading, isIntro, isFadeMusic, isArenaScene;
GlyphLayout layout;
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading) {
this(proc, screen, enterMatch, loading, false, false);
}
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading, String loadingMessage) {
this(proc, screen, enterMatch, loading, false, false, loadingMessage, null, null, "");
this(proc, screen, enterMatch, loading, false, false, loadingMessage, null, "", "", "");
}
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading, boolean intro, boolean fadeMusic) {
this(proc, screen, enterMatch, loading, intro, fadeMusic, "", null, null, "");
this(proc, screen, enterMatch, loading, intro, fadeMusic, "", null, "", "", "");
}
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading, boolean intro, boolean fadeMusic, String loadingMessage, TextureRegion vsIcon, TextureRegion player, String enemy) {
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading, boolean intro, boolean fadeMusic, String loadingMessage, TextureRegion player, String enemyAtlas, String playerName, String enemyName) {
progressBar = new FProgressBar();
progressBar.setMaximum(100);
progressBar.setPercentMode(true);
@@ -57,8 +60,11 @@ public class TransitionScreen extends FContainer {
screenUIBackground = null;
}
playerAvatar = player;
enemyAtlasPath = enemy;
vsTexture = vsIcon;
playerAvatarName = playerName;
enemyAvatarName = enemyName;
enemyAtlasPath = enemyAtlas;
vsTexture = Forge.getAssets().fallback_skins().get(2);
layout = new GlyphLayout();
}
public FProgressBar getProgressBar() {
@@ -128,8 +134,6 @@ public class TransitionScreen extends FContainer {
g.draw(progressBar);
}
} else if (matchTransition) {
if (textureRegion != null) {
if (isArenaScene) {
float screenW = Forge.isLandscapeMode() ? Forge.getScreenWidth() : Forge.getScreenHeight();
float screenH = Forge.isLandscapeMode() ? Forge.getScreenHeight() : Forge.getScreenWidth();
float scale = screenW/4;
@@ -137,36 +141,52 @@ public class TransitionScreen extends FContainer {
float centerY = screenH/2;
TextureRegion enemyAvatar = Config.instance().getAtlas(enemyAtlasPath).createSprite("Avatar");
enemyAvatar.flip(true, false);
g.drawChromatic(screenUIBackground, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), 1.1f*percentage);
if (Forge.isLandscapeMode()) {
g.drawImage(playerAvatar, scale / 3 * percentage, centerY - scale / 2, scale, scale);
g.drawImage(enemyAvatar, screenW - scale - (percentage * scale / 3), centerY - scale / 2, scale, scale);
float vsScale = (screenW / 3.2f) * percentage;
g.startRotateTransform(screenW/2, screenH/2, 180-(180*percentage));
g.drawImage(vsTexture, centerX - vsScale / 2, centerY - vsScale / 2, vsScale, vsScale);
g.endTransform();
} else {
g.drawImage(playerAvatar, centerY - scale / 2, scale / 3 * percentage, scale, scale);
g.drawImage(enemyAvatar,centerY - scale / 2 ,screenW - scale - (percentage * scale / 3), scale, scale);
float vsScale = (screenW / 3.2f) * percentage;
g.startRotateTransform(screenH/2, screenW/2, 180-(180*percentage));
g.drawImage(vsTexture, centerY - vsScale / 2, centerX - vsScale / 2, vsScale, vsScale);
g.endTransform();
}
g.setAlphaComposite(1-(percentage+0.6f));
BitmapFont font = Controls.getBitmapFont("default", 5f);
if (textureRegion != null) {
if (isArenaScene)
g.drawImage(screenUIBackground, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
else
g.drawImage(FSkinTexture.ADV_BG_TEXTURE, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
g.setAlphaComposite(1-percentage);
g.drawImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
g.setAlphaComposite(oldAlpha);
}
if (Forge.isLandscapeMode()) {
//player
float playerAvatarX = (screenW/4 - scale/2) * percentage;
float playerAvatarY = centerY - scale/2;
g.drawImage(playerAvatar, playerAvatarX, playerAvatarY, scale, scale);
layout.setText(font, playerAvatarName);
g.drawText(playerAvatarName, font, screenW/4 - layout.width/2, playerAvatarY - layout.height, Color.WHITE, percentage);
//enemy
float enemyAvatarX = screenW - screenW/4 - (scale/2 * percentage);
float enemyAvatarY = centerY - scale/2;
g.drawImage(enemyAvatar, enemyAvatarX, enemyAvatarY, scale, scale);
layout.setText(font, enemyAvatarName);
g.drawText(enemyAvatarName, font, screenW - screenW/4 - layout.width/2, enemyAvatarY - layout.height, Color.WHITE, percentage);
//vs
float vsScale = (screenW / 3.2f);
g.drawHueShift(vsTexture, centerX - vsScale / 2, centerY - vsScale / 2, vsScale, vsScale, percentage*4);
} else {
if (GuiBase.isAndroid()) {
g.drawChromatic(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), percentage);
} else {
int max = Forge.isLandscapeMode() ? Forge.getScreenHeight() / 32 : Forge.getScreenWidth() / 32;
int min = Forge.isLandscapeMode() ? Forge.getScreenHeight() / 64 : Forge.getScreenWidth() / 64;
int val = MyRandom.getRandom().nextInt(max - min) + min;
g.drawPixelatedWarp(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), val * percentage);
}
}
//enemy
float enemyAvatarX = centerY - scale / 2;
float enemyAvatarY = scale / 3 * percentage;
g.drawImage(enemyAvatar, enemyAvatarX, enemyAvatarY, scale, scale);
//player
float playerAvatarX = centerY - scale / 2;
float playerAvatarY = screenW - scale - (percentage * scale / 3);
g.drawImage(playerAvatar, playerAvatarX, playerAvatarY, scale, scale);
//vs
float vsScale = (screenW / 3.2f);
g.drawHueShift(vsTexture, centerY - vsScale / 2, centerX - vsScale / 2, vsScale, vsScale, percentage*4);
//names
layout.setText(font, enemyAvatarName);
g.drawText(enemyAvatarName, font, centerY - layout.width/2, screenW - scale/4, Color.WHITE, percentage);
layout.setText(font, playerAvatarName);
g.drawText(playerAvatarName, font, centerY - layout.width/2, 0 + scale/4, Color.WHITE, percentage);
}
//reset bitmapfont
Controls.getBitmapFont("default");
} else if (isIntro) {
if (textureRegion != null) {
if (Forge.advStartup) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 67 KiB