mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
Merge pull request #1991 from kevlahnota/newmaster2
update Adventure Matchscreen
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -92,7 +94,7 @@ public class Graphics {
|
||||
shaderGrayscale.dispose();
|
||||
shaderUnderwater.dispose();
|
||||
shaderWarp.dispose();
|
||||
if(dummyTexture != null) dummyTexture.dispose();
|
||||
if (dummyTexture != null) dummyTexture.dispose();
|
||||
}
|
||||
|
||||
public SpriteBatch getBatch() {
|
||||
@@ -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
|
||||
}
|
||||
@@ -181,7 +200,7 @@ public class Graphics {
|
||||
displayObj.draw(this);
|
||||
|
||||
if (displayObj.getRotate90() || displayObj.getRotate180()) {
|
||||
endTransform();
|
||||
endTransform();
|
||||
}
|
||||
|
||||
visibleBounds = backup;
|
||||
@@ -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
|
||||
|
||||
@@ -264,16 +302,17 @@ public class Graphics {
|
||||
public void drawLineArrow(float arrowThickness, FSkinColor skinColor, float x1, float y1, float x2, float y2) {
|
||||
fillCircle(skinColor.getColor(), x2, y2, arrowThickness);
|
||||
drawLineArrow(arrowThickness, skinColor.getColor(), x1, y1, x2, y2);
|
||||
fillCircle(Color.WHITE, x2, y2, arrowThickness/2);
|
||||
drawLine(arrowThickness/3, Color.WHITE, x1, y1, x2, y2);
|
||||
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
|
||||
|
||||
float angle = new Vector2(x1 - x2, y1 - y2).angleRad();
|
||||
float arrowHeadRotation = (float)(Math.PI * 0.8f);
|
||||
Vector2 arrowCorner3 = new Vector2(x2 + (thickness/3) * (float)Math.cos(angle + arrowHeadRotation), y2 + (thickness/3) * (float)Math.sin(angle + arrowHeadRotation));
|
||||
Vector2 arrowCorner4 = new Vector2(x2 + (thickness/3) * (float)Math.cos(angle - arrowHeadRotation), y2 + (thickness/3) * (float)Math.sin(angle - arrowHeadRotation));
|
||||
float arrowHeadRotation = (float) (Math.PI * 0.8f);
|
||||
Vector2 arrowCorner3 = new Vector2(x2 + (thickness / 3) * (float) Math.cos(angle + arrowHeadRotation), y2 + (thickness / 3) * (float) Math.sin(angle + arrowHeadRotation));
|
||||
Vector2 arrowCorner4 = new Vector2(x2 + (thickness / 3) * (float) Math.cos(angle - arrowHeadRotation), y2 + (thickness / 3) * (float) Math.sin(angle - arrowHeadRotation));
|
||||
|
||||
if (thickness > 1) {
|
||||
Gdx.gl.glLineWidth(thickness);
|
||||
@@ -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
|
||||
|
||||
@@ -319,31 +360,31 @@ public class Graphics {
|
||||
Gdx.gl.glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
float angle = new Vector2(x2 - x1, y2 - y1).angleRad();
|
||||
float perpRotation = (float)(Math.PI * 0.5f);
|
||||
float arrowHeadRotation = (float)(Math.PI * 0.8f);
|
||||
float arrowTipAngle = (float)(Math.PI - arrowHeadRotation);
|
||||
float perpRotation = (float) (Math.PI * 0.5f);
|
||||
float arrowHeadRotation = (float) (Math.PI * 0.8f);
|
||||
float arrowTipAngle = (float) (Math.PI - arrowHeadRotation);
|
||||
float halfThickness = arrowThickness / 2;
|
||||
|
||||
int index = 0;
|
||||
float[] vertices = new float[14];
|
||||
Vector2 arrowCorner1 = new Vector2(x2 + arrowSize * (float)Math.cos(angle + arrowHeadRotation), y2 + arrowSize * (float)Math.sin(angle + arrowHeadRotation));
|
||||
Vector2 arrowCorner2 = new Vector2(x2 + arrowSize * (float)Math.cos(angle - arrowHeadRotation), y2 + arrowSize * (float)Math.sin(angle - arrowHeadRotation));
|
||||
Vector2 arrowCorner1 = new Vector2(x2 + arrowSize * (float) Math.cos(angle + arrowHeadRotation), y2 + arrowSize * (float) Math.sin(angle + arrowHeadRotation));
|
||||
Vector2 arrowCorner2 = new Vector2(x2 + arrowSize * (float) Math.cos(angle - arrowHeadRotation), y2 + arrowSize * (float) Math.sin(angle - arrowHeadRotation));
|
||||
float arrowCornerLen = (arrowCorner1.dst(arrowCorner2) - arrowThickness) / 2;
|
||||
float arrowHeadLen = arrowSize * (float)Math.cos(arrowTipAngle);
|
||||
float arrowHeadLen = arrowSize * (float) Math.cos(arrowTipAngle);
|
||||
index = addVertex(arrowCorner1.x, arrowCorner1.y, vertices, index);
|
||||
index = addVertex(x2, y2, vertices, index);
|
||||
index = addVertex(arrowCorner2.x, arrowCorner2.y, vertices, index);
|
||||
index = addVertex(arrowCorner2.x + arrowCornerLen * (float)Math.cos(angle + perpRotation), arrowCorner2.y + arrowCornerLen * (float)Math.sin(angle + perpRotation), vertices, index);
|
||||
index = addVertex(x1 + halfThickness * (float)Math.cos(angle - perpRotation), y1 + halfThickness * (float)Math.sin(angle - perpRotation), vertices, index);
|
||||
index = addVertex(x1 + halfThickness * (float)Math.cos(angle + perpRotation), y1 + halfThickness * (float)Math.sin(angle + perpRotation), vertices, index);
|
||||
index = addVertex(arrowCorner1.x + arrowCornerLen * (float)Math.cos(angle - perpRotation), arrowCorner1.y + arrowCornerLen * (float)Math.sin(angle - perpRotation), vertices, index);
|
||||
index = addVertex(arrowCorner2.x + arrowCornerLen * (float) Math.cos(angle + perpRotation), arrowCorner2.y + arrowCornerLen * (float) Math.sin(angle + perpRotation), vertices, index);
|
||||
index = addVertex(x1 + halfThickness * (float) Math.cos(angle - perpRotation), y1 + halfThickness * (float) Math.sin(angle - perpRotation), vertices, index);
|
||||
index = addVertex(x1 + halfThickness * (float) Math.cos(angle + perpRotation), y1 + halfThickness * (float) Math.sin(angle + perpRotation), vertices, index);
|
||||
index = addVertex(arrowCorner1.x + arrowCornerLen * (float) Math.cos(angle - perpRotation), arrowCorner1.y + arrowCornerLen * (float) Math.sin(angle - perpRotation), vertices, index);
|
||||
|
||||
//draw arrow tail
|
||||
startShape(ShapeType.Filled);
|
||||
shapeRenderer.setColor(color);
|
||||
shapeRenderer.rectLine(adjustX(x1), adjustY(y1, 0),
|
||||
adjustX(x2 - arrowHeadLen * (float)Math.cos(angle)), //shorten tail to make room for arrow head
|
||||
adjustY(y2 - arrowHeadLen * (float)Math.sin(angle), 0), arrowThickness);
|
||||
adjustX(x2 - arrowHeadLen * (float) Math.cos(angle)), //shorten tail to make room for arrow head
|
||||
adjustY(y2 - arrowHeadLen * (float) Math.sin(angle), 0), arrowThickness);
|
||||
|
||||
//draw arrow head
|
||||
shapeRenderer.triangle(vertices[0], vertices[1], vertices[2], vertices[3], vertices[4], vertices[5]);
|
||||
@@ -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
|
||||
|
||||
@@ -408,8 +450,8 @@ public class Graphics {
|
||||
shapeRenderer.arc(adjustX(x) + w - cornerRadius, adjustY(y + cornerRadius, 0), cornerRadius, 0f, 90f);
|
||||
shapeRenderer.arc(adjustX(x) + w - cornerRadius, adjustY(y + h - cornerRadius, 0), cornerRadius, 270, 90f);
|
||||
shapeRenderer.arc(adjustX(x) + cornerRadius, adjustY(y + h - cornerRadius, 0), cornerRadius, 180, 90f);
|
||||
shapeRenderer.rect(adjustX(x), adjustY(y+cornerRadius, h-cornerRadius*2), w, h-cornerRadius*2);
|
||||
shapeRenderer.rect(adjustX(x+cornerRadius), adjustY(y, h), w-cornerRadius*2, h);
|
||||
shapeRenderer.rect(adjustX(x), adjustY(y + cornerRadius, h - cornerRadius * 2), w, h - cornerRadius * 2);
|
||||
shapeRenderer.rect(adjustX(x + cornerRadius), adjustY(y, h), w - cornerRadius * 2, h);
|
||||
|
||||
endShape();
|
||||
|
||||
@@ -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) {
|
||||
@@ -443,8 +486,8 @@ public class Graphics {
|
||||
shapeRenderer.arc(adjustX(x) + w - cornerRadius, adjustY(y + cornerRadius, 0), cornerRadius, 0f, 90f);
|
||||
shapeRenderer.arc(adjustX(x) + w - cornerRadius, adjustY(y + h - cornerRadius, 0), cornerRadius, 270, 90f);
|
||||
shapeRenderer.arc(adjustX(x) + cornerRadius, adjustY(y + h - cornerRadius, 0), cornerRadius, 180, 90f);
|
||||
shapeRenderer.rect(adjustX(x), adjustY(y+cornerRadius, h-cornerRadius*2), w, h-cornerRadius*2);
|
||||
shapeRenderer.rect(adjustX(x+cornerRadius), adjustY(y, h), w-cornerRadius*2, h);
|
||||
shapeRenderer.rect(adjustX(x), adjustY(y + cornerRadius, h - cornerRadius * 2), w, h - cornerRadius * 2);
|
||||
shapeRenderer.rect(adjustX(x + cornerRadius), adjustY(y, h), w - cornerRadius * 2, h);
|
||||
endShape();
|
||||
if (color.a < 1) {
|
||||
Gdx.gl.glDisable(GL_BLEND);
|
||||
@@ -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,16 +524,18 @@ 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);
|
||||
drawLine(thickness, color, x, y+h, x+w, y+h);
|
||||
drawLine(thickness, color, x+w-thickness/2f, y+thickness/2f, x+w-thickness/2f, y+h-thickness/2f);
|
||||
drawLine(thickness, color, x, y, x + w, y);
|
||||
drawLine(thickness, color, x + thickness / 2f, y + thickness / 2f, x + thickness / 2f, y + h - thickness / 2f);
|
||||
drawLine(thickness, color, x, y + h, x + w, y + h);
|
||||
drawLine(thickness, color, x + w - thickness / 2f, y + thickness / 2f, x + w - thickness / 2f, y + h - thickness / 2f);
|
||||
}
|
||||
|
||||
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,17 +706,21 @@ 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;
|
||||
if(tint && !tintColor.equals(borderColor)){
|
||||
drawRoundRect(2f, borderLining(borderColor.toString()), x, y, w, h, (h-w)/12);
|
||||
fillRoundRect(tintColor, x, y, w, h, (h-w)/12);
|
||||
if (tint && !tintColor.equals(borderColor)) {
|
||||
drawRoundRect(2f, borderLining(borderColor.toString()), x, y, w, h, (h - w) / 12);
|
||||
fillRoundRect(tintColor, x, y, w, h, (h - w) / 12);
|
||||
} else {
|
||||
if (image != null) {
|
||||
image.draw(this, x, y, w, h);
|
||||
@@ -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);
|
||||
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...
|
||||
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,13 +959,14 @@ 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;
|
||||
if (amount != null) {
|
||||
batch.end();
|
||||
shaderPixelate.bind();
|
||||
shaderPixelate.setUniformf("u_resolution", Forge.isLandscapeMode() ? w : h , Forge.isLandscapeMode() ? h : w);
|
||||
shaderPixelate.setUniformf("u_resolution", Forge.isLandscapeMode() ? w : h, Forge.isLandscapeMode() ? h : w);
|
||||
shaderPixelate.setUniformf("u_cellSize", amount);
|
||||
shaderPixelate.setUniformf("u_yflip", flipY ? 1f : 0f);
|
||||
shaderPixelate.setUniformf("u_bias", 0.7f);
|
||||
@@ -874,13 +982,14 @@ 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;
|
||||
if (amount != null) {
|
||||
batch.end();
|
||||
shaderPixelate.bind();
|
||||
shaderPixelate.setUniformf("u_resolution", Forge.isLandscapeMode() ? w : h , Forge.isLandscapeMode() ? h : w);
|
||||
shaderPixelate.setUniformf("u_resolution", Forge.isLandscapeMode() ? w : h, Forge.isLandscapeMode() ? h : w);
|
||||
shaderPixelate.setUniformf("u_cellSize", amount);
|
||||
shaderPixelate.setUniformf("u_yflip", flipY ? 1 : 0);
|
||||
shaderPixelate.setUniformf("u_bias", 0.6f);
|
||||
@@ -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;
|
||||
@@ -904,7 +1014,7 @@ public class Graphics {
|
||||
shaderPixelateWarp.bind();
|
||||
shaderPixelateWarp.setUniformf("u_resolution", image.getRegionWidth(), image.getRegionHeight());
|
||||
shaderPixelateWarp.setUniformf("u_cellSize", amount);
|
||||
shaderPixelateWarp.setUniformf("u_amount", 0.2f*amount);
|
||||
shaderPixelateWarp.setUniformf("u_amount", 0.2f * amount);
|
||||
shaderPixelateWarp.setUniformf("u_speed", 0.5f);
|
||||
shaderPixelateWarp.setUniformf("u_time", 0.8f);
|
||||
batch.setShader(shaderPixelateWarp);
|
||||
@@ -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,13 +1079,14 @@ 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;
|
||||
batch.end();
|
||||
shaderUnderwater.bind();
|
||||
shaderUnderwater.setUniformf("u_amount", 10f*time);
|
||||
shaderUnderwater.setUniformf("u_speed", 0.5f*time);
|
||||
shaderUnderwater.setUniformf("u_amount", 10f * time);
|
||||
shaderUnderwater.setUniformf("u_speed", 0.5f * time);
|
||||
shaderUnderwater.setUniformf("u_time", time);
|
||||
shaderUnderwater.setUniformf("u_bias", 0.7f);
|
||||
batch.setShader(shaderUnderwater);
|
||||
@@ -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,32 +1134,37 @@ 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;
|
||||
image.draw(this, x, y, w, h);
|
||||
if(withDarkOverlay){
|
||||
if (withDarkOverlay) {
|
||||
float oldalpha = alphaComposite;
|
||||
setAlphaComposite(0.4f);
|
||||
fillRect(Color.BLACK, x, y, w, h);
|
||||
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;
|
||||
//1st image is the image on top of the shader, 2nd image is for the outline reference for the shader glow...
|
||||
//1st image is the image on top of the shader, 2nd image is for the outline reference for the shader glow...
|
||||
// if the 1st image don't have transparency in the middle (only on the sides, top and bottom, use the 1st image as outline reference...
|
||||
if (!selected) {
|
||||
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
|
||||
@@ -1065,12 +1186,13 @@ 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;
|
||||
float yBox = y-(h*0.25f);
|
||||
float yBox = y - (h * 0.25f);
|
||||
if (!selected) {
|
||||
cardArt.draw(this,x+((w-w*scale)/2), y+((h-h*scale)/3f), w*scale, h*scale/1.85f);
|
||||
cardArt.draw(this, x + ((w - w * scale) / 2), y + ((h - h * scale) / 3f), w * scale, h * scale / 1.85f);
|
||||
batch.draw(image, adjustX(x), adjustY(yBox, h), w, h);
|
||||
} else {
|
||||
batch.end();
|
||||
@@ -1087,7 +1209,7 @@ public class Graphics {
|
||||
batch.setShader(null);
|
||||
batch.begin();
|
||||
//cardart
|
||||
cardArt.draw(this,x+((w-w*scale)/2), y+((h-h*scale)/3f), w*scale, h*scale/1.85f);
|
||||
cardArt.draw(this, x + ((w - w * scale) / 2), y + ((h - h * scale) / 3f), w * scale, h * scale / 1.85f);
|
||||
//deckbox
|
||||
batch.draw(image, adjustX(x), adjustY(yBox, h), w, h);
|
||||
}
|
||||
@@ -1097,8 +1219,8 @@ public class Graphics {
|
||||
if (image == null)
|
||||
return;
|
||||
if (startClip(x, y, w, h)) { //only render if clip successful, otherwise it will escape bounds
|
||||
int tilesW = (int)(w / image.getWidth()) + 1;
|
||||
int tilesH = (int)(h / image.getHeight()) + 1;
|
||||
int tilesW = (int) (w / image.getWidth()) + 1;
|
||||
int tilesH = (int) (h / image.getHeight()) + 1;
|
||||
batch.draw(image, adjustX(x), adjustY(y, h),
|
||||
image.getWidth() * tilesW,
|
||||
image.getHeight() * tilesH,
|
||||
@@ -1136,7 +1258,7 @@ public class Graphics {
|
||||
shapeRenderer.setTransformMatrix(batch.getTransformMatrix().idt());
|
||||
Dtransforms.removeFirst();
|
||||
transformCount--;
|
||||
if(transformCount != Dtransforms.size()) {
|
||||
if (transformCount != Dtransforms.size()) {
|
||||
System.err.println(String.format("Stack count: %d, transformCount: %d", Dtransforms.size(), transformCount));
|
||||
transformCount = 0;
|
||||
Dtransforms.clear();
|
||||
@@ -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,20 +1380,21 @@ public class Graphics {
|
||||
public float adjustY(float y, float height) {
|
||||
return regionHeight - y - bounds.y - height; //flip y-axis
|
||||
}
|
||||
public Color borderLining(String c){
|
||||
|
||||
public Color borderLining(String c) {
|
||||
if (c == null || c == "")
|
||||
return Color.valueOf("#fffffd");
|
||||
int c_r = Integer.parseInt(c.substring(0,2),16);
|
||||
int c_g = Integer.parseInt(c.substring(2,4),16);
|
||||
int c_b = Integer.parseInt(c.substring(4,6),16);
|
||||
int c_r = Integer.parseInt(c.substring(0, 2), 16);
|
||||
int c_g = Integer.parseInt(c.substring(2, 4), 16);
|
||||
int c_b = Integer.parseInt(c.substring(4, 6), 16);
|
||||
int brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000;
|
||||
return brightness > 155 ? Color.valueOf("#171717") : Color.valueOf("#fffffd");
|
||||
return brightness > 155 ? Color.valueOf("#171717") : Color.valueOf("#fffffd");
|
||||
}
|
||||
|
||||
public Texture getDummyTexture(){
|
||||
if (dummyTexture == null){
|
||||
public Texture getDummyTexture() {
|
||||
if (dummyTexture == null) {
|
||||
Pixmap P = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
|
||||
P.setColor(1f,1f,1f,1f);
|
||||
P.setColor(1f, 1f, 1f, 1f);
|
||||
P.drawPixel(0, 0);
|
||||
dummyTexture = new Texture(P);
|
||||
P.dispose();
|
||||
|
||||
@@ -25,9 +25,9 @@ public class Shaders {
|
||||
+ " gl_Position = u_projTrans * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n"
|
||||
+ "}\n";
|
||||
/*
|
||||
* Test Pixelate shader
|
||||
*
|
||||
**/
|
||||
* Test Pixelate shader
|
||||
*
|
||||
**/
|
||||
public static final String vertPixelateShader = "attribute vec4 a_position;\n" +
|
||||
"attribute vec4 a_color;\n" +
|
||||
"attribute vec2 a_texCoord0;\n" +
|
||||
@@ -42,7 +42,31 @@ public class Shaders {
|
||||
" v_texCoords = a_texCoord0;\n" +
|
||||
" gl_Position = u_projTrans * a_position;\n" +
|
||||
"}";
|
||||
public static final String fragRipple="#ifdef GL_ES\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" +
|
||||
"#else\n" +
|
||||
@@ -74,7 +98,7 @@ public class Shaders {
|
||||
"\t\tcolor = texture2D(u_texture, coord);\n" +
|
||||
"\tgl_FragColor = mix(vec4(0.0, 0.0, 0.0, 1.0), vec4(color.rgba * dist), u_bias);\n" +
|
||||
"}";
|
||||
public static final String fragChromaticAbberation="#ifdef GL_ES\n" +
|
||||
public static final String fragChromaticAbberation = "#ifdef GL_ES\n" +
|
||||
"#define LOWP lowp\n" +
|
||||
"precision mediump float;\n" +
|
||||
"#else\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 =
|
||||
|
||||
@@ -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,16 +25,14 @@ 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;
|
||||
private final TextraButton startButton;
|
||||
|
||||
public static ArenaScene instance() {
|
||||
if(object==null)
|
||||
object=new ArenaScene();
|
||||
if (object == null)
|
||||
object = new ArenaScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -46,7 +40,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
private final TextraLabel goldLabel;
|
||||
|
||||
private final Group arenaPlane;
|
||||
private final Random rand=new Random();
|
||||
private final Random rand = new Random();
|
||||
|
||||
final Sprite fighterSpot;
|
||||
final Sprite lostOverlay;
|
||||
@@ -58,49 +52,45 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
final Sprite edgeM;
|
||||
final Sprite edgeWin;
|
||||
final Sprite edgeWinM;
|
||||
boolean arenaStarted=false;
|
||||
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");
|
||||
up = atlas.createSprite("Up");
|
||||
upWin = atlas.createSprite("UpWin");
|
||||
side = atlas.createSprite("Side");
|
||||
sideWin = atlas.createSprite("SideWin");
|
||||
edge = atlas.createSprite("Edge");
|
||||
edgeM = atlas.createSprite("Edge");
|
||||
edgeM.setFlip(true, false);
|
||||
edgeWin = atlas.createSprite("EdgeWin");
|
||||
edgeWinM = atlas.createSprite("EdgeWin");
|
||||
edgeWinM.setFlip(true, false);
|
||||
gridSize = fighterSpot.getRegionWidth();
|
||||
|
||||
|
||||
|
||||
TextureAtlas atlas=Config.instance().getAtlas(Paths.ARENA_ATLAS);
|
||||
fighterSpot=atlas.createSprite("Spot");
|
||||
lostOverlay=atlas.createSprite("Lost");
|
||||
up=atlas.createSprite("Up");
|
||||
upWin=atlas.createSprite("UpWin");
|
||||
side=atlas.createSprite("Side");
|
||||
sideWin=atlas.createSprite("SideWin");
|
||||
edge=atlas.createSprite("Edge");
|
||||
edgeM=atlas.createSprite("Edge");
|
||||
edgeM.setFlip(true,false);
|
||||
edgeWin=atlas.createSprite("EdgeWin");
|
||||
edgeWinM=atlas.createSprite("EdgeWin");
|
||||
edgeWinM.setFlip(true,false);
|
||||
gridSize=fighterSpot.getRegionWidth();
|
||||
|
||||
goldLabel=ui.findActor("gold");
|
||||
goldLabel = ui.findActor("gold");
|
||||
ui.onButtonPress("done", () -> {
|
||||
if(!arenaStarted)
|
||||
if (!arenaStarted)
|
||||
ArenaScene.this.done();
|
||||
else
|
||||
showAreYouSure();
|
||||
});
|
||||
ui.onButtonPress("start", () -> startButton());
|
||||
doneButton = ui.findActor("done");
|
||||
ScrollPane pane= ui.findActor("arena");
|
||||
arenaPlane=new Table();
|
||||
ScrollPane pane = ui.findActor("arena");
|
||||
arenaPlane = new Table();
|
||||
pane.setActor(arenaPlane);
|
||||
|
||||
startButton=ui.findActor("start");
|
||||
|
||||
startButton = ui.findActor("start");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void showAreYouSure() {
|
||||
|
||||
Dialog areYouSureDialog= prepareDialog(Forge.getLocalizer().getMessage("lblConcedeTitle"),ButtonYes|ButtonNo,()->loose());
|
||||
Dialog areYouSureDialog = prepareDialog(Forge.getLocalizer().getMessage("lblConcedeTitle"), ButtonYes | ButtonNo, () -> loose());
|
||||
areYouSureDialog.text(Forge.getLocalizer().getMessage("lblConcedeCurrentGame"));
|
||||
showDialog(areYouSureDialog);
|
||||
}
|
||||
@@ -109,26 +99,24 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
doneButton.layout();
|
||||
startButton.setDisabled(true);
|
||||
arenaStarted=false;
|
||||
arenaStarted = false;
|
||||
}
|
||||
|
||||
private void startButton() {
|
||||
if(roundsWon ==0)
|
||||
{
|
||||
Dialog startDialog = prepareDialog(Forge.getLocalizer().getMessage("lblStart"), ButtonYes|ButtonNo,()->startArena());
|
||||
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;
|
||||
int roundsWon = 0;
|
||||
|
||||
private void startArena() {
|
||||
goldLabel.setVisible(false);
|
||||
arenaStarted=true;
|
||||
arenaStarted = true;
|
||||
startButton.setText(Forge.getLocalizer().getMessage("lblContinue"));
|
||||
startButton.layout();
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblConcede"));
|
||||
@@ -137,48 +125,41 @@ 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)
|
||||
{
|
||||
boolean leftWon=rand.nextBoolean();
|
||||
if(leftWon)
|
||||
{
|
||||
winners.add(fighters.get(i));
|
||||
winnersEnemies.add(enemies.get(i));
|
||||
moveFighter(fighters.get(i),true);
|
||||
markLostFighter(fighters.get(i+1));
|
||||
}
|
||||
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)
|
||||
{
|
||||
markLostFighter(fighters.get(fighters.size-2));
|
||||
moveFighter(fighters.get(fighters.size-1),false);
|
||||
winners.add(fighters.get(fighters.size-1));
|
||||
roundsWon++;
|
||||
Array<Actor> winners = new Array<>();
|
||||
Array<EnemySprite> winnersEnemies = new Array<>();
|
||||
for (int i = 0; i < fighters.size - 2; i += 2) {
|
||||
boolean leftWon = rand.nextBoolean();
|
||||
if (leftWon) {
|
||||
winners.add(fighters.get(i));
|
||||
winnersEnemies.add(enemies.get(i));
|
||||
moveFighter(fighters.get(i), true);
|
||||
markLostFighter(fighters.get(i + 1));
|
||||
} else {
|
||||
markLostFighter(fighters.get(i));
|
||||
moveFighter(fighters.get(i + 1), false);
|
||||
winners.add(fighters.get(i + 1));
|
||||
winnersEnemies.add(enemies.get(i + 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
markLostFighter(fighters.get(fighters.size-1));
|
||||
moveFighter(fighters.get(fighters.size-2),true);
|
||||
winners.add(fighters.get(fighters.size-2));
|
||||
if (winner) {
|
||||
markLostFighter(fighters.get(fighters.size - 2));
|
||||
moveFighter(fighters.get(fighters.size - 1), false);
|
||||
winners.add(fighters.get(fighters.size - 1));
|
||||
roundsWon++;
|
||||
} else {
|
||||
markLostFighter(fighters.get(fighters.size - 1));
|
||||
moveFighter(fighters.get(fighters.size - 2), true);
|
||||
winners.add(fighters.get(fighters.size - 2));
|
||||
loose();
|
||||
}
|
||||
|
||||
fighters=winners;
|
||||
enemies=winnersEnemies;
|
||||
if(roundsWon >=arenaData.rounds )
|
||||
{
|
||||
arenaStarted=false;
|
||||
fighters = winners;
|
||||
enemies = winnersEnemies;
|
||||
if (roundsWon >= arenaData.rounds) {
|
||||
arenaStarted = false;
|
||||
startButton.setDisabled(true);
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
||||
doneButton.layout();
|
||||
@@ -186,49 +167,44 @@ 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);
|
||||
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);
|
||||
if (i == 0)
|
||||
leftImg = new Image(leftPlayer ? edgeWin : edgeWinM);
|
||||
else
|
||||
leftImg=new Image(sideWin);
|
||||
leftImg.setPosition(actor.getX()+(i*(leftPlayer?1:-1))*gridSize+widthDiff/2,actor.getY()+gridSize*2+widthDiff/2);
|
||||
leftImg = new Image(sideWin);
|
||||
leftImg.setPosition(actor.getX() + (i * (leftPlayer ? 1 : -1)) * gridSize + widthDiff / 2, actor.getY() + gridSize * 2 + widthDiff / 2);
|
||||
arenaPlane.addActor(leftImg);
|
||||
}
|
||||
|
||||
|
||||
actor.moveBy((float) (gridSize*stepsToTheSide*(leftPlayer?1:-1)),gridSize*2f);
|
||||
actor.moveBy((float) (gridSize * stepsToTheSide * (leftPlayer ? 1 : -1)), gridSize * 2f);
|
||||
}
|
||||
|
||||
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);
|
||||
Image lost = new Image(lostOverlay);
|
||||
float widthDiff = fighter.getWidth() - lost.getWidth();
|
||||
lost.setPosition(fighter.getX() + widthDiff / 2, fighter.getY() + widthDiff / 2);
|
||||
arenaPlane.addActor(lost);
|
||||
}
|
||||
|
||||
private void startRound() {
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
EnemySprite enemy = enemies.get(enemies.size-1);
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
EnemySprite enemy = enemies.get(enemies.size - 1);
|
||||
FThreads.invokeInEdtNowOrLater(() -> {
|
||||
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,14 +212,11 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
public boolean done() {
|
||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||
Forge.switchToLast();
|
||||
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++)
|
||||
{
|
||||
data.addAll(arenaData.rewards[i][j].generate(false, null ));
|
||||
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++) {
|
||||
data.addAll(arenaData.rewards[i][j].generate(false, null));
|
||||
}
|
||||
}
|
||||
RewardScene.instance().loadRewards(data, RewardScene.Type.Loot, null);
|
||||
@@ -251,96 +224,84 @@ 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;
|
||||
|
||||
public void loadArenaData(ArenaData data,long seed) {
|
||||
public void loadArenaData(ArenaData data, long seed) {
|
||||
startButton.setText(Forge.getLocalizer().getMessage("lblStart"));
|
||||
startButton.layout();
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
||||
doneButton.layout();
|
||||
arenaData=data;
|
||||
arenaData = data;
|
||||
//rand.setSeed(seed); allow to reshuffle arena enemies for now
|
||||
|
||||
enemies.clear();
|
||||
fighters.clear();
|
||||
arenaPlane.clear();
|
||||
roundsWon =0;
|
||||
int numberOfEnemies= (int) (Math.pow(2f, data.rounds)-1);
|
||||
roundsWon = 0;
|
||||
int numberOfEnemies = (int) (Math.pow(2f, data.rounds) - 1);
|
||||
|
||||
|
||||
for(int i=0;i<numberOfEnemies;i++)
|
||||
{
|
||||
EnemySprite enemy=new EnemySprite(WorldData.getEnemy(data.enemyPool[rand.nextInt(data.enemyPool.length)]));
|
||||
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()));
|
||||
}
|
||||
fighters.add(new Image(Current.player().avatar()));
|
||||
player=fighters.get(fighters.size-1);
|
||||
player = fighters.get(fighters.size - 1);
|
||||
|
||||
|
||||
goldLabel.setText(data.entryFee +" [+Gold]");
|
||||
goldLabel.setText(data.entryFee + " [+Gold]");
|
||||
goldLabel.layout();
|
||||
goldLabel.setVisible(true);
|
||||
|
||||
startButton.setDisabled(data.entryFee>Current.player().getGold());
|
||||
int currentSpots=numberOfEnemies+1;
|
||||
int gridWidth=currentSpots*2;
|
||||
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)
|
||||
{
|
||||
float widthDiff=gridSize-fighters.get(fighterIndex).getWidth();
|
||||
fighters.get(fighterIndex).setPosition(x*gridSize+widthDiff/2,y*gridSize*2+widthDiff/2);
|
||||
startButton.setDisabled(data.entryFee > Current.player().getGold());
|
||||
int currentSpots = numberOfEnemies + 1;
|
||||
int gridWidth = currentSpots * 2;
|
||||
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) {
|
||||
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));
|
||||
fighterIndex++;
|
||||
}
|
||||
}
|
||||
Image spotImg=new Image(fighterSpot);
|
||||
spotImg.setPosition(x*gridSize,y*gridSize*2);
|
||||
Image spotImg = new Image(fighterSpot);
|
||||
spotImg.setPosition(x * gridSize, y * gridSize * 2);
|
||||
arenaPlane.addActor(spotImg);
|
||||
|
||||
if(y!=gridHeight-1)
|
||||
{
|
||||
Image upImg=new Image(up);
|
||||
upImg.setPosition(x*gridSize,y*gridSize*2+gridSize);
|
||||
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)
|
||||
{
|
||||
leftImg=new Image(edge);
|
||||
rightImg=new Image(edgeM);
|
||||
if (i == Math.pow(2, (y - 1)) - 1) {
|
||||
leftImg = new Image(edge);
|
||||
rightImg = new Image(edgeM);
|
||||
} else {
|
||||
leftImg = new Image(side);
|
||||
rightImg = new Image(side);
|
||||
}
|
||||
else
|
||||
{
|
||||
leftImg=new Image(side);
|
||||
rightImg=new Image(side);
|
||||
}
|
||||
leftImg.setPosition((x-(i+1))*gridSize,y*gridSize*2);
|
||||
rightImg.setPosition((x+(i+1))*gridSize,y*gridSize*2);
|
||||
leftImg.setPosition((x - (i + 1)) * gridSize, y * gridSize * 2);
|
||||
rightImg.setPosition((x + (i + 1)) * gridSize, y * gridSize * 2);
|
||||
arenaPlane.addActor(leftImg);
|
||||
arenaPlane.addActor(rightImg);
|
||||
}
|
||||
@@ -349,5 +310,4 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,10 +51,11 @@ public class DuelScene extends ForgeScene {
|
||||
private static DuelScene object;
|
||||
|
||||
public static DuelScene instance() {
|
||||
if(object==null)
|
||||
object=new DuelScene();
|
||||
if (object == null)
|
||||
object = new DuelScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
//GameLobby lobby;
|
||||
HostedMatch hostedMatch;
|
||||
EnemySprite enemy;
|
||||
@@ -85,7 +86,7 @@ public class DuelScene extends ForgeScene {
|
||||
String enemyName = (enemy.nameOverride.isEmpty() ? enemy.getData().name : enemy.nameOverride);
|
||||
boolean showMessages = enemy.getData().copyPlayerDeck && Current.player().isUsingCustomDeck();
|
||||
Current.player().clearBlessing();
|
||||
if ((chaosBattle||showMessages) && !winner) {
|
||||
if ((chaosBattle || showMessages) && !winner) {
|
||||
callbackExit = true;
|
||||
List<String> insult = Lists.newArrayList("I'm sorry...", "... ....", "Learn from your defeat.",
|
||||
"I haven't begun to use my full power.", "No matter how much you try, you still won't beat me.",
|
||||
@@ -244,7 +245,7 @@ public class DuelScene extends ForgeScene {
|
||||
this.AIExtras = aiCards;
|
||||
deck = deckProxy.getDeck();
|
||||
} else {
|
||||
deck = currentEnemy.copyPlayerDeck ? this.playerDeck : currentEnemy.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck()||Current.player().getDifficulty().name.equalsIgnoreCase("Hard"));
|
||||
deck = currentEnemy.copyPlayerDeck ? this.playerDeck : currentEnemy.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().getDifficulty().name.equalsIgnoreCase("Hard"));
|
||||
}
|
||||
RegisteredPlayer aiPlayer = RegisteredPlayer.forVariants(playerCount, appliedVariants, deck, null, false, null, null);
|
||||
|
||||
@@ -300,7 +301,7 @@ public class DuelScene extends ForgeScene {
|
||||
hostedMatch.startMatch(rules, appliedVariants, players, guiMap);
|
||||
MatchController.instance.setGameView(hostedMatch.getGameView());
|
||||
boolean showMessages = enemy.getData().copyPlayerDeck && Current.player().isUsingCustomDeck();
|
||||
if (chaosBattle||showMessages) {
|
||||
if (chaosBattle || showMessages) {
|
||||
List<String> list = Lists.newArrayList("It all depends on your skill!", "It's showtime!", "Let's party!",
|
||||
"You've proved yourself!", "Are you ready? Go!", "Prepare to strike, now!", "Let's go!", "What's next?",
|
||||
"Yeah, I've been waitin' for this!", "The stage of battle is set!", "And the battle begins!", "Let's get started!",
|
||||
|
||||
@@ -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;
|
||||
@@ -27,8 +26,8 @@ public class GameScene extends HudScene {
|
||||
private static GameScene object;
|
||||
|
||||
public static GameScene instance() {
|
||||
if(object==null)
|
||||
object=new GameScene();
|
||||
if (object == null)
|
||||
object = new GameScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -58,18 +57,18 @@ 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;
|
||||
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();
|
||||
World world = Current.world();
|
||||
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;
|
||||
location = forHeader ? TextUtil.capitalize(data.name) + " Map" : data.name;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
location = forHeader ? "Waste Map" : "waste";
|
||||
|
||||
@@ -56,7 +56,7 @@ public class MapStage extends GameStage {
|
||||
final Array<MapActor> actors = new Array<>();
|
||||
|
||||
TiledMap map;
|
||||
Array<Rectangle> collisionRect=new Array<>();
|
||||
Array<Rectangle> collisionRect = new Array<>();
|
||||
private boolean isInMap = false;
|
||||
MapLayer spriteLayer;
|
||||
private PointOfInterestChanges changes;
|
||||
@@ -76,9 +76,9 @@ public class MapStage extends GameStage {
|
||||
//These maps are defined as embedded properties within the Tiled maps.
|
||||
private EffectData effect; //"Dungeon Effect": Character Effect applied to all adversaries within the map.
|
||||
private boolean preventEscape = false; //Prevents player from escaping the dungeon by any means that aren't an exit.
|
||||
private final Array< TextraButton> dialogButtonMap=new Array<>();
|
||||
private final Array<TextraButton> dialogButtonMap = new Array<>();
|
||||
|
||||
public InputEvent eventTouchDown, eventTouchUp;
|
||||
public InputEvent eventTouchDown, eventTouchUp;
|
||||
TextraButton selectedKey;
|
||||
private boolean respawnEnemies;
|
||||
|
||||
@@ -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,9 +246,10 @@ public class MapStage extends GameStage {
|
||||
setDialogStage(GameHUD.getInstance());
|
||||
showDialog();
|
||||
}
|
||||
Array<EntryActor> otherEntries=new Array<>();
|
||||
Array<EntryActor> spawnClassified=new Array<>();
|
||||
Array<EntryActor> sourceMapMatch=new Array<>();
|
||||
|
||||
Array<EntryActor> otherEntries = new Array<>();
|
||||
Array<EntryActor> spawnClassified = new Array<>();
|
||||
Array<EntryActor> sourceMapMatch = new Array<>();
|
||||
|
||||
public void loadMap(TiledMap map, String sourceMap) {
|
||||
isLoadingMatch = false;
|
||||
@@ -263,9 +264,9 @@ public class MapStage extends GameStage {
|
||||
actors.clear();
|
||||
collisionRect.clear();
|
||||
|
||||
if(collisionGroup!=null)
|
||||
if (collisionGroup != null)
|
||||
collisionGroup.remove();
|
||||
collisionGroup=null;
|
||||
collisionGroup = null;
|
||||
|
||||
float width = Float.parseFloat(map.getProperties().get("width").toString());
|
||||
float height = Float.parseFloat(map.getProperties().get("height").toString());
|
||||
@@ -281,13 +282,10 @@ 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"))
|
||||
{
|
||||
respawnEnemies=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
respawnEnemies=false;
|
||||
if (MP.get("respawnEnemies") != null && MP.get("respawnEnemies") instanceof Boolean && (Boolean) MP.get("respawnEnemies")) {
|
||||
respawnEnemies = true;
|
||||
} else {
|
||||
respawnEnemies = false;
|
||||
}
|
||||
if (MP.get("preventEscape") != null) preventEscape = (boolean) MP.get("preventEscape");
|
||||
|
||||
@@ -310,34 +308,31 @@ public class MapStage extends GameStage {
|
||||
loadObjects(layer, sourceMap);
|
||||
}
|
||||
}
|
||||
if(!spawnClassified.isEmpty())
|
||||
if (!spawnClassified.isEmpty())
|
||||
spawnClassified.first().spawn();
|
||||
else if(!sourceMapMatch.isEmpty())
|
||||
else if (!sourceMapMatch.isEmpty())
|
||||
sourceMapMatch.first().spawn();
|
||||
else if(!otherEntries.isEmpty())
|
||||
else if (!otherEntries.isEmpty())
|
||||
otherEntries.first().spawn();
|
||||
|
||||
//reduce geometry in collision rectangles
|
||||
int oldSize;
|
||||
do {
|
||||
oldSize=collisionRect.size;
|
||||
for(int i=0;i<collisionRect.size;i++)
|
||||
{
|
||||
Rectangle r1= collisionRect.get(i);
|
||||
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
|
||||
oldSize = collisionRect.size;
|
||||
for (int i = 0; i < collisionRect.size; i++) {
|
||||
Rectangle r1 = collisionRect.get(i);
|
||||
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
|
||||
|
||||
||(Math.abs((r1.x+r1.width)-r2.x)<1&&Math.abs(r1.y-r2.y)<1&&Math.abs(r1.height-r2.height)<1)//right edge is the same as left edge
|
||||
|| (Math.abs((r1.x + r1.width) - r2.x) < 1 && Math.abs(r1.y - r2.y) < 1 && Math.abs(r1.height - r2.height) < 1)//right edge is the same as left edge
|
||||
|
||||
||(Math.abs(r1.x - r2.x )<1&& Math.abs((r1.y+r1.height)-r2.y)<1&&Math.abs(r1.width-r2.width)<1)//top edge is the same as bottom edge
|
||||
|| (Math.abs(r1.x - r2.x) < 1 && Math.abs((r1.y + r1.height) - r2.y) < 1 && Math.abs(r1.width - r2.width) < 1)//top edge is the same as bottom edge
|
||||
|
||||
||(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
|
||||
|| (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)
|
||||
)
|
||||
{
|
||||
|| containsOrEquals(r1, r2) || containsOrEquals(r2, r1)
|
||||
) {
|
||||
r1.merge(r2);
|
||||
collisionRect.removeIndex(j);
|
||||
i--;
|
||||
@@ -345,19 +340,20 @@ public class MapStage extends GameStage {
|
||||
}
|
||||
}
|
||||
}
|
||||
}while (oldSize!=collisionRect.size);
|
||||
} while (oldSize != collisionRect.size);
|
||||
if (spriteLayer == null) System.err.print("Warning: No spriteLayer present in map.\n");
|
||||
|
||||
getPlayerSprite().stop();
|
||||
}
|
||||
|
||||
static public boolean containsOrEquals(Rectangle r1,Rectangle r2) {
|
||||
static public boolean containsOrEquals(Rectangle r1, Rectangle r2) {
|
||||
float xmi = r2.x;
|
||||
float xma = xmi + r2.width;
|
||||
float ymi = r2.y;
|
||||
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++) {
|
||||
@@ -390,7 +386,7 @@ public class MapStage extends GameStage {
|
||||
for (MapObject obj : layer.getObjects()) {
|
||||
MapProperties prop = obj.getProperties();
|
||||
String type = prop.get("type", String.class);
|
||||
if (type!=null) {
|
||||
if (type != null) {
|
||||
int id = prop.get("id", int.class);
|
||||
if (changes.isObjectDeleted(id))
|
||||
continue;
|
||||
@@ -403,20 +399,16 @@ public class MapStage extends GameStage {
|
||||
float w = Float.parseFloat(prop.get("width").toString());
|
||||
float h = Float.parseFloat(prop.get("height").toString());
|
||||
|
||||
String targetMap=prop.get("teleport").toString();
|
||||
boolean spawnPlayerThere=(targetMap==null||targetMap.isEmpty()&&sourceMap.isEmpty())||//if target is null and "from world"
|
||||
!sourceMap.isEmpty()&&targetMap.equals(sourceMap);
|
||||
String targetMap = prop.get("teleport").toString();
|
||||
boolean spawnPlayerThere = (targetMap == null || targetMap.isEmpty() && sourceMap.isEmpty()) ||//if target is null and "from world"
|
||||
!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)
|
||||
{
|
||||
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) {
|
||||
spawnClassified.add(entry);
|
||||
}else if(spawnPlayerThere)
|
||||
{
|
||||
} else if (spawnPlayerThere) {
|
||||
sourceMapMatch.add(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
otherEntries.add(entry);
|
||||
}
|
||||
addMapActor(obj, entry);
|
||||
@@ -484,11 +476,10 @@ 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());
|
||||
Forge.switchScene(ArenaScene.instance());
|
||||
ArenaScene.instance().loadArenaData(arenaData, WorldSave.getCurrentSave().getWorld().getRandom().nextLong());
|
||||
Forge.switchScene(ArenaScene.instance());
|
||||
}));
|
||||
break;
|
||||
case "exit":
|
||||
@@ -498,10 +489,10 @@ public class MapStage extends GameStage {
|
||||
if (obj instanceof TiledMapTileMapObject) {
|
||||
TiledMapTileMapObject tiledObj = (TiledMapTileMapObject) obj;
|
||||
DialogActor dialog;
|
||||
if(prop.containsKey("sprite"))
|
||||
dialog= new DialogActor(this, id, prop.get("dialog").toString(), prop.get("sprite").toString());
|
||||
if (prop.containsKey("sprite"))
|
||||
dialog = new DialogActor(this, id, prop.get("dialog").toString(), prop.get("sprite").toString());
|
||||
else
|
||||
dialog= new DialogActor(this, id, prop.get("dialog").toString(), tiledObj.getTextureRegion());
|
||||
dialog = new DialogActor(this, id, prop.get("dialog").toString(), tiledObj.getTextureRegion());
|
||||
addMapActor(obj, dialog);
|
||||
}
|
||||
break;
|
||||
@@ -611,12 +602,12 @@ public class MapStage extends GameStage {
|
||||
|
||||
protected void getReward() {
|
||||
isLoadingMatch = false;
|
||||
RewardScene.instance().loadRewards(currentMob.getRewards(), RewardScene.Type.Loot, null);
|
||||
RewardScene.instance().loadRewards(currentMob.getRewards(), RewardScene.Type.Loot, null);
|
||||
Forge.switchScene(RewardScene.instance());
|
||||
if (currentMob.defeatDialog == null) {
|
||||
currentMob.remove();
|
||||
actors.removeValue(currentMob, true);
|
||||
if(!respawnEnemies||currentMob.getData().boss)
|
||||
if (!respawnEnemies || currentMob.getData().boss)
|
||||
changes.deleteObject(currentMob.getId());
|
||||
} else {
|
||||
currentMob.defeatDialog.activate();
|
||||
@@ -638,8 +629,8 @@ public class MapStage extends GameStage {
|
||||
|
||||
@Override
|
||||
protected void onActing(float delta) {
|
||||
float sprintingMod=currentModifications.containsKey(PlayerModification.Sprint)?2:1;
|
||||
player.setMoveModifier(2*sprintingMod);
|
||||
float sprintingMod = currentModifications.containsKey(PlayerModification.Sprint) ? 2 : 1;
|
||||
player.setMoveModifier(2 * sprintingMod);
|
||||
oldPosition4.set(oldPosition3);
|
||||
oldPosition3.set(oldPosition2);
|
||||
oldPosition2.set(oldPosition);
|
||||
@@ -659,10 +650,10 @@ public class MapStage extends GameStage {
|
||||
} else if (actor instanceof RewardSprite) {
|
||||
Gdx.input.vibrate(50);
|
||||
if (Controllers.getCurrent() != null && Controllers.getCurrent().canVibrate())
|
||||
Controllers.getCurrent().startVibration(100,1);
|
||||
Controllers.getCurrent().startVibration(100, 1);
|
||||
startPause(0.1f, () -> { //Switch to item pickup scene.
|
||||
RewardSprite RS = (RewardSprite) actor;
|
||||
RewardScene.instance().loadRewards(RS.getRewards(), RewardScene.Type.Loot, null);
|
||||
RewardScene.instance().loadRewards(RS.getRewards(), RewardScene.Type.Loot, null);
|
||||
RS.remove();
|
||||
actors.removeValue(RS, true);
|
||||
changes.deleteObject(RS.getId());
|
||||
@@ -683,11 +674,11 @@ public class MapStage extends GameStage {
|
||||
Gdx.input.vibrate(50);
|
||||
int duration = mob.getData().boss ? 400 : 200;
|
||||
if (Controllers.getCurrent() != null && Controllers.getCurrent().canVibrate())
|
||||
Controllers.getCurrent().startVibration(duration,1);
|
||||
Controllers.getCurrent().startVibration(duration, 1);
|
||||
startPause(0.8f, () -> {
|
||||
Forge.setCursor(null, Forge.magnifyToggle ? "1" : "2");
|
||||
SoundSystem.instance.play(SoundEffectType.ManaBurn, false);
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
FThreads.invokeInEdtNowOrLater(() -> {
|
||||
if (!isLoadingMatch) {
|
||||
isLoadingMatch = true;
|
||||
@@ -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;
|
||||
}
|
||||
@@ -717,12 +709,12 @@ public class MapStage extends GameStage {
|
||||
|
||||
dialogButtonMap.clear();
|
||||
for (int i = 0; i < dialog.getButtonTable().getCells().size; i++) {
|
||||
dialogButtonMap.add( (TextraButton) dialog.getButtonTable().getCells().get(i).getActor());
|
||||
dialogButtonMap.add((TextraButton) dialog.getButtonTable().getCells().get(i).getActor());
|
||||
}
|
||||
dialog.show(dialogStage, Actions.show());
|
||||
dialog.setPosition((dialogStage.getWidth() - dialog.getWidth()) / 2, (dialogStage.getHeight() - dialog.getHeight()) / 2);
|
||||
dialogOnlyInput = true;
|
||||
if (Forge.hasGamepad()&&!dialogButtonMap.isEmpty())
|
||||
if (Forge.hasGamepad() && !dialogButtonMap.isEmpty())
|
||||
dialogStage.setKeyboardFocus(dialogButtonMap.first());
|
||||
}
|
||||
|
||||
@@ -792,40 +784,36 @@ 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))
|
||||
{
|
||||
i+=1;
|
||||
i%=dialogButtonMap.size;
|
||||
for (int i = 0; i < dialogButtonMap.size; i++) {
|
||||
if (dialogStage.getKeyboardFocus() == dialogButtonMap.get(i)) {
|
||||
i += 1;
|
||||
i %= dialogButtonMap.size;
|
||||
dialogStage.setKeyboardFocus(dialogButtonMap.get(i));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
i-=1;
|
||||
if(i<0)
|
||||
i=dialogButtonMap.size-1;
|
||||
for (int i = 0; i < dialogButtonMap.size; i++) {
|
||||
if (dialogStage.getKeyboardFocus() == dialogButtonMap.get(i)) {
|
||||
i -= 1;
|
||||
if (i < 0)
|
||||
i = dialogButtonMap.size - 1;
|
||||
dialogStage.setKeyboardFocus(dialogButtonMap.get(i));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,8 +40,7 @@ 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;
|
||||
private static WorldStage instance = null;
|
||||
protected EnemySprite currentMob;
|
||||
protected Random rand = MyRandom.getRandom();
|
||||
WorldBackground background;
|
||||
@@ -49,8 +48,8 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
private static final float spawnInterval = 4;//todo config
|
||||
private PointOfInterestMapSprite collidingPoint;
|
||||
protected ArrayList<Pair<Float, EnemySprite>> enemies = new ArrayList<>();
|
||||
private final static Float dieTimer=20f;//todo config
|
||||
private Float globalTimer=0f;
|
||||
private final static Float dieTimer = 20f;//todo config
|
||||
private Float globalTimer = 0f;
|
||||
|
||||
public WorldStage() {
|
||||
super();
|
||||
@@ -63,57 +62,50 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
return instance == null ? instance = new WorldStage() : instance;
|
||||
}
|
||||
|
||||
final Rectangle tempBoundingRect = new Rectangle();
|
||||
final Vector2 enemyMoveVector = new Vector2();
|
||||
|
||||
final Rectangle tempBoundingRect=new Rectangle();
|
||||
final Vector2 enemyMoveVector =new Vector2();
|
||||
@Override
|
||||
protected void onActing(float delta) {
|
||||
if (player.isMoving()) {
|
||||
handleMonsterSpawn(delta);
|
||||
handlePointsOfInterestCollision();
|
||||
globalTimer+=delta;
|
||||
globalTimer += delta;
|
||||
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
|
||||
while (it.hasNext()) {
|
||||
Pair<Float, EnemySprite> pair= it.next();
|
||||
if(globalTimer>=pair.getKey()+dieTimer)
|
||||
{
|
||||
Pair<Float, EnemySprite> pair = it.next();
|
||||
if (globalTimer >= pair.getKey() + dieTimer) {
|
||||
|
||||
foregroundSprites.removeActor(pair.getValue());
|
||||
it.remove();
|
||||
continue;
|
||||
}
|
||||
EnemySprite mob=pair.getValue();
|
||||
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());
|
||||
enemyMoveVector.setLength(mob.speed() * delta);
|
||||
tempBoundingRect.set(mob.getX() + enemyMoveVector.x, mob.getY() + enemyMoveVector.y, mob.getWidth(), mob.getHeight() * mob.getCollisionHeight());
|
||||
|
||||
if(!mob.getData().flying && WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if direct path is not possible
|
||||
if (!mob.getData().flying && WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if direct path is not possible
|
||||
{
|
||||
tempBoundingRect.set(mob.getX()+ enemyMoveVector.x,mob.getY(),mob.getWidth(),mob.getHeight());
|
||||
if(WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if only x path is not possible
|
||||
tempBoundingRect.set(mob.getX() + enemyMoveVector.x, mob.getY(), mob.getWidth(), mob.getHeight());
|
||||
if (WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if only x path is not possible
|
||||
{
|
||||
tempBoundingRect.set(mob.getX(),mob.getY()+ enemyMoveVector.y,mob.getWidth(),mob.getHeight());
|
||||
if(!WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if y path is possible
|
||||
tempBoundingRect.set(mob.getX(), mob.getY() + enemyMoveVector.y, mob.getWidth(), mob.getHeight());
|
||||
if (!WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if y path is possible
|
||||
{
|
||||
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);
|
||||
@@ -121,16 +113,16 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
Gdx.input.vibrate(50);
|
||||
int duration = mob.getData().boss ? 400 : 200;
|
||||
if (Controllers.getCurrent() != null && Controllers.getCurrent().canVibrate())
|
||||
Controllers.getCurrent().startVibration(duration,1);
|
||||
Controllers.getCurrent().startVibration(duration, 1);
|
||||
startPause(0.8f, () -> {
|
||||
Forge.setCursor(null, Forge.magnifyToggle ? "1" : "2");
|
||||
SoundSystem.instance.play(SoundEffectType.ManaBurn, false);
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
FThreads.invokeInEdtNowOrLater(() -> {
|
||||
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,29 +130,27 @@ 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()) {
|
||||
Pair<Float, EnemySprite> pair = it.next();
|
||||
if (pair.getValue()==currentMob) {
|
||||
if (pair.getValue() == currentMob) {
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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() {
|
||||
|
||||
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)
|
||||
{
|
||||
if(currentModifications.containsKey(PlayerModification.Fly))
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -219,23 +206,23 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
World world = WorldSave.getCurrentSave().getWorld();
|
||||
int currentBiome = World.highestBiome(world.getBiome((int) player.getX() / world.getTileSize(), (int) player.getY() / world.getTileSize()));
|
||||
List<BiomeData> biomeData = WorldSave.getCurrentSave().getWorld().getData().GetBiomes();
|
||||
float sprintingMod=currentModifications.containsKey(PlayerModification.Sprint)?2:1;
|
||||
float sprintingMod = currentModifications.containsKey(PlayerModification.Sprint) ? 2 : 1;
|
||||
if (biomeData.size() <= currentBiome) {// "if isOnRoad
|
||||
player.setMoveModifier(1.5f*sprintingMod);
|
||||
player.setMoveModifier(1.5f * sprintingMod);
|
||||
return;
|
||||
}
|
||||
player.setMoveModifier(1.0f*sprintingMod);
|
||||
player.setMoveModifier(1.0f * sprintingMod);
|
||||
BiomeData data = biomeData.get(currentBiome);
|
||||
if (data == null) return;
|
||||
|
||||
spawnDelay -= delta;
|
||||
if(spawnDelay>=0) return;
|
||||
spawnDelay=spawnInterval + ( rand.nextFloat() * 4.0f );
|
||||
if (spawnDelay >= 0) return;
|
||||
spawnDelay = spawnInterval + (rand.nextFloat() * 4.0f);
|
||||
|
||||
ArrayList<EnemyData> list = data.getEnemyList();
|
||||
if (list == null)
|
||||
return;
|
||||
EnemyData enemyData = data.getEnemy( 1.0f );
|
||||
EnemyData enemyData = data.getEnemy(1.0f);
|
||||
spawn(enemyData);
|
||||
}
|
||||
|
||||
@@ -245,23 +232,20 @@ 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++)
|
||||
{
|
||||
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()))
|
||||
{
|
||||
enemies.add(Pair.of(globalTimer,sprite));
|
||||
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())) {
|
||||
enemies.add(Pair.of(globalTimer, sprite));
|
||||
foregroundSprites.addActor(sprite);
|
||||
return true;
|
||||
}
|
||||
int g=0;
|
||||
int g = 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -273,13 +257,13 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
//spriteGroup.setCullingArea(new Rectangle(player.getX()-getViewport().getWorldHeight()/2,player.getY()-getViewport().getWorldHeight()/2,getViewport().getWorldHeight(),getViewport().getWorldHeight()));
|
||||
super.draw();
|
||||
if (WorldSave.getCurrentSave().getPlayer().hasAnnounceFantasy()) {
|
||||
MapStage.getInstance().showDeckAwardDialog("{BLINK=WHITE;RED}Chaos Mode!{ENDBLINK}\n"+ WorldSave.getCurrentSave().getPlayer().getName()+ "'s Deck: "+
|
||||
WorldSave.getCurrentSave().getPlayer().getSelectedDeck().getName()+
|
||||
MapStage.getInstance().showDeckAwardDialog("{BLINK=WHITE;RED}Chaos Mode!{ENDBLINK}\n" + WorldSave.getCurrentSave().getPlayer().getName() + "'s Deck: " +
|
||||
WorldSave.getCurrentSave().getPlayer().getSelectedDeck().getName() +
|
||||
"\nEnemy will use Preconstructed or Random Generated Decks. Genetic AI Decks will be available to some enemies on Hard difficulty.", WorldSave.getCurrentSave().getPlayer().getSelectedDeck());
|
||||
WorldSave.getCurrentSave().getPlayer().clearAnnounceFantasy();
|
||||
} else if (WorldSave.getCurrentSave().getPlayer().hasAnnounceCustom()) {
|
||||
MapStage.getInstance().showDeckAwardDialog("{GRADIENT}Custom Deck Mode!{ENDGRADIENT}\n"+ WorldSave.getCurrentSave().getPlayer().getName()+ "'s Deck: "+
|
||||
WorldSave.getCurrentSave().getPlayer().getSelectedDeck().getName()+
|
||||
MapStage.getInstance().showDeckAwardDialog("{GRADIENT}Custom Deck Mode!{ENDGRADIENT}\n" + WorldSave.getCurrentSave().getPlayer().getName() + "'s Deck: " +
|
||||
WorldSave.getCurrentSave().getPlayer().getSelectedDeck().getName() +
|
||||
"\nSome enemies will use Genetic AI Decks randomly.", WorldSave.getCurrentSave().getPlayer().getSelectedDeck());
|
||||
WorldSave.getCurrentSave().getPlayer().clearAnnounceCustom();
|
||||
}
|
||||
@@ -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,12 +280,10 @@ 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);
|
||||
background.loadChunk(pos.x, pos.y);
|
||||
handlePointsOfInterestCollision();
|
||||
}
|
||||
|
||||
@@ -315,57 +296,49 @@ 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++)
|
||||
{
|
||||
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++) {
|
||||
EnemySprite sprite = new EnemySprite(WorldData.getEnemy(names.get(i)));
|
||||
sprite.setX(x.get(i));
|
||||
sprite.setY(y.get(i));
|
||||
enemies.add(Pair.of(timeouts.get(i),sprite));
|
||||
enemies.add(Pair.of(timeouts.get(i), sprite));
|
||||
foregroundSprites.addActor(sprite);
|
||||
}
|
||||
globalTimer=data.readFloat("globalTimer");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
globalTimer = data.readFloat("globalTimer");
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
|
||||
for(Pair<Float, EnemySprite> enemy:enemies)
|
||||
for (Pair<Float, EnemySprite> enemy : enemies)
|
||||
foregroundSprites.removeActor(enemy.getValue());
|
||||
enemies.clear();
|
||||
background.clear();
|
||||
player=null;
|
||||
player = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaveFileData save() {
|
||||
SaveFileData data=new SaveFileData();
|
||||
List<Float> timeouts=new ArrayList<>();
|
||||
List<String> names=new ArrayList<>();
|
||||
List<Float> x=new ArrayList<>();
|
||||
List<Float> y=new ArrayList<>();
|
||||
for(Pair<Float, EnemySprite> enemy:enemies)
|
||||
{
|
||||
SaveFileData data = new SaveFileData();
|
||||
List<Float> timeouts = new ArrayList<>();
|
||||
List<String> names = new ArrayList<>();
|
||||
List<Float> x = new ArrayList<>();
|
||||
List<Float> y = new ArrayList<>();
|
||||
for (Pair<Float, EnemySprite> enemy : enemies) {
|
||||
timeouts.add(enemy.getKey());
|
||||
names.add(enemy.getValue().getData().name);
|
||||
x.add(enemy.getValue().getX());
|
||||
y.add(enemy.getValue().getY());
|
||||
}
|
||||
data.storeObject("timeouts",timeouts);
|
||||
data.storeObject("names",names);
|
||||
data.storeObject("x",x);
|
||||
data.storeObject("y",y);
|
||||
data.store("globalTimer",globalTimer);
|
||||
data.storeObject("timeouts", timeouts);
|
||||
data.storeObject("names", names);
|
||||
data.storeObject("x", x);
|
||||
data.storeObject("y", y);
|
||||
data.store("globalTimer", globalTimer);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -376,23 +349,19 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
|
||||
|
||||
public void removeNearestEnemy() {
|
||||
|
||||
float shortestDist=Float.MAX_VALUE;
|
||||
EnemySprite enemy=null;
|
||||
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)
|
||||
{
|
||||
shortestDist=dist;
|
||||
enemy=pair.getValue();
|
||||
float dist = pair.getValue().pos().sub(player.pos()).len();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,45 +134,59 @@ public class TransitionScreen extends FContainer {
|
||||
g.draw(progressBar);
|
||||
}
|
||||
} else if (matchTransition) {
|
||||
float screenW = Forge.isLandscapeMode() ? Forge.getScreenWidth() : Forge.getScreenHeight();
|
||||
float screenH = Forge.isLandscapeMode() ? Forge.getScreenHeight() : Forge.getScreenWidth();
|
||||
float scale = screenW/4;
|
||||
float centerX = screenW/2;
|
||||
float centerY = screenH/2;
|
||||
TextureRegion enemyAvatar = Config.instance().getAtlas(enemyAtlasPath).createSprite("Avatar");
|
||||
enemyAvatar.flip(true, false);
|
||||
BitmapFont font = Controls.getBitmapFont("default", 5f);
|
||||
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;
|
||||
float centerX = screenW/2;
|
||||
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));
|
||||
g.drawImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
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 {
|
||||
//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 |
Reference in New Issue
Block a user