Merge branch 'master' into 'master'

[Adventure] Fix World Background & Loading Transition

See merge request core-developers/forge!6314
This commit is contained in:
Anthony Calosa
2022-02-27 11:33:31 +00:00
15 changed files with 299 additions and 278 deletions

View File

@@ -11,9 +11,11 @@ import forge.Forge;
import forge.adventure.character.EnemySprite;
import forge.adventure.data.EnemyData;
import forge.adventure.data.WorldData;
import forge.adventure.player.AdventurePlayer;
import forge.adventure.stage.GameHUD;
import forge.adventure.util.Controls;
import forge.adventure.util.Current;
import forge.adventure.world.WorldSave;
import forge.player.GamePlayerUtil;
import org.apache.commons.lang3.tuple.Pair;
@@ -23,6 +25,7 @@ public class PlayerStatisticScene extends UIScene {
Image avatar;
Label money, life;
Label totalWins;
Label totalLoss;
Label lossWinRatio;
@@ -71,6 +74,22 @@ public class PlayerStatisticScene extends UIScene {
if (avatar != null) {
avatar.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
}
if (life != null) {
AdventurePlayer.current().onLifeChange(new Runnable() {
@Override
public void run() {
life.setText(AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife());
}
});
}
if (money != null) {
WorldSave.getCurrentSave().getPlayer().onGoldChange(new Runnable() {
@Override
public void run() {
money.setText(String.valueOf(AdventurePlayer.current().getGold()));
}
});
}
if (totalWins != null) {
totalWins.setText(Current.player().getStatistic().totalWins());
}
@@ -112,7 +131,8 @@ public class PlayerStatisticScene extends UIScene {
});
avatar = ui.findActor("avatar");
playerName = ui.findActor("playerName");
life = ui.findActor("lifePoints");
money = ui.findActor("money");
totalWins = ui.findActor("totalWins");
totalLoss = ui.findActor("totalLoss");
lossWinRatio = ui.findActor("lossWinRatio");

View File

@@ -110,8 +110,12 @@ public class SaveLoadScene extends UIScene {
stage.setKeyboardFocus(textInput);
} else {
if (WorldSave.load(currentSlot)) {
Forge.setTransitionScreen(new TransitionScreen(null, null, false, true));
Forge.setTransitionScreen(new TransitionScreen(new Runnable() {
@Override
public void run() {
Forge.switchScene(SceneType.GameScene.instance);
}
}, null, false, true));
} else {
Forge.clearTransitionScreen();
}

View File

@@ -39,7 +39,7 @@ public class GameHUD extends Stage {
private final Image miniMapPlayer;
private final Label lifePoints;
private final Label money;
private Image miniMap;
private Image miniMap, gamehud, mapborder, avatarborder;
private TextButton deckActor, menuActor, statsActor;
private boolean deckPressed = false;
private boolean menuPressed = false;
@@ -60,9 +60,12 @@ public class GameHUD extends Stage {
ui = new UIActor(Config.instance().getFile(GuiBase.isAndroid() ? "ui/hud_mobile.json" : "ui/hud.json"));
miniMap = ui.findActor("map");
mapborder = ui.findActor("mapborder");
avatarborder = ui.findActor("avatarborder");
deckActor = ui.findActor("deck");
menuActor = ui.findActor("menu");
statsActor = ui.findActor("statistic");
gamehud = ui.findActor("gamehud");
miniMapPlayer = new Image(new Texture(Config.instance().getFile("ui/minimap_player.png")));
//create touchpad skin
@@ -129,7 +132,6 @@ public class GameHUD extends Stage {
money.setText(String.valueOf(AdventurePlayer.current().getGold()));
}
}) ;
miniMap = ui.findActor("map");
addActor(ui);
addActor(miniMapPlayer);
@@ -241,19 +243,19 @@ public class GameHUD extends Stage {
return true;
}
float uiX = ui.findActor("gamehud").getX();
float uiY = ui.findActor("gamehud").getY();
float uiTop = ui.findActor("gamehud").getTop();
float uiRight = ui.findActor("gamehud").getRight();
float uiX = gamehud.getX();
float uiY = gamehud.getY();
float uiTop = gamehud.getTop();
float uiRight = gamehud.getRight();
//gamehud bounds
if (c.x>=uiX&&c.x<=uiRight&&c.y>=uiY&&c.y<=uiTop) {
return true;
}
float mMapX = ui.findActor("map").getX();
float mMapY = ui.findActor("map").getY();
float mMapT = ui.findActor("map").getTop();
float mMapR = ui.findActor("map").getRight();
float mMapX = miniMap.getX();
float mMapY = miniMap.getY();
float mMapT = miniMap.getTop();
float mMapR = miniMap.getRight();
//map bounds
if (c.x>=mMapX&&c.x<=mMapR&&c.y>=mMapY&&c.y<=mMapT) {
if (MapStage.getInstance().isInMap())
@@ -333,4 +335,23 @@ public class GameHUD extends Stage {
private void menu() {
gameStage.openMenu();
}
public void showHideMap(boolean visible) {
miniMap.setVisible(visible);
mapborder.setVisible(visible);
miniMapPlayer.setVisible(visible);
avatarborder.setVisible(visible);
avatar.setVisible(visible);
lifePoints.setVisible(visible);
money.setVisible(visible);
gamehud.setVisible(visible);
if (visible) {
deckActor.getColor().a = 1f;
menuActor.getColor().a = 1f;
statsActor.getColor().a = 1f;
} else {
deckActor.getColor().a = 0.5f;
menuActor.getColor().a = 0.5f;
statsActor.getColor().a = 0.5f;
}
}
}

View File

@@ -7,7 +7,7 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
import forge.Forge;
import forge.adventure.character.MapActor;
import forge.adventure.character.PlayerSprite;
@@ -33,20 +33,22 @@ public abstract class GameStage extends Stage {
private final float timer = 0;
private float animationTimeout = 0;
public void startPause(int i) {
public void startPause(float i) {
startPause(i, null);
}
public void startPause(int i,Runnable runnable) {
public void startPause(float i, Runnable runnable) {
onEndAction = runnable;
animationTimeout = i;
player.setMovementDirection(Vector2.Zero);
}
public boolean isPaused() {
return animationTimeout > 0;
}
public GameStage() {
super(new StretchViewport(Scene.GetIntendedWidth(), Scene.GetIntendedHeight(), new OrthographicCamera()));
super(new ExtendViewport(Scene.GetIntendedWidth(), Scene.GetIntendedHeight(), new OrthographicCamera()));
WorldSave.getCurrentSave().onLoad(new Runnable() {
@Override
public void run() {
@@ -71,6 +73,7 @@ public abstract class GameStage extends Stage {
public void setWinner(boolean b) {
}
public void setBounds(float width, float height) {
getViewport().setWorldSize(width, height);
}
@@ -93,9 +96,8 @@ public abstract class GameStage extends Stage {
}
Runnable onEndAction;
@Override
public final void act(float delta) {
super.act(delta);
@@ -104,13 +106,11 @@ public abstract class GameStage extends Stage {
animationTimeout -= delta;
return;
}
if(isPaused())
{
if (isPaused()) {
return;
}
if (onEndAction != null) {
onEndAction.run();
@@ -139,14 +139,12 @@ public abstract class GameStage extends Stage {
camera.position.y = Math.min(Math.max(Scene.GetIntendedHeight() / 2f, player.pos().y), getViewport().getWorldHeight() - Scene.GetIntendedHeight() / 2f);
onActing(delta);
}
abstract protected void onActing(float delta);
@Override
public boolean keyDown(int keycode) {
super.keyDown(keycode);
@@ -168,8 +166,7 @@ public abstract class GameStage extends Stage {
}
if (keycode == Input.Keys.F5)//todo config
{
if(!((TileMapScene)SceneType.TileMapScene.instance).currentMap().isInMap())
{
if (!((TileMapScene) SceneType.TileMapScene.instance).currentMap().isInMap()) {
GetPlayer().storePos();
WorldSave.getCurrentSave().header.createPreview();
WorldSave.getCurrentSave().quickSave();
@@ -178,14 +175,12 @@ public abstract class GameStage extends Stage {
}
if (keycode == Input.Keys.F8)//todo config
{
if(!((TileMapScene)SceneType.TileMapScene.instance).currentMap().isInMap())
{
if (!((TileMapScene) SceneType.TileMapScene.instance).currentMap().isInMap()) {
WorldSave.getCurrentSave().quickLoad();
enter();
}
}
if (keycode == Input.Keys.F12)
{
if (keycode == Input.Keys.F12) {
debugCollision(true);
for (Actor actor : foregroundSprites.getChildren()) {
if (actor instanceof MapActor) {
@@ -194,8 +189,7 @@ public abstract class GameStage extends Stage {
}
player.setBoundDebug(true);
}
if (keycode == Input.Keys.F11)
{
if (keycode == Input.Keys.F11) {
debugCollision(false);
for (Actor actor : foregroundSprites.getChildren()) {
if (actor instanceof MapActor) {
@@ -204,12 +198,10 @@ public abstract class GameStage extends Stage {
}
player.setBoundDebug(false);
}
if (keycode == Input.Keys.F10)
{
if (keycode == Input.Keys.F10) {
setDebugAll(true);
}
if (keycode == Input.Keys.F9)
{
if (keycode == Input.Keys.F9) {
setDebugAll(false);
}
return true;
@@ -262,6 +254,7 @@ public abstract class GameStage extends Stage {
touchY = -1;
player.stop();
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
stop();
@@ -304,25 +297,21 @@ public abstract class GameStage extends Stage {
stop();
}
public boolean isColliding(Rectangle boundingRect)
{
public boolean isColliding(Rectangle boundingRect) {
return false;
}
public void prepareCollision(Vector2 pos, Vector2 direction, Rectangle boundingRect)
{
public void prepareCollision(Vector2 pos, Vector2 direction, Rectangle boundingRect) {
}
public Vector2 adjustMovement( Vector2 direction, Rectangle boundingRect)
{
public Vector2 adjustMovement(Vector2 direction, Rectangle boundingRect) {
Vector2 adjDirX = direction.cpy();
Vector2 adjDirY = direction.cpy();
boolean foundX = false;
boolean foundY = false;
while(true)
{
while (true) {
if(!isColliding(new Rectangle(boundingRect.x+adjDirX.x,boundingRect.y+adjDirX.y, boundingRect.width, boundingRect.height)))
{
if (!isColliding(new Rectangle(boundingRect.x + adjDirX.x, boundingRect.y + adjDirX.y, boundingRect.width, boundingRect.height))) {
foundX = true;
break;
}
@@ -334,10 +323,8 @@ public abstract class GameStage extends Stage {
else
adjDirX.x = Math.round(Math.max(0, adjDirX.x + 1));
}
while(true)
{
if(!isColliding(new Rectangle(boundingRect.x+adjDirY.x,boundingRect.y+adjDirY.y, boundingRect.width, boundingRect.height)))
{
while (true) {
if (!isColliding(new Rectangle(boundingRect.x + adjDirY.x, boundingRect.y + adjDirY.y, boundingRect.width, boundingRect.height))) {
foundY = true;
break;
}

View File

@@ -2,6 +2,7 @@ package forge.adventure.stage;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.maps.MapLayer;
import com.badlogic.gdx.maps.MapObject;
import com.badlogic.gdx.maps.MapProperties;
@@ -27,6 +28,7 @@ import forge.adventure.data.WorldData;
import forge.adventure.pointofintrest.PointOfInterestChanges;
import forge.adventure.scene.DuelScene;
import forge.adventure.scene.RewardScene;
import forge.adventure.scene.Scene;
import forge.adventure.scene.SceneType;
import forge.adventure.util.Config;
import forge.adventure.util.Current;
@@ -62,20 +64,22 @@ public class MapStage extends GameStage {
private final Vector2 oldPosition2 = new Vector2();
private final Vector2 oldPosition3 = new Vector2();
private final Vector2 oldPosition4 = new Vector2();
private boolean isLoadingMatch = false;
public void clearIsInMap() {
isInMap = false;
GameHUD.getInstance().showHideMap(true);
}
public MapLayer getSpriteLayer()
{
public MapLayer getSpriteLayer() {
return spriteLayer;
}
public PointOfInterestChanges getChanges()
{
public PointOfInterestChanges getChanges() {
return changes;
}
public static MapStage getInstance() {
return instance == null ? instance = new MapStage() : instance;
}
@@ -88,39 +92,36 @@ public class MapStage extends GameStage {
actors.add(newActor);
foregroundSprites.addActor(newActor);
}
public void addMapActor(MapActor newActor) {
actors.add(newActor);
foregroundSprites.addActor(newActor);
}
@Override
public boolean isColliding( Rectangle adjustedBoundingRect)
{
for(Rectangle collision:currentCollidingRectangles)
{
if(collision.overlaps(adjustedBoundingRect))
{
public boolean isColliding(Rectangle adjustedBoundingRect) {
for (Rectangle collision : currentCollidingRectangles) {
if (collision.overlaps(adjustedBoundingRect)) {
return true;
}
}
return false;
}
final ArrayList<Rectangle> currentCollidingRectangles = new ArrayList<>();
@Override
public void prepareCollision(Vector2 pos, Vector2 direction, Rectangle boundingRect)
{
public void prepareCollision(Vector2 pos, Vector2 direction, Rectangle boundingRect) {
currentCollidingRectangles.clear();
int x1 = (int) (Math.min(boundingRect.x, boundingRect.x + direction.x) / tileWidth);
int y1 = (int) (Math.min(boundingRect.y, boundingRect.y + direction.y) / tileHeight);
int x2 = (int) (Math.min(boundingRect.x + boundingRect.width, boundingRect.x + boundingRect.width + direction.x) / tileWidth);
int y2 = (int) (Math.min(boundingRect.y + boundingRect.height, boundingRect.y + boundingRect.height + direction.y) / tileHeight);
for(int x=x1;x<=x2;x++)
{
for(int y=y1;y<=y2;y++)
{
if(x<0||x>=width||y<0||y>=height)
{
for (int x = x1; x <= x2; x++) {
for (int y = y1; y <= y2; y++) {
if (x < 0 || x >= width || y < 0 || y >= height) {
continue;
}
currentCollidingRectangles.addAll(collision[x][y]);
@@ -130,19 +131,16 @@ public class MapStage extends GameStage {
Group collisionGroup;
@Override
protected void debugCollision(boolean b) {
if(collisionGroup==null)
{
if (collisionGroup == null) {
collisionGroup = new Group();
for (int x = 0; x < collision.length; x++)
{
for (int y = 0; y < collision[x].length; y++)
{
for(Rectangle rectangle:collision[x][y])
{
for (int x = 0; x < collision.length; x++) {
for (int y = 0; y < collision[x].length; y++) {
for (Rectangle rectangle : collision[x][y]) {
MapActor collisionActor = new MapActor();
collisionActor.setBoundDebug(true);
collisionActor.setWidth(rectangle.width);
@@ -155,19 +153,18 @@ public class MapStage extends GameStage {
}
}
if(b)
{
if (b) {
addActor(collisionGroup);
}
else
{
} else {
collisionGroup.remove();
}
}
public void loadMap(TiledMap map,String sourceMap) {
public void loadMap(TiledMap map, String sourceMap) {
isLoadingMatch = false;
isInMap = true;
GameHUD.getInstance().showHideMap(false);
this.map = map;
for (MapActor actor : new Array.ArrayIterator<>(actors)) {
actor.remove();
@@ -184,18 +181,13 @@ public class MapStage extends GameStage {
GetPlayer().stop();
for(MapLayer layer: map.getLayers())
{
if(layer.getProperties().containsKey("spriteLayer")&&layer.getProperties().get("spriteLayer",boolean.class))
{
for (MapLayer layer : map.getLayers()) {
if (layer.getProperties().containsKey("spriteLayer") && layer.getProperties().get("spriteLayer", boolean.class)) {
spriteLayer = layer;
}
if(layer instanceof TiledMapTileLayer)
{
if (layer instanceof TiledMapTileLayer) {
loadCollision((TiledMapTileLayer) layer);
}
else
{
} else {
loadObjects(layer, sourceMap);
}
}
@@ -203,20 +195,16 @@ public class MapStage extends GameStage {
}
private void loadCollision(TiledMapTileLayer layer) {
for(int x=0;x<layer.getWidth();x++)
{
for(int y=0;y<layer.getHeight();y++)
{
for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) {
if (collision[x][y] == null)
collision[x][y] = new ArrayList<>();
ArrayList<Rectangle> map = collision[x][y];
TiledMapTileLayer.Cell cell = layer.getCell(x, y);
if (cell == null)
continue;
for(MapObject collision:cell.getTile().getObjects())
{
if(collision instanceof RectangleMapObject)
{
for (MapObject collision : cell.getTile().getObjects()) {
if (collision instanceof RectangleMapObject) {
Rectangle r = ((RectangleMapObject) collision).getRectangle();
map.add(new Rectangle((Math.round(layer.getTileWidth() * x) + r.x), (Math.round(layer.getTileHeight() * y) + r.y), Math.round(r.width), Math.round(r.height)));
}
@@ -271,13 +259,10 @@ public class MapStage extends GameStage {
Array<ShopData> shops;
if (possibleShops.size() == 0 || shopList.equals(""))
shops = WorldData.getShopList();
else
{
else {
shops = new Array<>();
for(ShopData data:new Array.ArrayIterator<>(WorldData.getShopList()))
{
if(possibleShops.contains(data.name))
{
for (ShopData data : new Array.ArrayIterator<>(WorldData.getShopList())) {
if (possibleShops.contains(data.name)) {
shops.add(data);
}
}
@@ -287,22 +272,18 @@ public class MapStage extends GameStage {
ShopData data = shops.get(WorldSave.getCurrentSave().getWorld().getRandom().nextInt(shops.size));
Array<Reward> ret = new Array<Reward>();
for(RewardData rdata:new Array.ArrayIterator<>(data.rewards))
{
for (RewardData rdata : new Array.ArrayIterator<>(data.rewards)) {
ret.addAll(rdata.generate(false));
}
ShopActor actor = new ShopActor(this, id, ret);
addMapActor(obj, actor);
if(prop.containsKey("signYOffset")&&prop.containsKey("signXOffset"))
{
if (prop.containsKey("signYOffset") && prop.containsKey("signXOffset")) {
try {
TextureSprite sprite = new TextureSprite(Config.instance().getAtlas(data.spriteAtlas).createSprite(data.sprite));
sprite.setX(actor.getX() + Float.parseFloat(prop.get("signXOffset").toString()));
sprite.setY(actor.getY() + Float.parseFloat(prop.get("signYOffset").toString()));
addMapActor(sprite);
}
catch (Exception e)
{
} catch (Exception e) {
System.err.print("Can not create Texture for " + data.sprite + " Obj:" + data);
}
}
@@ -313,21 +294,20 @@ public class MapStage extends GameStage {
}
public boolean exit() {
isInMap=false;
isLoadingMatch = false;
clearIsInMap();
Forge.switchScene(SceneType.GameScene.instance);
return true;
}
@Override
public void setWinner(boolean playerWins) {
isLoadingMatch = false;
if (playerWins) {
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
currentMob.setAnimation(CharacterSprite.AnimationTypes.Death);
startPause(1, new Runnable() {
startPause(0.3f, new Runnable() {
@Override
public void run() {
MapStage.this.getReward();
@@ -336,10 +316,9 @@ public class MapStage extends GameStage {
} else {
player.setAnimation(CharacterSprite.AnimationTypes.Hit);
currentMob.setAnimation(CharacterSprite.AnimationTypes.Attack);
startPause(1, new Runnable() {
startPause(0.5f, new Runnable() {
@Override
public void run() {
player.setAnimation(CharacterSprite.AnimationTypes.Idle);
currentMob.setAnimation(CharacterSprite.AnimationTypes.Idle);
player.setPosition(oldPosition4);
@@ -353,53 +332,53 @@ public class MapStage extends GameStage {
}
protected void getReward()
{
protected void getReward() {
isLoadingMatch = false;
((RewardScene) SceneType.RewardScene.instance).loadRewards(currentMob.getRewards(), RewardScene.Type.Loot, null);
currentMob.remove();
actors.removeValue(currentMob, true);
changes.deleteObject(currentMob.getId());
currentMob = null;
Gdx.input.vibrate(50);
Forge.switchScene(SceneType.RewardScene.instance);
}
@Override
protected void onActing(float delta) {
oldPosition4.set(oldPosition3);
oldPosition3.set(oldPosition2);
oldPosition2.set(oldPosition);
oldPosition.set(player.pos());
for (MapActor actor : new Array.ArrayIterator<>(actors)) {
if (actor.collideWithPlayer(player)) {
if(actor instanceof EnemySprite)
{
if (actor instanceof EnemySprite) {
EnemySprite mob = (EnemySprite) actor;
currentMob = mob;
if(mob.getData().deck==null||mob.getData().deck.isEmpty())
{
if (mob.getData().deck == null || mob.getData().deck.isEmpty()) {
currentMob.setAnimation(CharacterSprite.AnimationTypes.Death);
startPause(1, new Runnable() {
Gdx.input.vibrate(50);
startPause(0.3f, new Runnable() {
@Override
public void run() {
MapStage.this.getReward();
}
});
}
else
{
break;
} else {
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
mob.setAnimation(CharacterSprite.AnimationTypes.Attack);
Gdx.input.vibrate(50);
Forge.setCursor(null, Forge.magnifyToggle ? "1" : "2");
SoundSystem.instance.play(SoundEffectType.ManaBurn, false);
if (!isLoadingMatch) {
isLoadingMatch = true;
Forge.setTransitionScreen(new TransitionScreen(new Runnable() {
@Override
public void run() {
Forge.clearTransitionScreen();
}
}, ScreenUtils.getFrameBufferTexture(), true, false));
startPause(1, new Runnable() {
}
startPause(0.5f, new Runnable() {
@Override
public void run() {
((DuelScene) SceneType.DuelScene.instance).setEnemy(mob);
@@ -407,17 +386,15 @@ public class MapStage extends GameStage {
Forge.switchScene(SceneType.DuelScene.instance);
}
});
break;
}
}
}
}
}
public void setPointOfInterest(PointOfInterestChanges change) {
changes = change;
}

View File

@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import forge.adventure.world.WorldSave;
import forge.gui.GuiBase;
import java.util.ArrayList;
@@ -69,15 +68,6 @@ public class WorldBackground extends Actor {
currentChunkX = pos.x;
currentChunkY = pos.y;
}
batch.disableBlending();
if (GuiBase.isAndroid()) {
//TODO WorldBackground for Android
if (t == null)
t = new Texture(WorldSave.getCurrentSave().getWorld().getBiomeImage2());
batch.draw(t, 0, 0, WorldStage.getInstance().getViewport().getWorldWidth(), WorldStage.getInstance().getViewport().getWorldHeight());
} else {
for (int x = -1; x < 2; x++) {
for (int y = -1; y < 2; y++) {
if (pos.y + y < 0 || pos.x + x < 0 || pos.y >= chunks[0].length || pos.x >= chunks.length)
@@ -87,8 +77,6 @@ public class WorldBackground extends Actor {
batch.draw(getChunkTexture(pos.x + x, pos.y + y), transChunkToWorld(pos.x + x), transChunkToWorld(pos.y + y));
}
}
}
batch.enableBlending();
}
@@ -124,7 +112,7 @@ public class WorldBackground extends Actor {
public Texture getChunkTexture(int x, int y) {
Texture tex = chunks[x][y];
if (tex == null) {
Texture newChunk = new Texture(chunkSize * tileSize, chunkSize * tileSize, Pixmap.Format.RGB888);
Texture newChunk = new Texture(chunkSize * tileSize, chunkSize * tileSize, Pixmap.Format.RGBA8888);
for (int cx = 0; cx < chunkSize; cx++) {
for (int cy = 0; cy < chunkSize; cy++) {
newChunk.draw(WorldSave.getCurrentSave().getWorld().getBiomeSprite(cx + chunkSize * x, cy + chunkSize * y), cx * tileSize, (chunkSize * tileSize) - (cy + 1) * tileSize);
@@ -155,7 +143,7 @@ public class WorldBackground extends Actor {
if(loadingTexture==null)
{
Pixmap loadPix = new Pixmap(chunkSize * tileSize, chunkSize * tileSize, Pixmap.Format.RGB565);
Pixmap loadPix = new Pixmap(chunkSize * tileSize, chunkSize * tileSize, Pixmap.Format.RGBA8888);
loadPix.setColor(0.5f, 0.5f, 0.5f, 1);
loadPix.fill();
loadingTexture = new Texture(loadPix);

View File

@@ -90,7 +90,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
Forge.clearTransitionScreen();
}
}, ScreenUtils.getFrameBufferTexture(), true, false));
startPause(1, new Runnable() {
startPause(0.5f, new Runnable() {
@Override
public void run() {
((DuelScene) SceneType.DuelScene.instance).setEnemy(currentMob);
@@ -129,20 +129,19 @@ public class WorldStage extends GameStage implements SaveFileContent {
if (playerIsWinner) {
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
currentMob.setAnimation(CharacterSprite.AnimationTypes.Death);
startPause(1, new Runnable() {
startPause(0.5f, new Runnable() {
@Override
public void run() {
((RewardScene) SceneType.RewardScene.instance).loadRewards(currentMob.getRewards(), RewardScene.Type.Loot, null);
WorldStage.this.removeEnemy(currentMob);
currentMob = null;
Gdx.input.vibrate(50);
Forge.switchScene(SceneType.RewardScene.instance);
}
});
} else {
player.setAnimation(CharacterSprite.AnimationTypes.Hit);
currentMob.setAnimation(CharacterSprite.AnimationTypes.Attack);
startPause(1, new Runnable() {
startPause(0.5f, new Runnable() {
@Override
public void run() {
Current.player().defeated();

View File

@@ -19,7 +19,7 @@ import java.util.ArrayList;
public class BiomeTexture implements Serializable {
private final BiomeData data;
private final int tileSize;
public Pixmap emptyPixmap = new Pixmap(1, 1, Pixmap.Format.RGB888);
public Pixmap emptyPixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
ArrayList<ArrayList<Pixmap>> images = new ArrayList<>();
ArrayList<ArrayList<Pixmap>> smallImages = new ArrayList<>();
ArrayList<IntMap<Pixmap>> edgeImages = new ArrayList<>();

View File

@@ -34,7 +34,7 @@ public class World implements Disposable, SaveFileContent {
private WorldData data;
private Pixmap biomeImage, biomeImage2;
private Pixmap biomeImage;
private long[][] biomeMap;
private int[][] terrainMap;
private int width;
@@ -135,7 +135,7 @@ public class World implements Disposable, SaveFileContent {
}
public Pixmap getBiomeSprite(int x, int y) {
if (x < 0 || y <= 0 || x >= width || y > height)
return new Pixmap(data.tileSize, data.tileSize, Pixmap.Format.RGB888);
return new Pixmap(data.tileSize, data.tileSize, Pixmap.Format.RGBA8888);
long biomeIndex = getBiome(x, y);
int terrain = getTerrainIndex(x, y);
@@ -242,8 +242,7 @@ public class World implements Disposable, SaveFileContent {
//save at all data
biomeMap = new long[width][height];
terrainMap= new int[width][height];
Pixmap pix = new Pixmap(width, height, Pixmap.Format.RGB888);
Pixmap pix2 = new Pixmap(width, height, Pixmap.Format.RGB888);
Pixmap pix = new Pixmap(width, height, Pixmap.Format.RGBA8888);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
@@ -291,8 +290,6 @@ public class World implements Disposable, SaveFileContent {
color.fromHsv(hsv);
pix.setColor(color.r, color.g, color.b, 1);
pix.drawPixel(x, y);
pix2.setColor(color.r, color.g, color.b, 1);
pix2.drawPixel(x, y);
biomeMap[x][y] |= (1L << biomeIndex);
int terrainCounter=1;
if(biome.terrain==null)
@@ -480,7 +477,6 @@ public class World implements Disposable, SaveFileContent {
}
}
biomeImage = pix;
biomeImage2 = pix2;
return this;//new World();
}
@@ -517,15 +513,6 @@ public class World implements Disposable, SaveFileContent {
return biomeImage;
}
public Pixmap getBiomeImage2() {
if (biomeImage2 == null) {
generateNew(0);
return biomeImage2;
}
return biomeImage2;
}
public List<Pair<Vector2, Integer>> GetMapObjects(int chunkX, int chunkY) {
return mapObjectIds.positions(chunkX, chunkY);
}

View File

@@ -22,7 +22,7 @@ public class WorldSaveHeader implements java.io.Serializable, Disposable {
out.writeUTF(name);
if (preview == null)
preview = new Pixmap(1, 1, Pixmap.Format.RGB888);
preview = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
Serializer.WritePixmap(out, preview, true);
out.writeObject(saveDate);
}
@@ -42,7 +42,7 @@ public class WorldSaveHeader implements java.io.Serializable, Disposable {
public void createPreview() {
Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Pixmap scaled = new Pixmap(WorldSaveHeader.previewImageWidth, (int) (WorldSaveHeader.previewImageWidth / (Scene.GetIntendedWidth() / (float) Scene.GetIntendedHeight())), Pixmap.Format.RGB888);
Pixmap scaled = new Pixmap(WorldSaveHeader.previewImageWidth, (int) (WorldSaveHeader.previewImageWidth / (Scene.GetIntendedWidth() / (float) Scene.GetIntendedHeight())), Pixmap.Format.RGBA8888);
scaled.drawPixmap(pixmap,
0, 0, pixmap.getWidth(), pixmap.getHeight(),
0, 0, scaled.getWidth(), scaled.getHeight());

View File

@@ -22,6 +22,7 @@
},
{
"type": "Image",
"name": "mapborder",
"image": "ui/minimap.png",
"width": 64,
"height": 64,
@@ -38,6 +39,7 @@
},
{
"type": "Image",
"name": "avatarborder",
"image": "ui/avatarhud.png",
"width": 32,
"height": 32,

View File

@@ -22,6 +22,7 @@
},
{
"type": "Image",
"name": "mapborder",
"image": "ui/minimap.png",
"width": 80,
"height": 80,
@@ -38,6 +39,7 @@
},
{
"type": "Image",
"name": "avatarborder",
"image": "ui/avatarhud.png",
"width": 46,
"height": 46,

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -28,7 +28,7 @@
{
"type": "Image",
"name": "avatar",
"x": 350,
"x": 320,
"y": 28,
"width": 64,
"height": 64
@@ -36,7 +36,7 @@
{
"type": "Image",
"image": "ui/avatarhud.png",
"x": 350,
"x": 320,
"y": 28,
"width": 64,
"height": 64
@@ -113,6 +113,40 @@
"x": 335,
"y": 212
},
{
"type": "Image",
"image": "ui/life.png",
"x": 400,
"y": 40,
"width": 16,
"height": 16
},
{
"type": "Image",
"image": "ui/money.png",
"x": 400,
"y": 60,
"width": 16,
"height": 16
},
{
"type": "Label",
"name": "lifePoints",
"font": "black",
"width": 64,
"height": 16,
"x": 420,
"y": 40
},
{
"type": "Label",
"name": "money",
"font": "black",
"width": 64,
"height": 16,
"x": 420,
"y": 60
},
{
"type": "Table",
"font": "default"