Added weapon factory block, refactored recipes

This commit is contained in:
Anuken
2018-01-05 23:38:59 -05:00
parent cccf4a7e38
commit a4cc149aab
27 changed files with 360 additions and 211 deletions

View File

@@ -1,15 +1,11 @@
package io.anuke.mindustry.resource;
public enum Mech{
standard,
scout{{
}};
public float speedBoost = 1f, damageBoost = 1f;
public int regenRate = 10;
public int health = 20;
public class Mech extends Upgrade{
public static final Mech
private Mech(){
standard = new Mech("standard");
public Mech(String name){
super(name);
}
}

View File

@@ -1,114 +1,15 @@
package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.*;
import static io.anuke.mindustry.resource.Section.*;
public class Recipe {
public Block result;
public ItemStack[] requirements;
public Section section;
public enum Recipe{
stonewall(defense, DefenseBlocks.stonewall, stack(Item.stone, 12)),
ironwall(defense, DefenseBlocks.ironwall, stack(Item.iron, 12)),
steelwall(defense, DefenseBlocks.steelwall, stack(Item.steel, 12)),
titaniumwall(defense, DefenseBlocks.titaniumwall, stack(Item.titanium, 12)),
duriumwall(defense, DefenseBlocks.diriumwall, stack(Item.dirium, 12)),
//compositewall(defense, DefenseBlocks.compositewall, stack(Item.dirium, 2), stack(Item.titanium, 2), stack(Item.steel, 2), stack(Item.iron, 2)),
steelwalllarge(defense, DefenseBlocks.steelwalllarge, stack(Item.steel, 12*4)),
titaniumwalllarge(defense, DefenseBlocks.titaniumwalllarge, stack(Item.titanium, 12*4)),
duriumwalllarge(defense, DefenseBlocks.diriumwalllarge, stack(Item.dirium, 12*4)),
door(defense, DefenseBlocks.door, stack(Item.steel, 3), stack(Item.iron, 3*4)),
largedoor(defense, DefenseBlocks.largedoor, stack(Item.steel, 3*4), stack(Item.iron, 3*4*4)),
titaniumshieldwall(defense, DefenseBlocks.titaniumshieldwall, stack(Item.titanium, 16)),
conveyor(distribution, DistributionBlocks.conveyor, stack(Item.stone, 1)),
steelconveyor(distribution, DistributionBlocks.steelconveyor, stack(Item.steel, 1)),
poweredconveyor(distribution, DistributionBlocks.pulseconveyor, stack(Item.dirium, 1)),
router(distribution, DistributionBlocks.router, stack(Item.stone, 2)),
junction(distribution, DistributionBlocks.junction, stack(Item.iron, 2)),
tunnel(distribution, DistributionBlocks.tunnel, stack(Item.iron, 2)),
conduit(distribution, DistributionBlocks.conduit, stack(Item.steel, 1)),
pulseconduit(distribution, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
liquidrouter(distribution, DistributionBlocks.liquidrouter, stack(Item.steel, 2)),
liquidjunction(distribution, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
sorter(distribution, DistributionBlocks.sorter, stack(Item.steel, 2)),
turret(weapon, WeaponBlocks.turret, stack(Item.stone, 4)),
dturret(weapon, WeaponBlocks.doubleturret, stack(Item.stone, 7)),
machineturret(weapon, WeaponBlocks.machineturret, stack(Item.iron, 8), stack(Item.stone, 10)),
shotgunturret(weapon, WeaponBlocks.shotgunturret, stack(Item.iron, 10), stack(Item.stone, 10)),
flameturret(weapon, WeaponBlocks.flameturret, stack(Item.iron, 12), stack(Item.steel, 9)),
sniperturret(weapon, WeaponBlocks.sniperturret, stack(Item.iron, 15), stack(Item.steel, 10)),
laserturret(weapon, WeaponBlocks.laserturret, stack(Item.steel, 12), stack(Item.titanium, 12)),
mortarturret(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 25), stack(Item.titanium, 15)),
teslaturret(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 25), stack(Item.dirium, 15)),
plasmaturret(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 20), stack(Item.dirium, 15)),
chainturret(weapon, WeaponBlocks.chainturret, stack(Item.steel, 50), stack(Item.titanium, 25), stack(Item.dirium, 40)),
titanturret(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),
smelter(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
crucible(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
coalpurifier(crafting, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
titaniumpurifier(crafting, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
oilrefinery(crafting, ProductionBlocks.oilrefinery, stack(Item.steel, 15), stack(Item.iron, 15)),
stoneformer(crafting, ProductionBlocks.stoneformer, stack(Item.steel, 10), stack(Item.iron, 10)),
lavasmelter(crafting, ProductionBlocks.lavasmelter, stack(Item.steel, 30), stack(Item.titanium, 15)),
stonedrill(production, ProductionBlocks.stonedrill, stack(Item.stone, 12)),
irondrill(production, ProductionBlocks.irondrill, stack(Item.stone, 25)),
coaldrill(production, ProductionBlocks.coaldrill, stack(Item.stone, 25), stack(Item.iron, 40)),
titaniumdrill(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 40), stack(Item.steel, 50)),
uraniumdrill(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
omnidrill(production, ProductionBlocks.omnidrill, stack(Item.titanium, 30), stack(Item.dirium, 40)),
coalgenerator(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
thermalgenerator(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)),
combustiongenerator(power, ProductionBlocks.combustiongenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
rtgenerator(power, ProductionBlocks.rtgenerator, stack(Item.titanium, 20), stack(Item.steel, 20)),
nuclearreactor(power, ProductionBlocks.nuclearReactor, stack(Item.titanium, 40), stack(Item.dirium, 40), stack(Item.steel, 50)),
powerbooster(power, DistributionBlocks.powerbooster, stack(Item.steel, 8), stack(Item.iron, 8)),
powerlaser(power, DistributionBlocks.powerlaser, stack(Item.steel, 3), stack(Item.iron, 3)),
powerlasercorner(power, DistributionBlocks.powerlasercorner, stack(Item.steel, 4), stack(Item.iron, 4)),
powerlaserrouter(power, DistributionBlocks.powerlaserrouter, stack(Item.steel, 5), stack(Item.iron, 5)),
shieldgenerator(power, DefenseBlocks.shieldgenerator, stack(Item.titanium, 30), stack(Item.dirium, 30)),
teleporter(distribution, DistributionBlocks.teleporter, stack(Item.steel, 20), stack(Item.dirium, 15)),
healturret(power, DefenseBlocks.repairturret, stack(Item.iron, 30)),
megahealturret(power, DefenseBlocks.megarepairturret, stack(Item.iron, 20), stack(Item.steel, 30)),
pump(production, ProductionBlocks.pump, stack(Item.steel, 10)),
fluxpump(production, ProductionBlocks.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5));
public Block result;
public ItemStack[] requirements;
public Section section;
private Recipe(Section section, Block result, ItemStack... requirements){
this.result = result;
this.requirements = requirements;
this.section = section;
}
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
public static Recipe getByResult(Block block){
for(Recipe recipe : Recipe.values()){
if(recipe.result == block){
return recipe;
}
}
return null;
}
public static Array<Recipe> getBy(Section section, Array<Recipe> r){
for(Recipe recipe : Recipe.values()){
if(recipe.section == section)
r.add(recipe);
}
return r;
}
public Recipe(Section section, Block result, ItemStack... requirements){
this.result = result;
this.requirements = requirements;
this.section = section;
}
}

View File

@@ -0,0 +1,113 @@
package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.DefenseBlocks;
import io.anuke.mindustry.world.blocks.DistributionBlocks;
import io.anuke.mindustry.world.blocks.ProductionBlocks;
import io.anuke.mindustry.world.blocks.WeaponBlocks;
import static io.anuke.mindustry.resource.Section.*;
public class Recipes {
private static final Array<Recipe> list = Array.with(
new Recipe(defense, DefenseBlocks.stonewall, stack(Item.stone, 12)),
new Recipe(defense, DefenseBlocks.ironwall, stack(Item.iron, 12)),
new Recipe(defense, DefenseBlocks.steelwall, stack(Item.steel, 12)),
new Recipe(defense, DefenseBlocks.titaniumwall, stack(Item.titanium, 12)),
new Recipe(defense, DefenseBlocks.diriumwall, stack(Item.dirium, 12)),
new Recipe(defense, DefenseBlocks.steelwalllarge, stack(Item.steel, 12*4)),
new Recipe(defense, DefenseBlocks.titaniumwalllarge, stack(Item.titanium, 12*4)),
new Recipe(defense, DefenseBlocks.diriumwalllarge, stack(Item.dirium, 12*4)),
new Recipe(defense, DefenseBlocks.door, stack(Item.steel, 3), stack(Item.iron, 3*4)),
new Recipe(defense, DefenseBlocks.largedoor, stack(Item.steel, 3*4), stack(Item.iron, 3*4*4)),
new Recipe(defense, DefenseBlocks.titaniumshieldwall, stack(Item.titanium, 16)),
new Recipe(distribution, DistributionBlocks.conveyor, stack(Item.stone, 1)),
new Recipe(distribution, DistributionBlocks.steelconveyor, stack(Item.steel, 1)),
new Recipe(distribution, DistributionBlocks.pulseconveyor, stack(Item.dirium, 1)),
new Recipe(distribution, DistributionBlocks.router, stack(Item.stone, 2)),
new Recipe(distribution, DistributionBlocks.junction, stack(Item.iron, 2)),
new Recipe(distribution, DistributionBlocks.tunnel, stack(Item.iron, 2)),
new Recipe(distribution, DistributionBlocks.conduit, stack(Item.steel, 1)),
new Recipe(distribution, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
new Recipe(distribution, DistributionBlocks.liquidrouter, stack(Item.steel, 2)),
new Recipe(distribution, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
new Recipe(distribution, DistributionBlocks.sorter, stack(Item.steel, 2)),
new Recipe(weapon, WeaponBlocks.turret, stack(Item.stone, 4)),
new Recipe(weapon, WeaponBlocks.doubleturret, stack(Item.stone, 7)),
new Recipe(weapon, WeaponBlocks.machineturret, stack(Item.iron, 8), stack(Item.stone, 10)),
new Recipe(weapon, WeaponBlocks.shotgunturret, stack(Item.iron, 10), stack(Item.stone, 10)),
new Recipe(weapon, WeaponBlocks.flameturret, stack(Item.iron, 12), stack(Item.steel, 9)),
new Recipe(weapon, WeaponBlocks.sniperturret, stack(Item.iron, 15), stack(Item.steel, 10)),
new Recipe(weapon, WeaponBlocks.laserturret, stack(Item.steel, 12), stack(Item.titanium, 12)),
new Recipe(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 25), stack(Item.titanium, 15)),
new Recipe(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 25), stack(Item.dirium, 15)),
new Recipe(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 20), stack(Item.dirium, 15)),
new Recipe(weapon, WeaponBlocks.chainturret, stack(Item.steel, 50), stack(Item.titanium, 25), stack(Item.dirium, 40)),
new Recipe(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),
new Recipe(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
new Recipe(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
new Recipe(crafting, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
new Recipe(crafting, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
new Recipe(crafting, ProductionBlocks.oilrefinery, stack(Item.steel, 15), stack(Item.iron, 15)),
new Recipe(crafting, ProductionBlocks.stoneformer, stack(Item.steel, 10), stack(Item.iron, 10)),
new Recipe(crafting, ProductionBlocks.lavasmelter, stack(Item.steel, 30), stack(Item.titanium, 15)),
new Recipe(crafting, ProductionBlocks.weaponFactory, stack(Item.steel, 30), stack(Item.titanium, 15)),
new Recipe(production, ProductionBlocks.stonedrill, stack(Item.stone, 12)),
new Recipe(production, ProductionBlocks.irondrill, stack(Item.stone, 25)),
new Recipe(production, ProductionBlocks.coaldrill, stack(Item.stone, 25), stack(Item.iron, 40)),
new Recipe(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 40), stack(Item.steel, 50)),
new Recipe(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
new Recipe(production, ProductionBlocks.omnidrill, stack(Item.titanium, 30), stack(Item.dirium, 40)),
new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
new Recipe(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)),
new Recipe(power, ProductionBlocks.combustiongenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
new Recipe(power, ProductionBlocks.rtgenerator, stack(Item.titanium, 20), stack(Item.steel, 20)),
new Recipe(power, ProductionBlocks.nuclearReactor, stack(Item.titanium, 40), stack(Item.dirium, 40), stack(Item.steel, 50)),
new Recipe(power, DistributionBlocks.powerbooster, stack(Item.steel, 8), stack(Item.iron, 8)),
new Recipe(power, DistributionBlocks.powerlaser, stack(Item.steel, 3), stack(Item.iron, 3)),
new Recipe(power, DistributionBlocks.powerlasercorner, stack(Item.steel, 4), stack(Item.iron, 4)),
new Recipe(power, DistributionBlocks.powerlaserrouter, stack(Item.steel, 5), stack(Item.iron, 5)),
new Recipe(power, DefenseBlocks.shieldgenerator, stack(Item.titanium, 30), stack(Item.dirium, 30)),
new Recipe(distribution, DistributionBlocks.teleporter, stack(Item.steel, 20), stack(Item.dirium, 15)),
new Recipe(power, DefenseBlocks.repairturret, stack(Item.iron, 30)),
new Recipe(power, DefenseBlocks.megarepairturret, stack(Item.iron, 20), stack(Item.steel, 30)),
new Recipe(production, ProductionBlocks.pump, stack(Item.steel, 10)),
new Recipe(production, ProductionBlocks.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5))
);
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
public static Array<Recipe> all(){
return list;
}
public static Recipe getByResult(Block block){
for(Recipe recipe : list){
if(recipe.result == block){
return recipe;
}
}
return null;
}
public static Array<Recipe> getBy(Section section, Array<Recipe> r){
for(Recipe recipe : list){
if(recipe.section == section)
r.add(recipe);
}
return r;
}
}

View File

@@ -1,18 +1,28 @@
package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.Array;
import io.anuke.ucore.util.Bundles;
public abstract class Upgrade {
private static Array<Upgrade> upgrades = new Array<>();
private static byte lastid;
public final byte id;
public final String name;
public final String description;
public Upgrade(){
public Upgrade(String name){
this.id = lastid ++;
this.name = name;
this.description = Bundles.getNotNull("upgrade."+name+".description");
upgrades.add(this);
}
public String localized(){
return Bundles.get("upgrade." + name + ".name");
}
public static Upgrade getByID(byte id){
return upgrades.get(id);
}

View File

@@ -11,7 +11,6 @@ import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.Mathf;
public class Weapon extends Upgrade{
@@ -22,31 +21,31 @@ public class Weapon extends Upgrade{
effect = Fx.shoot3;
}
},
triblaster = new Weapon("blaster", 13, BulletType.shot){
triblaster = new Weapon("triblaster", 13, BulletType.shot){
{
shots = 3;
effect = Fx.shoot;
}
},
multigun = new Weapon("blaster", 6, BulletType.multishot){
multigun = new Weapon("multigun", 6, BulletType.multishot){
{
effect = Fx.shoot2;
inaccuracy = 8f;
}
},
flamer = new Weapon("blaster", 5, BulletType.flame){
flamer = new Weapon("flamer", 5, BulletType.flame){
{
shootsound = "flame2";
inaccuracy = 12f;
}
},
railgun = new Weapon("blaster", 40, BulletType.sniper){
railgun = new Weapon("railgun", 40, BulletType.sniper){
{
shootsound = "railgun";
effect = Fx.railshoot;
}
},
mortar = new Weapon("blaster", 100, BulletType.shell){
mortar = new Weapon("mortar", 100, BulletType.shell){
{
shootsound = "bigshot";
effect = Fx.mortarshoot;
@@ -60,15 +59,11 @@ public class Weapon extends Upgrade{
float inaccuracy = 0f;
float shake = 0f;
Effect effect;
public final String description;
public final String name;
private Weapon(String name, float reload, BulletType type){
super(name);
this.reload = reload;
this.type = type;
this.name = name;
this.description = Bundles.getNotNull("weapon."+name+".description");
}
public void update(Player p){
@@ -77,7 +72,6 @@ public class Weapon extends Upgrade{
}
}
void shootInternal(Player p, float x, float y, float rotation){
Angles.shotgun(shots, 12f, rotation, f -> bullet(p, x, y, f + Mathf.range(inaccuracy)));
Angles.translation(rotation, 3f);
@@ -86,7 +80,7 @@ public class Weapon extends Upgrade{
Effects.sound(shootsound, x, y);
}
void shoot(Player p, float x, float y, float angle){
public void shoot(Player p, float x, float y, float angle){
shootInternal(p, x, y, angle);
if(Net.active() && p == Vars.player){
@@ -98,10 +92,6 @@ public class Weapon extends Upgrade{
Angles.translation(angle, 3f);
new Bullet(type, owner, x + Angles.x(), y + Angles.y(), angle).add();
}
public String localized(){
return Bundles.get("weapon."+name + ".name");
}
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);