mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Merge pull request #6002 from kevlahnota/master2
add resetPlayerLocation on defeat
This commit is contained in:
@@ -153,7 +153,7 @@ public class GuiMobile implements IGuiBase {
|
|||||||
@Override
|
@Override
|
||||||
public void showImageDialog(final ISkinImage image, final String message, final String title) {
|
public void showImageDialog(final ISkinImage image, final String message, final String title) {
|
||||||
if (Forge.isMobileAdventureMode) {
|
if (Forge.isMobileAdventureMode) {
|
||||||
FThreads.invokeInEdtNowOrLater(() -> MapStage.getInstance().showImageDialog("Achievement Earned\n"+message, (FBufferedImage)image));
|
FThreads.invokeInEdtNowOrLater(() -> MapStage.getInstance().showImageDialog("Achievement Earned\n"+message, (FBufferedImage)image, null));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new WaitCallback<Integer>() {
|
new WaitCallback<Integer>() {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class EntryActor extends MapActor{
|
|||||||
{
|
{
|
||||||
if(targetMap==null||targetMap.isEmpty())
|
if(targetMap==null||targetMap.isEmpty())
|
||||||
{
|
{
|
||||||
stage.exitDungeon();
|
stage.exitDungeon(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class PortalActor extends EntryActor {
|
|||||||
}
|
}
|
||||||
if (currentAnimationType == PortalAnimationTypes.Active) {
|
if (currentAnimationType == PortalAnimationTypes.Active) {
|
||||||
if (targetMap == null || targetMap.isEmpty()) {
|
if (targetMap == null || targetMap.isEmpty()) {
|
||||||
stage.exitDungeon();
|
stage.exitDungeon(false);
|
||||||
} else {
|
} else {
|
||||||
if (targetMap.equals(currentMap)) {
|
if (targetMap.equals(currentMap)) {
|
||||||
stage.spawn(entryTargetObject);
|
stage.spawn(entryTargetObject);
|
||||||
|
|||||||
@@ -737,11 +737,10 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
|
|
||||||
public boolean defeated() {
|
public boolean defeated() {
|
||||||
gold = (int) (gold - (gold * difficultyData.goldLoss));
|
gold = (int) (gold - (gold * difficultyData.goldLoss));
|
||||||
int newLife = (int) (life - (maxLife * difficultyData.lifeLoss));
|
life = (int) (life - (maxLife * difficultyData.lifeLoss));
|
||||||
life = Math.max(1, newLife);
|
|
||||||
onLifeTotalChangeList.emit();
|
onLifeTotalChangeList.emit();
|
||||||
onGoldChangeList.emit();
|
onGoldChangeList.emit();
|
||||||
return newLife < 1;
|
return life < 1;
|
||||||
//If true, the player would have had 0 or less, and thus is actually "defeated" if the caller cares about it
|
//If true, the player would have had 0 or less, and thus is actually "defeated" if the caller cares about it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ public class ConsoleCommandInterpreter {
|
|||||||
});
|
});
|
||||||
registerCommand(new String[]{"leave"}, s -> {
|
registerCommand(new String[]{"leave"}, s -> {
|
||||||
if (!MapStage.getInstance().isInMap()) return "not on a map";
|
if (!MapStage.getInstance().isInMap()) return "not on a map";
|
||||||
MapStage.getInstance().exitDungeon();
|
MapStage.getInstance().exitDungeon(false);
|
||||||
return "Got out";
|
return "Got out";
|
||||||
});
|
});
|
||||||
registerCommand(new String[]{"debug", "collision"}, s -> {
|
registerCommand(new String[]{"debug", "collision"}, s -> {
|
||||||
|
|||||||
@@ -882,7 +882,7 @@ public class GameHUD extends Stage {
|
|||||||
@Override
|
@Override
|
||||||
public boolean act(float v) {
|
public boolean act(float v) {
|
||||||
if (exitDungeon) {
|
if (exitDungeon) {
|
||||||
MapStage.getInstance().exitDungeon();
|
MapStage.getInstance().exitDungeon(false);
|
||||||
setDisabled(exitToWorldMapActor, true, "[%120][+ExitToWorldMap]", "\uFF0F");
|
setDisabled(exitToWorldMapActor, true, "[%120][+ExitToWorldMap]", "\uFF0F");
|
||||||
setDisabled(bookmarkActor, true, "[%120][+Bookmark]", "\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.StartScene;
|
||||||
import forge.adventure.scene.TileMapScene;
|
import forge.adventure.scene.TileMapScene;
|
||||||
import forge.adventure.util.Controls;
|
import forge.adventure.util.Controls;
|
||||||
|
import forge.adventure.util.Current;
|
||||||
import forge.adventure.util.KeyBinding;
|
import forge.adventure.util.KeyBinding;
|
||||||
import forge.adventure.util.MapDialog;
|
import forge.adventure.util.MapDialog;
|
||||||
import forge.adventure.util.Paths;
|
import forge.adventure.util.Paths;
|
||||||
@@ -46,7 +47,9 @@ import forge.card.ColorSet;
|
|||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckProxy;
|
import forge.deck.DeckProxy;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
|
import forge.gui.FThreads;
|
||||||
import forge.gui.GuiBase;
|
import forge.gui.GuiBase;
|
||||||
|
import forge.screens.TransitionScreen;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -144,12 +147,12 @@ public abstract class GameStage extends Stage {
|
|||||||
showDialog();
|
showDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showImageDialog(String message, FBufferedImage fb) {
|
public void showImageDialog(String message, FBufferedImage fb, Runnable runnable) {
|
||||||
dialog.getContentTable().clear();
|
dialog.getContentTable().clear();
|
||||||
dialog.getButtonTable().clear();
|
dialog.getButtonTable().clear();
|
||||||
dialog.clearListeners();
|
dialog.clearListeners();
|
||||||
|
|
||||||
if (fb.getTexture() != null) {
|
if (fb != null && fb.getTexture() != null) {
|
||||||
TextureRegion tr = new TextureRegion(fb.getTexture());
|
TextureRegion tr = new TextureRegion(fb.getTexture());
|
||||||
tr.flip(true, true);
|
tr.flip(true, true);
|
||||||
Image image = new Image(tr);
|
Image image = new Image(tr);
|
||||||
@@ -166,9 +169,13 @@ public abstract class GameStage extends Stage {
|
|||||||
Timer.schedule(new Timer.Task() {
|
Timer.schedule(new Timer.Task() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
fb.dispose();
|
if (fb != null)
|
||||||
|
fb.dispose();
|
||||||
}
|
}
|
||||||
}, 0.5f);
|
}, 0.5f);
|
||||||
|
if (runnable != null) {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
})).width(240f);
|
})).width(240f);
|
||||||
dialog.setKeepWithinStage(true);
|
dialog.setKeepWithinStage(true);
|
||||||
setDialogStage(GameHUD.getInstance());
|
setDialogStage(GameHUD.getInstance());
|
||||||
@@ -634,4 +641,17 @@ public abstract class GameStage extends Stage {
|
|||||||
teleported(position);
|
teleported(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetPlayerLocation()
|
||||||
|
{
|
||||||
|
PointOfInterest poi = Current.world().findPointsOfInterest("Spawn");
|
||||||
|
if (poi != null) {
|
||||||
|
showImageDialog(Forge.getLocalizer().getMessage("lblYouDied", Current.player().getName()), null,
|
||||||
|
() -> FThreads.invokeInEdtNowOrLater(() -> Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||||
|
WorldStage.getInstance().setPosition(new Vector2(poi.getPosition().x - 16f, poi.getPosition().y + 16f));
|
||||||
|
WorldStage.getInstance().loadPOI(poi);
|
||||||
|
Forge.clearTransitionScreen();
|
||||||
|
}, null, false, true, false, false))));
|
||||||
|
}//Spawn shouldn't be null
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ public class MapStage extends GameStage {
|
|||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
case "exit":
|
case "exit":
|
||||||
addMapActor(obj, new OnCollide(MapStage.this::exitDungeon));
|
addMapActor(obj, new OnCollide(() -> MapStage.this.exitDungeon(false)));
|
||||||
break;
|
break;
|
||||||
case "dialog":
|
case "dialog":
|
||||||
if (obj instanceof TiledMapTileMapObject) {
|
if (obj instanceof TiledMapTileMapObject) {
|
||||||
@@ -749,13 +749,15 @@ public class MapStage extends GameStage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean exitDungeon() {
|
public boolean exitDungeon(boolean defeated) {
|
||||||
WorldSave.getCurrentSave().autoSave();
|
WorldSave.getCurrentSave().autoSave();
|
||||||
AdventureQuestController.instance().updateQuestsLeave();
|
AdventureQuestController.instance().updateQuestsLeave();
|
||||||
clearIsInMap();
|
clearIsInMap();
|
||||||
AdventureQuestController.instance().showQuestDialogs(this);
|
AdventureQuestController.instance().showQuestDialogs(this);
|
||||||
isLoadingMatch = false;
|
isLoadingMatch = false;
|
||||||
effect = null; //Reset dungeon effects.
|
effect = null; //Reset dungeon effects.
|
||||||
|
if (defeated)
|
||||||
|
WorldStage.getInstance().resetPlayerLocation();
|
||||||
Forge.switchScene(GameScene.instance());
|
Forge.switchScene(GameScene.instance());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -799,18 +801,18 @@ public class MapStage extends GameStage {
|
|||||||
AdventureQuestController.instance().updateQuestsLose(currentMob);
|
AdventureQuestController.instance().updateQuestsLose(currentMob);
|
||||||
AdventureQuestController.instance().showQuestDialogs(MapStage.this);
|
AdventureQuestController.instance().showQuestDialogs(MapStage.this);
|
||||||
boolean defeated = Current.player().defeated();
|
boolean defeated = Current.player().defeated();
|
||||||
if (canFailDungeon && defeated) {
|
//If hardcore mode is added, check and redirect to game over screen here
|
||||||
//If hardcore mode is added, check and redirect to game over screen here
|
if (canFailDungeon && !defeated)
|
||||||
dungeonFailedDialog();
|
dungeonFailedDialog(true);
|
||||||
exitDungeon();
|
else
|
||||||
}
|
exitDungeon(defeated);
|
||||||
MapStage.this.stop();
|
MapStage.this.stop();
|
||||||
currentMob = null;
|
currentMob = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dungeonFailedDialog() {
|
private void dungeonFailedDialog(boolean exit) {
|
||||||
dialog.getButtonTable().clear();
|
dialog.getButtonTable().clear();
|
||||||
dialog.getContentTable().clear();
|
dialog.getContentTable().clear();
|
||||||
dialog.clearListeners();
|
dialog.clearListeners();
|
||||||
@@ -829,7 +831,8 @@ public class MapStage extends GameStage {
|
|||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
L.skipToTheEnd();
|
L.skipToTheEnd();
|
||||||
super.clicked(event, x, y);
|
super.clicked(event, x, y);
|
||||||
//exitDungeon();
|
if (exit)
|
||||||
|
exitDungeon(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialog.getButtonTable().add(ok).width(240f);
|
dialog.getButtonTable().add(ok).width(240f);
|
||||||
|
|||||||
@@ -188,11 +188,14 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
currentMob.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
currentMob.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||||
startPause(0.5f, () -> {
|
startPause(0.5f, () -> {
|
||||||
currentMob.resetCollisionHeight();
|
currentMob.resetCollisionHeight();
|
||||||
Current.player().defeated();
|
boolean defeated = Current.player().defeated();
|
||||||
AdventureQuestController.instance().updateQuestsLose(currentMob);
|
AdventureQuestController.instance().updateQuestsLose(currentMob);
|
||||||
AdventureQuestController.instance().showQuestDialogs(MapStage.getInstance());
|
AdventureQuestController.instance().showQuestDialogs(MapStage.getInstance());
|
||||||
WorldStage.this.removeEnemy(currentMob);
|
WorldStage.this.removeEnemy(currentMob);
|
||||||
currentMob = null;
|
currentMob = null;
|
||||||
|
if (defeated) {
|
||||||
|
WorldStage.getInstance().resetPlayerLocation();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,17 +212,9 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
|||||||
if (point == collidingPoint) {
|
if (point == collidingPoint) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
WorldSave.getCurrentSave().autoSave();
|
||||||
WorldSave.getCurrentSave().autoSave();
|
loadPOI(point.getPointOfInterest());
|
||||||
TileMapScene.instance().load(point.getPointOfInterest());
|
point.getMapSprite().checkOut();
|
||||||
stop();
|
|
||||||
TileMapScene.instance().setFromWorldMap(true);
|
|
||||||
Forge.switchScene(TileMapScene.instance());
|
|
||||||
point.getMapSprite().checkOut();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Error loading map...");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (point == collidingPoint) {
|
if (point == collidingPoint) {
|
||||||
collidingPoint = null;
|
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
|
@Override
|
||||||
public boolean isColliding(Rectangle boundingRect) {
|
public boolean isColliding(Rectangle boundingRect) {
|
||||||
if (currentModifications.containsKey(PlayerModification.Fly))
|
if (currentModifications.containsKey(PlayerModification.Fly))
|
||||||
|
|||||||
@@ -3420,3 +3420,4 @@ AdvBossIntro32=Nicht blinzeln!
|
|||||||
AdvBossIntro33=Hier kann man nicht verlieren!
|
AdvBossIntro33=Hier kann man nicht verlieren!
|
||||||
AdvBossIntro34=Es gibt kein Zurück!
|
AdvBossIntro34=Es gibt kein Zurück!
|
||||||
AdvBossIntro35=Jetzt geht es um alles oder nichts!
|
AdvBossIntro35=Jetzt geht es um alles oder nichts!
|
||||||
|
lblYouDied={0}, du bist gestorben!!!
|
||||||
@@ -3153,3 +3153,4 @@ AdvBossIntro32=Don't blink!
|
|||||||
AdvBossIntro33=You can't lose here!
|
AdvBossIntro33=You can't lose here!
|
||||||
AdvBossIntro34=There's no turning back!
|
AdvBossIntro34=There's no turning back!
|
||||||
AdvBossIntro35=It's all or nothing now!
|
AdvBossIntro35=It's all or nothing now!
|
||||||
|
lblYouDied={0}, You Died!!!
|
||||||
@@ -3434,3 +3434,4 @@ AdvBossIntro32=¡No parpadees!
|
|||||||
AdvBossIntro33=¡No puedes perder aquí!
|
AdvBossIntro33=¡No puedes perder aquí!
|
||||||
AdvBossIntro34=¡No hay marcha atrás!
|
AdvBossIntro34=¡No hay marcha atrás!
|
||||||
AdvBossIntro35=¡Ahora es todo o nada!
|
AdvBossIntro35=¡Ahora es todo o nada!
|
||||||
|
lblYouDied={0}, ¡¡¡Moriste!!!
|
||||||
@@ -3428,3 +3428,4 @@ AdvBossIntro32=Ne clignez pas des yeux !
|
|||||||
AdvBossIntro33=Vous ne pouvez pas perdre ici !
|
AdvBossIntro33=Vous ne pouvez pas perdre ici !
|
||||||
AdvBossIntro34=Il n'y a pas de retour en arrière!
|
AdvBossIntro34=Il n'y a pas de retour en arrière!
|
||||||
AdvBossIntro35=C'est tout ou rien maintenant !
|
AdvBossIntro35=C'est tout ou rien maintenant !
|
||||||
|
lblYouDied={0}, tu es mort !!!
|
||||||
@@ -3426,3 +3426,4 @@ AdvBossIntro32=Non sbattere le palpebre!
|
|||||||
AdvBossIntro33=Non puoi perdere qui!
|
AdvBossIntro33=Non puoi perdere qui!
|
||||||
AdvBossIntro34=Non si può tornare indietro!
|
AdvBossIntro34=Non si può tornare indietro!
|
||||||
AdvBossIntro35=Adesso è tutto o niente!
|
AdvBossIntro35=Adesso è tutto o niente!
|
||||||
|
lblYouDied={0}, sei morto!!!
|
||||||
@@ -3422,3 +3422,4 @@ AdvBossIntro32=瞬きしないでください!
|
|||||||
AdvBossIntro33=ここで負けるわけにはいかない!
|
AdvBossIntro33=ここで負けるわけにはいかない!
|
||||||
AdvBossIntro34=もう後戻りはできない!
|
AdvBossIntro34=もう後戻りはできない!
|
||||||
AdvBossIntro35=もう、オール・オア・ナッシングだ!
|
AdvBossIntro35=もう、オール・オア・ナッシングだ!
|
||||||
|
lblYouDied={0}、死んだ!!!
|
||||||
@@ -3512,3 +3512,4 @@ AdvBossIntro32=Não pisque!
|
|||||||
AdvBossIntro33=Você não pode perder aqui!
|
AdvBossIntro33=Você não pode perder aqui!
|
||||||
AdvBossIntro34=Não há como voltar atrás!
|
AdvBossIntro34=Não há como voltar atrás!
|
||||||
AdvBossIntro35=É tudo ou nada agora!
|
AdvBossIntro35=É tudo ou nada agora!
|
||||||
|
lblYouDied={0}, você morreu!!!
|
||||||
@@ -3413,3 +3413,4 @@ AdvBossIntro32=别眨眼!
|
|||||||
AdvBossIntro33=在这里你不能输!
|
AdvBossIntro33=在这里你不能输!
|
||||||
AdvBossIntro34=没有回头路了!
|
AdvBossIntro34=没有回头路了!
|
||||||
AdvBossIntro35=现在要么全有要么全无!
|
AdvBossIntro35=现在要么全有要么全无!
|
||||||
|
lblYouDied={0},你死了!!!
|
||||||
Reference in New Issue
Block a user