mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
update GameHUD
This commit is contained in:
@@ -2,15 +2,20 @@ package forge.adventure.player;
|
|||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.Null;
|
import com.badlogic.gdx.utils.Null;
|
||||||
|
import com.github.tommyettinger.textra.TextraLabel;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.adventure.data.*;
|
import forge.adventure.data.*;
|
||||||
import forge.adventure.pointofintrest.PointOfInterestChanges;
|
import forge.adventure.pointofintrest.PointOfInterestChanges;
|
||||||
import forge.adventure.scene.AdventureDeckEditor;
|
import forge.adventure.scene.AdventureDeckEditor;
|
||||||
import forge.adventure.scene.DeckEditScene;
|
import forge.adventure.scene.DeckEditScene;
|
||||||
|
import forge.adventure.stage.GameHUD;
|
||||||
|
import forge.adventure.stage.GameStage;
|
||||||
import forge.adventure.stage.MapStage;
|
import forge.adventure.stage.MapStage;
|
||||||
|
import forge.adventure.stage.WorldStage;
|
||||||
import forge.adventure.util.*;
|
import forge.adventure.util.*;
|
||||||
import forge.adventure.world.WorldSave;
|
import forge.adventure.world.WorldSave;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
@@ -598,6 +603,28 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
return HeroListData.getRaces().get(Current.player().heroRace);
|
return HeroListData.getRaces().get(Current.player().heroRace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameStage getCurrentGameStage() {
|
||||||
|
if (MapStage.getInstance().isInMap())
|
||||||
|
return MapStage.getInstance();
|
||||||
|
return WorldStage.getInstance();
|
||||||
|
}
|
||||||
|
public void addStatusMessage(String iconName, String message, Integer itemCount, float x, float y) {
|
||||||
|
String symbol = itemCount == null || itemCount < 0 ? "" : " +";
|
||||||
|
String icon = iconName == null ? "" : "[+" + iconName + "]";
|
||||||
|
String count = itemCount == null ? "" : String.valueOf(itemCount);
|
||||||
|
TextraLabel actor = Controls.newTextraLabel("[%95]" + icon + "[WHITE]" + symbol + count + " " + message);
|
||||||
|
actor.setPosition(x, y);
|
||||||
|
actor.addAction(Actions.after(
|
||||||
|
Actions.sequence(
|
||||||
|
Actions.parallel(
|
||||||
|
Actions.moveBy(0f, 5f, 4f),
|
||||||
|
Actions.fadeIn(2f)
|
||||||
|
),
|
||||||
|
Actions.fadeOut(3f),
|
||||||
|
Actions.removeActor()
|
||||||
|
)));
|
||||||
|
GameHUD.getInstance().addActor(actor);
|
||||||
|
}
|
||||||
public void addCard(PaperCard card) {
|
public void addCard(PaperCard card) {
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
newCards.add(card);
|
newCards.add(card);
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ public class GameHUD extends Stage {
|
|||||||
static public GameHUD instance;
|
static public GameHUD instance;
|
||||||
private final GameStage gameStage;
|
private final GameStage gameStage;
|
||||||
private final Image avatar, miniMapPlayer;
|
private final Image avatar, miniMapPlayer;
|
||||||
private final TextraLabel lifePoints;
|
private final TypingLabel lifePoints;
|
||||||
private final TextraLabel money;
|
private final TypingLabel money;
|
||||||
private final TextraLabel shards;
|
private final TypingLabel shards;
|
||||||
private final TextraLabel keys;
|
private final TextraLabel keys;
|
||||||
private final TextraLabel notificationText = Controls.newTextraLabel("");
|
private final TextraLabel notificationText = Controls.newTextraLabel("");
|
||||||
private final Image miniMap, gamehud, mapborder, avatarborder, blank;
|
private final Image miniMap, gamehud, mapborder, avatarborder, blank;
|
||||||
@@ -60,7 +60,7 @@ public class GameHUD extends Stage {
|
|||||||
private final Console console;
|
private final Console console;
|
||||||
float TOUCHPAD_SCALE = 70f, referenceX;
|
float TOUCHPAD_SCALE = 70f, referenceX;
|
||||||
float opacity = 1f;
|
float opacity = 1f;
|
||||||
private boolean debugMap, updatelife;
|
private boolean debugMap;
|
||||||
|
|
||||||
private final Dialog dialog;
|
private final Dialog dialog;
|
||||||
private boolean dialogOnlyInput;
|
private boolean dialogOnlyInput;
|
||||||
@@ -129,8 +129,11 @@ public class GameHUD extends Stage {
|
|||||||
ui.onButtonPress("exittoworldmap", this::exitToWorldMap);
|
ui.onButtonPress("exittoworldmap", this::exitToWorldMap);
|
||||||
ui.onButtonPress("bookmark", this::bookmark);
|
ui.onButtonPress("bookmark", this::bookmark);
|
||||||
lifePoints = ui.findActor("lifePoints");
|
lifePoints = ui.findActor("lifePoints");
|
||||||
|
lifePoints.skipToTheEnd();
|
||||||
shards = ui.findActor("shards");
|
shards = ui.findActor("shards");
|
||||||
|
shards.skipToTheEnd();
|
||||||
money = ui.findActor("money");
|
money = ui.findActor("money");
|
||||||
|
money.skipToTheEnd();
|
||||||
shards.setText("[%95][+Shards] 0");
|
shards.setText("[%95][+Shards] 0");
|
||||||
money.setText("[%95][+Gold] ");
|
money.setText("[%95][+Gold] ");
|
||||||
lifePoints.setText("[%95][+Life] 20/20");
|
lifePoints.setText("[%95][+Life] 20/20");
|
||||||
@@ -139,11 +142,31 @@ public class GameHUD extends Stage {
|
|||||||
scrollPane.setPosition(2, 2);
|
scrollPane.setPosition(2, 2);
|
||||||
scrollPane.setStyle(Controls.getSkin().get("translucent", ScrollPane.ScrollPaneStyle.class));
|
scrollPane.setStyle(Controls.getSkin().get("translucent", ScrollPane.ScrollPaneStyle.class));
|
||||||
addActor(scrollPane);
|
addActor(scrollPane);
|
||||||
AdventurePlayer.current().onLifeChange(() -> lifePoints.setText("[%95][+Life]" + lifepointsTextColor + " " + AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife()));
|
AdventurePlayer.current().onLifeChange(() -> {
|
||||||
AdventurePlayer.current().onShardsChange(() -> shards.setText("[%95][+Shards] " + AdventurePlayer.current().getShards()));
|
String effect = "{EMERGE}";
|
||||||
AdventurePlayer.current().onEquipmentChanged(this::updateAbility);
|
String heartbeat = "";
|
||||||
|
//colored lifepoints
|
||||||
|
if (Current.player().getLife() >= Current.player().getMaxLife()) {
|
||||||
|
//color green if max life
|
||||||
|
lifepointsTextColor = "[GREEN]";
|
||||||
|
} else if (Current.player().getLife() <= 5) {
|
||||||
|
//color red if critical
|
||||||
|
effect = "";
|
||||||
|
heartbeat = "{HEARTBEAT=0.5;0.5}";
|
||||||
|
lifepointsTextColor = "{ENDHEARTBEAT}[RED]";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lifepointsTextColor = "[WHITE]";
|
||||||
|
}
|
||||||
|
lifePoints.restart("[%95]" + heartbeat + "[+Life]" + lifepointsTextColor + effect + " " + AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife());
|
||||||
|
|
||||||
WorldSave.getCurrentSave().getPlayer().onGoldChange(() -> money.setText("[%95][+Gold] " + AdventurePlayer.current().getGold()));
|
});
|
||||||
|
AdventurePlayer.current().onShardsChange(() -> {
|
||||||
|
|
||||||
|
shards.restart("[%95][+Shards] {EMERGE}" + AdventurePlayer.current().getShards());
|
||||||
|
});
|
||||||
|
AdventurePlayer.current().onGoldChange(() -> money.restart("[%95][+Gold] {EMERGE}" + AdventurePlayer.current().getGold()));
|
||||||
|
AdventurePlayer.current().onEquipmentChanged(this::updateAbility);
|
||||||
addActor(ui);
|
addActor(ui);
|
||||||
addActor(miniMapPlayer);
|
addActor(miniMapPlayer);
|
||||||
console = new Console();
|
console = new Console();
|
||||||
@@ -268,7 +291,6 @@ public class GameHUD extends Stage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
updatelife = false;
|
|
||||||
int yPos = (int) gameStage.player.getY();
|
int yPos = (int) gameStage.player.getY();
|
||||||
int xPos = (int) gameStage.player.getX();
|
int xPos = (int) gameStage.player.getX();
|
||||||
act(Gdx.graphics.getDeltaTime()); //act the Hud
|
act(Gdx.graphics.getDeltaTime()); //act the Hud
|
||||||
@@ -281,29 +303,7 @@ public class GameHUD extends Stage {
|
|||||||
!Controls.actorContainsVector(notificationPane, new Vector2(miniMapPlayer.getX(),miniMapPlayer.getY()))
|
!Controls.actorContainsVector(notificationPane, new Vector2(miniMapPlayer.getX(),miniMapPlayer.getY()))
|
||||||
&& (!Controls.actorContainsVector(console, new Vector2(miniMapPlayer.getX(),miniMapPlayer.getY()))
|
&& (!Controls.actorContainsVector(console, new Vector2(miniMapPlayer.getX(),miniMapPlayer.getY()))
|
||||||
|| !console.isVisible())); // prevent drawing on top of console or notifications
|
|| !console.isVisible())); // prevent drawing on top of console or notifications
|
||||||
//colored lifepoints
|
|
||||||
if (Current.player().getLife() >= Current.player().getMaxLife()) {
|
|
||||||
//color green if max life
|
|
||||||
if (!lifepointsTextColor.equals("[GREEN]")) {
|
|
||||||
lifepointsTextColor = "[GREEN]";
|
|
||||||
updatelife = true;
|
|
||||||
}
|
|
||||||
} else if (Current.player().getLife() <= 5) {
|
|
||||||
//color red if critical
|
|
||||||
if (!lifepointsTextColor.equals("[RED]")) {
|
|
||||||
lifepointsTextColor = "[RED]";
|
|
||||||
updatelife = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!lifepointsTextColor.isEmpty()) {
|
|
||||||
lifepointsTextColor = "";
|
|
||||||
updatelife = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (updatelife) {
|
|
||||||
updatelife = false;
|
|
||||||
lifePoints.setText("[%95][+Life]" + lifepointsTextColor + " " + AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife());
|
|
||||||
}
|
|
||||||
if (!MapStage.getInstance().isInMap())
|
if (!MapStage.getInstance().isInMap())
|
||||||
updateMusic();
|
updateMusic();
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.github.tommyettinger.textra.TypingLabel;
|
|||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.adventure.character.*;
|
import forge.adventure.character.*;
|
||||||
import forge.adventure.data.*;
|
import forge.adventure.data.*;
|
||||||
|
import forge.adventure.player.AdventurePlayer;
|
||||||
import forge.adventure.pointofintrest.PointOfInterestChanges;
|
import forge.adventure.pointofintrest.PointOfInterestChanges;
|
||||||
import forge.adventure.scene.*;
|
import forge.adventure.scene.*;
|
||||||
import forge.adventure.util.*;
|
import forge.adventure.util.*;
|
||||||
@@ -1026,20 +1027,42 @@ public class MapStage extends GameStage {
|
|||||||
Gdx.input.vibrate(50);
|
Gdx.input.vibrate(50);
|
||||||
if (Controllers.getCurrent() != null && Controllers.getCurrent().canVibrate())
|
if (Controllers.getCurrent() != null && Controllers.getCurrent().canVibrate())
|
||||||
Controllers.getCurrent().startVibration(100, 1);
|
Controllers.getCurrent().startVibration(100, 1);
|
||||||
startPause(0.1f, () -> { //Switch to item pickup scene.
|
|
||||||
RewardSprite RS = (RewardSprite) actor;
|
RewardSprite RS = (RewardSprite) actor;
|
||||||
RewardScene.instance().loadRewards(RS.getRewards(), RewardScene.Type.Loot, null);
|
Array<Reward> rewards = RS.getRewards();
|
||||||
|
|
||||||
|
if (rewards.size == 1) {
|
||||||
|
Reward reward = rewards.get(0);
|
||||||
|
switch (reward.getType()) {
|
||||||
|
case Life:
|
||||||
|
case Shards:
|
||||||
|
case Gold:
|
||||||
|
String message = Forge.getLocalizer().getMessageorUseDefault("lbl" + reward.getType().name(), reward.getType().name());
|
||||||
|
AdventurePlayer.current().addStatusMessage(reward.getType().name(), message, reward.getCount(), actor.getX(), actor.getY() + player.getHeight());
|
||||||
|
AdventurePlayer.current().addReward(reward);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
showRewardScene(rewards);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showRewardScene(rewards);
|
||||||
|
}
|
||||||
RS.remove();
|
RS.remove();
|
||||||
actors.removeValue(RS, true);
|
actors.removeValue(RS, true);
|
||||||
changes.deleteObject(RS.getId());
|
changes.deleteObject(RS.getId());
|
||||||
Forge.switchScene(RewardScene.instance());
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showRewardScene(Array<Reward> rewards) {
|
||||||
|
startPause(0.1f, () -> {
|
||||||
|
RewardScene.instance().loadRewards(rewards, RewardScene.Type.Loot, null);
|
||||||
|
Forge.switchScene(RewardScene.instance());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
boolean started = false;
|
boolean started = false;
|
||||||
public void beginDuel(EnemySprite mob) {
|
public void beginDuel(EnemySprite mob) {
|
||||||
if (mob == null) return;
|
if (mob == null) return;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
"y": 10
|
"y": 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "lifePoints",
|
"name": "lifePoints",
|
||||||
"font": "default",
|
"font": "default",
|
||||||
"width": 64,
|
"width": 64,
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
"y": 56
|
"y": 56
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "shards",
|
"name": "shards",
|
||||||
"font": "default",
|
"font": "default",
|
||||||
"width": 64,
|
"width": 64,
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
"y": 70
|
"y": 70
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "money",
|
"name": "money",
|
||||||
"font": "default",
|
"font": "default",
|
||||||
"width": 64,
|
"width": 64,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
"y": 10
|
"y": 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "lifePoints",
|
"name": "lifePoints",
|
||||||
"font": "default",
|
"font": "default",
|
||||||
"width": 64,
|
"width": 64,
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
"y": 56
|
"y": 56
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "shards",
|
"name": "shards",
|
||||||
"font": "default",
|
"font": "default",
|
||||||
"width": 64,
|
"width": 64,
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
"y": 70
|
"y": 70
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "money",
|
"name": "money",
|
||||||
"font": "default",
|
"font": "default",
|
||||||
"width": 64,
|
"width": 64,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
"y": 10
|
"y": 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "lifePoints",
|
"name": "lifePoints",
|
||||||
"width": 48,
|
"width": 48,
|
||||||
"height": 3,
|
"height": 3,
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
"y": 62
|
"y": 62
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "shards",
|
"name": "shards",
|
||||||
"font": "default",
|
"font": "default",
|
||||||
"width": 48,
|
"width": 48,
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
"y": 76
|
"y": 76
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "TypingLabel",
|
||||||
"name": "money",
|
"name": "money",
|
||||||
"font": "default",
|
"font": "default",
|
||||||
"width": 48,
|
"width": 48,
|
||||||
|
|||||||
Reference in New Issue
Block a user