mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
update BuyButton for RewardScene
This commit is contained in:
@@ -41,12 +41,13 @@ public class RewardScene extends UIScene {
|
|||||||
private PointOfInterestChanges changes;
|
private PointOfInterestChanges changes;
|
||||||
|
|
||||||
public static RewardScene instance() {
|
public static RewardScene instance() {
|
||||||
if(object==null)
|
if (object == null)
|
||||||
object=new RewardScene();
|
object = new RewardScene();
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showTooltips = false;
|
private boolean showTooltips = false;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
Shop,
|
Shop,
|
||||||
Loot,
|
Loot,
|
||||||
@@ -55,7 +56,7 @@ public class RewardScene extends UIScene {
|
|||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
Array<Actor> generated = new Array<>();
|
Array<Actor> generated = new Array<>();
|
||||||
static public final float CARD_WIDTH = 550f ;
|
static public final float CARD_WIDTH = 550f;
|
||||||
static public final float CARD_HEIGHT = 400f;
|
static public final float CARD_HEIGHT = 400f;
|
||||||
static public final float CARD_WIDTH_TO_HEIGHT = CARD_WIDTH / CARD_HEIGHT;
|
static public final float CARD_WIDTH_TO_HEIGHT = CARD_WIDTH / CARD_HEIGHT;
|
||||||
ItemPool<PaperCard> collectionPool = null;
|
ItemPool<PaperCard> collectionPool = null;
|
||||||
@@ -65,7 +66,7 @@ public class RewardScene extends UIScene {
|
|||||||
super(Forge.isLandscapeMode() ? "ui/items.json" : "ui/items_portrait.json");
|
super(Forge.isLandscapeMode() ? "ui/items.json" : "ui/items_portrait.json");
|
||||||
|
|
||||||
playerGold = Controls.newAccountingLabel(ui.findActor("playerGold"), false);
|
playerGold = Controls.newAccountingLabel(ui.findActor("playerGold"), false);
|
||||||
playerShards = Controls.newAccountingLabel(ui.findActor("playerShards"),true);
|
playerShards = Controls.newAccountingLabel(ui.findActor("playerShards"), true);
|
||||||
shopNameLabel = ui.findActor("shopName");
|
shopNameLabel = ui.findActor("shopName");
|
||||||
ui.onButtonPress("done", this::done);
|
ui.onButtonPress("done", this::done);
|
||||||
ui.onButtonPress("detail", this::toggleToolTip);
|
ui.onButtonPress("detail", this::toggleToolTip);
|
||||||
@@ -87,6 +88,7 @@ public class RewardScene extends UIScene {
|
|||||||
super.disconnected(controller);
|
super.disconnected(controller);
|
||||||
updateDetailButton();
|
updateDetailButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDetailButton() {
|
private void updateDetailButton() {
|
||||||
detailButton.setVisible(Controllers.getCurrent() != null);
|
detailButton.setVisible(Controllers.getCurrent() != null);
|
||||||
detailButton.layout();
|
detailButton.layout();
|
||||||
@@ -94,29 +96,21 @@ public class RewardScene extends UIScene {
|
|||||||
|
|
||||||
private void toggleToolTip() {
|
private void toggleToolTip() {
|
||||||
|
|
||||||
Selectable selectable=getSelected();
|
Selectable selectable = getSelected();
|
||||||
if(selectable==null)
|
if (selectable == null)
|
||||||
return;
|
return;
|
||||||
RewardActor actor;
|
RewardActor actor;
|
||||||
if(selectable.actor instanceof BuyButton)
|
if (selectable.actor instanceof BuyButton) {
|
||||||
{
|
actor = ((BuyButton) selectable.actor).rewardActor;
|
||||||
actor= ((BuyButton) selectable.actor).reward;
|
} else if (selectable.actor instanceof RewardActor) {
|
||||||
}
|
actor = (RewardActor) selectable.actor;
|
||||||
else if (selectable.actor instanceof RewardActor)
|
} else {
|
||||||
{
|
|
||||||
actor= (RewardActor) selectable.actor;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(actor.toolTipIsVisible())
|
if (actor.toolTipIsVisible()) {
|
||||||
{
|
|
||||||
actor.hideTooltip();
|
actor.hideTooltip();
|
||||||
}
|
} else {
|
||||||
else
|
if (!actor.isFlipped())
|
||||||
{
|
|
||||||
if(!actor.isFlipped())
|
|
||||||
actor.showTooltip();
|
actor.showTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,8 +122,8 @@ public class RewardScene extends UIScene {
|
|||||||
|
|
||||||
public void quitScene() {
|
public void quitScene() {
|
||||||
//There were reports of memory leaks after using the shop many times, so remove() everything on exit to be sure.
|
//There were reports of memory leaks after using the shop many times, so remove() everything on exit to be sure.
|
||||||
for(Actor A: new Array.ArrayIterator<>(generated)) {
|
for (Actor A : new Array.ArrayIterator<>(generated)) {
|
||||||
if(A instanceof RewardActor){
|
if (A instanceof RewardActor) {
|
||||||
((RewardActor) A).removeTooltip();
|
((RewardActor) A).removeTooltip();
|
||||||
((RewardActor) A).dispose();
|
((RewardActor) A).dispose();
|
||||||
A.remove();
|
A.remove();
|
||||||
@@ -144,13 +138,16 @@ public class RewardScene extends UIScene {
|
|||||||
}
|
}
|
||||||
Forge.switchToLast();
|
Forge.switchToLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reactivateInputs() {
|
public void reactivateInputs() {
|
||||||
Gdx.input.setInputProcessor(stage);
|
Gdx.input.setInputProcessor(stage);
|
||||||
doneButton.toFront();
|
doneButton.toFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean done() {
|
public boolean done() {
|
||||||
return done(false);
|
return done(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean done(boolean skipShowLoot) {
|
boolean done(boolean skipShowLoot) {
|
||||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||||
if (!skipShowLoot) {
|
if (!skipShowLoot) {
|
||||||
@@ -158,22 +155,23 @@ public class RewardScene extends UIScene {
|
|||||||
showLootOrDone();
|
showLootOrDone();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Shop:
|
case Shop:
|
||||||
doneButton.setText("[+OK]");
|
doneButton.setText("[+OK]");
|
||||||
break;
|
break;
|
||||||
case QuestReward:
|
case QuestReward:
|
||||||
case Loot:
|
case Loot:
|
||||||
doneButton.setText("[+OK]");
|
doneButton.setText("[+OK]");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shown = false;
|
shown = false;
|
||||||
clearGenerated();
|
clearGenerated();
|
||||||
quitScene();
|
quitScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearGenerated() {
|
void clearGenerated() {
|
||||||
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
||||||
if (!(actor instanceof RewardActor)) {
|
if (!(actor instanceof RewardActor)) {
|
||||||
@@ -187,7 +185,8 @@ public class RewardScene extends UIScene {
|
|||||||
reward.clearHoldToolTip();
|
reward.clearHoldToolTip();
|
||||||
try {
|
try {
|
||||||
stage.getActors().removeValue(reward, true);
|
stage.getActors().removeValue(reward, true);
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +251,7 @@ public class RewardScene extends UIScene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateRestockButton(){
|
void updateRestockButton() {
|
||||||
if (!shopActor.canRestock())
|
if (!shopActor.canRestock())
|
||||||
return;
|
return;
|
||||||
int price = shopActor.getRestockPrice();
|
int price = shopActor.getRestockPrice();
|
||||||
@@ -260,11 +259,11 @@ public class RewardScene extends UIScene {
|
|||||||
restockButton.setDisabled(WorldSave.getCurrentSave().getPlayer().getShards() < price);
|
restockButton.setDisabled(WorldSave.getCurrentSave().getPlayer().getShards() < price);
|
||||||
}
|
}
|
||||||
|
|
||||||
void restockShop(){
|
void restockShop() {
|
||||||
if (!shopActor.canRestock())
|
if (!shopActor.canRestock())
|
||||||
return;
|
return;
|
||||||
int price = shopActor.getRestockPrice();
|
int price = shopActor.getRestockPrice();
|
||||||
if(changes!=null)
|
if (changes != null)
|
||||||
changes.generateNewShopSeed(shopActor.getObjectId());
|
changes.generateNewShopSeed(shopActor.getObjectId());
|
||||||
|
|
||||||
Current.player().takeShards(price);
|
Current.player().takeShards(price);
|
||||||
@@ -273,7 +272,7 @@ public class RewardScene extends UIScene {
|
|||||||
SoundSystem.instance.play(SoundEffectType.Shuffle, false);
|
SoundSystem.instance.play(SoundEffectType.Shuffle, false);
|
||||||
|
|
||||||
updateBuyButtons();
|
updateBuyButtons();
|
||||||
if(changes==null)
|
if (changes == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clearGenerated();
|
clearGenerated();
|
||||||
@@ -287,28 +286,36 @@ public class RewardScene extends UIScene {
|
|||||||
ret.addAll(rdata.generate(false, false));
|
ret.addAll(rdata.generate(false, false));
|
||||||
}
|
}
|
||||||
shopActor.setRewardData(ret);
|
shopActor.setRewardData(ret);
|
||||||
loadRewards(ret, RewardScene.Type.Shop,shopActor);
|
loadRewards(ret, RewardScene.Type.Shop, shopActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadRewards(Deck deck, Type type, ShopActor shopActor, boolean noSell){
|
public void loadRewards(Deck deck, Type type, ShopActor shopActor, boolean noSell) {
|
||||||
Array<Reward> rewards = new Array<>();
|
Array<Reward> rewards = new Array<>();
|
||||||
for (PaperCard card : deck.getAllCardsInASinglePool().toFlatList()){
|
for (PaperCard card : deck.getAllCardsInASinglePool().toFlatList()) {
|
||||||
rewards.add(new Reward(card, noSell));
|
rewards.add(new Reward(card, noSell));
|
||||||
}
|
}
|
||||||
loadRewards(rewards, type, shopActor);
|
loadRewards(rewards, type, shopActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateCollectionPool() {
|
||||||
|
if (Type.Shop != this.type)
|
||||||
|
return;
|
||||||
|
if (this.collectionPool == null)
|
||||||
|
this.collectionPool = new ItemPool<>(PaperCard.class);
|
||||||
|
else
|
||||||
|
this.collectionPool.clear();
|
||||||
|
|
||||||
|
this.collectionPool.addAllFlat(AdventurePlayer.current().getCollectionCards(true).toFlatList());
|
||||||
|
}
|
||||||
|
|
||||||
public void loadRewards(Array<Reward> newRewards, Type type, ShopActor shopActor) {
|
public void loadRewards(Array<Reward> newRewards, Type type, ShopActor shopActor) {
|
||||||
clearSelectable();
|
clearSelectable();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
doneClicked = false;
|
doneClicked = false;
|
||||||
if (type==Type.Shop) {
|
updateCollectionPool();
|
||||||
|
if (type == Type.Shop) {
|
||||||
this.shopActor = shopActor;
|
this.shopActor = shopActor;
|
||||||
this.changes = shopActor.getMapStage().getChanges();
|
this.changes = shopActor.getMapStage().getChanges();
|
||||||
if (this.collectionPool == null) {
|
|
||||||
this.collectionPool = new ItemPool<>(PaperCard.class);
|
|
||||||
this.collectionPool.addAllFlat(AdventurePlayer.current().getCollectionCards(true).toFlatList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
||||||
actor.remove();
|
actor.remove();
|
||||||
@@ -319,25 +326,23 @@ public class RewardScene extends UIScene {
|
|||||||
generated.clear();
|
generated.clear();
|
||||||
|
|
||||||
Actor card = ui.findActor("cards");
|
Actor card = ui.findActor("cards");
|
||||||
if(type==Type.Shop) {
|
if (type == Type.Shop) {
|
||||||
String shopName = shopActor.getDescription();
|
String shopName = shopActor.getDescription();
|
||||||
if (shopName != null && !shopName.isEmpty()) {
|
if (shopName != null && !shopName.isEmpty()) {
|
||||||
shopNameLabel.setVisible(true);
|
shopNameLabel.setVisible(true);
|
||||||
shopNameLabel.setText("[%?SHINY]{GRADIENT}" + shopName + "{ENDGRADIENT}");
|
shopNameLabel.setText("[%?SHINY]{GRADIENT}" + shopName + "{ENDGRADIENT}");
|
||||||
shopNameLabel.skipToTheEnd();
|
shopNameLabel.skipToTheEnd();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
shopNameLabel.setVisible(false);
|
shopNameLabel.setVisible(false);
|
||||||
}
|
}
|
||||||
Actor background = ui.findActor("market_background");
|
Actor background = ui.findActor("market_background");
|
||||||
if(background!=null)
|
if (background != null)
|
||||||
background.setVisible(true);
|
background.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
shopNameLabel.setVisible(false);
|
shopNameLabel.setVisible(false);
|
||||||
shopNameLabel.setText("");
|
shopNameLabel.setText("");
|
||||||
Actor background = ui.findActor("market_background");
|
Actor background = ui.findActor("market_background");
|
||||||
if(background!=null)
|
if (background != null)
|
||||||
background.setVisible(false);
|
background.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,8 +372,7 @@ public class RewardScene extends UIScene {
|
|||||||
|
|
||||||
if (shopActor.canRestock()) {
|
if (shopActor.canRestock()) {
|
||||||
restockButton.setVisible(true);
|
restockButton.setVisible(true);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
restockButton.setVisible(false);
|
restockButton.setVisible(false);
|
||||||
restockButton.setDisabled(true);
|
restockButton.setDisabled(true);
|
||||||
}
|
}
|
||||||
@@ -399,22 +403,22 @@ public class RewardScene extends UIScene {
|
|||||||
bestCardHeight = h;
|
bestCardHeight = h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float AR = 480f/270f;
|
float AR = 480f / 270f;
|
||||||
int x = Forge.getDeviceAdapter().getRealScreenSize(false).getLeft();
|
int x = Forge.getDeviceAdapter().getRealScreenSize(false).getLeft();
|
||||||
int y = Forge.getDeviceAdapter().getRealScreenSize(false).getRight();
|
int y = Forge.getDeviceAdapter().getRealScreenSize(false).getRight();
|
||||||
int realX = Forge.getDeviceAdapter().getRealScreenSize(true).getLeft();
|
int realX = Forge.getDeviceAdapter().getRealScreenSize(true).getLeft();
|
||||||
int realY = Forge.getDeviceAdapter().getRealScreenSize(true).getRight();
|
int realY = Forge.getDeviceAdapter().getRealScreenSize(true).getRight();
|
||||||
float fW = Math.max(x, y);
|
float fW = Math.max(x, y);
|
||||||
float fH = Math.min(x, y);
|
float fH = Math.min(x, y);
|
||||||
float mul = fW/fH < AR ? AR/(fW/fH) : (fW/fH)/AR;
|
float mul = fW / fH < AR ? AR / (fW / fH) : (fW / fH) / AR;
|
||||||
if (fW/fH >= 2f) {//tall display
|
if (fW / fH >= 2f) {//tall display
|
||||||
mul = (fW/fH) - ((fW/fH)/AR);
|
mul = (fW / fH) - ((fW / fH) / AR);
|
||||||
if ((fW/fH) >= 2.1f && (fW/fH) < 2.2f)
|
if ((fW / fH) >= 2.1f && (fW / fH) < 2.2f)
|
||||||
mul *= 0.9f;
|
mul *= 0.9f;
|
||||||
else if ((fW/fH) > 2.2f) //ultrawide 21:9 Galaxy Fold, Huawei X2, Xperia 1
|
else if ((fW / fH) > 2.2f) //ultrawide 21:9 Galaxy Fold, Huawei X2, Xperia 1
|
||||||
mul *= 0.8f;
|
mul *= 0.8f;
|
||||||
}
|
}
|
||||||
cardHeight = bestCardHeight * 0.90f ;
|
cardHeight = bestCardHeight * 0.90f;
|
||||||
Float custom = Forge.isLandscapeMode() ? Config.instance().getSettingData().rewardCardAdjLandscape : Config.instance().getSettingData().rewardCardAdj;
|
Float custom = Forge.isLandscapeMode() ? Config.instance().getSettingData().rewardCardAdjLandscape : Config.instance().getSettingData().rewardCardAdj;
|
||||||
if (custom != null && custom != 1f) {
|
if (custom != null && custom != 1f) {
|
||||||
mul *= custom;
|
mul *= custom;
|
||||||
@@ -423,16 +427,16 @@ public class RewardScene extends UIScene {
|
|||||||
mul *= Forge.isLandscapeMode() ? 0.95f : 1.05f;
|
mul *= Forge.isLandscapeMode() ? 0.95f : 1.05f;
|
||||||
} else {
|
} else {
|
||||||
//immersive | no navigation and/or showing cutout cam
|
//immersive | no navigation and/or showing cutout cam
|
||||||
if (fW/fH > 2.2f)
|
if (fW / fH > 2.2f)
|
||||||
mul *= Forge.isLandscapeMode() ? 1.1f : 1.6f;
|
mul *= Forge.isLandscapeMode() ? 1.1f : 1.6f;
|
||||||
else if (fW/fH >= 2.1f)
|
else if (fW / fH >= 2.1f)
|
||||||
mul *= Forge.isLandscapeMode() ? 1.05f : 1.5f;
|
mul *= Forge.isLandscapeMode() ? 1.05f : 1.5f;
|
||||||
else if (fW/fH >= 2f)
|
else if (fW / fH >= 2f)
|
||||||
mul *= Forge.isLandscapeMode() ? 1f : 1.4f;
|
mul *= Forge.isLandscapeMode() ? 1f : 1.4f;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cardWidth = (cardHeight / CARD_WIDTH_TO_HEIGHT)*mul;
|
cardWidth = (cardHeight / CARD_WIDTH_TO_HEIGHT) * mul;
|
||||||
|
|
||||||
yOff += (targetHeight - (cardHeight * numberOfRows)) / 2f;
|
yOff += (targetHeight - (cardHeight * numberOfRows)) / 2f;
|
||||||
xOff += (targetWidth - (cardWidth * numberOfColumns)) / 2f;
|
xOff += (targetWidth - (cardWidth * numberOfColumns)) / 2f;
|
||||||
@@ -456,7 +460,7 @@ public class RewardScene extends UIScene {
|
|||||||
lastRowXAdjust = ((numberOfColumns * cardWidth) - (lastRowCount * cardWidth)) / 2;
|
lastRowXAdjust = ((numberOfColumns * cardWidth) - (lastRowCount * cardWidth)) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
RewardActor actor = new RewardActor(reward, type == Type.Loot || type == Type.QuestReward,type);
|
RewardActor actor = new RewardActor(reward, type == Type.Loot || type == Type.QuestReward, type);
|
||||||
|
|
||||||
actor.setBounds(lastRowXAdjust + xOff + cardWidth * (i % numberOfColumns) + spacing, yOff + cardHeight * currentRow + spacing, cardWidth - spacing * 2, cardHeight - spacing * 2);
|
actor.setBounds(lastRowXAdjust + xOff + cardWidth * (i % numberOfColumns) + spacing, yOff + cardHeight * currentRow + spacing, cardWidth - spacing * 2, cardHeight - spacing * 2);
|
||||||
|
|
||||||
@@ -464,21 +468,12 @@ public class RewardScene extends UIScene {
|
|||||||
if (currentRow != ((i + 1) / numberOfColumns))
|
if (currentRow != ((i + 1) / numberOfColumns))
|
||||||
yOff += doneButton.getHeight();
|
yOff += doneButton.getHeight();
|
||||||
|
|
||||||
BuyButton buyCardButton = new BuyButton(shopActor.getObjectId(), i, actor, doneButton, shopActor.getPriceModifier());
|
BuyButton buyCardButton = new BuyButton(shopActor.getObjectId(), i, actor, reward, doneButton, shopActor.getPriceModifier());
|
||||||
generated.add(buyCardButton);
|
generated.add(buyCardButton);
|
||||||
if (!skipCard) {
|
if (!skipCard) {
|
||||||
stage.addActor(buyCardButton);
|
stage.addActor(buyCardButton);
|
||||||
addToSelectable(buyCardButton);
|
addToSelectable(buyCardButton);
|
||||||
}
|
}
|
||||||
if (this.collectionPool != null && Reward.Type.Card.equals(reward.getType())) {
|
|
||||||
int count = collectionPool.count(reward.getCard());
|
|
||||||
String text = buyCardButton.getTextraLabel().storedText;
|
|
||||||
buyCardButton.setText("[%75]" + text + "\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + count);
|
|
||||||
} else if (Reward.Type.Item.equals(reward.getType())) {
|
|
||||||
int count = AdventurePlayer.current().countItem(reward.getItem().name);
|
|
||||||
String text = buyCardButton.getTextraLabel().storedText;
|
|
||||||
buyCardButton.setText("[%75]" + text + "\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + count);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
addToSelectable(actor);
|
addToSelectable(actor);
|
||||||
}
|
}
|
||||||
@@ -502,21 +497,37 @@ public class RewardScene extends UIScene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BuyButton extends TextraButton {
|
private class BuyButton extends TextraButton {
|
||||||
private final int objectID;
|
private final int objectID;
|
||||||
private final int index;
|
private final int index;
|
||||||
public RewardActor reward;
|
public RewardActor rewardActor;
|
||||||
|
private Reward reward;
|
||||||
int price;
|
int price;
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
setDisabled(WorldSave.getCurrentSave().getPlayer().getGold() < price);
|
setDisabled(WorldSave.getCurrentSave().getPlayer().getGold() < price);
|
||||||
|
updateOwned();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuyButton(int id, int i, RewardActor actor, TextraButton style, float shopModifier) {
|
void updateOwned() {
|
||||||
super("", style.getStyle(),Controls.getTextraFont());
|
if (Type.Shop != type)
|
||||||
|
return;
|
||||||
|
if (collectionPool != null && Reward.Type.Card.equals(reward.getType())) {
|
||||||
|
int count = collectionPool.count(reward.getCard());
|
||||||
|
setText("[%75]" + price + " [+Gold]\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + count);
|
||||||
|
} else if (Reward.Type.Item.equals(reward.getType())) {
|
||||||
|
int count = AdventurePlayer.current().countItem(reward.getItem().name);
|
||||||
|
setText("[%75]" + price + " [+Gold]\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuyButton(int id, int i, RewardActor actor, Reward reward, TextraButton style, float shopModifier) {
|
||||||
|
super("", style.getStyle(), Controls.getTextraFont());
|
||||||
this.objectID = id;
|
this.objectID = id;
|
||||||
this.index = i;
|
this.index = i;
|
||||||
reward = actor;
|
rewardActor = actor;
|
||||||
|
this.reward = reward;
|
||||||
setHeight(style.getHeight());
|
setHeight(style.getHeight());
|
||||||
setWidth(actor.getWidth());
|
setWidth(actor.getWidth());
|
||||||
setX(actor.getX());
|
setX(actor.getX());
|
||||||
@@ -524,29 +535,31 @@ public class RewardScene extends UIScene {
|
|||||||
price = CardUtil.getRewardPrice(actor.getReward());
|
price = CardUtil.getRewardPrice(actor.getReward());
|
||||||
price *= Current.player().goldModifier();
|
price *= Current.player().goldModifier();
|
||||||
price *= shopModifier;
|
price *= shopModifier;
|
||||||
setText(price+" [+Gold]");
|
setText(price + " [+Gold]");
|
||||||
|
updateOwned();
|
||||||
addListener(new ClickListener() {
|
addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
if (Current.player().getGold() >= price) {
|
if (Current.player().getGold() >= price) {
|
||||||
if(!shopActor.isUnlimited())
|
if (!shopActor.isUnlimited())
|
||||||
changes.buyCard(objectID, index);
|
changes.buyCard(objectID, index);
|
||||||
|
|
||||||
Current.player().takeGold(price);
|
Current.player().takeGold(price);
|
||||||
Current.player().addReward(reward.getReward());
|
Current.player().addReward(rewardActor.getReward());
|
||||||
|
|
||||||
Gdx.input.vibrate(5);
|
Gdx.input.vibrate(5);
|
||||||
SoundSystem.instance.play(SoundEffectType.FlipCoin, false);
|
SoundSystem.instance.play(SoundEffectType.FlipCoin, false);
|
||||||
|
|
||||||
updateBuyButtons();
|
if (changes == null)
|
||||||
if(changes==null)
|
return;
|
||||||
return;
|
setDisabled(true);
|
||||||
setDisabled(true);
|
rewardActor.sold();
|
||||||
reward.sold();
|
getColor().a = 0.5f;
|
||||||
getColor().a = 0.5f;
|
updateCollectionPool();
|
||||||
setText("SOLD");
|
updateBuyButtons();
|
||||||
removeListener(this);
|
setText("SOLD");
|
||||||
}
|
removeListener(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user