use of com.janfic.games.computercombat.actors.CollectionPackActor in project computercombat by janfic.
the class OpenPackScreen method show.
@Override
public void show() {
this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(camera);
this.skin = game.getAssetManager().get(Assets.SKIN);
this.collections = SQLAPI.getSingleton().getCollections();
List<Integer> collectionIDs = new ArrayList<>();
collectionIDs.add(collection.getID());
if (collection.getID() == 0) {
for (Collection c : collections) {
collectionIDs.add(c.getID());
}
}
collectionIDs.remove((Integer) 0);
this.collectionCards = SQLAPI.getSingleton().getCardsInCollection(collectionIDs, game.getCurrentProfile().getUID());
System.out.println(collectionCards);
this.pack = new CollectionPackActor(game, skin, collection);
pack.setScale(1.25f);
Gdx.input.setInputProcessor(stage);
Table table = new Table();
table.setFillParent(true);
table.defaults().space(20);
TextButton openButton = new TextButton("Open!", skin);
openButton.setTouchable(Touchable.disabled);
List<Card> openCards = new ArrayList<>();
openCards.add(roll());
openCards.add(roll());
openCards.add(roll());
end = new TextButton("Okay", skin);
end.setVisible(false);
end.setPosition(10, 10);
end.setSize(100, 30);
end.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Map<Integer, Integer> added = new HashMap<>();
for (Card openCard : openCards) {
added.put(openCard.getID(), added.getOrDefault(openCard.getID(), 0) + 1);
}
SQLAPI.getSingleton().addCardsToProfile(added, game.getCurrentProfile());
SQLAPI.getSingleton().saveProfile(game.getCurrentProfile());
game.popScreen();
}
});
table.add(pack).row();
table.add(openButton).width(100).row();
Action cardAction = Actions.sequence(Actions.visible(false), Actions.delay(1), Actions.moveBy(0, -stage.getHeight() * 2), Actions.visible(true), Actions.moveBy(0, stage.getHeight() * 2, 2, Interpolation.fastSlow), Actions.delay(2));
Action buttonAction = Actions.sequence(Actions.fadeOut(0), Actions.delay(3), Actions.fadeIn(1), Actions.touchable(Touchable.enabled));
openButton.addAction(buttonAction);
pack.addAction(cardAction);
cardActors = new ArrayList<>();
openButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
pack.open();
openButton.setVisible(false);
Action open = Actions.sequence(Actions.moveBy(0, -200, 1), Actions.run(() -> {
confetti();
for (CollectionCard openCard : cardActors) {
openCard.setPosition(pack.getX(), pack.getY());
openCard.setSize(pack.getWidth() - 4, pack.getHeight());
openCard.addAction(Actions.parallel(Actions.moveBy(0, 200, 1, Interpolation.circleOut), Actions.moveBy((cardActors.indexOf(openCard) - 1) * 150, 0, 1, Interpolation.circleIn)));
}
}), Actions.run(() -> {
end.setVisible(true);
}));
pack.addAction(open);
}
});
for (Card openCard : openCards) {
CollectionCard c = new CollectionCard(game, skin, openCard, 1);
cardActors.add(c);
stage.addActor(c);
}
stage.addActor(table);
stage.addActor(end);
table.layout();
}
use of com.janfic.games.computercombat.actors.CollectionPackActor in project computercombat by janfic.
the class DownloadScreen method show.
@Override
public void show() {
this.cam = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(cam);
this.collections = SQLAPI.getSingleton().getCollections();
packs.clear();
for (Collection collection : collections) {
packs.add(new CollectionPackActor(game, skin, collection));
}
Gdx.input.setInputProcessor(stage);
Table table = new Table();
table.setFillParent(true);
table.defaults().space(5);
table.pad(4);
packsTable = new Table(skin);
packsTable.defaults().space(5);
ScrollPane scrollPane = new ScrollPane(packsTable, skin);
makePacks();
Panel packInfoTable = new Panel(skin);
packInfoTable.defaults().space(3).pad(2);
packInfoTable.top();
Label packInfoLabel = new Label("About", skin, "title");
packInfoLabel.setAlignment(Align.center);
packInfoTable.add(packInfoLabel).growX().row();
packName = new Label("Press a Pack to learn more.", skin);
packDescription = new Label("Press a Pack to learn more.", skin);
Label packPriceLabel = new Label("Packets to Download:", skin);
packPrice = new Label("???", skin);
packName.setWrap(true);
packPrice.setWrap(true);
packDescription.setWrap(true);
packPriceLabel.setWrap(true);
packName.setAlignment(Align.center);
packPrice.setAlignment(Align.center);
packDescription.setAlignment(Align.center);
packPriceLabel.setAlignment(Align.center);
Image packetsImage = new Image(game.getAssetManager().get("texture_packs/components.atlas", TextureAtlas.class).findRegion("network"));
Table packetTable = new Table(skin);
packetTable.defaults().space(10);
packetTable.add(packetsImage).size(24, 24);
packetTable.add(packPrice);
packInfoTable.add(packName).growX().row();
packInfoTable.add(packDescription).grow().row();
packInfoTable.add(packPriceLabel).growX().expandY().bottom().row();
packInfoTable.add(packetTable).growX().row();
TextButton viewCollectionButton = new TextButton("View Collection", skin);
final TextButton downloadButton = new TextButton("Download", skin);
packInfoTable.add(viewCollectionButton).growX().row();
packInfoTable.add(downloadButton).growX();
Table titleTable = new Table(skin);
titleTable.setBackground("border");
Label title = new Label("Card Packs", skin);
title.setAlignment(Align.center);
TextButton backButton = new TextButton("Back", skin);
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.popScreen();
}
});
Image playerPacketImage = new Image(game.getAssetManager().get("texture_packs/components.atlas", TextureAtlas.class).findRegion("network"));
Table playerPacketTable = new Table(skin);
playerPacketTable.defaults().padRight(10);
playerPacketTable.add(new Label("Your Packets: ", skin));
playerPacketTable.add(playerPacketImage).size(24, 24);
playerPacketTable.add(new Label("" + game.getCurrentProfile().getPackets(), skin));
titleTable.add(backButton);
titleTable.add(title).growX();
titleTable.add(playerPacketTable).row();
table.add(scrollPane).grow();
table.add(packInfoTable).minWidth(200).growY().row();
table.add(titleTable).growX().colspan(2).row();
stage.addActor(table);
downloadButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (game.getCurrentProfile().getPackets() >= collections.get(selected).getPrice()) {
downloadButton.addAction(Actions.sequence(Actions.touchable(Touchable.disabled), Actions.color(Color.GREEN), Actions.color(Color.WHITE, 1), Actions.run(() -> {
game.getCurrentProfile().setPackets(game.getCurrentProfile().getPackets() - collections.get(selected).getPrice());
game.pushScreen(new OpenPackScreen(game, collections.get(selected)));
}), Actions.touchable(Touchable.enabled)));
} else {
downloadButton.addAction(Actions.sequence(Actions.touchable(Touchable.disabled), Actions.color(Color.RED), Actions.color(Color.WHITE, 1), Actions.touchable(Touchable.enabled)));
}
}
});
viewCollectionButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (selected > 0) {
game.pushScreen(new CollectionScreen(game, collections.get(selected)));
}
}
});
}
Aggregations