Implemented dual wielding
This commit is contained in:
@@ -122,7 +122,7 @@ text.settings.game=Game
|
|||||||
text.settings.sound=Sound
|
text.settings.sound=Sound
|
||||||
text.settings.graphics=Graphics
|
text.settings.graphics=Graphics
|
||||||
text.upgrades=Upgrades
|
text.upgrades=Upgrades
|
||||||
text.purchased=[LIME]Purchased!
|
text.purchased=[LIME]Created!
|
||||||
text.weapons=Weapons
|
text.weapons=Weapons
|
||||||
text.paused=Paused
|
text.paused=Paused
|
||||||
text.respawn=Respawning in
|
text.respawn=Respawning in
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ public class Control extends Module{
|
|||||||
"select", Input.MOUSE_LEFT,
|
"select", Input.MOUSE_LEFT,
|
||||||
"break", Input.MOUSE_RIGHT,
|
"break", Input.MOUSE_RIGHT,
|
||||||
"shoot", Input.MOUSE_LEFT,
|
"shoot", Input.MOUSE_LEFT,
|
||||||
|
"weapon_alt_select", Input.Q,
|
||||||
"zoom_hold", Input.CONTROL_LEFT,
|
"zoom_hold", Input.CONTROL_LEFT,
|
||||||
"zoom", new Axis(Input.SCROLL),
|
"zoom", new Axis(Input.SCROLL),
|
||||||
"menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
|
"menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
|
||||||
@@ -223,7 +224,7 @@ public class Control extends Module{
|
|||||||
weapons.clear();
|
weapons.clear();
|
||||||
|
|
||||||
weapons.add(Weapon.blaster);
|
weapons.add(Weapon.blaster);
|
||||||
player.weapon = weapons.first();
|
player.weaponLeft = player.weaponRight = weapons.first();
|
||||||
|
|
||||||
lastUpdated = -1;
|
lastUpdated = -1;
|
||||||
wave = 1;
|
wave = 1;
|
||||||
@@ -672,5 +673,4 @@ public class Control extends Module{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,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.id;
|
packet.weaponid = weapon.id;
|
||||||
packet.x = x;
|
packet.x = x;
|
||||||
packet.y = y;
|
packet.y = y;
|
||||||
packet.rotation = angle;
|
packet.rotation = angle;
|
||||||
|
|||||||
@@ -156,8 +156,7 @@ public class NetServer extends Module{
|
|||||||
|
|
||||||
Net.handleServer(UpgradePacket.class, packet -> {
|
Net.handleServer(UpgradePacket.class, packet -> {
|
||||||
Weapon weapon = (Weapon)Upgrade.getByID(packet.id);
|
Weapon weapon = (Weapon)Upgrade.getByID(packet.id);
|
||||||
//TODO
|
Vars.control.removeItems(UpgradeRecipes.get(weapon));
|
||||||
//Vars.control.removeItems(weapon.requirements);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ public class UI extends SceneModule{
|
|||||||
public SettingsMenuDialog settings;
|
public SettingsMenuDialog settings;
|
||||||
public ControlsDialog controls;
|
public ControlsDialog controls;
|
||||||
public MapEditorDialog editor;
|
public MapEditorDialog editor;
|
||||||
public UpgradeDialog upgrades;
|
|
||||||
|
|
||||||
public final MenuFragment menufrag = new MenuFragment();
|
public final MenuFragment menufrag = new MenuFragment();
|
||||||
public final ToolFragment toolfrag = new ToolFragment();
|
public final ToolFragment toolfrag = new ToolFragment();
|
||||||
@@ -135,7 +134,6 @@ public class UI extends SceneModule{
|
|||||||
join = new JoinDialog();
|
join = new JoinDialog();
|
||||||
discord = new DiscordDialog();
|
discord = new DiscordDialog();
|
||||||
load = new LoadDialog();
|
load = new LoadDialog();
|
||||||
upgrades = new UpgradeDialog();
|
|
||||||
levels = new LevelDialog();
|
levels = new LevelDialog();
|
||||||
settings = new SettingsMenuDialog();
|
settings = new SettingsMenuDialog();
|
||||||
paused = new PausedDialog();
|
paused = new PausedDialog();
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ public class Player extends DestructibleEntity implements Syncable{
|
|||||||
public String name = "name";
|
public String name = "name";
|
||||||
public boolean isAndroid;
|
public boolean isAndroid;
|
||||||
|
|
||||||
public Weapon weapon = Weapon.blaster;
|
public Weapon weaponLeft = Weapon.blaster;
|
||||||
|
public Weapon weaponRight = Weapon.blaster;
|
||||||
public Mech mech = Mech.standard;
|
public Mech mech = Mech.standard;
|
||||||
|
|
||||||
public float angle;
|
public float angle;
|
||||||
@@ -129,7 +130,8 @@ public class Player extends DestructibleEntity implements Syncable{
|
|||||||
&& !ui.hasMouse() && !control.getInput().onConfigurable();
|
&& !ui.hasMouse() && !control.getInput().onConfigurable();
|
||||||
|
|
||||||
if(shooting){
|
if(shooting){
|
||||||
weapon.update(player);
|
weaponLeft.update(player, true);
|
||||||
|
weaponRight.update(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.keyDown("dash") && Timers.get(this, "dashfx", 3) && vector.len() > 0){
|
if(Inputs.keyDown("dash") && Timers.get(this, "dashfx", 3) && vector.len() > 0){
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){
|
for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){
|
||||||
if(Inputs.keyTap("weapon_" + i)){
|
if(Inputs.keyTap("weapon_" + i)){
|
||||||
player.weapon = control.getWeapons().get(i - 1);
|
player.weaponLeft = player.weaponRight = control.getWeapons().get(i - 1);
|
||||||
ui.weaponfrag.update();
|
ui.weaponfrag.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class NetworkIO {
|
|||||||
load(file.read());
|
load(file.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO GWT support
|
|
||||||
public static void load(InputStream is){
|
public static void load(InputStream is){
|
||||||
|
|
||||||
try(DataInputStream stream = new DataInputStream(is)){
|
try(DataInputStream stream = new DataInputStream(is)){
|
||||||
@@ -187,6 +187,7 @@ public class NetworkIO {
|
|||||||
|
|
||||||
Vars.control.getWeapons().clear();
|
Vars.control.getWeapons().clear();
|
||||||
Vars.control.getWeapons().add(Weapon.blaster);
|
Vars.control.getWeapons().add(Weapon.blaster);
|
||||||
|
Vars.player.weaponLeft = Vars.player.weaponRight = Weapon.blaster;
|
||||||
Vars.ui.weaponfrag.update();
|
Vars.ui.weaponfrag.update();
|
||||||
|
|
||||||
//enemies
|
//enemies
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class Save12 extends SaveFileVersion {
|
|||||||
|
|
||||||
Vars.control.getWeapons().clear();
|
Vars.control.getWeapons().clear();
|
||||||
Vars.control.getWeapons().add(Weapon.blaster);
|
Vars.control.getWeapons().add(Weapon.blaster);
|
||||||
Vars.player.weapon = Weapon.blaster;
|
Vars.player.weaponLeft = Vars.player.weaponRight = Weapon.blaster;
|
||||||
|
|
||||||
int weapons = stream.readByte();
|
int weapons = stream.readByte();
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class Save13 extends SaveFileVersion {
|
|||||||
|
|
||||||
Vars.control.getWeapons().clear();
|
Vars.control.getWeapons().clear();
|
||||||
Vars.control.getWeapons().add(Weapon.blaster);
|
Vars.control.getWeapons().add(Weapon.blaster);
|
||||||
Vars.player.weapon = Weapon.blaster;
|
Vars.player.weaponLeft = Vars.player.weaponRight = Weapon.blaster;
|
||||||
|
|
||||||
int weapons = stream.readByte();
|
int weapons = stream.readByte();
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class Save14 extends SaveFileVersion{
|
|||||||
|
|
||||||
Vars.control.getWeapons().clear();
|
Vars.control.getWeapons().clear();
|
||||||
Vars.control.getWeapons().add(Weapon.blaster);
|
Vars.control.getWeapons().add(Weapon.blaster);
|
||||||
Vars.player.weapon = Weapon.blaster;
|
Vars.player.weaponLeft = Vars.player.weaponRight = Weapon.blaster;
|
||||||
|
|
||||||
int weapons = stream.readByte();
|
int weapons = stream.readByte();
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ public class UpgradeRecipes {
|
|||||||
Weapon.mortar, list(stack(Item.titanium, 40), stack(Item.steel, 60))
|
Weapon.mortar, list(stack(Item.titanium, 40), stack(Item.steel, 60))
|
||||||
);
|
);
|
||||||
|
|
||||||
public ItemStack[] get(Upgrade upgrade){
|
private static final ItemStack[] empty = {};
|
||||||
return recipes.get(upgrade);
|
|
||||||
|
public static ItemStack[] get(Upgrade upgrade){
|
||||||
|
return recipes.get(upgrade, empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entries<Upgrade, ItemStack[]> getAllRecipes(){
|
public static Entries<Upgrade, ItemStack[]> getAllRecipes(){
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class Weapon extends Upgrade{
|
|||||||
multigun = new Weapon("multigun", 6, BulletType.multishot){
|
multigun = new Weapon("multigun", 6, BulletType.multishot){
|
||||||
{
|
{
|
||||||
effect = Fx.shoot2;
|
effect = Fx.shoot2;
|
||||||
inaccuracy = 8f;
|
inaccuracy = 6f;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
flamer = new Weapon("flamer", 5, BulletType.flame){
|
flamer = new Weapon("flamer", 5, BulletType.flame){
|
||||||
@@ -39,7 +39,7 @@ public class Weapon extends Upgrade{
|
|||||||
inaccuracy = 12f;
|
inaccuracy = 12f;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
railgun = new Weapon("railgun", 40, BulletType.sniper){
|
railgun = new Weapon("railgun", 30, BulletType.sniper){
|
||||||
{
|
{
|
||||||
shootsound = "railgun";
|
shootsound = "railgun";
|
||||||
effect = Fx.railshoot;
|
effect = Fx.railshoot;
|
||||||
@@ -67,9 +67,11 @@ public class Weapon extends Upgrade{
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Player p){
|
public void update(Player p, boolean left){
|
||||||
if(Timers.get(p, "reload", reload)){
|
if(Timers.get(p, "reload"+left, reload)){
|
||||||
shoot(p, p.x, p.y, Angles.mouseAngle(p.x, p.y));
|
float ang = Angles.mouseAngle(p.x, p.y);
|
||||||
|
Angles.translation(ang + Mathf.sign(left) * -70f, 2f);
|
||||||
|
shoot(p, p.x + Angles.x(), p.y + Angles.y(), Angles.mouseAngle(p.x + Angles.x(), p.y + Angles.y()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,132 +0,0 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
|
||||||
|
|
||||||
|
|
||||||
public class UpgradeDialog extends FloatingDialog{
|
|
||||||
boolean wasPaused = false;
|
|
||||||
|
|
||||||
public UpgradeDialog() {
|
|
||||||
super("$text.upgrades");
|
|
||||||
setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup(){
|
|
||||||
/*
|
|
||||||
addCloseButton();
|
|
||||||
|
|
||||||
hidden(()->{
|
|
||||||
if(!wasPaused)
|
|
||||||
GameState.set(State.playing);
|
|
||||||
});
|
|
||||||
shown(()->{
|
|
||||||
wasPaused = GameState.is(State.paused);
|
|
||||||
GameState.set(State.paused);
|
|
||||||
});
|
|
||||||
|
|
||||||
Table weptab = new Table();
|
|
||||||
weptab.margin(20);
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for(Upgrade upgrade : Upgrade.getAllUpgrades()){
|
|
||||||
if(!(upgrade instanceof Weapon)) continue;
|
|
||||||
|
|
||||||
Weapon weapon = (Weapon)upgrade;
|
|
||||||
|
|
||||||
TextButton button = new TextButton(weapon.localized());
|
|
||||||
|
|
||||||
Image img = new Image(Draw.region(weapon.name));
|
|
||||||
button.add(img).size(8*5);
|
|
||||||
button.getCells().reverse();
|
|
||||||
button.row();
|
|
||||||
button.margin(14);
|
|
||||||
button.getLabelCell().left();
|
|
||||||
button.pack();
|
|
||||||
|
|
||||||
button.update(()->{
|
|
||||||
if(control.hasWeapon(weapon)){
|
|
||||||
button.setDisabled(true);
|
|
||||||
button.setColor(Color.GRAY);
|
|
||||||
}else if(!control.hasItems(weapon.requirements)){
|
|
||||||
button.setDisabled(true);
|
|
||||||
}else{
|
|
||||||
button.setDisabled(false);
|
|
||||||
button.setColor(Color.WHITE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(i > 0 && (i)%2==0)
|
|
||||||
weptab.row();
|
|
||||||
|
|
||||||
i++;
|
|
||||||
|
|
||||||
weptab.add(button).width(220);
|
|
||||||
|
|
||||||
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)){
|
|
||||||
ItemStack[] req = weapon.requirements;
|
|
||||||
for(ItemStack s : req){
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
button.addListener(tip);
|
|
||||||
|
|
||||||
button.clicked(()->{
|
|
||||||
if(button.isDisabled()) return;
|
|
||||||
|
|
||||||
control.removeItems(weapon.requirements);
|
|
||||||
control.addWeapon(weapon);
|
|
||||||
ui.weaponfrag.update();
|
|
||||||
run.listen();
|
|
||||||
Effects.sound("purchase");
|
|
||||||
|
|
||||||
if(Net.active() && Net.client()){
|
|
||||||
Vars.netClient.handleUpgrade(weapon);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
content().add("$text.weapons");
|
|
||||||
content().row();
|
|
||||||
content().add(weptab);
|
|
||||||
content().row();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -241,7 +241,6 @@ public class BlocksFragment implements Fragment{
|
|||||||
}).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
|
}).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
desctable.add().pad(2);
|
desctable.add().pad(2);
|
||||||
|
|
||||||
Table requirements = new Table();
|
Table requirements = new Table();
|
||||||
@@ -252,12 +251,11 @@ public class BlocksFragment implements Fragment{
|
|||||||
desctable.left();
|
desctable.left();
|
||||||
|
|
||||||
for(ItemStack stack : recipe.requirements){
|
for(ItemStack stack : recipe.requirements){
|
||||||
ItemStack fs = stack;
|
|
||||||
requirements.addImage(Draw.region("icon-"+stack.item.name)).size(8*3);
|
requirements.addImage(Draw.region("icon-"+stack.item.name)).size(8*3);
|
||||||
Label reqlabel = new Label("");
|
Label reqlabel = new Label("");
|
||||||
|
|
||||||
reqlabel.update(()->{
|
reqlabel.update(()->{
|
||||||
int current = control.getAmount(fs.item);
|
int current = control.getAmount(stack.item);
|
||||||
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
|
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
|
||||||
|
|
||||||
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
|
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
|
||||||
@@ -271,8 +269,7 @@ public class BlocksFragment implements Fragment{
|
|||||||
|
|
||||||
desctable.row();
|
desctable.row();
|
||||||
|
|
||||||
Label label = new Label("[health]"+ Bundles.get("text.health")+": " + recipe.result.health + (recipe.result.description == null ?
|
Label label = new Label("[health]"+ Bundles.get("text.health")+": " + recipe.result.health);
|
||||||
"" : ("\n[]" + recipe.result.description)));
|
|
||||||
label.setWrap(true);
|
label.setWrap(true);
|
||||||
desctable.add(label).width(200).padTop(4).padBottom(2);
|
desctable.add(label).width(200).padTop(4).padBottom(2);
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.anuke.mindustry.core.GameState.State;
|
|||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.core.Inputs;
|
||||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
import io.anuke.ucore.scene.ui.Tooltip;
|
import io.anuke.ucore.scene.ui.Tooltip;
|
||||||
@@ -29,6 +30,7 @@ public class WeaponFragment implements Fragment{
|
|||||||
weapontable.clearChildren();
|
weapontable.clearChildren();
|
||||||
|
|
||||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
|
group.setMaxCheckCount(2);
|
||||||
|
|
||||||
weapontable.defaults().size(58, 62);
|
weapontable.defaults().size(58, 62);
|
||||||
|
|
||||||
@@ -39,12 +41,16 @@ public class WeaponFragment implements Fragment{
|
|||||||
group.add(button);
|
group.add(button);
|
||||||
|
|
||||||
button.clicked(()->{
|
button.clicked(()->{
|
||||||
if(weapon == player.weapon) return;
|
//if(weapon == player.weapon) return;
|
||||||
player.weapon = weapon;
|
if(Inputs.keyDown("weapon_alt_select")){
|
||||||
|
player.weaponRight = weapon;
|
||||||
|
}else {
|
||||||
|
player.weaponLeft = weapon;
|
||||||
|
}
|
||||||
button.setChecked(true);
|
button.setChecked(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
button.setChecked(weapon == player.weapon);
|
button.update(() -> button.setChecked(weapon == player.weaponLeft || weapon == player.weaponRight)); //TODO
|
||||||
|
|
||||||
weapontable.add(button);
|
weapontable.add(button);
|
||||||
|
|
||||||
@@ -52,7 +58,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.localized(), 0.5f).left().padBottom(3f);
|
||||||
|
|
||||||
tiptable.row();
|
tiptable.row();
|
||||||
tiptable.row();
|
tiptable.row();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class DefenseBlocks{
|
|||||||
repairturret = new RepairTurret("repairturret"){
|
repairturret = new RepairTurret("repairturret"){
|
||||||
{
|
{
|
||||||
range = 30;
|
range = 30;
|
||||||
reload = 60f;
|
reload = 40f;
|
||||||
health = 60;
|
health = 60;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -58,7 +58,7 @@ public class DefenseBlocks{
|
|||||||
megarepairturret = new RepairTurret("megarepairturret"){
|
megarepairturret = new RepairTurret("megarepairturret"){
|
||||||
{
|
{
|
||||||
range = 44;
|
range = 44;
|
||||||
reload = 30f;
|
reload = 20f;
|
||||||
powerUsed = 0.15f;
|
powerUsed = 0.15f;
|
||||||
health = 90;
|
health = 90;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.production;
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import io.anuke.mindustry.Vars;
|
||||||
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Upgrade;
|
import io.anuke.mindustry.resource.Upgrade;
|
||||||
|
import io.anuke.mindustry.resource.UpgradeRecipes;
|
||||||
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;
|
||||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.function.Listenable;
|
import io.anuke.ucore.function.Listenable;
|
||||||
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
@@ -17,12 +20,11 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
|||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
|
||||||
public class WeaponFactory extends Block implements Configurable{
|
public class WeaponFactory extends Block implements Configurable{
|
||||||
protected ObjectMap<Weapon, ItemStack[]> costs = new ObjectMap<>();
|
|
||||||
|
|
||||||
public WeaponFactory(String name){
|
public WeaponFactory(String name){
|
||||||
super(name);
|
super(name);
|
||||||
solid = true;
|
solid = true;
|
||||||
breakable = true;
|
destructible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -31,13 +33,11 @@ public class WeaponFactory extends Block implements Configurable{
|
|||||||
|
|
||||||
Table content = new Table();
|
Table content = new Table();
|
||||||
|
|
||||||
content.add("$text.upgrades").colspan(3).row();
|
|
||||||
|
|
||||||
for(Upgrade upgrade : Upgrade.getAllUpgrades()){
|
for(Upgrade upgrade : Upgrade.getAllUpgrades()){
|
||||||
if(!(upgrade instanceof Weapon)) continue;
|
if(!(upgrade instanceof Weapon)) continue;
|
||||||
Weapon weapon = (Weapon)upgrade;
|
Weapon weapon = (Weapon)upgrade;
|
||||||
|
|
||||||
ItemStack[] requirements = costs.get(weapon);
|
ItemStack[] requirements = UpgradeRecipes.get(weapon);
|
||||||
|
|
||||||
Table tiptable = new Table();
|
Table tiptable = new Table();
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ public class WeaponFactory extends Block implements Configurable{
|
|||||||
String description = weapon.description;
|
String description = weapon.description;
|
||||||
|
|
||||||
tiptable.background("pane");
|
tiptable.background("pane");
|
||||||
tiptable.add("[orange]" + weapon.localized(), 0.5f).left().padBottom(4f);
|
tiptable.add("[orange]" + weapon.localized(), 0.5f).left().padBottom(2f);
|
||||||
|
|
||||||
Table reqtable = new Table();
|
Table reqtable = new Table();
|
||||||
|
|
||||||
@@ -67,14 +67,14 @@ public class WeaponFactory extends Block implements Configurable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
tiptable.row();
|
tiptable.row();
|
||||||
tiptable.add().size(10);
|
tiptable.add().size(4);
|
||||||
tiptable.row();
|
tiptable.row();
|
||||||
tiptable.add("[gray]" + description).left();
|
tiptable.add("[gray]" + description).left();
|
||||||
tiptable.row();
|
tiptable.row();
|
||||||
if(control.hasWeapon(weapon)){
|
if(control.hasWeapon(weapon)){
|
||||||
tiptable.add("$text.purchased").padTop(6).left();
|
tiptable.add("$text.purchased").padTop(4).left();
|
||||||
}
|
}
|
||||||
tiptable.margin(14f);
|
tiptable.margin(8f);
|
||||||
};
|
};
|
||||||
|
|
||||||
run.listen();
|
run.listen();
|
||||||
@@ -84,10 +84,18 @@ public class WeaponFactory extends Block implements Configurable{
|
|||||||
tip.setInstant(true);
|
tip.setInstant(true);
|
||||||
|
|
||||||
ImageButton button = content.addImageButton("white", 8*4, () -> {
|
ImageButton button = content.addImageButton("white", 8*4, () -> {
|
||||||
|
control.removeItems(requirements);
|
||||||
|
control.addWeapon(weapon);
|
||||||
|
Vars.ui.weaponfrag.update();
|
||||||
|
run.listen();
|
||||||
|
Effects.sound("purchase");
|
||||||
|
|
||||||
}).size(49f, 54f).padBottom(-5)
|
if(Net.active() && Net.client()){
|
||||||
.get();
|
Vars.netClient.handleUpgrade(weapon);
|
||||||
|
}
|
||||||
|
}).size(49f, 54f).padBottom(-5).get();
|
||||||
|
|
||||||
|
button.setDisabled(() -> control.hasWeapon(weapon));
|
||||||
button.getStyle().imageUp = new TextureRegionDrawable(Draw.region(weapon.name));
|
button.getStyle().imageUp = new TextureRegionDrawable(Draw.region(weapon.name));
|
||||||
button.addListener(tip);
|
button.addListener(tip);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user