expanded teleport actor on maps added capitals

This commit is contained in:
Grimm
2022-08-17 16:57:56 +02:00
parent acaec64078
commit 745e9bc3ee
30 changed files with 2109 additions and 1814 deletions

View File

@@ -37,6 +37,7 @@ public class CharacterSprite extends MapActor {
}
protected void load(String path) {
if(path==null||path.isEmpty())return;
TextureAtlas atlas = Config.instance().getAtlas(path);
/*
for (Texture texture : new ObjectSet.ObjectSetIterator<>( atlas.getTextures()))

View File

@@ -8,17 +8,23 @@ import forge.adventure.util.MapDialog;
/**
* Map actor that will show a text message with optional choices
*/
public class DialogActor extends MapActor {
public class DialogActor extends CharacterSprite {
private final MapStage stage;
private final TextureRegion textureRegion;
private final MapDialog dialog;
public DialogActor(MapStage stage, int id, String S, TextureRegion textureRegion) {
super(id);
super(id,"");
this.stage = stage;
dialog = new MapDialog(S, stage, id);
this.textureRegion = textureRegion;
}
public DialogActor(MapStage stage, int id, String S, String sprite) {
super(id,sprite);
this.stage = stage;
dialog = new MapDialog(S, stage, id);
this.textureRegion = null;
}
@Override
public void onPlayerCollide() {
@@ -29,8 +35,10 @@ public class DialogActor extends MapActor {
@Override
public void draw(Batch batch, float alpha) {
batch.draw(textureRegion, getX(), getY(), getWidth(), getHeight());
super.draw(batch, alpha);
if(textureRegion!=null)
batch.draw(textureRegion, getX(), getY(), getWidth(), getHeight());
else
super.draw(batch, alpha);
}
}

View File

@@ -1,5 +1,6 @@
package forge.adventure.character;
import com.badlogic.gdx.math.Vector2;
import forge.adventure.scene.SceneType;
import forge.adventure.scene.TileMapScene;
import forge.adventure.stage.MapStage;
@@ -12,29 +13,28 @@ public class EntryActor extends MapActor{
private final MapStage stage;
String targetMap;
public EntryActor(MapStage stage,String sourceMap, int id,String targetMap,float x,float y,float w,float h,String direction)
public EntryActor(MapStage stage, int id,String targetMap,float x,float y,float w,float h,String direction,boolean spawnPlayerThere)
{
super(id);
this.stage = stage;
this.targetMap = targetMap;
if((targetMap==null||targetMap.isEmpty()&&sourceMap.isEmpty())||//if target is null and "from world"
!sourceMap.isEmpty()&&targetMap.equals(sourceMap)) //or if source is this target
if(spawnPlayerThere) //or if source is this target
{
switch(direction)
{
case "up":
stage.GetPlayer().setPosition(x,y+h);
stage.GetPlayer().setPosition(x+w/2-stage.GetPlayer().getWidth()/2,y+h);
break;
case "down":
stage.GetPlayer().setPosition(x,y-stage.GetPlayer().getHeight());
stage.GetPlayer().setPosition(x+w/2-stage.GetPlayer().getWidth()/2,y-stage.GetPlayer().getHeight());
break;
case "right":
stage.GetPlayer().setPosition(x-stage.GetPlayer().getWidth(),y);
stage.GetPlayer().setPosition(x-stage.GetPlayer().getWidth(),y+h/2-stage.GetPlayer().getHeight()/2);
break;
case "left":
stage.GetPlayer().setPosition(x+w,y);
stage.GetPlayer().setPosition(x+w,y+h/2-stage.GetPlayer().getHeight()/2);
break;
}

View File

@@ -23,6 +23,13 @@ public class ItemData {
public String iconName;
public boolean questItem=false;
public int cost=1000;
public boolean usableOnMap;
public boolean usableInPoi;
public String commandOnUse;
public int manaNeeded;
public ItemData()
{

View File

@@ -19,6 +19,10 @@ public class PointOfInterestData {
public String sprite;
public String map;
public float radiusFactor;
public float offsetX=0f;
public float offsetY=0f;
public boolean markOnMap;

View File

@@ -46,6 +46,7 @@ public class GameScene extends HudScene {
Forge.clearTransitionScreen();
Forge.clearCurrentScreen();
super.enter();
WorldStage.getInstance().handlePointsOfInterestCollision();
}
}

View File

@@ -78,6 +78,7 @@ public class MapStage extends GameStage {
//These maps are defined as embedded properties within the Tiled maps.
private EffectData effect; //"Dungeon Effect": Character Effect applied to all adversaries within the map.
private boolean preventEscape = false; //Prevents player from escaping the dungeon by any means that aren't an exit.
private boolean foundPlayerSpawn;
public boolean getDialogOnlyInput() {
@@ -343,6 +344,7 @@ public class MapStage extends GameStage {
GetPlayer().stop();
spriteLayer = null;
foundPlayerSpawn=false;
for (MapLayer layer : map.getLayers()) {
if (layer.getProperties().containsKey("spriteLayer") && layer.getProperties().get("spriteLayer", boolean.class)) {
spriteLayer = layer;
@@ -404,7 +406,18 @@ public class MapStage extends GameStage {
float y = Float.parseFloat(prop.get("y").toString());
float w = Float.parseFloat(prop.get("width").toString());
float h = Float.parseFloat(prop.get("height").toString());
EntryActor entry = new EntryActor(this, sourceMap, id, prop.get("teleport").toString(), x, y, w, h, prop.get("direction").toString());
String targetMap=prop.get("teleport").toString();
boolean spawnPlayerThere=(targetMap==null||targetMap.isEmpty()&&sourceMap.isEmpty())||//if target is null and "from world"
!sourceMap.isEmpty()&&targetMap.equals(sourceMap);
if(foundPlayerSpawn)
spawnPlayerThere=false;
if((prop.containsKey("spawn")&&prop.get("spawn").toString()=="true")&&spawnPlayerThere)
{
foundPlayerSpawn=true;
spawnPlayerThere=true;
}//set spawn to option with "spawn" over other entries
EntryActor entry = new EntryActor(this, id, prop.get("teleport").toString(), x, y, w, h, prop.get("direction").toString(),spawnPlayerThere);
addMapActor(obj, entry);
break;
case "reward":
@@ -486,7 +499,11 @@ public class MapStage extends GameStage {
case "dialog":
if(obj instanceof TiledMapTileMapObject) {
TiledMapTileMapObject tiledObj = (TiledMapTileMapObject) obj;
DialogActor dialog = new DialogActor(this, id, prop.get("dialog").toString(), tiledObj.getTextureRegion());
DialogActor dialog;
if(prop.containsKey("sprite"))
dialog= new DialogActor(this, id, prop.get("dialog").toString(), prop.get("sprite").toString());
else
dialog= new DialogActor(this, id, prop.get("dialog").toString(), tiledObj.getTextureRegion());
addMapActor(obj, dialog);
}
break;

View File

@@ -81,7 +81,7 @@ public class WorldBackground extends Actor {
}
private void loadChunk(int x, int y) {
public void loadChunk(int x, int y) {
if (chunksSprites[x][y] == null)
chunksSprites[x][y] = MapSprite.GetMapSprites(x, y);

View File

@@ -1,6 +1,7 @@
package forge.adventure.stage;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
@@ -176,7 +177,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
}
}
private void handlePointsOfInterestCollision() {
public void handlePointsOfInterestCollision() {
for (Actor actor : foregroundSprites.getChildren()) {
if (actor.getClass() == PointOfInterestMapSprite.class) {
@@ -286,6 +287,9 @@ public class WorldStage extends GameStage implements SaveFileContent {
"\nEnemy will use Preconstructed or Random Generated Decks. Genetic AI Decks will be available to some enemies on Hard difficulty.", WorldSave.getCurrentSave().getPlayer().getSelectedDeck());
WorldSave.getCurrentSave().getPlayer().clearAnnounceFantasy();
}
GridPoint2 pos = background.translateFromWorldToChunk(player.getX(), player.getY());
background.loadChunk(pos.x,pos.y);
handlePointsOfInterestCollision();
}
@Override

View File

@@ -426,7 +426,7 @@ public class World implements Disposable, SaveFileContent {
List<Rectangle> otherPoints = new ArrayList<>();
clearTerrain((int) (data.width * data.playerStartPosX), (int) (data.height * data.playerStartPosY), 10);
otherPoints.add(new Rectangle(((float) data.width * data.playerStartPosX * (float) data.tileSize) - data.tileSize * 3, ((float) data.height * data.playerStartPosY * data.tileSize) - data.tileSize * 3, data.tileSize * 6, data.tileSize * 6));
//otherPoints.add(new Rectangle(((float) data.width * data.playerStartPosX * (float) data.tileSize) - data.tileSize * 3, ((float) data.height * data.playerStartPosY * data.tileSize) - data.tileSize * 3, data.tileSize * 6, data.tileSize * 6));
int biomeIndex2 = -1;
for (BiomeData biome : data.GetBiomes()) {
biomeIndex2++;
@@ -443,6 +443,9 @@ public class World implements Disposable, SaveFileContent {
y *= (biome.height * height / 2);
y += (height - (biome.startPointY * height));
y += (poi.offsetY * (biome.height * height));
x += (poi.offsetX * (biome.width * width));
if ((int) x < 0 || (int) y <= 0 || (int) y >= height || (int) x >= width || biomeIndex2 != highestBiome(getBiome((int) x, (int) y))) {
continue;
}
@@ -492,8 +495,16 @@ public class World implements Disposable, SaveFileContent {
Color color = biome.GetColor();
pix.setColor(color.r, 0.1f, 0.1f, 1);
pix.fillRectangle((int) x / data.tileSize - 3, height - (int) y / data.tileSize - 3, 6, 6);
if(poi.markOnMap)
{
pix.setColor(0.1f, 0.1f, 1f, 1);
pix.fillCircle((int) x / data.tileSize - 3, height - (int) y / data.tileSize - 3, 10);
}
else
{
pix.setColor(1, 0.1f, 0.1f, 1);
pix.fillCircle((int) x / data.tileSize - 3, height - (int) y / data.tileSize - 3, 3);
}
if (poi.type != null && poi.type.equals("town")) {