Implemented number key weapon switching

This commit is contained in:
Anuken 2017-05-10 11:29:47 -04:00
parent 8cc44b5c8c
commit e0a1e75203
4 changed files with 29 additions and 2 deletions

Binary file not shown.

View File

@ -3,6 +3,7 @@ package io.anuke.mindustry;
import static io.anuke.mindustry.Vars.*;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.Input.Keys;
import io.anuke.mindustry.entities.Weapon;
import io.anuke.mindustry.resource.ItemStack;
@ -55,6 +56,11 @@ public class Input{
Cursors.restoreCursor();
}
for(int i = 0; i < 9; i ++)
if(Inputs.keyUp(Keys.valueOf(""+(i+1))) && getWeapon(i) != null){
currentWeapon = getWeapon(i);
ui.updateWeapons();
}
if(Inputs.buttonUp(Buttons.LEFT) && recipe != null &&
World.validPlace(World.tilex(), World.tiley(), recipe.result) && !ui.hasMouse()){
@ -104,4 +110,25 @@ public class Input{
}
}
public static int currentWeapons(){
int i = 0;
for(Weapon w : Weapon.values())
if(weapons.get(w))
i ++;
return i;
}
public static Weapon getWeapon(int id){
int i = 0;
for(Weapon w : Weapon.values())
if(weapons.get(w))
if(i ++ == id)
return w;
return null;
}
}

View File

@ -19,7 +19,7 @@ public class Vars{
public static final float wavespace = 20*60;
public static final float enemyspawnspace = 65;
public static final float breakduration = 30;
public static boolean debug = false;
public static boolean debug = true;
public static final Vector2 vector = new Vector2();

View File

@ -10,7 +10,7 @@ public class DesktopLauncher {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setTitle("Mindustry");
config.setMaximized(true);
config.useVsync(false);
//config.useVsync(false);
config.setWindowedMode(800, 600);
new Lwjgl3Application(new Mindustry(), config);
}