mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
add resetPlayerLocation on defeat
This commit is contained in:
@@ -43,7 +43,7 @@ public class EntryActor extends MapActor{
|
||||
{
|
||||
if(targetMap==null||targetMap.isEmpty())
|
||||
{
|
||||
stage.exitDungeon();
|
||||
stage.exitDungeon(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PortalActor extends EntryActor {
|
||||
}
|
||||
if (currentAnimationType == PortalAnimationTypes.Active) {
|
||||
if (targetMap == null || targetMap.isEmpty()) {
|
||||
stage.exitDungeon();
|
||||
stage.exitDungeon(false);
|
||||
} else {
|
||||
if (targetMap.equals(currentMap)) {
|
||||
stage.spawn(entryTargetObject);
|
||||
|
||||
@@ -193,7 +193,7 @@ public class ConsoleCommandInterpreter {
|
||||
});
|
||||
registerCommand(new String[]{"leave"}, s -> {
|
||||
if (!MapStage.getInstance().isInMap()) return "not on a map";
|
||||
MapStage.getInstance().exitDungeon();
|
||||
MapStage.getInstance().exitDungeon(false);
|
||||
return "Got out";
|
||||
});
|
||||
registerCommand(new String[]{"debug", "collision"}, s -> {
|
||||
|
||||
@@ -882,7 +882,7 @@ public class GameHUD extends Stage {
|
||||
@Override
|
||||
public boolean act(float v) {
|
||||
if (exitDungeon) {
|
||||
MapStage.getInstance().exitDungeon();
|
||||
MapStage.getInstance().exitDungeon(false);
|
||||
setDisabled(exitToWorldMapActor, true, "[%120][+ExitToWorldMap]", "\uFF0F");
|
||||
setDisabled(bookmarkActor, true, "[%120][+Bookmark]", "\uFF0F");
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import forge.adventure.scene.Scene;
|
||||
import forge.adventure.scene.StartScene;
|
||||
import forge.adventure.scene.TileMapScene;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.adventure.util.Current;
|
||||
import forge.adventure.util.KeyBinding;
|
||||
import forge.adventure.util.MapDialog;
|
||||
import forge.adventure.util.Paths;
|
||||
@@ -46,7 +47,9 @@ import forge.card.ColorSet;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.game.GameType;
|
||||
import forge.gui.FThreads;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.screens.TransitionScreen;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -149,7 +152,7 @@ public abstract class GameStage extends Stage {
|
||||
dialog.getButtonTable().clear();
|
||||
dialog.clearListeners();
|
||||
|
||||
if (fb.getTexture() != null) {
|
||||
if (fb != null && fb.getTexture() != null) {
|
||||
TextureRegion tr = new TextureRegion(fb.getTexture());
|
||||
tr.flip(true, true);
|
||||
Image image = new Image(tr);
|
||||
@@ -166,7 +169,8 @@ public abstract class GameStage extends Stage {
|
||||
Timer.schedule(new Timer.Task() {
|
||||
@Override
|
||||
public void run() {
|
||||
fb.dispose();
|
||||
if (fb != null)
|
||||
fb.dispose();
|
||||
}
|
||||
}, 0.5f);
|
||||
})).width(240f);
|
||||
@@ -634,4 +638,22 @@ public abstract class GameStage extends Stage {
|
||||
teleported(position);
|
||||
}
|
||||
|
||||
public void resetPlayerLocation()
|
||||
{
|
||||
PointOfInterest poi = Current.world().findPointsOfInterest("Spawn");
|
||||
if (poi != null) {
|
||||
Timer.schedule(new Timer.Task() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtNowOrLater(() -> Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||
WorldStage.getInstance().setPosition(poi.getPosition());
|
||||
WorldStage.getInstance().loadPOI(poi);
|
||||
Forge.clearTransitionScreen();
|
||||
showImageDialog(Forge.getLocalizer().getMessage("lblYouLostTheLastGame", Current.player().getName()), null);
|
||||
}, null, false, true, false, false)));
|
||||
}
|
||||
}, 0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -605,7 +605,7 @@ public class MapStage extends GameStage {
|
||||
}));
|
||||
break;
|
||||
case "exit":
|
||||
addMapActor(obj, new OnCollide(MapStage.this::exitDungeon));
|
||||
addMapActor(obj, new OnCollide(() -> MapStage.this.exitDungeon(false)));
|
||||
break;
|
||||
case "dialog":
|
||||
if (obj instanceof TiledMapTileMapObject) {
|
||||
@@ -749,13 +749,15 @@ public class MapStage extends GameStage {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean exitDungeon() {
|
||||
public boolean exitDungeon(boolean defeated) {
|
||||
WorldSave.getCurrentSave().autoSave();
|
||||
AdventureQuestController.instance().updateQuestsLeave();
|
||||
clearIsInMap();
|
||||
AdventureQuestController.instance().showQuestDialogs(this);
|
||||
isLoadingMatch = false;
|
||||
effect = null; //Reset dungeon effects.
|
||||
if (defeated)
|
||||
WorldStage.getInstance().resetPlayerLocation();
|
||||
Forge.switchScene(GameScene.instance());
|
||||
return true;
|
||||
}
|
||||
@@ -799,10 +801,11 @@ public class MapStage extends GameStage {
|
||||
AdventureQuestController.instance().updateQuestsLose(currentMob);
|
||||
AdventureQuestController.instance().showQuestDialogs(MapStage.this);
|
||||
boolean defeated = Current.player().defeated();
|
||||
if (canFailDungeon && defeated) {
|
||||
if (defeated) {
|
||||
//If hardcore mode is added, check and redirect to game over screen here
|
||||
dungeonFailedDialog();
|
||||
exitDungeon();
|
||||
if (canFailDungeon)
|
||||
dungeonFailedDialog();
|
||||
exitDungeon(true);
|
||||
}
|
||||
MapStage.this.stop();
|
||||
currentMob = null;
|
||||
|
||||
@@ -188,11 +188,14 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
currentMob.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||
startPause(0.5f, () -> {
|
||||
currentMob.resetCollisionHeight();
|
||||
Current.player().defeated();
|
||||
boolean defeated = Current.player().defeated();
|
||||
AdventureQuestController.instance().updateQuestsLose(currentMob);
|
||||
AdventureQuestController.instance().showQuestDialogs(MapStage.getInstance());
|
||||
WorldStage.this.removeEnemy(currentMob);
|
||||
currentMob = null;
|
||||
if (defeated) {
|
||||
WorldStage.getInstance().resetPlayerLocation();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -209,17 +212,9 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
if (point == collidingPoint) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
WorldSave.getCurrentSave().autoSave();
|
||||
TileMapScene.instance().load(point.getPointOfInterest());
|
||||
stop();
|
||||
TileMapScene.instance().setFromWorldMap(true);
|
||||
Forge.switchScene(TileMapScene.instance());
|
||||
point.getMapSprite().checkOut();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error loading map...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
WorldSave.getCurrentSave().autoSave();
|
||||
loadPOI(point.getPointOfInterest());
|
||||
point.getMapSprite().checkOut();
|
||||
} else {
|
||||
if (point == collidingPoint) {
|
||||
collidingPoint = null;
|
||||
@@ -229,6 +224,18 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadPOI(PointOfInterest poi) {
|
||||
try {
|
||||
TileMapScene.instance().load(poi);
|
||||
stop();
|
||||
TileMapScene.instance().setFromWorldMap(true);
|
||||
Forge.switchScene(TileMapScene.instance());
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error loading map...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isColliding(Rectangle boundingRect) {
|
||||
if (currentModifications.containsKey(PlayerModification.Fly))
|
||||
|
||||
Reference in New Issue
Block a user