Added weapon factory block, refactored recipes
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/weaponfactory.png
Normal file
BIN
core/assets-raw/sprites/blocks/weaponfactory.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 315 B |
@@ -266,18 +266,20 @@ keybind.weapon_6.name=weapon_6
|
|||||||
mode.waves.name=waves
|
mode.waves.name=waves
|
||||||
mode.sandbox.name=sandbox
|
mode.sandbox.name=sandbox
|
||||||
mode.freebuild.name=freebuild
|
mode.freebuild.name=freebuild
|
||||||
weapon.blaster.name=blaster
|
upgrade.standard.name=standard
|
||||||
weapon.blaster.description=Shoots a slow, weak bullet.
|
upgrade.standard.description=The standard mech.
|
||||||
weapon.triblaster.name=triblaster
|
upgrade.blaster.name=blaster
|
||||||
weapon.triblaster.description=Shoots 3 bullets in a spread.
|
upgrade.blaster.description=Shoots a slow, weak bullet.
|
||||||
weapon.multigun.name=multigun
|
upgrade.triblaster.name=triblaster
|
||||||
weapon.multigun.description=Shoots inaccurate bullets with a high\nrate of fire.
|
upgrade.triblaster.description=Shoots 3 bullets in a spread.
|
||||||
weapon.flamer.name=flamer
|
upgrade.multigun.name=multigun
|
||||||
weapon.flamer.description=Shoots a stream of fire.
|
upgrade.multigun.description=Shoots inaccurate bullets with a high\nrate of fire.
|
||||||
weapon.railgun.name=railgun
|
upgrade.flamer.name=flamer
|
||||||
weapon.railgun.description=Shoots one long-range bullet.
|
upgrade.flamer.description=Shoots a stream of fire.
|
||||||
weapon.mortar.name=mortar
|
upgrade.railgun.name=railgun
|
||||||
weapon.mortar.description=Shoots a slow, but damaging shell.
|
upgrade.railgun.description=Shoots one long-range bullet.
|
||||||
|
upgrade.mortar.name=mortar
|
||||||
|
upgrade.mortar.description=Shoots a slow, but damaging shell.
|
||||||
item.stone.name=stone
|
item.stone.name=stone
|
||||||
item.iron.name=iron
|
item.iron.name=iron
|
||||||
item.coal.name=coal
|
item.coal.name=coal
|
||||||
@@ -289,6 +291,7 @@ liquid.water.name=water
|
|||||||
liquid.plasma.name=plasma
|
liquid.plasma.name=plasma
|
||||||
liquid.lava.name=lava
|
liquid.lava.name=lava
|
||||||
liquid.oil.name=oil
|
liquid.oil.name=oil
|
||||||
|
block.weaponfactory.name=weapon factory
|
||||||
block.air.name=air
|
block.air.name=air
|
||||||
block.blockpart.name=blockpart
|
block.blockpart.name=blockpart
|
||||||
block.deepwater.name=deepwater
|
block.deepwater.name=deepwater
|
||||||
|
|||||||
@@ -95,6 +95,13 @@ blocks/block-2x2
|
|||||||
orig: 16, 16
|
orig: 16, 16
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
blocks/weaponfactory
|
||||||
|
rotate: false
|
||||||
|
xy: 844, 495
|
||||||
|
size: 16, 16
|
||||||
|
orig: 16, 16
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
blocks/block-3x3
|
blocks/block-3x3
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 698, 313
|
xy: 698, 313
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
@@ -17,6 +17,7 @@ import io.anuke.mindustry.net.Net.SendMode;
|
|||||||
import io.anuke.mindustry.net.Packets.*;
|
import io.anuke.mindustry.net.Packets.*;
|
||||||
import io.anuke.mindustry.net.Syncable;
|
import io.anuke.mindustry.net.Syncable;
|
||||||
import io.anuke.mindustry.net.Syncable.Interpolator;
|
import io.anuke.mindustry.net.Syncable.Interpolator;
|
||||||
|
import io.anuke.mindustry.resource.Upgrade;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -148,7 +149,7 @@ public class NetClient extends Module {
|
|||||||
Net.handle(ShootPacket.class, packet -> {
|
Net.handle(ShootPacket.class, packet -> {
|
||||||
Player player = Vars.control.playerGroup.getByID(packet.playerid);
|
Player player = Vars.control.playerGroup.getByID(packet.playerid);
|
||||||
|
|
||||||
Weapon weapon = Weapon.values()[packet.weaponid];
|
Weapon weapon = (Weapon) Upgrade.getByID(packet.weaponid);
|
||||||
weapon.shoot(player, packet.x, packet.y, packet.rotation);
|
weapon.shoot(player, packet.x, packet.y, packet.rotation);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -266,7 +267,7 @@ public class NetClient extends Module {
|
|||||||
|
|
||||||
public void handleUpgrade(Weapon weapon){
|
public void handleUpgrade(Weapon weapon){
|
||||||
UpgradePacket packet = new UpgradePacket();
|
UpgradePacket packet = new UpgradePacket();
|
||||||
packet.id = weapon.ordinal();
|
packet.id = weapon.id;
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +284,7 @@ public class NetClient extends Module {
|
|||||||
|
|
||||||
public void handleShoot(Weapon weapon, float x, float y, float angle){
|
public void handleShoot(Weapon weapon, float x, float y, float angle){
|
||||||
ShootPacket packet = new ShootPacket();
|
ShootPacket packet = new ShootPacket();
|
||||||
packet.weaponid = (byte)weapon.ordinal();
|
packet.weaponid = (byte)weapon.id;
|
||||||
packet.x = x;
|
packet.x = x;
|
||||||
packet.y = y;
|
packet.y = y;
|
||||||
packet.rotation = angle;
|
packet.rotation = angle;
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ import io.anuke.mindustry.io.NetworkIO;
|
|||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.Net.SendMode;
|
import io.anuke.mindustry.net.Net.SendMode;
|
||||||
import io.anuke.mindustry.net.Packets.*;
|
import io.anuke.mindustry.net.Packets.*;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.*;
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.UCore;
|
import io.anuke.ucore.UCore;
|
||||||
@@ -118,7 +116,7 @@ public class NetServer extends Module{
|
|||||||
Net.handleServer(ShootPacket.class, packet -> {
|
Net.handleServer(ShootPacket.class, packet -> {
|
||||||
Player player = connections.get(Net.getLastConnection());
|
Player player = connections.get(Net.getLastConnection());
|
||||||
|
|
||||||
Weapon weapon = Weapon.values()[packet.weaponid];
|
Weapon weapon = (Weapon)Upgrade.getByID(packet.weaponid);
|
||||||
weapon.shoot(player, packet.x, packet.y, packet.rotation);
|
weapon.shoot(player, packet.x, packet.y, packet.rotation);
|
||||||
packet.playerid = player.id;
|
packet.playerid = player.id;
|
||||||
|
|
||||||
@@ -129,7 +127,7 @@ public class NetServer extends Module{
|
|||||||
Vars.control.input.placeBlockInternal(packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, false);
|
Vars.control.input.placeBlockInternal(packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, false);
|
||||||
packet.playerid = connections.get(Net.getLastConnection()).id;
|
packet.playerid = connections.get(Net.getLastConnection()).id;
|
||||||
|
|
||||||
Recipe recipe = Recipe.getByResult(Block.getByID(packet.block));
|
Recipe recipe = Recipes.getByResult(Block.getByID(packet.block));
|
||||||
if(recipe != null){
|
if(recipe != null){
|
||||||
for(ItemStack stack : recipe.requirements){
|
for(ItemStack stack : recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
Vars.control.removeItem(stack);
|
||||||
@@ -157,8 +155,9 @@ public class NetServer extends Module{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Net.handleServer(UpgradePacket.class, packet -> {
|
Net.handleServer(UpgradePacket.class, packet -> {
|
||||||
Weapon weapon = Weapon.values()[packet.id];
|
Weapon weapon = (Weapon)Upgrade.getByID(packet.id);
|
||||||
Vars.control.removeItems(weapon.requirements);
|
//TODO
|
||||||
|
//Vars.control.removeItems(weapon.requirements);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,16 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Player extends DestructibleEntity implements Syncable{
|
public class Player extends DestructibleEntity implements Syncable{
|
||||||
private static final float speed = 1.1f;
|
static final float speed = 1.1f;
|
||||||
private static final float dashSpeed = 1.8f;
|
static final float dashSpeed = 1.8f;
|
||||||
|
|
||||||
public String name = "name";
|
public String name = "name";
|
||||||
public Weapon weapon = Weapon.blaster;
|
|
||||||
public Mech mech = Mech.standard;
|
|
||||||
public float angle;
|
|
||||||
public boolean isAndroid;
|
public boolean isAndroid;
|
||||||
|
|
||||||
|
public Weapon weapon = Weapon.blaster;
|
||||||
|
public Mech mech = Mech.standard;
|
||||||
|
|
||||||
|
public float angle;
|
||||||
public transient float targetAngle = 0f;
|
public transient float targetAngle = 0f;
|
||||||
|
|
||||||
public transient int clientid;
|
public transient int clientid;
|
||||||
@@ -90,9 +91,9 @@ public class Player extends DestructibleEntity implements Syncable{
|
|||||||
String part = isAndroid ? "ship" : "mech";
|
String part = isAndroid ? "ship" : "mech";
|
||||||
|
|
||||||
if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal){
|
if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal){
|
||||||
Draw.rect(part+"-"+mech.name(), (int)x, (int)y, angle-90);
|
Draw.rect(part + "-" + mech.name, (int)x, (int)y, angle-90);
|
||||||
}else{
|
}else{
|
||||||
Draw.rect(part+"-"+mech.name(), x, y, angle-90);
|
Draw.rect(part + "-" + mech.name, x, y, angle-90);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import io.anuke.mindustry.graphics.Fx;
|
|||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
import io.anuke.mindustry.resource.Recipe;
|
||||||
|
import io.anuke.mindustry.resource.Recipes;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.SpawnPoint;
|
import io.anuke.mindustry.world.SpawnPoint;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -237,7 +238,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
|
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
|
||||||
Recipe result = null;
|
Recipe result = null;
|
||||||
|
|
||||||
for(Recipe recipe : Recipe.values()){
|
for(Recipe recipe : Recipes.all()){
|
||||||
if(recipe.result == block){
|
if(recipe.result == block){
|
||||||
result = recipe;
|
result = recipe;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import io.anuke.mindustry.core.Tutorial;
|
|||||||
import io.anuke.mindustry.core.Tutorial.Stage;
|
import io.anuke.mindustry.core.Tutorial.Stage;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.GameMode;
|
import io.anuke.mindustry.world.GameMode;
|
||||||
import io.anuke.mindustry.world.Map;
|
import io.anuke.mindustry.world.Map;
|
||||||
@@ -47,10 +46,6 @@ public class BundleGen {
|
|||||||
for(GameMode mode : GameMode.values()){
|
for(GameMode mode : GameMode.values()){
|
||||||
write("mode." + mode.name() + ".name=" + mode.name());
|
write("mode." + mode.name() + ".name=" + mode.name());
|
||||||
}
|
}
|
||||||
for(Weapon weapon : Weapon.values()){
|
|
||||||
write("weapon." + weapon.name() + ".name=" + weapon.name());
|
|
||||||
write("weapon." + weapon.name() + ".description=" + weapon.description);
|
|
||||||
}
|
|
||||||
for(Item item : Item.getAllItems()){
|
for(Item item : Item.getAllItems()){
|
||||||
write("item." + item.name + ".name=" + item.name);
|
write("item." + item.name + ".name=" + item.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import io.anuke.mindustry.entities.enemies.Enemy;
|
|||||||
import io.anuke.mindustry.entities.enemies.EnemyType;
|
import io.anuke.mindustry.entities.enemies.EnemyType;
|
||||||
import io.anuke.mindustry.io.SaveFileVersion;
|
import io.anuke.mindustry.io.SaveFileVersion;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.resource.Upgrade;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.mindustry.world.BlockLoader;
|
import io.anuke.mindustry.world.BlockLoader;
|
||||||
import io.anuke.mindustry.world.GameMode;
|
import io.anuke.mindustry.world.GameMode;
|
||||||
@@ -65,7 +66,7 @@ public class Save12 extends SaveFileVersion {
|
|||||||
int weapons = stream.readByte();
|
int weapons = stream.readByte();
|
||||||
|
|
||||||
for(int i = 0; i < weapons; i ++){
|
for(int i = 0; i < weapons; i ++){
|
||||||
Vars.control.addWeapon(Weapon.values()[stream.readByte()]);
|
Vars.control.addWeapon((Weapon)Upgrade.getByID(stream.readByte()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vars.ui.weaponfrag.update();
|
Vars.ui.weaponfrag.update();
|
||||||
@@ -194,7 +195,7 @@ public class Save12 extends SaveFileVersion {
|
|||||||
|
|
||||||
//start at 1, because the first weapon is always the starter - ignore that
|
//start at 1, because the first weapon is always the starter - ignore that
|
||||||
for(int i = 1; i < Vars.control.getWeapons().size; i ++){
|
for(int i = 1; i < Vars.control.getWeapons().size; i ++){
|
||||||
stream.writeByte(Vars.control.getWeapons().get(i).ordinal()); //weapon ordinal
|
stream.writeByte(Vars.control.getWeapons().get(i).id); //weapon ordinal
|
||||||
}
|
}
|
||||||
|
|
||||||
//--INVENTORY--
|
//--INVENTORY--
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import io.anuke.mindustry.entities.enemies.Enemy;
|
|||||||
import io.anuke.mindustry.entities.enemies.EnemyType;
|
import io.anuke.mindustry.entities.enemies.EnemyType;
|
||||||
import io.anuke.mindustry.io.SaveFileVersion;
|
import io.anuke.mindustry.io.SaveFileVersion;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.resource.Upgrade;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.Blocks;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
@@ -65,7 +66,7 @@ public class Save13 extends SaveFileVersion {
|
|||||||
int weapons = stream.readByte();
|
int weapons = stream.readByte();
|
||||||
|
|
||||||
for(int i = 0; i < weapons; i ++){
|
for(int i = 0; i < weapons; i ++){
|
||||||
Vars.control.addWeapon(Weapon.values()[stream.readByte()]);
|
Vars.control.addWeapon((Weapon) Upgrade.getByID(stream.readByte()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vars.ui.weaponfrag.update();
|
Vars.ui.weaponfrag.update();
|
||||||
@@ -204,7 +205,7 @@ public class Save13 extends SaveFileVersion {
|
|||||||
|
|
||||||
//start at 1, because the first weapon is always the starter - ignore that
|
//start at 1, because the first weapon is always the starter - ignore that
|
||||||
for(int i = 1; i < Vars.control.getWeapons().size; i ++){
|
for(int i = 1; i < Vars.control.getWeapons().size; i ++){
|
||||||
stream.writeByte(Vars.control.getWeapons().get(i).ordinal()); //weapon ordinal
|
stream.writeByte(Vars.control.getWeapons().get(i).id); //weapon ordinal
|
||||||
}
|
}
|
||||||
|
|
||||||
//--INVENTORY--
|
//--INVENTORY--
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.anuke.mindustry.entities.enemies.Enemy;
|
|||||||
import io.anuke.mindustry.entities.enemies.EnemyType;
|
import io.anuke.mindustry.entities.enemies.EnemyType;
|
||||||
import io.anuke.mindustry.io.SaveFileVersion;
|
import io.anuke.mindustry.io.SaveFileVersion;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.resource.Upgrade;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.GameMode;
|
import io.anuke.mindustry.world.GameMode;
|
||||||
@@ -83,7 +84,7 @@ public class Save14 extends SaveFileVersion{
|
|||||||
int weapons = stream.readByte();
|
int weapons = stream.readByte();
|
||||||
|
|
||||||
for(int i = 0; i < weapons; i ++){
|
for(int i = 0; i < weapons; i ++){
|
||||||
Vars.control.addWeapon(Weapon.values()[stream.readByte()]);
|
Vars.control.addWeapon((Weapon) Upgrade.getByID(stream.readByte()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vars.ui.weaponfrag.update();
|
Vars.ui.weaponfrag.update();
|
||||||
@@ -232,7 +233,7 @@ public class Save14 extends SaveFileVersion{
|
|||||||
|
|
||||||
//start at 1, because the first weapon is always the starter - ignore that
|
//start at 1, because the first weapon is always the starter - ignore that
|
||||||
for(int i = 1; i < Vars.control.getWeapons().size; i ++){
|
for(int i = 1; i < Vars.control.getWeapons().size; i ++){
|
||||||
stream.writeByte(Vars.control.getWeapons().get(i).ordinal()); //weapon ordinal
|
stream.writeByte(Vars.control.getWeapons().get(i).id); //weapon ordinal
|
||||||
}
|
}
|
||||||
|
|
||||||
//--INVENTORY--
|
//--INVENTORY--
|
||||||
|
|||||||
@@ -116,6 +116,6 @@ public class Packets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class UpgradePacket{
|
public static class UpgradePacket{
|
||||||
public int id; //weapon ID only, currently
|
public byte id; //weapon ID only, currently
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
package io.anuke.mindustry.resource;
|
package io.anuke.mindustry.resource;
|
||||||
|
|
||||||
public enum Mech{
|
public class Mech extends Upgrade{
|
||||||
standard,
|
public static final Mech
|
||||||
scout{{
|
|
||||||
|
|
||||||
}};
|
|
||||||
public float speedBoost = 1f, damageBoost = 1f;
|
|
||||||
public int regenRate = 10;
|
|
||||||
public int health = 20;
|
|
||||||
|
|
||||||
private Mech(){
|
standard = new Mech("standard");
|
||||||
|
|
||||||
|
public Mech(String name){
|
||||||
|
super(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,114 +1,15 @@
|
|||||||
package io.anuke.mindustry.resource;
|
package io.anuke.mindustry.resource;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.world.Block;
|
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{
|
public Recipe(Section section, Block result, ItemStack... requirements){
|
||||||
stonewall(defense, DefenseBlocks.stonewall, stack(Item.stone, 12)),
|
this.result = result;
|
||||||
ironwall(defense, DefenseBlocks.ironwall, stack(Item.iron, 12)),
|
this.requirements = requirements;
|
||||||
steelwall(defense, DefenseBlocks.steelwall, stack(Item.steel, 12)),
|
this.section = section;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
113
core/src/io/anuke/mindustry/resource/Recipes.java
Normal file
113
core/src/io/anuke/mindustry/resource/Recipes.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,28 @@
|
|||||||
package io.anuke.mindustry.resource;
|
package io.anuke.mindustry.resource;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import io.anuke.ucore.util.Bundles;
|
||||||
|
|
||||||
public abstract class Upgrade {
|
public abstract class Upgrade {
|
||||||
private static Array<Upgrade> upgrades = new Array<>();
|
private static Array<Upgrade> upgrades = new Array<>();
|
||||||
private static byte lastid;
|
private static byte lastid;
|
||||||
|
|
||||||
public final byte id;
|
public final byte id;
|
||||||
|
public final String name;
|
||||||
|
public final String description;
|
||||||
|
|
||||||
public Upgrade(){
|
public Upgrade(String name){
|
||||||
this.id = lastid ++;
|
this.id = lastid ++;
|
||||||
|
this.name = name;
|
||||||
|
this.description = Bundles.getNotNull("upgrade."+name+".description");
|
||||||
|
|
||||||
upgrades.add(this);
|
upgrades.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String localized(){
|
||||||
|
return Bundles.get("upgrade." + name + ".name");
|
||||||
|
}
|
||||||
|
|
||||||
public static Upgrade getByID(byte id){
|
public static Upgrade getByID(byte id){
|
||||||
return upgrades.get(id);
|
return upgrades.get(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import io.anuke.ucore.core.Effects.Effect;
|
|||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.entities.Entity;
|
import io.anuke.ucore.entities.Entity;
|
||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
import io.anuke.ucore.util.Bundles;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class Weapon extends Upgrade{
|
public class Weapon extends Upgrade{
|
||||||
@@ -22,31 +21,31 @@ public class Weapon extends Upgrade{
|
|||||||
effect = Fx.shoot3;
|
effect = Fx.shoot3;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
triblaster = new Weapon("blaster", 13, BulletType.shot){
|
triblaster = new Weapon("triblaster", 13, BulletType.shot){
|
||||||
{
|
{
|
||||||
shots = 3;
|
shots = 3;
|
||||||
effect = Fx.shoot;
|
effect = Fx.shoot;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
multigun = new Weapon("blaster", 6, BulletType.multishot){
|
multigun = new Weapon("multigun", 6, BulletType.multishot){
|
||||||
{
|
{
|
||||||
effect = Fx.shoot2;
|
effect = Fx.shoot2;
|
||||||
inaccuracy = 8f;
|
inaccuracy = 8f;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
flamer = new Weapon("blaster", 5, BulletType.flame){
|
flamer = new Weapon("flamer", 5, BulletType.flame){
|
||||||
{
|
{
|
||||||
shootsound = "flame2";
|
shootsound = "flame2";
|
||||||
inaccuracy = 12f;
|
inaccuracy = 12f;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
railgun = new Weapon("blaster", 40, BulletType.sniper){
|
railgun = new Weapon("railgun", 40, BulletType.sniper){
|
||||||
{
|
{
|
||||||
shootsound = "railgun";
|
shootsound = "railgun";
|
||||||
effect = Fx.railshoot;
|
effect = Fx.railshoot;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mortar = new Weapon("blaster", 100, BulletType.shell){
|
mortar = new Weapon("mortar", 100, BulletType.shell){
|
||||||
{
|
{
|
||||||
shootsound = "bigshot";
|
shootsound = "bigshot";
|
||||||
effect = Fx.mortarshoot;
|
effect = Fx.mortarshoot;
|
||||||
@@ -60,15 +59,11 @@ public class Weapon extends Upgrade{
|
|||||||
float inaccuracy = 0f;
|
float inaccuracy = 0f;
|
||||||
float shake = 0f;
|
float shake = 0f;
|
||||||
Effect effect;
|
Effect effect;
|
||||||
|
|
||||||
public final String description;
|
|
||||||
public final String name;
|
|
||||||
|
|
||||||
private Weapon(String name, float reload, BulletType type){
|
private Weapon(String name, float reload, BulletType type){
|
||||||
|
super(name);
|
||||||
this.reload = reload;
|
this.reload = reload;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
|
||||||
this.description = Bundles.getNotNull("weapon."+name+".description");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Player p){
|
public void update(Player p){
|
||||||
@@ -77,7 +72,6 @@ public class Weapon extends Upgrade{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void shootInternal(Player p, float x, float y, float rotation){
|
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.shotgun(shots, 12f, rotation, f -> bullet(p, x, y, f + Mathf.range(inaccuracy)));
|
||||||
Angles.translation(rotation, 3f);
|
Angles.translation(rotation, 3f);
|
||||||
@@ -86,7 +80,7 @@ public class Weapon extends Upgrade{
|
|||||||
Effects.sound(shootsound, x, y);
|
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);
|
shootInternal(p, x, y, angle);
|
||||||
|
|
||||||
if(Net.active() && p == Vars.player){
|
if(Net.active() && p == Vars.player){
|
||||||
@@ -98,10 +92,6 @@ public class Weapon extends Upgrade{
|
|||||||
Angles.translation(angle, 3f);
|
Angles.translation(angle, 3f);
|
||||||
new Bullet(type, owner, x + Angles.x(), y + Angles.y(), angle).add();
|
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){
|
private static ItemStack stack(Item item, int amount){
|
||||||
return new ItemStack(item, amount);
|
return new ItemStack(item, amount);
|
||||||
|
|||||||
@@ -1,24 +1,6 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import io.anuke.mindustry.Vars;
|
|
||||||
import io.anuke.mindustry.core.GameState;
|
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
|
||||||
import io.anuke.ucore.core.Draw;
|
|
||||||
import io.anuke.ucore.core.Effects;
|
|
||||||
import io.anuke.ucore.function.Listenable;
|
|
||||||
import io.anuke.ucore.scene.ui.Image;
|
|
||||||
import io.anuke.ucore.scene.ui.TextButton;
|
|
||||||
import io.anuke.ucore.scene.ui.Tooltip;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.control;
|
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
|
||||||
|
|
||||||
public class UpgradeDialog extends FloatingDialog{
|
public class UpgradeDialog extends FloatingDialog{
|
||||||
boolean wasPaused = false;
|
boolean wasPaused = false;
|
||||||
|
|
||||||
@@ -28,6 +10,7 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
|
/*
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
|
||||||
hidden(()->{
|
hidden(()->{
|
||||||
@@ -43,10 +26,14 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
weptab.margin(20);
|
weptab.margin(20);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(Weapon weapon : Weapon.values()){
|
for(Upgrade upgrade : Upgrade.getAllUpgrades()){
|
||||||
TextButton button = new TextButton("$weapon."+weapon.name()+".name");
|
if(!(upgrade instanceof Weapon)) continue;
|
||||||
|
|
||||||
|
Weapon weapon = (Weapon)upgrade;
|
||||||
|
|
||||||
|
TextButton button = new TextButton(weapon.localized());
|
||||||
|
|
||||||
Image img = new Image(Draw.region(weapon.name()));
|
Image img = new Image(Draw.region(weapon.name));
|
||||||
button.add(img).size(8*5);
|
button.add(img).size(8*5);
|
||||||
button.getCells().reverse();
|
button.getCells().reverse();
|
||||||
button.row();
|
button.row();
|
||||||
@@ -139,6 +126,7 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
content().row();
|
content().row();
|
||||||
content().add(weptab);
|
content().add(weptab);
|
||||||
content().row();
|
content().row();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class BlockConfigFragment implements Fragment {
|
|||||||
|
|
||||||
table.update(()->{
|
table.update(()->{
|
||||||
table.setOrigin(Align.center);
|
table.setOrigin(Align.center);
|
||||||
Vector2 pos = Graphics.screen(tile.worldx(), tile.worldy());
|
Vector2 pos = Graphics.screen(tile.worldx() + tile.block().getPlaceOffset().x, tile.worldy() + tile.block().getPlaceOffset().y);
|
||||||
table.setPosition(pos.x, pos.y, Align.center);
|
table.setPosition(pos.x, pos.y, Align.center);
|
||||||
if(configTile == null || configTile.block() == Blocks.air){
|
if(configTile == null || configTile.block() == Blocks.air){
|
||||||
hideConfig();
|
hideConfig();
|
||||||
|
|||||||
@@ -9,10 +9,7 @@ import io.anuke.mindustry.Vars;
|
|||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.*;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
|
||||||
import io.anuke.mindustry.resource.Section;
|
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.graphics.Hue;
|
import io.anuke.ucore.graphics.Hue;
|
||||||
@@ -72,17 +69,17 @@ public class BlocksFragment implements Fragment{
|
|||||||
|
|
||||||
Stack stack = new Stack();
|
Stack stack = new Stack();
|
||||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
Array<Recipe> recipes = new Array<Recipe>();
|
Array<Recipe> recipes = new Array<>();
|
||||||
|
|
||||||
for (Section sec : Section.values()) {
|
for (Section sec : Section.values()) {
|
||||||
recipes.clear();
|
recipes.clear();
|
||||||
Recipe.getBy(sec, recipes);
|
Recipes.getBy(sec, recipes);
|
||||||
maxcol = Math.max((int) ((float) recipes.size / rows + 1), maxcol);
|
maxcol = Math.max((int) ((float) recipes.size / rows + 1), maxcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Section sec : Section.values()) {
|
for (Section sec : Section.values()) {
|
||||||
recipes.clear();
|
recipes.clear();
|
||||||
Recipe.getBy(sec, recipes);
|
Recipes.getBy(sec, recipes);
|
||||||
|
|
||||||
Table table = new Table();
|
Table table = new Table();
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class WeaponFragment implements Fragment{
|
|||||||
weapontable.defaults().size(58, 62);
|
weapontable.defaults().size(58, 62);
|
||||||
|
|
||||||
for(Weapon weapon : control.getWeapons()){
|
for(Weapon weapon : control.getWeapons()){
|
||||||
ImageButton button = new ImageButton(Draw.region(weapon.name()), "toggle");
|
ImageButton button = new ImageButton(Draw.region(weapon.name), "toggle");
|
||||||
button.getImageCell().size(8*5);
|
button.getImageCell().size(8*5);
|
||||||
|
|
||||||
group.add(button);
|
group.add(button);
|
||||||
@@ -52,7 +52,7 @@ public class WeaponFragment implements Fragment{
|
|||||||
String description = weapon.description;
|
String description = weapon.description;
|
||||||
|
|
||||||
tiptable.background("button");
|
tiptable.background("button");
|
||||||
tiptable.add("$weapon."+weapon.name()+".name", 0.5f).left().padBottom(3f);
|
tiptable.add("$weapon."+weapon.name+".name", 0.5f).left().padBottom(3f);
|
||||||
|
|
||||||
tiptable.row();
|
tiptable.row();
|
||||||
tiptable.row();
|
tiptable.row();
|
||||||
@@ -65,7 +65,5 @@ public class WeaponFragment implements Fragment{
|
|||||||
|
|
||||||
button.addListener(tip);
|
button.addListener(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
weapontable.addImageButton("icon-menu", 8*4, ui.upgrades::show);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,5 +199,10 @@ public class ProductionBlocks{
|
|||||||
health = 600;
|
health = 600;
|
||||||
breaktime *= 2.3f;
|
breaktime *= 2.3f;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
weaponFactory = new WeaponFactory("weaponfactory"){
|
||||||
|
{
|
||||||
|
width = height = 2;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
|
import io.anuke.mindustry.resource.Upgrade;
|
||||||
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.function.Listenable;
|
||||||
|
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||||
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
import io.anuke.ucore.scene.ui.Tooltip;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
|
||||||
|
public class WeaponFactory extends Block implements Configurable{
|
||||||
|
protected ObjectMap<Weapon, ItemStack[]> costs = new ObjectMap<>();
|
||||||
|
|
||||||
|
public WeaponFactory(String name){
|
||||||
|
super(name);
|
||||||
|
solid = true;
|
||||||
|
breakable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildTable(Tile tile, Table table) {
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
Table content = new Table();
|
||||||
|
|
||||||
|
content.add("$text.upgrades").colspan(3).row();
|
||||||
|
|
||||||
|
for(Upgrade upgrade : Upgrade.getAllUpgrades()){
|
||||||
|
if(!(upgrade instanceof Weapon)) continue;
|
||||||
|
Weapon weapon = (Weapon)upgrade;
|
||||||
|
|
||||||
|
ItemStack[] requirements = costs.get(weapon);
|
||||||
|
|
||||||
|
Table tiptable = new Table();
|
||||||
|
|
||||||
|
Listenable run = ()->{
|
||||||
|
tiptable.clearChildren();
|
||||||
|
|
||||||
|
String description = weapon.description;
|
||||||
|
|
||||||
|
tiptable.background("pane");
|
||||||
|
tiptable.add("[orange]" + weapon.localized(), 0.5f).left().padBottom(4f);
|
||||||
|
|
||||||
|
Table reqtable = new Table();
|
||||||
|
|
||||||
|
tiptable.row();
|
||||||
|
tiptable.add(reqtable).left();
|
||||||
|
|
||||||
|
if(!control.hasWeapon(weapon)){
|
||||||
|
for(ItemStack s : requirements){
|
||||||
|
|
||||||
|
int amount = Math.min(control.getAmount(s.item), s.amount);
|
||||||
|
reqtable.addImage(Draw.region("icon-" + s.item.name)).padRight(3).size(8*2);
|
||||||
|
reqtable.add(
|
||||||
|
(amount >= s.amount ? "" : "[RED]")
|
||||||
|
+ amount + " / " +s.amount, 0.5f).left();
|
||||||
|
reqtable.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tiptable.row();
|
||||||
|
tiptable.add().size(10);
|
||||||
|
tiptable.row();
|
||||||
|
tiptable.add("[gray]" + description).left();
|
||||||
|
tiptable.row();
|
||||||
|
if(control.hasWeapon(weapon)){
|
||||||
|
tiptable.add("$text.purchased").padTop(6).left();
|
||||||
|
}
|
||||||
|
tiptable.margin(14f);
|
||||||
|
};
|
||||||
|
|
||||||
|
run.listen();
|
||||||
|
|
||||||
|
Tooltip<Table> tip = new Tooltip<>(tiptable, run);
|
||||||
|
|
||||||
|
tip.setInstant(true);
|
||||||
|
|
||||||
|
ImageButton button = content.addImageButton("white", 8*4, () -> {
|
||||||
|
|
||||||
|
}).size(49f, 54f).padBottom(-5)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
button.getStyle().imageUp = new TextureRegionDrawable(Draw.region(weapon.name));
|
||||||
|
button.addListener(tip);
|
||||||
|
|
||||||
|
if(++i % 3 == 0){
|
||||||
|
content.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table.add(content).padTop(140f);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -136,6 +136,7 @@ public class KryoClient implements ClientProvider{
|
|||||||
for(Class<?> c : types){
|
for(Class<?> c : types){
|
||||||
client.getKryo().register(c);
|
client.getKryo().register(c);
|
||||||
}
|
}
|
||||||
|
KryoRegistrator.register(client.getKryo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
38
kryonet/src/io/anuke/kryonet/KryoRegistrator.java
Normal file
38
kryonet/src/io/anuke/kryonet/KryoRegistrator.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package io.anuke.kryonet;
|
||||||
|
|
||||||
|
import com.esotericsoftware.kryo.Kryo;
|
||||||
|
import com.esotericsoftware.kryo.Serializer;
|
||||||
|
import com.esotericsoftware.kryo.io.Input;
|
||||||
|
import com.esotericsoftware.kryo.io.Output;
|
||||||
|
import io.anuke.mindustry.resource.Mech;
|
||||||
|
import io.anuke.mindustry.resource.Upgrade;
|
||||||
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
|
|
||||||
|
public class KryoRegistrator {
|
||||||
|
|
||||||
|
public static void register(Kryo kryo){
|
||||||
|
kryo.register(Weapon.class, new Serializer<Weapon>() {
|
||||||
|
@Override
|
||||||
|
public void write(Kryo kryo, Output output, Weapon object) {
|
||||||
|
output.writeByte(object.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Weapon read(Kryo kryo, Input input, Class type) {
|
||||||
|
return (Weapon)Upgrade.getByID(input.readByte());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
kryo.register(Mech.class, new Serializer<Mech>() {
|
||||||
|
@Override
|
||||||
|
public void write(Kryo kryo, Output output, Mech object) {
|
||||||
|
output.writeByte(object.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mech read(Kryo kryo, Input input, Class type) {
|
||||||
|
return (Mech)Upgrade.getByID(input.readByte());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -190,6 +190,7 @@ public class KryoServer implements ServerProvider {
|
|||||||
for(Class<?> c : types){
|
for(Class<?> c : types){
|
||||||
server.getKryo().register(c);
|
server.getKryo().register(c);
|
||||||
}
|
}
|
||||||
|
KryoRegistrator.register(server.getKryo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user