mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
update Adventure Matchscreen
This commit is contained in:
@@ -350,6 +350,9 @@ public class Forge implements ApplicationListener {
|
|||||||
try {
|
try {
|
||||||
FileHandle transitionFile = Config.instance().getFile("ui/transition.png");
|
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 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())
|
if (transitionFile.exists())
|
||||||
Forge.getAssets().fallback_skins().put(1, new Texture(transitionFile));
|
Forge.getAssets().fallback_skins().put(1, new Texture(transitionFile));
|
||||||
if (titleBGFile.exists())
|
if (titleBGFile.exists())
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Deque;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.*;
|
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.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
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 shaderRipple = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragRipple);
|
||||||
private final ShaderProgram shaderPixelateWarp = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragPixelateShaderWarp);
|
private final ShaderProgram shaderPixelateWarp = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragPixelateShaderWarp);
|
||||||
private final ShaderProgram shaderChromaticAbberation = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragChromaticAbberation);
|
private final ShaderProgram shaderChromaticAbberation = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragChromaticAbberation);
|
||||||
|
private final ShaderProgram shaderHueShift = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragHueShift);
|
||||||
|
|
||||||
private Texture dummyTexture = null;
|
private Texture dummyTexture = null;
|
||||||
|
|
||||||
@@ -102,6 +104,7 @@ public class Graphics {
|
|||||||
public boolean startClip() {
|
public boolean startClip() {
|
||||||
return startClip(0, 0, bounds.width, bounds.height);
|
return startClip(0, 0, bounds.width, bounds.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean startClip(float x, float y, float w, float h) {
|
public boolean startClip(float x, float y, float w, float h) {
|
||||||
batch.flush(); //must flush batch to prevent other things not rendering
|
batch.flush(); //must flush batch to prevent other things not rendering
|
||||||
|
|
||||||
@@ -115,22 +118,40 @@ public class Graphics {
|
|||||||
float maxY = minY;
|
float maxY = minY;
|
||||||
tmp.set(clip.x + clip.width, clip.y, 0);
|
tmp.set(clip.x + clip.width, clip.y, 0);
|
||||||
tmp.mul(batch.getTransformMatrix());
|
tmp.mul(batch.getTransformMatrix());
|
||||||
if (tmp.x < minX) { minX = tmp.x; }
|
if (tmp.x < minX) {
|
||||||
else if (tmp.x > maxX) { maxX = tmp.x; }
|
minX = tmp.x;
|
||||||
if (tmp.y < minY) { minY = tmp.y; }
|
} else if (tmp.x > maxX) {
|
||||||
else if (tmp.y > maxY) { maxY = tmp.y; }
|
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.set(clip.x + clip.width, clip.y + clip.height, 0);
|
||||||
tmp.mul(batch.getTransformMatrix());
|
tmp.mul(batch.getTransformMatrix());
|
||||||
if (tmp.x < minX) { minX = tmp.x; }
|
if (tmp.x < minX) {
|
||||||
else if (tmp.x > maxX) { maxX = tmp.x; }
|
minX = tmp.x;
|
||||||
if (tmp.y < minY) { minY = tmp.y; }
|
} else if (tmp.x > maxX) {
|
||||||
else if (tmp.y > maxY) { maxY = tmp.y; }
|
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.set(clip.x, clip.y + clip.height, 0);
|
||||||
tmp.mul(batch.getTransformMatrix());
|
tmp.mul(batch.getTransformMatrix());
|
||||||
if (tmp.x < minX) { minX = tmp.x; }
|
if (tmp.x < minX) {
|
||||||
else if (tmp.x > maxX) { maxX = tmp.x; }
|
minX = tmp.x;
|
||||||
if (tmp.y < minY) { minY = tmp.y; }
|
} else if (tmp.x > maxX) {
|
||||||
else if (tmp.y > maxY) { maxY = tmp.y; }
|
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);
|
clip.set(minX, minY, maxX - minX, maxY - minY);
|
||||||
}
|
}
|
||||||
@@ -140,12 +161,12 @@ public class Graphics {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endClip() {
|
public void endClip() {
|
||||||
if (failedClipCount == 0) {
|
if (failedClipCount == 0) {
|
||||||
batch.flush(); //must flush batch to ensure stuffed rendered during clip respects that clip
|
batch.flush(); //must flush batch to ensure stuffed rendered during clip respects that clip
|
||||||
ScissorStack.popScissors();
|
ScissorStack.popScissors();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
failedClipCount--;
|
failedClipCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,8 +180,7 @@ public class Graphics {
|
|||||||
bounds = new Rectangle(parentBounds.x + displayObj.getLeft(), parentBounds.y + displayObj.getTop(), displayObj.getWidth(), displayObj.getHeight());
|
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
|
if (!Dtransforms.isEmpty()) { //transform screen position if needed by applying transform matrix to rectangle
|
||||||
updateScreenPosForRotation(displayObj);
|
updateScreenPosForRotation(displayObj);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
displayObj.screenPos.set(bounds);
|
displayObj.screenPos.set(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,8 +192,7 @@ public class Graphics {
|
|||||||
if (displayObj.getRotate90()) { //use top-right corner of bounds as pivot point
|
if (displayObj.getRotate90()) { //use top-right corner of bounds as pivot point
|
||||||
startRotateTransform(displayObj.getWidth(), 0, -90);
|
startRotateTransform(displayObj.getWidth(), 0, -90);
|
||||||
updateScreenPosForRotation(displayObj);
|
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);
|
startRotateTransform(displayObj.getWidth() / 2, displayObj.getHeight() / 2, 180);
|
||||||
//screen position won't change for this object from a 180 degree rotation
|
//screen position won't change for this object from a 180 degree rotation
|
||||||
}
|
}
|
||||||
@@ -201,24 +220,42 @@ public class Graphics {
|
|||||||
tmp.set(bounds.x + bounds.width, regionHeight - bounds.y, 0);
|
tmp.set(bounds.x + bounds.width, regionHeight - bounds.y, 0);
|
||||||
tmp.mul(batch.getTransformMatrix());
|
tmp.mul(batch.getTransformMatrix());
|
||||||
tmp.y = regionHeight - tmp.y;
|
tmp.y = regionHeight - tmp.y;
|
||||||
if (tmp.x < minX) { minX = tmp.x; }
|
if (tmp.x < minX) {
|
||||||
else if (tmp.x > maxX) { maxX = tmp.x; }
|
minX = tmp.x;
|
||||||
if (tmp.y < minY) { minY = tmp.y; }
|
} else if (tmp.x > maxX) {
|
||||||
else if (tmp.y > maxY) { maxY = tmp.y; }
|
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.set(bounds.x + bounds.width, regionHeight - bounds.y - bounds.height, 0);
|
||||||
tmp.mul(batch.getTransformMatrix());
|
tmp.mul(batch.getTransformMatrix());
|
||||||
tmp.y = regionHeight - tmp.y;
|
tmp.y = regionHeight - tmp.y;
|
||||||
if (tmp.x < minX) { minX = tmp.x; }
|
if (tmp.x < minX) {
|
||||||
else if (tmp.x > maxX) { maxX = tmp.x; }
|
minX = tmp.x;
|
||||||
if (tmp.y < minY) { minY = tmp.y; }
|
} else if (tmp.x > maxX) {
|
||||||
else if (tmp.y > maxY) { maxY = tmp.y; }
|
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.set(bounds.x, regionHeight - bounds.y - bounds.height, 0);
|
||||||
tmp.mul(batch.getTransformMatrix());
|
tmp.mul(batch.getTransformMatrix());
|
||||||
tmp.y = regionHeight - tmp.y;
|
tmp.y = regionHeight - tmp.y;
|
||||||
if (tmp.x < minX) { minX = tmp.x; }
|
if (tmp.x < minX) {
|
||||||
else if (tmp.x > maxX) { maxX = tmp.x; }
|
minX = tmp.x;
|
||||||
if (tmp.y < minY) { minY = tmp.y; }
|
} else if (tmp.x > maxX) {
|
||||||
else if (tmp.y > maxY) { maxY = tmp.y; }
|
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);
|
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) {
|
public void drawLine(float thickness, FSkinColor skinColor, float x1, float y1, float x2, float y2) {
|
||||||
drawLine(thickness, skinColor.getColor(), x1, y1, x2, y2);
|
drawLine(thickness, skinColor.getColor(), x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawLine(float thickness, Color color, float x1, float y1, float x2, float y2) {
|
public void drawLine(float thickness, Color color, float x1, float y1, float x2, float y2) {
|
||||||
batch.end(); //must pause batch while rendering shapes
|
batch.end(); //must pause batch while rendering shapes
|
||||||
|
|
||||||
@@ -267,6 +305,7 @@ public class Graphics {
|
|||||||
fillCircle(Color.WHITE, x2, y2, arrowThickness / 2);
|
fillCircle(Color.WHITE, x2, y2, arrowThickness / 2);
|
||||||
drawLine(arrowThickness / 3, Color.WHITE, x1, y1, x2, y2);
|
drawLine(arrowThickness / 3, Color.WHITE, x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawLineArrow(float thickness, Color color, float x1, float y1, float x2, float y2) {
|
public void drawLineArrow(float thickness, Color color, float x1, float y1, float x2, float y2) {
|
||||||
batch.end(); //must pause batch while rendering shapes
|
batch.end(); //must pause batch while rendering shapes
|
||||||
|
|
||||||
@@ -306,9 +345,11 @@ public class Graphics {
|
|||||||
|
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawArrow(float borderThickness, float arrowThickness, float arrowSize, FSkinColor skinColor, float x1, float y1, float x2, float y2) {
|
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);
|
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) {
|
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
|
batch.end(); //must pause batch while rendering shapes
|
||||||
|
|
||||||
@@ -381,6 +422,7 @@ public class Graphics {
|
|||||||
public void drawRoundRect(float thickness, FSkinColor skinColor, float x, float y, float w, float h, float cornerRadius) {
|
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);
|
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) {
|
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
|
batch.end(); //must pause batch while rendering shapes
|
||||||
|
|
||||||
@@ -429,6 +471,7 @@ public class Graphics {
|
|||||||
public void fillRoundRect(FSkinColor skinColor, float x, float y, float w, float h, float cornerRadius) {
|
public void fillRoundRect(FSkinColor skinColor, float x, float y, float w, float h, float cornerRadius) {
|
||||||
fillRoundRect(skinColor.getColor(), x, y, w, h, cornerRadius);
|
fillRoundRect(skinColor.getColor(), x, y, w, h, cornerRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillRoundRect(Color color, float x, float y, float w, float h, float cornerRadius) {
|
public void fillRoundRect(Color color, float x, float y, float w, float h, float cornerRadius) {
|
||||||
batch.end(); //must pause batch while rendering shapes
|
batch.end(); //must pause batch while rendering shapes
|
||||||
if (alphaComposite < 1) {
|
if (alphaComposite < 1) {
|
||||||
@@ -455,6 +498,7 @@ public class Graphics {
|
|||||||
public void drawRect(float thickness, FSkinColor skinColor, float x, float y, float w, float h) {
|
public void drawRect(float thickness, FSkinColor skinColor, float x, float y, float w, float h) {
|
||||||
drawRect(thickness, skinColor.getColor(), x, y, w, h);
|
drawRect(thickness, skinColor.getColor(), x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawRect(float thickness, Color color, float x, float y, float w, float h) {
|
public void drawRect(float thickness, Color color, float x, float y, float w, float h) {
|
||||||
batch.end(); //must pause batch while rendering shapes
|
batch.end(); //must pause batch while rendering shapes
|
||||||
|
|
||||||
@@ -480,6 +524,7 @@ public class Graphics {
|
|||||||
|
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawRectLines(float thickness, Color color, float x, float y, float w, float h) {
|
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, y, x + w, y);
|
||||||
drawLine(thickness, color, x + thickness / 2f, y + thickness / 2f, x + thickness / 2f, y + h - thickness / 2f);
|
drawLine(thickness, color, x + thickness / 2f, y + thickness / 2f, x + thickness / 2f, y + h - thickness / 2f);
|
||||||
@@ -490,6 +535,7 @@ public class Graphics {
|
|||||||
public void fillRect(FSkinColor skinColor, float x, float y, float w, float h) {
|
public void fillRect(FSkinColor skinColor, float x, float y, float w, float h) {
|
||||||
fillRect(skinColor.getColor(), x, y, w, h);
|
fillRect(skinColor.getColor(), x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillRect(Color color, float x, float y, float w, float h) {
|
public void fillRect(Color color, float x, float y, float w, float h) {
|
||||||
batch.end(); //must pause batch while rendering shapes
|
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) {
|
public void drawCircle(float thickness, FSkinColor skinColor, float x, float y, float radius) {
|
||||||
drawCircle(thickness, skinColor.getColor(), x, y, radius);
|
drawCircle(thickness, skinColor.getColor(), x, y, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawCircle(float thickness, Color color, float x, float y, float radius) {
|
public void drawCircle(float thickness, Color color, float x, float y, float radius) {
|
||||||
batch.end(); //must pause batch while rendering shapes
|
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) {
|
public void fillCircle(FSkinColor skinColor, float x, float y, float radius) {
|
||||||
fillCircle(skinColor.getColor(), x, y, radius);
|
fillCircle(skinColor.getColor(), x, y, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillCircle(Color color, float x, float y, float radius) {
|
public void fillCircle(Color color, float x, float y, float radius) {
|
||||||
batch.end(); //must pause batch while rendering shapes
|
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) {
|
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);
|
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) {
|
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
|
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) {
|
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);
|
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) {
|
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);
|
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) {
|
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);
|
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) {
|
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
|
batch.end(); //must pause batch while rendering shapes
|
||||||
|
|
||||||
@@ -654,11 +706,15 @@ public class Graphics {
|
|||||||
alphaComposite = alphaComposite0;
|
alphaComposite = alphaComposite0;
|
||||||
batch.setColor(new Color(1, 1, 1, alphaComposite));
|
batch.setColor(new Color(1, 1, 1, alphaComposite));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetAlphaComposite() {
|
public void resetAlphaComposite() {
|
||||||
alphaComposite = 1;
|
alphaComposite = 1;
|
||||||
batch.setColor(Color.WHITE);
|
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) {
|
public void drawBorderImage(FImage image, Color borderColor, Color tintColor, float x, float y, float w, float h, boolean tint) {
|
||||||
float oldalpha = alphaComposite;
|
float oldalpha = alphaComposite;
|
||||||
@@ -673,17 +729,20 @@ public class Graphics {
|
|||||||
}
|
}
|
||||||
setAlphaComposite(oldalpha);
|
setAlphaComposite(oldalpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawborderImage(Color borderColor, float x, float y, float w, float h) {
|
public void drawborderImage(Color borderColor, float x, float y, float w, float h) {
|
||||||
float oldalpha = alphaComposite;
|
float oldalpha = alphaComposite;
|
||||||
fillRoundRect(borderColor, x, y, w, h, (h - w) / 12);
|
fillRoundRect(borderColor, x, y, w, h, (h - w) / 12);
|
||||||
setAlphaComposite(oldalpha);
|
setAlphaComposite(oldalpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawImage(FImage image, Color borderColor, float x, float y, float w, float h) {
|
public void drawImage(FImage image, Color borderColor, float x, float y, float w, float h) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
image.draw(this, x, y, w, h);
|
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) {
|
public void drawAvatarImage(FImage image, float x, float y, float w, float h, boolean drawGrayscale) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -704,6 +763,7 @@ public class Graphics {
|
|||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawCardImage(FImage image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
|
public void drawCardImage(FImage image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -726,6 +786,7 @@ public class Graphics {
|
|||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawCardImage(Texture image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
|
public void drawCardImage(Texture image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
|
||||||
if (!drawGrayscale) {
|
if (!drawGrayscale) {
|
||||||
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
|
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
|
||||||
@@ -746,6 +807,7 @@ public class Graphics {
|
|||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawCardImage(TextureRegion image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
|
public void drawCardImage(TextureRegion image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGrayscale, boolean damaged) {
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
if (!drawGrayscale) {
|
if (!drawGrayscale) {
|
||||||
@@ -768,6 +830,7 @@ public class Graphics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawGrayTransitionImage(FImage image, float x, float y, float w, float h, float percentage) {
|
public void drawGrayTransitionImage(FImage image, float x, float y, float w, float h, float percentage) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -784,6 +847,7 @@ public class Graphics {
|
|||||||
batch.setShader(null);
|
batch.setShader(null);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawGrayTransitionImage(Texture image, float x, float y, float w, float h, boolean withDarkOverlay, float percentage) {
|
public void drawGrayTransitionImage(Texture image, float x, float y, float w, float h, boolean withDarkOverlay, float percentage) {
|
||||||
batch.end();
|
batch.end();
|
||||||
shaderGrayscale.bind();
|
shaderGrayscale.bind();
|
||||||
@@ -798,6 +862,7 @@ public class Graphics {
|
|||||||
batch.setShader(null);
|
batch.setShader(null);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawGrayTransitionImage(TextureRegion image, float x, float y, float w, float h, boolean withDarkOverlay, float percentage) {
|
public void drawGrayTransitionImage(TextureRegion image, float x, float y, float w, float h, boolean withDarkOverlay, float percentage) {
|
||||||
batch.end();
|
batch.end();
|
||||||
shaderGrayscale.bind();
|
shaderGrayscale.bind();
|
||||||
@@ -812,6 +877,47 @@ public class Graphics {
|
|||||||
batch.setShader(null);
|
batch.setShader(null);
|
||||||
batch.begin();
|
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) {
|
public void drawChromatic(TextureRegion image, float x, float y, float w, float h, Float time) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -831,6 +937,7 @@ public class Graphics {
|
|||||||
drawImage(image, x, y, w, h);
|
drawImage(image, x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawRipple(FImage image, float x, float y, float w, float h, Float amount, boolean flipY) {
|
public void drawRipple(FImage image, float x, float y, float w, float h, Float amount, boolean flipY) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -852,6 +959,7 @@ public class Graphics {
|
|||||||
drawImage(image, x, y, w, h);
|
drawImage(image, x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawPixelated(FImage image, float x, float y, float w, float h, Float amount, boolean flipY) {
|
public void drawPixelated(FImage image, float x, float y, float w, float h, Float amount, boolean flipY) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -874,6 +982,7 @@ public class Graphics {
|
|||||||
drawImage(image, x, y, w, h);
|
drawImage(image, x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawPixelated(TextureRegion image, float x, float y, float w, float h, Float amount, boolean flipY) {
|
public void drawPixelated(TextureRegion image, float x, float y, float w, float h, Float amount, boolean flipY) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -896,6 +1005,7 @@ public class Graphics {
|
|||||||
drawImage(image, x, y, w, h);
|
drawImage(image, x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawPixelatedWarp(TextureRegion image, float x, float y, float w, float h, float amount) {
|
public void drawPixelatedWarp(TextureRegion image, float x, float y, float w, float h, float amount) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -919,6 +1029,7 @@ public class Graphics {
|
|||||||
drawImage(image, x, y, w, h);
|
drawImage(image, x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawWarpImage(Texture image, float x, float y, float w, float h, float time) {
|
public void drawWarpImage(Texture image, float x, float y, float w, float h, float time) {
|
||||||
batch.end();
|
batch.end();
|
||||||
shaderWarp.bind();
|
shaderWarp.bind();
|
||||||
@@ -934,6 +1045,7 @@ public class Graphics {
|
|||||||
batch.setShader(null);
|
batch.setShader(null);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawWarpImage(TextureRegion image, float x, float y, float w, float h, float time) {
|
public void drawWarpImage(TextureRegion image, float x, float y, float w, float h, float time) {
|
||||||
batch.end();
|
batch.end();
|
||||||
shaderWarp.bind();
|
shaderWarp.bind();
|
||||||
@@ -949,6 +1061,7 @@ public class Graphics {
|
|||||||
batch.setShader(null);
|
batch.setShader(null);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawWarpImage(FImage image, float x, float y, float w, float h, float time) {
|
public void drawWarpImage(FImage image, float x, float y, float w, float h, float time) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -966,6 +1079,7 @@ public class Graphics {
|
|||||||
batch.setShader(null);
|
batch.setShader(null);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawUnderWaterImage(FImage image, float x, float y, float w, float h, float time) {
|
public void drawUnderWaterImage(FImage image, float x, float y, float w, float h, float time) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -984,6 +1098,7 @@ public class Graphics {
|
|||||||
batch.setShader(null);
|
batch.setShader(null);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawNightDay(FImage image, float x, float y, float w, float h, Float time) {
|
public void drawNightDay(FImage image, float x, float y, float w, float h, Float time) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -1003,6 +1118,7 @@ public class Graphics {
|
|||||||
drawImage(image, x, y, w, h);
|
drawImage(image, x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawUnderWaterImage(TextureRegion image, float x, float y, float w, float h, float time) {
|
public void drawUnderWaterImage(TextureRegion image, float x, float y, float w, float h, float time) {
|
||||||
batch.end();
|
batch.end();
|
||||||
shaderUnderwater.bind();
|
shaderUnderwater.bind();
|
||||||
@@ -1018,9 +1134,11 @@ public class Graphics {
|
|||||||
batch.setShader(null);
|
batch.setShader(null);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawImage(FImage image, float x, float y, float w, float h) {
|
public void drawImage(FImage image, float x, float y, float w, float h) {
|
||||||
drawImage(image, x, y, w, h, false);
|
drawImage(image, x, y, w, h, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawImage(FImage image, float x, float y, float w, float h, boolean withDarkOverlay) {
|
public void drawImage(FImage image, float x, float y, float w, float h, boolean withDarkOverlay) {
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
@@ -1032,14 +1150,17 @@ public class Graphics {
|
|||||||
setAlphaComposite(oldalpha);
|
setAlphaComposite(oldalpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawImage(Texture image, float x, float y, float w, float h) {
|
public void drawImage(Texture image, float x, float y, float w, float h) {
|
||||||
if (image != null)
|
if (image != null)
|
||||||
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
|
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawImage(TextureRegion image, float x, float y, float w, float h) {
|
public void drawImage(TextureRegion image, float x, float y, float w, float h) {
|
||||||
if (image != null)
|
if (image != null)
|
||||||
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
|
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) {
|
public void drawImage(TextureRegion image, TextureRegion glowImageReference, float x, float y, float w, float h, Color glowColor, boolean selected) {
|
||||||
if (image == null || glowImageReference == null)
|
if (image == null || glowImageReference == null)
|
||||||
return;
|
return;
|
||||||
@@ -1065,6 +1186,7 @@ public class Graphics {
|
|||||||
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
|
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) {
|
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)
|
if (image == null || glowImageReference == null)
|
||||||
return;
|
return;
|
||||||
@@ -1149,16 +1271,26 @@ public class Graphics {
|
|||||||
public void drawRotatedImage(Texture image, float x, float y, float w, float h, float originX, float originY, float rotation) {
|
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);
|
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) {
|
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);
|
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) {
|
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);
|
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) {
|
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);
|
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) {
|
public void drawText(String text, FSkinFont font, Color color, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically) {
|
||||||
try {
|
try {
|
||||||
if (text == null)
|
if (text == null)
|
||||||
@@ -1173,8 +1305,7 @@ public class Graphics {
|
|||||||
TextBounds textBounds;
|
TextBounds textBounds;
|
||||||
if (wrap) {
|
if (wrap) {
|
||||||
textBounds = font.getWrappedBounds(text, w);
|
textBounds = font.getWrappedBounds(text, w);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
textBounds = font.getMultiLineBounds(text);
|
textBounds = font.getMultiLineBounds(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1185,12 +1316,10 @@ public class Graphics {
|
|||||||
font = font.shrink();
|
font = font.shrink();
|
||||||
if (wrap) {
|
if (wrap) {
|
||||||
textBounds = font.getWrappedBounds(text, w);
|
textBounds = font.getWrappedBounds(text, w);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
textBounds = font.getMultiLineBounds(text);
|
textBounds = font.getMultiLineBounds(text);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
needClip = true;
|
needClip = true;
|
||||||
break;
|
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) {
|
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);
|
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) {
|
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) {
|
if (shadow) {
|
||||||
float oldAlpha = alphaComposite;
|
float oldAlpha = alphaComposite;
|
||||||
@@ -1250,6 +1380,7 @@ public class Graphics {
|
|||||||
public float adjustY(float y, float height) {
|
public float adjustY(float y, float height) {
|
||||||
return regionHeight - y - bounds.y - height; //flip y-axis
|
return regionHeight - y - bounds.y - height; //flip y-axis
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color borderLining(String c) {
|
public Color borderLining(String c) {
|
||||||
if (c == null || c == "")
|
if (c == null || c == "")
|
||||||
return Color.valueOf("#fffffd");
|
return Color.valueOf("#fffffd");
|
||||||
|
|||||||
@@ -42,6 +42,30 @@ public class Shaders {
|
|||||||
" v_texCoords = a_texCoord0;\n" +
|
" v_texCoords = a_texCoord0;\n" +
|
||||||
" gl_Position = u_projTrans * a_position;\n" +
|
" gl_Position = u_projTrans * a_position;\n" +
|
||||||
"}";
|
"}";
|
||||||
|
public static final String fragHueShift = "#ifdef GL_ES\n" +
|
||||||
|
"#define LOWP lowp\n" +
|
||||||
|
"precision mediump float;\n" +
|
||||||
|
"#else\n" +
|
||||||
|
"#define LOWP \n" +
|
||||||
|
"#endif\n" +
|
||||||
|
"varying vec2 v_texCoords;\n" +
|
||||||
|
"uniform sampler2D u_texture;\n" +
|
||||||
|
"uniform float u_time;\n" +
|
||||||
|
"\n" +
|
||||||
|
"vec3 hs(vec3 c, float s) {\n" +
|
||||||
|
" vec3 m=vec3(cos(s),s=sin(s)*.5774,-s);\n" +
|
||||||
|
" return c*mat3(m+=(1.-m.x)/3.,m.zxy,m.yzx);\n" +
|
||||||
|
"}\n" +
|
||||||
|
"\n" +
|
||||||
|
"void main() {\n" +
|
||||||
|
"\tvec2 uv = v_texCoords;\n" +
|
||||||
|
" vec4 orig = texture2D(u_texture, uv);\n" +
|
||||||
|
" vec3 col = texture2D(u_texture, uv).rgb;\n" +
|
||||||
|
" vec4 col2 = vec4(hs(col, u_time), 1.);\n" +
|
||||||
|
" //multiply the original texture alpha to render only opaque shifted colors \n" +
|
||||||
|
" col2.a *= orig.a;\n" +
|
||||||
|
" gl_FragColor = col2;\n" +
|
||||||
|
"}";
|
||||||
public static final String fragRipple = "#ifdef GL_ES\n" +
|
public static final String fragRipple = "#ifdef GL_ES\n" +
|
||||||
"#define LOWP lowp\n" +
|
"#define LOWP lowp\n" +
|
||||||
"precision mediump float;\n" +
|
"precision mediump float;\n" +
|
||||||
@@ -1135,6 +1159,7 @@ public class Shaders {
|
|||||||
* {@link com.github.tommyettinger.colorful.rgb.ColorTools#rgb(float, float, float, float)}.
|
* {@link com.github.tommyettinger.colorful.rgb.ColorTools#rgb(float, float, float, float)}.
|
||||||
* <br>
|
* <br>
|
||||||
* Meant for use with {@link #vertexShader}.
|
* Meant for use with {@link #vertexShader}.
|
||||||
|
*
|
||||||
* @see #fragmentShaderConfigurableContrast a per-sprite-configurable version of this
|
* @see #fragmentShaderConfigurableContrast a per-sprite-configurable version of this
|
||||||
*/
|
*/
|
||||||
public static String fragmentShaderFlatLightness =
|
public static String fragmentShaderFlatLightness =
|
||||||
@@ -1176,6 +1201,7 @@ public class Shaders {
|
|||||||
* the specific way this uses them.
|
* the specific way this uses them.
|
||||||
* <br>
|
* <br>
|
||||||
* Meant for use with {@link #vertexShader}.
|
* Meant for use with {@link #vertexShader}.
|
||||||
|
*
|
||||||
* @see #fragmentShaderFlatLightness if you only need one contrast setting and still want to set color tints
|
* @see #fragmentShaderFlatLightness if you only need one contrast setting and still want to set color tints
|
||||||
*/
|
*/
|
||||||
public static String fragmentShaderConfigurableContrast =
|
public static String fragmentShaderConfigurableContrast =
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package forge.adventure.scene;
|
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.Sprite;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
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.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||||
@@ -15,7 +12,6 @@ import forge.Forge;
|
|||||||
import forge.adventure.character.EnemySprite;
|
import forge.adventure.character.EnemySprite;
|
||||||
import forge.adventure.data.ArenaData;
|
import forge.adventure.data.ArenaData;
|
||||||
import forge.adventure.data.WorldData;
|
import forge.adventure.data.WorldData;
|
||||||
import forge.adventure.player.AdventurePlayer;
|
|
||||||
import forge.adventure.stage.GameHUD;
|
import forge.adventure.stage.GameHUD;
|
||||||
import forge.adventure.stage.IAfterMatch;
|
import forge.adventure.stage.IAfterMatch;
|
||||||
import forge.adventure.stage.WorldStage;
|
import forge.adventure.stage.WorldStage;
|
||||||
@@ -29,8 +25,6 @@ import java.util.Random;
|
|||||||
* Displays the rewards of a fight or a treasure
|
* Displays the rewards of a fight or a treasure
|
||||||
*/
|
*/
|
||||||
public class ArenaScene extends UIScene implements IAfterMatch {
|
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 static ArenaScene object;
|
||||||
private final float gridSize;
|
private final float gridSize;
|
||||||
private ArenaData arenaData;
|
private ArenaData arenaData;
|
||||||
@@ -59,11 +53,9 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
final Sprite edgeWin;
|
final Sprite edgeWin;
|
||||||
final Sprite edgeWinM;
|
final Sprite edgeWinM;
|
||||||
boolean arenaStarted = false;
|
boolean arenaStarted = false;
|
||||||
|
|
||||||
private ArenaScene() {
|
private ArenaScene() {
|
||||||
super(Forge.isLandscapeMode() ? "ui/arena.json" : "ui/arena_portrait.json");
|
super(Forge.isLandscapeMode() ? "ui/arena.json" : "ui/arena_portrait.json");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TextureAtlas atlas = Config.instance().getAtlas(Paths.ARENA_ATLAS);
|
TextureAtlas atlas = Config.instance().getAtlas(Paths.ARENA_ATLAS);
|
||||||
fighterSpot = atlas.createSprite("Spot");
|
fighterSpot = atlas.createSprite("Spot");
|
||||||
lostOverlay = atlas.createSprite("Lost");
|
lostOverlay = atlas.createSprite("Lost");
|
||||||
@@ -95,11 +87,9 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
startButton = ui.findActor("start");
|
startButton = ui.findActor("start");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showAreYouSure() {
|
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"));
|
areYouSureDialog.text(Forge.getLocalizer().getMessage("lblConcedeCurrentGame"));
|
||||||
showDialog(areYouSureDialog);
|
showDialog(areYouSureDialog);
|
||||||
@@ -113,19 +103,17 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startButton() {
|
private void startButton() {
|
||||||
if(roundsWon ==0)
|
if (roundsWon == 0) {
|
||||||
{
|
|
||||||
Dialog startDialog = prepareDialog(Forge.getLocalizer().getMessage("lblStart"), ButtonYes | ButtonNo, () -> startArena());
|
Dialog startDialog = prepareDialog(Forge.getLocalizer().getMessage("lblStart"), ButtonYes | ButtonNo, () -> startArena());
|
||||||
startDialog.text("Do you want to go into the Arena?");
|
startDialog.text("Do you want to go into the Arena?");
|
||||||
showDialog(startDialog);
|
showDialog(startDialog);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
startRound();
|
startRound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int roundsWon = 0;
|
int roundsWon = 0;
|
||||||
|
|
||||||
private void startArena() {
|
private void startArena() {
|
||||||
goldLabel.setVisible(false);
|
goldLabel.setVisible(false);
|
||||||
arenaStarted = true;
|
arenaStarted = true;
|
||||||
@@ -137,37 +125,31 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
Current.player().takeGold(arenaData.entryFee);
|
Current.player().takeGold(arenaData.entryFee);
|
||||||
startRound();
|
startRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWinner(boolean winner) {
|
public void setWinner(boolean winner) {
|
||||||
Array<Actor> winners = new Array<>();
|
Array<Actor> winners = new Array<>();
|
||||||
Array<EnemySprite> winnersEnemies = new Array<>();
|
Array<EnemySprite> winnersEnemies = new Array<>();
|
||||||
for(int i=0;i<fighters.size-2;i+=2)
|
for (int i = 0; i < fighters.size - 2; i += 2) {
|
||||||
{
|
|
||||||
boolean leftWon = rand.nextBoolean();
|
boolean leftWon = rand.nextBoolean();
|
||||||
if(leftWon)
|
if (leftWon) {
|
||||||
{
|
|
||||||
winners.add(fighters.get(i));
|
winners.add(fighters.get(i));
|
||||||
winnersEnemies.add(enemies.get(i));
|
winnersEnemies.add(enemies.get(i));
|
||||||
moveFighter(fighters.get(i), true);
|
moveFighter(fighters.get(i), true);
|
||||||
markLostFighter(fighters.get(i + 1));
|
markLostFighter(fighters.get(i + 1));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
markLostFighter(fighters.get(i));
|
markLostFighter(fighters.get(i));
|
||||||
moveFighter(fighters.get(i + 1), false);
|
moveFighter(fighters.get(i + 1), false);
|
||||||
winners.add(fighters.get(i + 1));
|
winners.add(fighters.get(i + 1));
|
||||||
winnersEnemies.add(enemies.get(i + 1));
|
winnersEnemies.add(enemies.get(i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(winner)
|
if (winner) {
|
||||||
{
|
|
||||||
markLostFighter(fighters.get(fighters.size - 2));
|
markLostFighter(fighters.get(fighters.size - 2));
|
||||||
moveFighter(fighters.get(fighters.size - 1), false);
|
moveFighter(fighters.get(fighters.size - 1), false);
|
||||||
winners.add(fighters.get(fighters.size - 1));
|
winners.add(fighters.get(fighters.size - 1));
|
||||||
roundsWon++;
|
roundsWon++;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
markLostFighter(fighters.get(fighters.size - 1));
|
markLostFighter(fighters.get(fighters.size - 1));
|
||||||
moveFighter(fighters.get(fighters.size - 2), true);
|
moveFighter(fighters.get(fighters.size - 2), true);
|
||||||
winners.add(fighters.get(fighters.size - 2));
|
winners.add(fighters.get(fighters.size - 2));
|
||||||
@@ -176,8 +158,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
|
|
||||||
fighters = winners;
|
fighters = winners;
|
||||||
enemies = winnersEnemies;
|
enemies = winnersEnemies;
|
||||||
if(roundsWon >=arenaData.rounds )
|
if (roundsWon >= arenaData.rounds) {
|
||||||
{
|
|
||||||
arenaStarted = false;
|
arenaStarted = false;
|
||||||
startButton.setDisabled(true);
|
startButton.setDisabled(true);
|
||||||
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
||||||
@@ -186,14 +167,12 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void moveFighter(Actor actor, boolean leftPlayer) {
|
private void moveFighter(Actor actor, boolean leftPlayer) {
|
||||||
|
|
||||||
Image spotImg = new Image(upWin);
|
Image spotImg = new Image(upWin);
|
||||||
double stepsToTheSide = Math.pow(2, roundsWon);
|
double stepsToTheSide = Math.pow(2, roundsWon);
|
||||||
float widthDiff = actor.getWidth() - spotImg.getWidth();
|
float widthDiff = actor.getWidth() - spotImg.getWidth();
|
||||||
spotImg.setPosition(actor.getX() + widthDiff / 2, actor.getY() + gridSize + widthDiff / 2);
|
spotImg.setPosition(actor.getX() + widthDiff / 2, actor.getY() + gridSize + widthDiff / 2);
|
||||||
arenaPlane.addActor(spotImg);
|
arenaPlane.addActor(spotImg);
|
||||||
for(int i=0;i<stepsToTheSide;i++)
|
for (int i = 0; i < stepsToTheSide; i++) {
|
||||||
{
|
|
||||||
Image leftImg;
|
Image leftImg;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
leftImg = new Image(leftPlayer ? edgeWin : edgeWinM);
|
leftImg = new Image(leftPlayer ? edgeWin : edgeWinM);
|
||||||
@@ -208,7 +187,6 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void markLostFighter(Actor fighter) {
|
private void markLostFighter(Actor fighter) {
|
||||||
|
|
||||||
Image lost = new Image(lostOverlay);
|
Image lost = new Image(lostOverlay);
|
||||||
float widthDiff = fighter.getWidth() - lost.getWidth();
|
float widthDiff = fighter.getWidth() - lost.getWidth();
|
||||||
lost.setPosition(fighter.getX() + widthDiff / 2, fighter.getY() + widthDiff / 2);
|
lost.setPosition(fighter.getX() + widthDiff / 2, fighter.getY() + widthDiff / 2);
|
||||||
@@ -222,13 +200,11 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||||
duelScene.initDuels(WorldStage.getInstance().getPlayerSprite(), enemy);
|
duelScene.initDuels(WorldStage.getInstance().getPlayerSprite(), enemy);
|
||||||
Forge.switchScene(duelScene);
|
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() {
|
public boolean start() {
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,13 +212,10 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
public boolean done() {
|
public boolean done() {
|
||||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||||
Forge.switchToLast();
|
Forge.switchToLast();
|
||||||
if(roundsWon !=0)
|
if (roundsWon != 0) {
|
||||||
{
|
|
||||||
Array<Reward> data = new Array<>();
|
Array<Reward> data = new Array<>();
|
||||||
for(int i = 0; i< roundsWon; i++)
|
for (int i = 0; i < roundsWon; i++) {
|
||||||
{
|
for (int j = 0; j < arenaData.rewards[i].length; j++) {
|
||||||
for(int j=0;j<arenaData.rewards[i].length;j++)
|
|
||||||
{
|
|
||||||
data.addAll(arenaData.rewards[i][j].generate(false, null));
|
data.addAll(arenaData.rewards[i][j].generate(false, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,13 +224,13 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
stage.act(delta);
|
stage.act(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Array<EnemySprite> enemies = new Array<>();
|
Array<EnemySprite> enemies = new Array<>();
|
||||||
Array<Actor> fighters = new Array<>();
|
Array<Actor> fighters = new Array<>();
|
||||||
Actor player;
|
Actor player;
|
||||||
@@ -277,8 +250,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
int numberOfEnemies = (int) (Math.pow(2f, data.rounds) - 1);
|
int numberOfEnemies = (int) (Math.pow(2f, data.rounds) - 1);
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<numberOfEnemies;i++)
|
for (int i = 0; i < numberOfEnemies; i++) {
|
||||||
{
|
|
||||||
EnemySprite enemy = new EnemySprite(WorldData.getEnemy(data.enemyPool[rand.nextInt(data.enemyPool.length)]));
|
EnemySprite enemy = new EnemySprite(WorldData.getEnemy(data.enemyPool[rand.nextInt(data.enemyPool.length)]));
|
||||||
enemies.add(enemy);
|
enemies.add(enemy);
|
||||||
fighters.add(new Image(enemy.getAvatar()));
|
fighters.add(new Image(enemy.getAvatar()));
|
||||||
@@ -297,16 +269,11 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
int gridHeight = data.rounds + 1;
|
int gridHeight = data.rounds + 1;
|
||||||
arenaPlane.setSize(gridWidth * gridSize, gridHeight * gridSize * 2);
|
arenaPlane.setSize(gridWidth * gridSize, gridHeight * gridSize * 2);
|
||||||
int fighterIndex = 0;
|
int fighterIndex = 0;
|
||||||
for(int x=0;x<gridWidth;x++)
|
for (int x = 0; x < gridWidth; x++) {
|
||||||
{
|
for (int y = 0; y < gridHeight; y++) {
|
||||||
for(int y=0;y<gridHeight;y++)
|
if (x % Math.pow(2, y + 1) == Math.pow(2, y)) {
|
||||||
{
|
if (y == 0) {
|
||||||
if(x % Math.pow(2,y+1) == Math.pow(2,y))
|
if (fighterIndex < fighters.size) {
|
||||||
{
|
|
||||||
if(y==0)
|
|
||||||
{
|
|
||||||
if(fighterIndex<fighters.size)
|
|
||||||
{
|
|
||||||
float widthDiff = gridSize - fighters.get(fighterIndex).getWidth();
|
float widthDiff = gridSize - fighters.get(fighterIndex).getWidth();
|
||||||
fighters.get(fighterIndex).setPosition(x * gridSize + widthDiff / 2, y * gridSize * 2 + widthDiff / 2);
|
fighters.get(fighterIndex).setPosition(x * gridSize + widthDiff / 2, y * gridSize * 2 + widthDiff / 2);
|
||||||
arenaPlane.addActor(fighters.get(fighterIndex));
|
arenaPlane.addActor(fighters.get(fighterIndex));
|
||||||
@@ -317,25 +284,19 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
spotImg.setPosition(x * gridSize, y * gridSize * 2);
|
spotImg.setPosition(x * gridSize, y * gridSize * 2);
|
||||||
arenaPlane.addActor(spotImg);
|
arenaPlane.addActor(spotImg);
|
||||||
|
|
||||||
if(y!=gridHeight-1)
|
if (y != gridHeight - 1) {
|
||||||
{
|
|
||||||
Image upImg = new Image(up);
|
Image upImg = new Image(up);
|
||||||
upImg.setPosition(x * gridSize, y * gridSize * 2 + gridSize);
|
upImg.setPosition(x * gridSize, y * gridSize * 2 + gridSize);
|
||||||
arenaPlane.addActor(upImg);
|
arenaPlane.addActor(upImg);
|
||||||
}
|
}
|
||||||
if(y!=0)
|
if (y != 0) {
|
||||||
{
|
for (int i = 0; i < Math.pow(2, (y - 1)); i++) {
|
||||||
for(int i=0;i<Math.pow(2,(y-1));i++)
|
|
||||||
{
|
|
||||||
Image leftImg;
|
Image leftImg;
|
||||||
Image rightImg;
|
Image rightImg;
|
||||||
if(i==Math.pow(2,(y-1))-1)
|
if (i == Math.pow(2, (y - 1)) - 1) {
|
||||||
{
|
|
||||||
leftImg = new Image(edge);
|
leftImg = new Image(edge);
|
||||||
rightImg = new Image(edgeM);
|
rightImg = new Image(edgeM);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
leftImg = new Image(side);
|
leftImg = new Image(side);
|
||||||
rightImg = new Image(side);
|
rightImg = new Image(side);
|
||||||
}
|
}
|
||||||
@@ -349,5 +310,4 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class DuelScene extends ForgeScene {
|
|||||||
object = new DuelScene();
|
object = new DuelScene();
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
//GameLobby lobby;
|
//GameLobby lobby;
|
||||||
HostedMatch hostedMatch;
|
HostedMatch hostedMatch;
|
||||||
EnemySprite enemy;
|
EnemySprite enemy;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package forge.adventure.scene;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.adventure.character.PlayerSprite;
|
|
||||||
import forge.adventure.data.BiomeData;
|
import forge.adventure.data.BiomeData;
|
||||||
import forge.adventure.stage.MapStage;
|
import forge.adventure.stage.MapStage;
|
||||||
import forge.adventure.stage.WorldStage;
|
import forge.adventure.stage.WorldStage;
|
||||||
@@ -58,15 +57,15 @@ public class GameScene extends HudScene {
|
|||||||
super.enter();
|
super.enter();
|
||||||
WorldStage.getInstance().handlePointsOfInterestCollision();
|
WorldStage.getInstance().handlePointsOfInterestCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAdventurePlayerLocation(boolean forHeader) {
|
public String getAdventurePlayerLocation(boolean forHeader) {
|
||||||
String location = "";
|
String location = "";
|
||||||
if (MapStage.getInstance().isInMap()) {
|
if (MapStage.getInstance().isInMap()) {
|
||||||
location = forHeader ? TileMapScene.instance().rootPoint.getData().name : TileMapScene.instance().rootPoint.getData().type;
|
location = forHeader ? TileMapScene.instance().rootPoint.getData().name : TileMapScene.instance().rootPoint.getData().type;
|
||||||
} else {
|
} else {
|
||||||
World world = Current.world();
|
World world = Current.world();
|
||||||
PlayerSprite player = WorldStage.getInstance().getPlayerSprite();
|
int currentBiome = World.highestBiome(world.getBiome((int) Current.player().getWorldPosX() / world.getTileSize(), (int) Current.player().getWorldPosY() / world.getTileSize()));
|
||||||
int currentBiome = World.highestBiome(world.getBiome((int) player.getX() / world.getTileSize(), (int) player.getY() / world.getTileSize()));
|
List<BiomeData> biomeData = world.getData().GetBiomes();
|
||||||
List<BiomeData> biomeData = Current.world().getData().GetBiomes();
|
|
||||||
try {
|
try {
|
||||||
BiomeData data = biomeData.get(currentBiome);
|
BiomeData data = biomeData.get(currentBiome);
|
||||||
location = forHeader ? TextUtil.capitalize(data.name) + " Map" : data.name;
|
location = forHeader ? TextUtil.capitalize(data.name) + " Map" : data.name;
|
||||||
|
|||||||
@@ -118,8 +118,7 @@ public class MapStage extends GameStage {
|
|||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MapStage()
|
private MapStage() {
|
||||||
{
|
|
||||||
dialog = Controls.newDialog("");
|
dialog = Controls.newDialog("");
|
||||||
eventTouchDown = new InputEvent();
|
eventTouchDown = new InputEvent();
|
||||||
eventTouchDown.setPointer(-1);
|
eventTouchDown.setPointer(-1);
|
||||||
@@ -128,6 +127,7 @@ public class MapStage extends GameStage {
|
|||||||
eventTouchUp.setPointer(-1);
|
eventTouchUp.setPointer(-1);
|
||||||
eventTouchUp.setType(InputEvent.Type.touchUp);
|
eventTouchUp.setType(InputEvent.Type.touchUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MapStage getInstance() {
|
public static MapStage getInstance() {
|
||||||
return instance == null ? instance = new MapStage() : instance;
|
return instance == null ? instance = new MapStage() : instance;
|
||||||
}
|
}
|
||||||
@@ -246,6 +246,7 @@ public class MapStage extends GameStage {
|
|||||||
setDialogStage(GameHUD.getInstance());
|
setDialogStage(GameHUD.getInstance());
|
||||||
showDialog();
|
showDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<EntryActor> otherEntries = new Array<>();
|
Array<EntryActor> otherEntries = new Array<>();
|
||||||
Array<EntryActor> spawnClassified = new Array<>();
|
Array<EntryActor> spawnClassified = new Array<>();
|
||||||
Array<EntryActor> sourceMapMatch = new Array<>();
|
Array<EntryActor> sourceMapMatch = new Array<>();
|
||||||
@@ -281,12 +282,9 @@ public class MapStage extends GameStage {
|
|||||||
effect = JSONStringLoader.parse(EffectData.class, map.getProperties().get("dungeonEffect").toString(), "");
|
effect = JSONStringLoader.parse(EffectData.class, map.getProperties().get("dungeonEffect").toString(), "");
|
||||||
effectDialog(effect);
|
effectDialog(effect);
|
||||||
}
|
}
|
||||||
if(MP.get("respawnEnemies")!=null&&MP.get("respawnEnemies") instanceof Boolean&&(Boolean)MP.get("respawnEnemies"))
|
if (MP.get("respawnEnemies") != null && MP.get("respawnEnemies") instanceof Boolean && (Boolean) MP.get("respawnEnemies")) {
|
||||||
{
|
|
||||||
respawnEnemies = true;
|
respawnEnemies = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
respawnEnemies = false;
|
respawnEnemies = false;
|
||||||
}
|
}
|
||||||
if (MP.get("preventEscape") != null) preventEscape = (boolean) MP.get("preventEscape");
|
if (MP.get("preventEscape") != null) preventEscape = (boolean) MP.get("preventEscape");
|
||||||
@@ -321,11 +319,9 @@ public class MapStage extends GameStage {
|
|||||||
int oldSize;
|
int oldSize;
|
||||||
do {
|
do {
|
||||||
oldSize = collisionRect.size;
|
oldSize = collisionRect.size;
|
||||||
for(int i=0;i<collisionRect.size;i++)
|
for (int i = 0; i < collisionRect.size; i++) {
|
||||||
{
|
|
||||||
Rectangle r1 = collisionRect.get(i);
|
Rectangle r1 = collisionRect.get(i);
|
||||||
for(int j=i+1;j<collisionRect.size;j++)
|
for (int j = i + 1; j < collisionRect.size; j++) {
|
||||||
{
|
|
||||||
Rectangle r2 = collisionRect.get(j);
|
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
|
if ((Math.abs(r1.x - (r2.x + r2.width)) < 1 && Math.abs(r1.y - r2.y) < 1 && Math.abs(r1.height - r2.height) < 1)//left edge is the same as right edge
|
||||||
|
|
||||||
@@ -336,8 +332,7 @@ public class MapStage extends GameStage {
|
|||||||
|| (Math.abs(r1.x - r2.x) < 1 && Math.abs(r1.y - (r2.y + r2.height)) < 1 && Math.abs(r1.width - r2.width) < 1)//bottom edge is the same as left edge
|
|| (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);
|
r1.merge(r2);
|
||||||
collisionRect.removeIndex(j);
|
collisionRect.removeIndex(j);
|
||||||
i--;
|
i--;
|
||||||
@@ -358,6 +353,7 @@ public class MapStage extends GameStage {
|
|||||||
float yma = ymi + r2.height;
|
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;
|
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) {
|
private void loadCollision(TiledMapTileLayer layer) {
|
||||||
for (int x = 0; x < layer.getWidth(); x++) {
|
for (int x = 0; x < layer.getWidth(); x++) {
|
||||||
for (int y = 0; y < layer.getHeight(); y++) {
|
for (int y = 0; y < layer.getHeight(); y++) {
|
||||||
@@ -408,15 +404,11 @@ public class MapStage extends GameStage {
|
|||||||
!sourceMap.isEmpty() && targetMap.equals(sourceMap);
|
!sourceMap.isEmpty() && targetMap.equals(sourceMap);
|
||||||
|
|
||||||
EntryActor entry = new EntryActor(this, id, prop.get("teleport").toString(), x, y, w, h, prop.get("direction").toString());
|
EntryActor entry = new EntryActor(this, id, prop.get("teleport").toString(), x, y, w, h, prop.get("direction").toString());
|
||||||
if((prop.containsKey("spawn")&& prop.get("spawn").toString().equals("true"))&&spawnPlayerThere)
|
if ((prop.containsKey("spawn") && prop.get("spawn").toString().equals("true")) && spawnPlayerThere) {
|
||||||
{
|
|
||||||
spawnClassified.add(entry);
|
spawnClassified.add(entry);
|
||||||
}else if(spawnPlayerThere)
|
} else if (spawnPlayerThere) {
|
||||||
{
|
|
||||||
sourceMapMatch.add(entry);
|
sourceMapMatch.add(entry);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
otherEntries.add(entry);
|
otherEntries.add(entry);
|
||||||
}
|
}
|
||||||
addMapActor(obj, entry);
|
addMapActor(obj, entry);
|
||||||
@@ -484,7 +476,6 @@ public class MapStage extends GameStage {
|
|||||||
addMapActor(obj, new OnCollide(() -> Forge.switchScene(SpellSmithScene.instance())));
|
addMapActor(obj, new OnCollide(() -> Forge.switchScene(SpellSmithScene.instance())));
|
||||||
break;
|
break;
|
||||||
case "arena":
|
case "arena":
|
||||||
|
|
||||||
addMapActor(obj, new OnCollide(() -> {
|
addMapActor(obj, new OnCollide(() -> {
|
||||||
ArenaData arenaData = JSONStringLoader.parse(ArenaData.class, prop.get("arena").toString(), "");
|
ArenaData arenaData = JSONStringLoader.parse(ArenaData.class, prop.get("arena").toString(), "");
|
||||||
ArenaScene.instance().loadArenaData(arenaData, WorldSave.getCurrentSave().getWorld().getRandom().nextLong());
|
ArenaScene.instance().loadArenaData(arenaData, WorldSave.getCurrentSave().getWorld().getRandom().nextLong());
|
||||||
@@ -696,7 +687,7 @@ public class MapStage extends GameStage {
|
|||||||
if (isInMap && effect != null)
|
if (isInMap && effect != null)
|
||||||
duelScene.setDungeonEffect(effect);
|
duelScene.setDungeonEffect(effect);
|
||||||
Forge.switchScene(duelScene);
|
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() {
|
public boolean isInMap() {
|
||||||
return isInMap;
|
return isInMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDialogOnlyInput() {
|
public boolean isDialogOnlyInput() {
|
||||||
return dialogOnlyInput;
|
return dialogOnlyInput;
|
||||||
}
|
}
|
||||||
@@ -792,18 +784,16 @@ public class MapStage extends GameStage {
|
|||||||
}
|
}
|
||||||
}, 0.10f);
|
}, 0.10f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectNextDialogButton() {
|
private void selectNextDialogButton() {
|
||||||
if (dialogButtonMap.size < 2)
|
if (dialogButtonMap.size < 2)
|
||||||
return;
|
return;
|
||||||
if(!(dialogStage.getKeyboardFocus() instanceof Button))
|
if (!(dialogStage.getKeyboardFocus() instanceof Button)) {
|
||||||
{
|
|
||||||
dialogStage.setKeyboardFocus(dialogButtonMap.first());
|
dialogStage.setKeyboardFocus(dialogButtonMap.first());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(int i=0;i<dialogButtonMap.size;i++)
|
for (int i = 0; i < dialogButtonMap.size; i++) {
|
||||||
{
|
if (dialogStage.getKeyboardFocus() == dialogButtonMap.get(i)) {
|
||||||
if(dialogStage.getKeyboardFocus()==dialogButtonMap.get(i))
|
|
||||||
{
|
|
||||||
i += 1;
|
i += 1;
|
||||||
i %= dialogButtonMap.size;
|
i %= dialogButtonMap.size;
|
||||||
dialogStage.setKeyboardFocus(dialogButtonMap.get(i));
|
dialogStage.setKeyboardFocus(dialogButtonMap.get(i));
|
||||||
@@ -811,18 +801,16 @@ public class MapStage extends GameStage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectPreviousDialogButton() {
|
private void selectPreviousDialogButton() {
|
||||||
if (dialogButtonMap.size < 2)
|
if (dialogButtonMap.size < 2)
|
||||||
return;
|
return;
|
||||||
if(!(dialogStage.getKeyboardFocus() instanceof Button))
|
if (!(dialogStage.getKeyboardFocus() instanceof Button)) {
|
||||||
{
|
|
||||||
dialogStage.setKeyboardFocus(dialogButtonMap.first());
|
dialogStage.setKeyboardFocus(dialogButtonMap.first());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(int i=0;i<dialogButtonMap.size;i++)
|
for (int i = 0; i < dialogButtonMap.size; i++) {
|
||||||
{
|
if (dialogStage.getKeyboardFocus() == dialogButtonMap.get(i)) {
|
||||||
if(dialogStage.getKeyboardFocus()==dialogButtonMap.get(i))
|
|
||||||
{
|
|
||||||
i -= 1;
|
i -= 1;
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
i = dialogButtonMap.size - 1;
|
i = dialogButtonMap.size - 1;
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import java.util.Random;
|
|||||||
* Stage for the over world. Will handle monster spawns
|
* Stage for the over world. Will handle monster spawns
|
||||||
*/
|
*/
|
||||||
public class WorldStage extends GameStage implements SaveFileContent {
|
public class WorldStage extends GameStage implements SaveFileContent {
|
||||||
|
|
||||||
private static WorldStage instance = null;
|
private static WorldStage instance = null;
|
||||||
protected EnemySprite currentMob;
|
protected EnemySprite currentMob;
|
||||||
protected Random rand = MyRandom.getRandom();
|
protected Random rand = MyRandom.getRandom();
|
||||||
@@ -63,9 +62,9 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
return instance == null ? instance = new WorldStage() : instance;
|
return instance == null ? instance = new WorldStage() : instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final Rectangle tempBoundingRect = new Rectangle();
|
final Rectangle tempBoundingRect = new Rectangle();
|
||||||
final Vector2 enemyMoveVector = new Vector2();
|
final Vector2 enemyMoveVector = new Vector2();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActing(float delta) {
|
protected void onActing(float delta) {
|
||||||
if (player.isMoving()) {
|
if (player.isMoving()) {
|
||||||
@@ -75,8 +74,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
|
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Pair<Float, EnemySprite> pair = it.next();
|
Pair<Float, EnemySprite> pair = it.next();
|
||||||
if(globalTimer>=pair.getKey()+dieTimer)
|
if (globalTimer >= pair.getKey() + dieTimer) {
|
||||||
{
|
|
||||||
|
|
||||||
foregroundSprites.removeActor(pair.getValue());
|
foregroundSprites.removeActor(pair.getValue());
|
||||||
it.remove();
|
it.remove();
|
||||||
@@ -84,8 +82,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
}
|
}
|
||||||
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.set(player.getX(), player.getY()).sub(mob.pos());
|
||||||
enemyMoveVector.setLength(mob.speed() * delta);
|
enemyMoveVector.setLength(mob.speed() * delta);
|
||||||
tempBoundingRect.set(mob.getX() + enemyMoveVector.x, mob.getY() + enemyMoveVector.y, mob.getWidth(), mob.getHeight() * mob.getCollisionHeight());
|
tempBoundingRect.set(mob.getX() + enemyMoveVector.x, mob.getY() + enemyMoveVector.y, mob.getWidth(), mob.getHeight() * mob.getCollisionHeight());
|
||||||
@@ -100,20 +97,15 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
{
|
{
|
||||||
mob.moveBy(0, enemyMoveVector.y);
|
mob.moveBy(0, enemyMoveVector.y);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
mob.moveBy(enemyMoveVector.x, 0);
|
mob.moveBy(enemyMoveVector.x, 0);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
mob.moveBy(enemyMoveVector.x, enemyMoveVector.y);
|
mob.moveBy(enemyMoveVector.x, enemyMoveVector.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (player.collideWith(mob)) {
|
if (player.collideWith(mob)) {
|
||||||
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||||
mob.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
mob.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||||
@@ -130,7 +122,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||||
duelScene.initDuels(player, mob);
|
duelScene.initDuels(player, mob);
|
||||||
Forge.switchScene(duelScene);
|
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;
|
currentMob = mob;
|
||||||
WorldSave.getCurrentSave().autoSave();
|
WorldSave.getCurrentSave().autoSave();
|
||||||
});
|
});
|
||||||
@@ -138,16 +130,14 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (Pair<Float, EnemySprite> pair : enemies) {
|
for (Pair<Float, EnemySprite> pair : enemies) {
|
||||||
pair.getValue().setAnimation(CharacterSprite.AnimationTypes.Idle);
|
pair.getValue().setAnimation(CharacterSprite.AnimationTypes.Idle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void removeEnemy(EnemySprite currentMob) {
|
|
||||||
|
|
||||||
|
private void removeEnemy(EnemySprite currentMob) {
|
||||||
currentMob.removeAfterEffects();
|
currentMob.removeAfterEffects();
|
||||||
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
|
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@@ -158,9 +148,9 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWinner(boolean playerIsWinner) {
|
public void setWinner(boolean playerIsWinner) {
|
||||||
|
|
||||||
if (playerIsWinner) {
|
if (playerIsWinner) {
|
||||||
Current.player().win();
|
Current.player().win();
|
||||||
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||||
@@ -179,12 +169,10 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
WorldStage.this.removeEnemy(currentMob);
|
WorldStage.this.removeEnemy(currentMob);
|
||||||
currentMob = null;
|
currentMob = null;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
public void handlePointsOfInterestCollision() {
|
public void handlePointsOfInterestCollision() {
|
||||||
|
|
||||||
for (Actor actor : foregroundSprites.getChildren()) {
|
for (Actor actor : foregroundSprites.getChildren()) {
|
||||||
if (actor.getClass() == PointOfInterestMapSprite.class) {
|
if (actor.getClass() == PointOfInterestMapSprite.class) {
|
||||||
PointOfInterestMapSprite point = (PointOfInterestMapSprite) actor;
|
PointOfInterestMapSprite point = (PointOfInterestMapSprite) actor;
|
||||||
@@ -200,18 +188,17 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isColliding(Rectangle boundingRect)
|
public boolean isColliding(Rectangle boundingRect) {
|
||||||
{
|
|
||||||
if (currentModifications.containsKey(PlayerModification.Fly))
|
if (currentModifications.containsKey(PlayerModification.Fly))
|
||||||
return false;
|
return false;
|
||||||
return WorldSave.getCurrentSave().getWorld().collidingTile(boundingRect);
|
return WorldSave.getCurrentSave().getWorld().collidingTile(boundingRect);
|
||||||
}
|
}
|
||||||
public boolean spawn(String enemy)
|
|
||||||
{
|
public boolean spawn(String enemy) {
|
||||||
return spawn(WorldData.getEnemy(enemy));
|
return spawn(WorldData.getEnemy(enemy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,18 +232,15 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
EnemySprite sprite = new EnemySprite(enemyData);
|
EnemySprite sprite = new EnemySprite(enemyData);
|
||||||
float unit = Scene.getIntendedHeight() / 6f;
|
float unit = Scene.getIntendedHeight() / 6f;
|
||||||
Vector2 spawnPos = new Vector2(1, 1);
|
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.setLength(unit + (unit * 3) * rand.nextFloat());
|
||||||
spawnPos.setAngleDeg(360 * rand.nextFloat());
|
spawnPos.setAngleDeg(360 * rand.nextFloat());
|
||||||
for(int i=0;i<10;i++)
|
for (int i = 0; i < 10; i++) {
|
||||||
{
|
|
||||||
boolean enemyXIsBigger = sprite.getX() > player.getX();
|
boolean enemyXIsBigger = sprite.getX() > player.getX();
|
||||||
boolean enemyYIsBigger = sprite.getY() > player.getY();
|
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.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)));
|
sprite.setY(player.getY() + spawnPos.y + (i * sprite.getHeight() * (enemyYIsBigger ? 1 : -1)));
|
||||||
if(sprite.getData().flying || !WorldSave.getCurrentSave().getWorld().collidingTile(sprite.boundingRect()))
|
if (sprite.getData().flying || !WorldSave.getCurrentSave().getWorld().collidingTile(sprite.boundingRect())) {
|
||||||
{
|
|
||||||
enemies.add(Pair.of(globalTimer, sprite));
|
enemies.add(Pair.of(globalTimer, sprite));
|
||||||
foregroundSprites.addActor(sprite);
|
foregroundSprites.addActor(sprite);
|
||||||
return true;
|
return true;
|
||||||
@@ -287,7 +271,6 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
|
||||||
getPlayerSprite().LoadPos();
|
getPlayerSprite().LoadPos();
|
||||||
getPlayerSprite().setMovementDirection(Vector2.Zero);
|
getPlayerSprite().setMovementDirection(Vector2.Zero);
|
||||||
for (Actor actor : foregroundSprites.getChildren()) {
|
for (Actor actor : foregroundSprites.getChildren()) {
|
||||||
@@ -297,10 +280,8 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
collidingPoint = point;
|
collidingPoint = point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
setBounds(WorldSave.getCurrentSave().getWorld().getWidthInPixels(), WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
setBounds(WorldSave.getCurrentSave().getWorld().getWidthInPixels(), WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
||||||
|
|
||||||
GridPoint2 pos = background.translateFromWorldToChunk(player.getX(), player.getY());
|
GridPoint2 pos = background.translateFromWorldToChunk(player.getX(), player.getY());
|
||||||
background.loadChunk(pos.x, pos.y);
|
background.loadChunk(pos.x, pos.y);
|
||||||
handlePointsOfInterestCollision();
|
handlePointsOfInterestCollision();
|
||||||
@@ -315,15 +296,11 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
public void load(SaveFileData data) {
|
public void load(SaveFileData data) {
|
||||||
try {
|
try {
|
||||||
clearCache();
|
clearCache();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<Float> timeouts = (List<Float>) data.readObject("timeouts");
|
List<Float> timeouts = (List<Float>) data.readObject("timeouts");
|
||||||
List<String> names = (List<String>) data.readObject("names");
|
List<String> names = (List<String>) data.readObject("names");
|
||||||
List<Float> x = (List<Float>) data.readObject("x");
|
List<Float> x = (List<Float>) data.readObject("x");
|
||||||
List<Float> y = (List<Float>) data.readObject("y");
|
List<Float> y = (List<Float>) data.readObject("y");
|
||||||
for(int i=0;i<timeouts.size();i++)
|
for (int i = 0; i < timeouts.size(); i++) {
|
||||||
{
|
|
||||||
EnemySprite sprite = new EnemySprite(WorldData.getEnemy(names.get(i)));
|
EnemySprite sprite = new EnemySprite(WorldData.getEnemy(names.get(i)));
|
||||||
sprite.setX(x.get(i));
|
sprite.setX(x.get(i));
|
||||||
sprite.setY(y.get(i));
|
sprite.setY(y.get(i));
|
||||||
@@ -331,15 +308,12 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
foregroundSprites.addActor(sprite);
|
foregroundSprites.addActor(sprite);
|
||||||
}
|
}
|
||||||
globalTimer = data.readFloat("globalTimer");
|
globalTimer = data.readFloat("globalTimer");
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
|
|
||||||
for (Pair<Float, EnemySprite> enemy : enemies)
|
for (Pair<Float, EnemySprite> enemy : enemies)
|
||||||
foregroundSprites.removeActor(enemy.getValue());
|
foregroundSprites.removeActor(enemy.getValue());
|
||||||
enemies.clear();
|
enemies.clear();
|
||||||
@@ -354,8 +328,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
List<Float> x = new ArrayList<>();
|
List<Float> x = new ArrayList<>();
|
||||||
List<Float> y = new ArrayList<>();
|
List<Float> y = new ArrayList<>();
|
||||||
for(Pair<Float, EnemySprite> enemy:enemies)
|
for (Pair<Float, EnemySprite> enemy : enemies) {
|
||||||
{
|
|
||||||
timeouts.add(enemy.getKey());
|
timeouts.add(enemy.getKey());
|
||||||
names.add(enemy.getValue().getData().name);
|
names.add(enemy.getValue().getData().name);
|
||||||
x.add(enemy.getValue().getX());
|
x.add(enemy.getValue().getX());
|
||||||
@@ -376,23 +349,19 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
|
|
||||||
|
|
||||||
public void removeNearestEnemy() {
|
public void removeNearestEnemy() {
|
||||||
|
|
||||||
float shortestDist = Float.MAX_VALUE;
|
float shortestDist = Float.MAX_VALUE;
|
||||||
EnemySprite enemy = null;
|
EnemySprite enemy = null;
|
||||||
for (Pair<Float, EnemySprite> pair : enemies) {
|
for (Pair<Float, EnemySprite> pair : enemies) {
|
||||||
float dist = pair.getValue().pos().sub(player.pos()).len();
|
float dist = pair.getValue().pos().sub(player.pos()).len();
|
||||||
if(dist<shortestDist)
|
if (dist < shortestDist) {
|
||||||
{
|
|
||||||
shortestDist = dist;
|
shortestDist = dist;
|
||||||
enemy = pair.getValue();
|
enemy = pair.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(enemy!=null)
|
if (enemy != null) {
|
||||||
{
|
|
||||||
enemy.playEffect(Paths.EFFECT_KILL);
|
enemy.playEffect(Paths.EFFECT_KILL);
|
||||||
removeEnemy(enemy);
|
removeEnemy(enemy);
|
||||||
player.playEffect(Paths.TRIGGER_KILL);
|
player.playEffect(Paths.TRIGGER_KILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,13 +229,15 @@ public class Controls {
|
|||||||
switch (fontName) {
|
switch (fontName) {
|
||||||
case "blackbig":
|
case "blackbig":
|
||||||
case "big":
|
case "big":
|
||||||
getSkin().getFont("default").getData().setScale(2, 2);
|
return getBitmapFont("default", 2);
|
||||||
return getSkin().getFont("default");
|
|
||||||
default:
|
default:
|
||||||
getSkin().getFont("default").getData().setScale(1, 1);
|
return getBitmapFont("default", 1);
|
||||||
return getSkin().getFont("default");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static public BitmapFont getBitmapFont(String fontName, float scaleXY) {
|
||||||
|
getSkin().getFont(fontName).getData().setScale(scaleXY, scaleXY);
|
||||||
|
return getSkin().getFont("default");
|
||||||
|
}
|
||||||
|
|
||||||
static public Skin getSkin() {
|
static public Skin getSkin() {
|
||||||
FileHandle skinFile = Config.instance().getFile(Paths.SKIN);
|
FileHandle skinFile = Config.instance().getFile(Paths.SKIN);
|
||||||
|
|||||||
@@ -1,41 +1,44 @@
|
|||||||
package forge.screens;
|
package forge.screens;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
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 com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
import forge.adventure.scene.ArenaScene;
|
import forge.adventure.scene.ArenaScene;
|
||||||
import forge.adventure.util.Config;
|
import forge.adventure.util.Config;
|
||||||
|
import forge.adventure.util.Controls;
|
||||||
import forge.animation.ForgeAnimation;
|
import forge.animation.ForgeAnimation;
|
||||||
import forge.assets.FSkin;
|
import forge.assets.FSkin;
|
||||||
import forge.assets.FSkinImage;
|
import forge.assets.FSkinImage;
|
||||||
import forge.assets.FSkinTexture;
|
import forge.assets.FSkinTexture;
|
||||||
import forge.gui.FThreads;
|
import forge.gui.FThreads;
|
||||||
import forge.gui.GuiBase;
|
|
||||||
import forge.sound.SoundSystem;
|
import forge.sound.SoundSystem;
|
||||||
import forge.toolbox.FContainer;
|
import forge.toolbox.FContainer;
|
||||||
import forge.toolbox.FProgressBar;
|
import forge.toolbox.FProgressBar;
|
||||||
import forge.util.MyRandom;
|
|
||||||
|
|
||||||
public class TransitionScreen extends FContainer {
|
public class TransitionScreen extends FContainer {
|
||||||
private BGAnimation bgAnimation;
|
private BGAnimation bgAnimation;
|
||||||
private FProgressBar progressBar;
|
private FProgressBar progressBar;
|
||||||
Runnable runnable;
|
Runnable runnable;
|
||||||
TextureRegion textureRegion, screenUIBackground, playerAvatar, vsTexture;
|
TextureRegion textureRegion, screenUIBackground, playerAvatar;
|
||||||
String enemyAtlasPath;
|
Texture vsTexture;
|
||||||
|
String enemyAtlasPath, playerAvatarName, enemyAvatarName;
|
||||||
private String message = "";
|
private String message = "";
|
||||||
boolean matchTransition, isloading, isIntro, isFadeMusic, isArenaScene;
|
boolean matchTransition, isloading, isIntro, isFadeMusic, isArenaScene;
|
||||||
|
GlyphLayout layout;
|
||||||
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading) {
|
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading) {
|
||||||
this(proc, screen, enterMatch, loading, false, false);
|
this(proc, screen, enterMatch, loading, false, false);
|
||||||
}
|
}
|
||||||
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading, String loadingMessage) {
|
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) {
|
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 = new FProgressBar();
|
||||||
progressBar.setMaximum(100);
|
progressBar.setMaximum(100);
|
||||||
progressBar.setPercentMode(true);
|
progressBar.setPercentMode(true);
|
||||||
@@ -57,8 +60,11 @@ public class TransitionScreen extends FContainer {
|
|||||||
screenUIBackground = null;
|
screenUIBackground = null;
|
||||||
}
|
}
|
||||||
playerAvatar = player;
|
playerAvatar = player;
|
||||||
enemyAtlasPath = enemy;
|
playerAvatarName = playerName;
|
||||||
vsTexture = vsIcon;
|
enemyAvatarName = enemyName;
|
||||||
|
enemyAtlasPath = enemyAtlas;
|
||||||
|
vsTexture = Forge.getAssets().fallback_skins().get(2);
|
||||||
|
layout = new GlyphLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FProgressBar getProgressBar() {
|
public FProgressBar getProgressBar() {
|
||||||
@@ -128,8 +134,6 @@ public class TransitionScreen extends FContainer {
|
|||||||
g.draw(progressBar);
|
g.draw(progressBar);
|
||||||
}
|
}
|
||||||
} else if (matchTransition) {
|
} else if (matchTransition) {
|
||||||
if (textureRegion != null) {
|
|
||||||
if (isArenaScene) {
|
|
||||||
float screenW = Forge.isLandscapeMode() ? Forge.getScreenWidth() : Forge.getScreenHeight();
|
float screenW = Forge.isLandscapeMode() ? Forge.getScreenWidth() : Forge.getScreenHeight();
|
||||||
float screenH = Forge.isLandscapeMode() ? Forge.getScreenHeight() : Forge.getScreenWidth();
|
float screenH = Forge.isLandscapeMode() ? Forge.getScreenHeight() : Forge.getScreenWidth();
|
||||||
float scale = screenW/4;
|
float scale = screenW/4;
|
||||||
@@ -137,36 +141,52 @@ public class TransitionScreen extends FContainer {
|
|||||||
float centerY = screenH/2;
|
float centerY = screenH/2;
|
||||||
TextureRegion enemyAvatar = Config.instance().getAtlas(enemyAtlasPath).createSprite("Avatar");
|
TextureRegion enemyAvatar = Config.instance().getAtlas(enemyAtlasPath).createSprite("Avatar");
|
||||||
enemyAvatar.flip(true, false);
|
enemyAvatar.flip(true, false);
|
||||||
g.drawChromatic(screenUIBackground, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), 1.1f*percentage);
|
BitmapFont font = Controls.getBitmapFont("default", 5f);
|
||||||
if (Forge.isLandscapeMode()) {
|
if (textureRegion != null) {
|
||||||
g.drawImage(playerAvatar, scale / 3 * percentage, centerY - scale / 2, scale, scale);
|
if (isArenaScene)
|
||||||
g.drawImage(enemyAvatar, screenW - scale - (percentage * scale / 3), centerY - scale / 2, scale, scale);
|
g.drawImage(screenUIBackground, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||||
float vsScale = (screenW / 3.2f) * percentage;
|
else
|
||||||
g.startRotateTransform(screenW/2, screenH/2, 180-(180*percentage));
|
g.drawImage(FSkinTexture.ADV_BG_TEXTURE, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||||
g.drawImage(vsTexture, centerX - vsScale / 2, centerY - vsScale / 2, vsScale, vsScale);
|
g.setAlphaComposite(1-percentage);
|
||||||
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.drawImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||||
g.setAlphaComposite(oldAlpha);
|
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 {
|
} else {
|
||||||
if (GuiBase.isAndroid()) {
|
//enemy
|
||||||
g.drawChromatic(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), percentage);
|
float enemyAvatarX = centerY - scale / 2;
|
||||||
} else {
|
float enemyAvatarY = scale / 3 * percentage;
|
||||||
int max = Forge.isLandscapeMode() ? Forge.getScreenHeight() / 32 : Forge.getScreenWidth() / 32;
|
g.drawImage(enemyAvatar, enemyAvatarX, enemyAvatarY, scale, scale);
|
||||||
int min = Forge.isLandscapeMode() ? Forge.getScreenHeight() / 64 : Forge.getScreenWidth() / 64;
|
//player
|
||||||
int val = MyRandom.getRandom().nextInt(max - min) + min;
|
float playerAvatarX = centerY - scale / 2;
|
||||||
g.drawPixelatedWarp(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), val * percentage);
|
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) {
|
} else if (isIntro) {
|
||||||
if (textureRegion != null) {
|
if (textureRegion != null) {
|
||||||
if (Forge.advStartup) {
|
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