Deploy dialog requirements done
This commit is contained in:
@@ -62,8 +62,9 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
itemRequirements = ItemStack.with(Items.copper, 2000);
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
blockRequirements = new Block[]{Blocks.router};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
@@ -75,7 +76,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -88,7 +89,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -101,7 +102,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -114,7 +115,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -127,7 +128,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -140,7 +141,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -153,7 +154,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -166,7 +167,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -179,7 +180,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -192,7 +193,7 @@ public class Zones implements ContentList{
|
||||
deployCost = ItemStack.with(Items.copper, 300);
|
||||
startingItems = ItemStack.with(Items.copper, 200);
|
||||
conditionWave = 15;
|
||||
zoneRequirements = new Zone[]{groundZero};
|
||||
zoneRequirements = new Zone[]{frozenForest};
|
||||
blockRequirements = new Block[]{Blocks.copperWall};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
@@ -200,5 +201,7 @@ public class Zones implements ContentList{
|
||||
waveSpacing = 60 * 80;
|
||||
}};
|
||||
}};
|
||||
|
||||
frozenForest.zoneRequirements = new Zone[]{frozenForest};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class UI implements ApplicationListener{
|
||||
public UI(){
|
||||
Skin skin = new Skin(Core.atlas);
|
||||
generateFonts(skin);
|
||||
skin.load(Core.files.internal("ui/uiskin.json"));
|
||||
skin.load(Core.files.internal("sprites/uiskin.json"));
|
||||
|
||||
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
||||
font.setUseIntegerPositions(true);
|
||||
@@ -238,7 +238,7 @@ public class UI implements ApplicationListener{
|
||||
Table table = new Table();
|
||||
table.setFillParent(true);
|
||||
table.actions(Actions.fadeOut(7f, Interpolation.fade), Actions.removeActor());
|
||||
table.top().add(info).padTop(8);
|
||||
table.top().add(info).padTop(40);
|
||||
Core.scene.add(table);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,10 @@ public class GlobalData{
|
||||
return getWaveScore(zone) >= zone.conditionWave;
|
||||
}
|
||||
|
||||
public int getItem(Item item){
|
||||
return items.get(item, 0);
|
||||
}
|
||||
|
||||
public void addItem(Item item, int amount){
|
||||
modified = true;
|
||||
items.getAndIncrement(item, 0, amount);
|
||||
@@ -84,7 +88,7 @@ public class GlobalData{
|
||||
* Results are not saved until you call {@link #save()}.
|
||||
*/
|
||||
public void unlockContent(UnlockableContent content){
|
||||
if(!content.canBeUnlocked() || content.alwaysUnlocked()) return;
|
||||
if(content.alwaysUnlocked()) return;
|
||||
|
||||
//fire unlock event so other classes can use it
|
||||
if(unlocked.getOr(content.getContentType(), ObjectSet::new).add(content.getContentName())){
|
||||
|
||||
@@ -3,8 +3,6 @@ package io.anuke.mindustry.game;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.data;
|
||||
|
||||
/**Base interface for an unlockable content type.*/
|
||||
public abstract class UnlockableContent extends MappableContent{
|
||||
/**Returns the localized name of this content.*/
|
||||
@@ -28,24 +26,4 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
public boolean alwaysUnlocked(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**Lists the content that must be unlocked in order for this specific content to become unlocked. May return null.*/
|
||||
public UnlockableContent[] getDependencies(){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**Returns whether dependencies are satisfied for unlocking this content.*/
|
||||
public boolean canBeUnlocked(){
|
||||
UnlockableContent[] depend = getDependencies();
|
||||
if(depend == null){
|
||||
return true;
|
||||
}else{
|
||||
for(UnlockableContent cont : depend){
|
||||
if(!data.isUnlocked(cont)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,6 @@ public class MapIO{
|
||||
String name = stream.readUTF();
|
||||
Block block = content.getByName(ContentType.block, name);
|
||||
if(block == null){
|
||||
//Log.info("Map load info: No block with name {0} found.", name);
|
||||
block = Blocks.air;
|
||||
}
|
||||
map.put(id, block.id);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ContentDisplay{
|
||||
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(8).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ContentDisplay{
|
||||
table.add(block.fullDescription).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(8).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,19 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.ObjectIntMap;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.TextButton;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.io.SaveIO.SaveException;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.ItemType;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -49,21 +53,35 @@ public class DeployDialog extends FloatingDialog{
|
||||
int i = 0;
|
||||
for(Zone zone : content.zones()){
|
||||
table(t -> {
|
||||
TextButton button = t.addButton(data.isUnlocked(zone) ? zone.localizedName() : "???", () -> {
|
||||
data.removeItems(zone.deployCost);
|
||||
hide();
|
||||
world.playZone(zone);
|
||||
}).size(200f).disabled(!data.hasItems(zone.deployCost) || !data.isUnlocked(zone)).get();
|
||||
TextButton button = t.addButton("", () -> {
|
||||
if(!data.isUnlocked(zone)){
|
||||
data.removeItems(zone.itemRequirements);
|
||||
data.unlockContent(zone);
|
||||
setup();
|
||||
}else{
|
||||
data.removeItems(zone.deployCost);
|
||||
hide();
|
||||
world.playZone(zone);
|
||||
}
|
||||
}).size(250f).disabled(b -> !canUnlock(zone)).get();
|
||||
|
||||
button.row();
|
||||
|
||||
if(data.getWaveScore(zone) > 0){
|
||||
button.add(Core.bundle.format("bestwave", data.getWaveScore(zone)));
|
||||
}
|
||||
|
||||
button.row();
|
||||
button.clearChildren();
|
||||
|
||||
if(data.isUnlocked(zone)){
|
||||
button.table(title -> {
|
||||
title.addImage("icon-zone").padRight(3);
|
||||
title.add(zone.localizedName());
|
||||
});
|
||||
button.row();
|
||||
|
||||
if(data.getWaveScore(zone) > 0){
|
||||
button.add(Core.bundle.format("bestwave", data.getWaveScore(zone)));
|
||||
}
|
||||
|
||||
button.row();
|
||||
|
||||
button.add("$launch").color(Color.LIGHT_GRAY).pad(4);
|
||||
button.row();
|
||||
button.table(req -> {
|
||||
for(ItemStack stack : zone.deployCost){
|
||||
req.addImage(stack.item.region).size(8 * 3);
|
||||
@@ -71,48 +89,72 @@ public class DeployDialog extends FloatingDialog{
|
||||
}
|
||||
}).pad(3).growX();
|
||||
}else{
|
||||
boolean anyNeeded = false;
|
||||
for(Zone other : zone.zoneRequirements){
|
||||
if(!data.isCompleted(other)){
|
||||
anyNeeded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
button.addImage("icon-zone-locked");
|
||||
button.row();
|
||||
button.add("$locked").padBottom(6);
|
||||
|
||||
if(anyNeeded){
|
||||
if(!hidden(zone)){
|
||||
button.row();
|
||||
|
||||
button.table(req -> {
|
||||
req.add("$complete").left();
|
||||
req.row();
|
||||
for(Zone other : zone.zoneRequirements){
|
||||
if(!data.isCompleted(other)){
|
||||
req.add("- [LIGHT_GRAY]" + other.localizedName()).left();
|
||||
req.row();
|
||||
}
|
||||
req.defaults().left();
|
||||
|
||||
if(zone.zoneRequirements.length > 0){
|
||||
req.table(r -> {
|
||||
r.add("$complete").colspan(2).left();
|
||||
r.row();
|
||||
for(Zone other : zone.zoneRequirements){
|
||||
r.addImage("icon-zone").padRight(4);
|
||||
r.add(other.localizedName()).color(Color.LIGHT_GRAY);
|
||||
r.addImage(data.isCompleted(zone) ? "icon-check-2" : "icon-cancel-2")
|
||||
.color(data.isCompleted(zone) ? Color.LIGHT_GRAY : Color.SCARLET).padLeft(3);
|
||||
r.row();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
req.table(r -> {
|
||||
if(zone.itemRequirements.length > 0){
|
||||
req.row();
|
||||
|
||||
if(zone.itemRequirements.length > 0){
|
||||
req.table(r -> {
|
||||
for(ItemStack stack : zone.itemRequirements){
|
||||
r.addImage(stack.item.region).size(8 * 3);
|
||||
r.add(stack.amount + "").left();
|
||||
r.addImage(stack.item.region).size(8 * 3).padRight(4);
|
||||
r.add(Math.min(data.getItem(stack.item), stack.amount) + "/" + stack.amount)
|
||||
.color(stack.amount > data.getItem(stack.item) ? Color.SCARLET : Color.LIGHT_GRAY).left();
|
||||
r.row();
|
||||
}
|
||||
}
|
||||
});
|
||||
}).pad(3).growX();
|
||||
}).padTop(10);
|
||||
}
|
||||
|
||||
req.row();
|
||||
|
||||
if(zone.blockRequirements.length > 0){
|
||||
req.table(r -> {
|
||||
r.add("$research.list").colspan(2).left();
|
||||
r.row();
|
||||
for(Block block : zone.blockRequirements){
|
||||
r.addImage(block.icon(Icon.small)).size(8 * 3).padRight(4);
|
||||
r.add(block.formalName).color(Color.LIGHT_GRAY);
|
||||
r.addImage(data.isUnlocked(block) ? "icon-check-2" : "icon-cancel-2")
|
||||
.color(data.isUnlocked(block) ? Color.LIGHT_GRAY : Color.SCARLET).padLeft(3);
|
||||
r.row();
|
||||
}
|
||||
|
||||
}).padTop(10);
|
||||
}
|
||||
}).growX();
|
||||
}
|
||||
}
|
||||
|
||||
button.row();
|
||||
button.addImage("icon-zone-locked").visible(() -> !data.isUnlocked(zone));
|
||||
}).pad(4);
|
||||
|
||||
if(++i % 4 == 0){
|
||||
if(++i % 2 == 0){
|
||||
row();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
addButton(Core.bundle.format("resume", control.saves.getZoneSlot().getZone().localizedName()), () -> {
|
||||
SaveSlot slot = control.saves.getZoneSlot();
|
||||
|
||||
TextButton button = addButton(Core.bundle.format("resume", slot.getZone().localizedName()), () -> {
|
||||
hide();
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
@@ -125,8 +167,42 @@ public class DeployDialog extends FloatingDialog{
|
||||
show();
|
||||
}
|
||||
});
|
||||
}).size(200f);
|
||||
}).size(200f).get();
|
||||
|
||||
String color = "[lightgray]";
|
||||
|
||||
button.defaults().colspan(2);
|
||||
button.row();
|
||||
button.add(Core.bundle.format("save.wave", color + slot.getWave()));
|
||||
button.row();
|
||||
button.label(() -> Core.bundle.format("save.playtime", color + slot.getPlayTime()));
|
||||
button.row();
|
||||
}
|
||||
}})).grow();
|
||||
}
|
||||
|
||||
boolean hidden(Zone zone){
|
||||
for(Zone other : zone.zoneRequirements){
|
||||
if(!data.isUnlocked(other)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean canUnlock(Zone zone){
|
||||
for(Zone other : zone.zoneRequirements){
|
||||
if(!data.isCompleted(other)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for(Block other : zone.blockRequirements){
|
||||
if(!data.isUnlocked(other)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return data.hasItems(zone.itemRequirements);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user