From 650b443fd02e368d14a1498156051a985789412d Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 12 Jan 2019 18:51:21 -0500 Subject: [PATCH] Starting items / Zone balancing --- core/src/io/anuke/mindustry/content/Bullets.java | 2 +- core/src/io/anuke/mindustry/content/Recipes.java | 9 +-------- core/src/io/anuke/mindustry/content/Zones.java | 9 ++++++++- core/src/io/anuke/mindustry/core/GameState.java | 2 +- core/src/io/anuke/mindustry/core/Logic.java | 10 +++++----- core/src/io/anuke/mindustry/core/World.java | 12 ++++++++++-- .../mindustry/maps/generators/RandomGenerator.java | 1 + core/src/io/anuke/mindustry/type/ItemStack.java | 8 ++++++++ core/src/io/anuke/mindustry/type/Zone.java | 4 ++++ .../io/anuke/mindustry/ui/dialogs/DeployDialog.java | 2 +- 10 files changed, 40 insertions(+), 19 deletions(-) diff --git a/core/src/io/anuke/mindustry/content/Bullets.java b/core/src/io/anuke/mindustry/content/Bullets.java index 94d397b6f5..0cc7113f10 100644 --- a/core/src/io/anuke/mindustry/content/Bullets.java +++ b/core/src/io/anuke/mindustry/content/Bullets.java @@ -242,7 +242,7 @@ public class Bullets implements ContentList{ bulletHeight = 9f; shootEffect = Fx.shootSmall; smokeEffect = Fx.shootSmallSmoke; - ammoMultiplier = 5; + ammoMultiplier = 2; }}; standardDense = new BasicBulletType(3.5f, 18, "bullet"){{ diff --git a/core/src/io/anuke/mindustry/content/Recipes.java b/core/src/io/anuke/mindustry/content/Recipes.java index 422cee0cb4..21b7e9f5e7 100644 --- a/core/src/io/anuke/mindustry/content/Recipes.java +++ b/core/src/io/anuke/mindustry/content/Recipes.java @@ -43,13 +43,6 @@ public class Recipes implements ContentList{ new Recipe(effect, Blocks.vault, new ItemStack(Items.titanium, 500), new ItemStack(Items.thorium, 250)); new Recipe(effect, Blocks.launchPad, new ItemStack(Items.copper, 500)); - //removed; no longer fits gameplay - /*new Recipe(effect, Blocks.core, - new ItemStack(Items.copper, 2000), new ItemStack(Items.titanium, 2000), - new ItemStack(Items.silicon, 1750), new ItemStack(Items.thorium, 1000), - new ItemStack(Items.surgealloy, 500), new ItemStack(Items.phasefabric, 750) - );*/ - //projectors new Recipe(effect, Blocks.mendProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.titanium, 150), new ItemStack(Items.titanium, 50), new ItemStack(Items.silicon, 180)); new Recipe(effect, Blocks.overdriveProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.titanium, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250)); @@ -131,7 +124,7 @@ public class Recipes implements ContentList{ new Recipe(power, Blocks.rtgGenerator, new ItemStack(Items.lead, 200), new ItemStack(Items.silicon, 150), new ItemStack(Items.phasefabric, 50), new ItemStack(Items.plastanium, 150), new ItemStack(Items.thorium, 100)); //DRILLS, PRODUCERS - new Recipe(production, Blocks.mechanicalDrill, new ItemStack(Items.copper, 45)).setAlwaysUnlocked(true); + new Recipe(production, Blocks.mechanicalDrill, new ItemStack(Items.copper, 20)).setAlwaysUnlocked(true); new Recipe(production, Blocks.pneumaticDrill, new ItemStack(Items.copper, 60), new ItemStack(Items.graphite, 50)); new Recipe(production, Blocks.laserDrill, new ItemStack(Items.copper, 70), new ItemStack(Items.graphite, 90), new ItemStack(Items.silicon, 60), new ItemStack(Items.titanium, 50)); new Recipe(production, Blocks.blastDrill, new ItemStack(Items.copper, 130), new ItemStack(Items.silicon, 120), new ItemStack(Items.titanium, 100), new ItemStack(Items.thorium, 60)); diff --git a/core/src/io/anuke/mindustry/content/Zones.java b/core/src/io/anuke/mindustry/content/Zones.java index 99cb983ef4..76b0f41aa9 100644 --- a/core/src/io/anuke/mindustry/content/Zones.java +++ b/core/src/io/anuke/mindustry/content/Zones.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.content; import io.anuke.mindustry.game.ContentList; +import io.anuke.mindustry.game.Rules; import io.anuke.mindustry.maps.generators.BasicGenerator; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.type.Zone; @@ -12,7 +13,13 @@ public class Zones implements ContentList{ public void load(){ wasteland = new Zone("wasteland", new BasicGenerator(256, 256, Items.lead, Items.copper)){{ - deployCost = new ItemStack[]{new ItemStack(Items.copper, 2)}; + deployCost = ItemStack.with(Items.copper, 100); + startingItems = ItemStack.with(Items.copper, 50); + rules = () -> new Rules(){{ + waves = true; + waveTimer = true; + waveSpacing = 60 * 60; + }}; }}; } } diff --git a/core/src/io/anuke/mindustry/core/GameState.java b/core/src/io/anuke/mindustry/core/GameState.java index 1b2c2f9d14..7ec682daeb 100644 --- a/core/src/io/anuke/mindustry/core/GameState.java +++ b/core/src/io/anuke/mindustry/core/GameState.java @@ -12,7 +12,7 @@ import static io.anuke.mindustry.Vars.waveTeam; public class GameState{ /**Current wave number, can be anything in non-wave modes.*/ public int wave = 1; - /**Wave time in ticks.*/ + /**Wave countdown in ticks.*/ public float wavetime; /**Whether the game is in game over state.*/ public boolean gameOver = false; diff --git a/core/src/io/anuke/mindustry/core/Logic.java b/core/src/io/anuke/mindustry/core/Logic.java index f2ac2e130a..4ccedec0b7 100644 --- a/core/src/io/anuke/mindustry/core/Logic.java +++ b/core/src/io/anuke/mindustry/core/Logic.java @@ -57,14 +57,14 @@ public class Logic implements ApplicationListener{ public void play(){ state.set(State.playing); - state.wavetime = 0; + state.wavetime = state.rules.waveSpacing * 2; //grace period of 2x wave time before game starts Events.fire(new PlayEvent()); } public void reset(){ state.wave = 1; - state.wavetime = 0; + state.wavetime = state.rules.waveSpacing; state.gameOver = false; state.teams = new Teams(); state.rules = new Rules(); @@ -79,7 +79,7 @@ public class Logic implements ApplicationListener{ public void runWave(){ world.spawner.spawnEnemies(); state.wave++; - state.wavetime = 0; + state.wavetime = state.rules.waveSpacing; Events.fire(new WaveEvent()); } @@ -122,10 +122,10 @@ public class Logic implements ApplicationListener{ Time.update(); if(state.rules.waves && state.rules.waveTimer && !state.gameOver){ - state.wavetime += Time.delta(); + state.wavetime = Math.max(state.wavetime - Time.delta(), 0); } - if(!Net.client() && state.wavetime >= state.rules.waveSpacing && state.rules.waves){ + if(!Net.client() && state.wavetime <= 0 && state.rules.waves){ runWave(); } diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index 3b88fbf759..a6ae216584 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -24,6 +24,8 @@ import io.anuke.mindustry.maps.MapTileData; import io.anuke.mindustry.maps.MapTileData.TileDataMarker; import io.anuke.mindustry.maps.Maps; import io.anuke.mindustry.maps.generators.Generator; +import io.anuke.mindustry.type.ItemStack; +import io.anuke.mindustry.type.Zone; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Pos; import io.anuke.mindustry.world.Tile; @@ -188,10 +190,16 @@ public class World implements ApplicationListener{ return generating; } - public void playGenerator(Generator generator){ + public void playZone(Zone zone){ ui.loadAnd(() -> { logic.reset(); - loadGenerator(generator); + state.rules = zone.rules.get(); + loadGenerator(zone.generator); + for(Tile core : state.teams.get(defaultTeam).cores){ + for(ItemStack stack : zone.startingItems){ + core.entity.items.add(stack.item, stack.amount); + } + } logic.play(); }); } diff --git a/core/src/io/anuke/mindustry/maps/generators/RandomGenerator.java b/core/src/io/anuke/mindustry/maps/generators/RandomGenerator.java index 9d27002200..74a51a360c 100644 --- a/core/src/io/anuke/mindustry/maps/generators/RandomGenerator.java +++ b/core/src/io/anuke/mindustry/maps/generators/RandomGenerator.java @@ -25,6 +25,7 @@ public abstract class RandomGenerator extends Generator{ } tiles[width/2][height/2].setBlock(Blocks.core, Team.blue); + tiles[width/2][height/2 - 6].setBlock(Blocks.launchPad, Team.blue); } /**Sets {@link #floor} and {@link #block} to the correct values as output. diff --git a/core/src/io/anuke/mindustry/type/ItemStack.java b/core/src/io/anuke/mindustry/type/ItemStack.java index 5714050602..663f98617f 100644 --- a/core/src/io/anuke/mindustry/type/ItemStack.java +++ b/core/src/io/anuke/mindustry/type/ItemStack.java @@ -12,4 +12,12 @@ public class ItemStack{ public boolean equals(ItemStack other){ return other != null && other.item == item && other.amount == amount; } + + public static ItemStack[] with(Object... items){ + ItemStack[] stacks = new ItemStack[items.length/2]; + for(int i = 0; i < items.length; i+= 2){ + stacks[i/2] = new ItemStack((Item)items[i], (Integer)items[i + 1]); + } + return stacks; + } } diff --git a/core/src/io/anuke/mindustry/type/Zone.java b/core/src/io/anuke/mindustry/type/Zone.java index caaf693533..5a943029ce 100644 --- a/core/src/io/anuke/mindustry/type/Zone.java +++ b/core/src/io/anuke/mindustry/type/Zone.java @@ -1,8 +1,10 @@ package io.anuke.mindustry.type; import io.anuke.arc.Core; +import io.anuke.arc.function.Supplier; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.mindustry.game.Rules; import io.anuke.mindustry.game.UnlockableContent; import io.anuke.mindustry.maps.generators.Generator; @@ -10,6 +12,8 @@ public class Zone extends UnlockableContent{ public final String name; public final Generator generator; public ItemStack[] deployCost = {}; + public ItemStack[] startingItems = {}; + public Supplier rules = Rules::new; public Zone(String name, Generator generator){ this.name = name; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java index ea67d0caf2..52da73a69e 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java @@ -45,7 +45,7 @@ public class DeployDialog extends FloatingDialog{ t.addButton(zone.localizedName(), () -> { data.removeItems(zone.deployCost); hide(); - world.playGenerator(zone.generator); + world.playZone(zone); }).size(150f).disabled(b -> !data.hasItems(zone.deployCost)); t.row(); t.table(req -> {