Broke 90% of all code
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import com.badlogic.gdx.Application.ApplicationType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import io.anuke.ucore.core.Inputs.Axis;
|
||||
import io.anuke.ucore.core.Inputs.DeviceType;
|
||||
import io.anuke.ucore.core.KeyBinds;
|
||||
import io.anuke.ucore.util.Input;
|
||||
|
||||
public class DefaultKeybinds {
|
||||
|
||||
public static void load(){
|
||||
KeyBinds.defaults(
|
||||
"move_x", new Axis(Input.A, Input.D),
|
||||
"move_y", new Axis(Input.S, Input.W),
|
||||
"select", Input.MOUSE_LEFT,
|
||||
"break", Input.MOUSE_RIGHT,
|
||||
"shoot", Input.MOUSE_LEFT,
|
||||
"zoom_hold", Input.CONTROL_LEFT,
|
||||
"zoom", new Axis(Input.SCROLL),
|
||||
"menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
|
||||
"pause", Input.SPACE,
|
||||
"dash", Input.SHIFT_LEFT,
|
||||
"rotate_alt", new Axis(Input.R, Input.E),
|
||||
"rotate", new Axis(Input.SCROLL),
|
||||
"player_list", Input.TAB,
|
||||
"chat", Input.ENTER,
|
||||
"weapon_1", Input.NUM_1,
|
||||
"weapon_2", Input.NUM_2,
|
||||
"weapon_3", Input.NUM_3,
|
||||
"weapon_4", Input.NUM_4,
|
||||
"weapon_5", Input.NUM_5,
|
||||
"weapon_6", Input.NUM_6
|
||||
);
|
||||
|
||||
KeyBinds.defaults(
|
||||
DeviceType.controller,
|
||||
"move_x", new Axis(Input.CONTROLLER_L_STICK_HORIZONTAL_AXIS),
|
||||
"move_y", new Axis(Input.CONTROLLER_L_STICK_VERTICAL_AXIS),
|
||||
"cursor_x", new Axis(Input.CONTROLLER_R_STICK_HORIZONTAL_AXIS),
|
||||
"cursor_y", new Axis(Input.CONTROLLER_R_STICK_VERTICAL_AXIS),
|
||||
"select", Input.CONTROLLER_R_BUMPER,
|
||||
"break", Input.CONTROLLER_L_BUMPER,
|
||||
"shoot", Input.CONTROLLER_R_TRIGGER,
|
||||
"zoom_hold", Input.ANY_KEY,
|
||||
"zoom", new Axis(Input.CONTROLLER_DPAD_DOWN, Input.CONTROLLER_DPAD_UP),
|
||||
"menu", Input.CONTROLLER_X,
|
||||
"pause", Input.CONTROLLER_L_TRIGGER,
|
||||
"dash", Input.CONTROLLER_Y,
|
||||
"rotate_alt", new Axis(Input.CONTROLLER_DPAD_RIGHT, Input.CONTROLLER_DPAD_LEFT),
|
||||
"rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B),
|
||||
"player_list", Input.CONTROLLER_START,
|
||||
"chat", Input.ENTER,
|
||||
"weapon_1", Input.NUM_1,
|
||||
"weapon_2", Input.NUM_2,
|
||||
"weapon_3", Input.NUM_3,
|
||||
"weapon_4", Input.NUM_4,
|
||||
"weapon_5", Input.NUM_5,
|
||||
"weapon_6", Input.NUM_6
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.ucore.function.Event;
|
||||
|
||||
public class EventType {
|
||||
|
||||
public interface PlayEvent extends Event{
|
||||
void handle();
|
||||
}
|
||||
|
||||
public interface ResetEvent extends Event{
|
||||
void handle();
|
||||
}
|
||||
|
||||
public interface WaveEvent extends Event{
|
||||
void handle();
|
||||
}
|
||||
|
||||
public interface GameOver extends Event{
|
||||
void handle();
|
||||
}
|
||||
|
||||
public interface StateChange extends Event{
|
||||
void handle(State from, State to);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static io.anuke.mindustry.Vars.debug;
|
||||
|
||||
public class Inventory {
|
||||
private final int[] items = new int[Item.getAllItems().size];
|
||||
|
||||
public void clearItems(){
|
||||
Arrays.fill(items, 0);
|
||||
|
||||
addItem(Item.stone, 40);
|
||||
|
||||
if(debug){
|
||||
Arrays.fill(items, 99999);
|
||||
}
|
||||
}
|
||||
|
||||
public void fill(){
|
||||
Arrays.fill(items, 999999999);
|
||||
}
|
||||
|
||||
public int getAmount(Item item){
|
||||
return items[item.id];
|
||||
}
|
||||
|
||||
public void addItem(Item item, int amount){
|
||||
items[item.id] += amount;
|
||||
}
|
||||
|
||||
public boolean hasItems(ItemStack[] items){
|
||||
for(ItemStack stack : items)
|
||||
if(!hasItem(stack))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasItems(ItemStack[] items, int scaling){
|
||||
for(ItemStack stack : items)
|
||||
if(!hasItem(stack.item, stack.amount * scaling))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasItem(ItemStack req){
|
||||
return items[req.item.id] >= req.amount;
|
||||
}
|
||||
|
||||
public boolean hasItem(Item item, int amount){
|
||||
return items[item.id] >= amount;
|
||||
}
|
||||
|
||||
public void removeItem(ItemStack req){
|
||||
items[req.item.id] -= req.amount;
|
||||
if(items[req.item.id] < 0) items[req.item.id] = 0; //prevents negative item glitches in multiplayer
|
||||
}
|
||||
|
||||
public void removeItems(ItemStack... reqs){
|
||||
for(ItemStack req : reqs)
|
||||
removeItem(req);
|
||||
}
|
||||
|
||||
public int[] getItems(){
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,8 @@ public class SpawnPoint{
|
||||
public PathFinder<Tile> finder;
|
||||
public SmoothGraphPath path = new SmoothGraphPath();
|
||||
public PathFinderRequest<Tile> request;
|
||||
|
||||
public SpawnPoint(Tile start){
|
||||
this.start = start;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
@@ -19,8 +18,7 @@ import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Tutorial{
|
||||
private Stage stage;
|
||||
@@ -32,7 +30,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
public boolean active(){
|
||||
return world.getMap() != null && world.getMap().name.equals("tutorial") && !GameState.is(State.menu);
|
||||
return world.getMap() != null && world.getMap().name.equals("tutorial") && !state.is(State.menu);
|
||||
}
|
||||
|
||||
public void buildUI(table table){
|
||||
@@ -73,7 +71,7 @@ public class Tutorial{
|
||||
//info.setText(stage.text);
|
||||
|
||||
if(stage.showBlock){
|
||||
Tile tile = world.tile(control.getCore().x + stage.blockPlaceX, control.getCore().y + stage.blockPlaceY);
|
||||
Tile tile = world.tile(world.getCore().x + stage.blockPlaceX, world.getCore().y + stage.blockPlaceY);
|
||||
|
||||
if(tile.block() == stage.targetBlock && (tile.getRotation() == stage.blockRotation || stage.blockRotation == -1)){
|
||||
move(true);
|
||||
@@ -88,7 +86,7 @@ public class Tutorial{
|
||||
|
||||
public void complete(){
|
||||
//new TextDialog("Congratulations!", "You have completed the tutorial!").padText(Unit.dp.inPixels(10f)).show();
|
||||
GameState.set(State.menu);
|
||||
state.set(State.menu);
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -104,7 +102,7 @@ public class Tutorial{
|
||||
|
||||
if(current < 0 || current >= Stage.values().length){
|
||||
break;
|
||||
}else if(Vars.android == Stage.values()[current].androidOnly || Vars.android != Stage.values()[current].desktopOnly){
|
||||
}else if(android == Stage.values()[current].androidOnly || android != Stage.values()[current].desktopOnly){
|
||||
stage = Stage.values()[current];
|
||||
stage.onSwitch();
|
||||
break;
|
||||
@@ -121,7 +119,7 @@ public class Tutorial{
|
||||
|
||||
if(current < 0 || current >= Stage.values().length){
|
||||
return false;
|
||||
}else if(Vars.android == Stage.values()[current].androidOnly || Vars.android != Stage.values()[current].desktopOnly){
|
||||
}else if(android == Stage.values()[current].androidOnly || android != Stage.values()[current].desktopOnly){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -198,7 +196,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.ui.<ImageButton>find("sectionbuttondistribution").fireClick();
|
||||
ui.<ImageButton>find("sectionbuttondistribution").fireClick();
|
||||
}
|
||||
},
|
||||
placeConveyorDesktop{
|
||||
@@ -232,7 +230,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
//Vars.player.recipe = null;
|
||||
//player.recipe = null;
|
||||
}
|
||||
},
|
||||
placeDrill{
|
||||
@@ -247,7 +245,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.ui.<ImageButton>find("sectionbuttonproduction").fireClick();
|
||||
ui.<ImageButton>find("sectionbuttonproduction").fireClick();
|
||||
}
|
||||
},
|
||||
blockInfo{
|
||||
@@ -273,7 +271,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
control.getInput().recipe = null;
|
||||
control.input().recipe = null;
|
||||
}
|
||||
},
|
||||
drillInfo{
|
||||
@@ -291,12 +289,12 @@ public class Tutorial{
|
||||
|
||||
void onSwitch(){
|
||||
for(int flip : new int[]{1, -1}){
|
||||
world.tile(control.getCore().x + flip, control.getCore().y - 2).setBlock(DistributionBlocks.conveyor, 2 * flip);
|
||||
world.tile(control.getCore().x + flip*2, control.getCore().y - 2).setBlock(DistributionBlocks.conveyor, 2 * flip);
|
||||
world.tile(control.getCore().x + flip*2, control.getCore().y - 3).setBlock(DistributionBlocks.conveyor, 2 * flip);
|
||||
world.tile(control.getCore().x + flip*2, control.getCore().y - 3).setBlock(DistributionBlocks.conveyor, 1);
|
||||
world.tile(control.getCore().x + flip*2, control.getCore().y - 4).setFloor(Blocks.stone);
|
||||
world.tile(control.getCore().x + flip*2, control.getCore().y - 4).setBlock(ProductionBlocks.stonedrill);
|
||||
world.tile(world.getCore().x + flip, world.getCore().y - 2).setBlock(DistributionBlocks.conveyor, 2 * flip);
|
||||
world.tile(world.getCore().x + flip*2, world.getCore().y - 2).setBlock(DistributionBlocks.conveyor, 2 * flip);
|
||||
world.tile(world.getCore().x + flip*2, world.getCore().y - 3).setBlock(DistributionBlocks.conveyor, 2 * flip);
|
||||
world.tile(world.getCore().x + flip*2, world.getCore().y - 3).setBlock(DistributionBlocks.conveyor, 1);
|
||||
world.tile(world.getCore().x + flip*2, world.getCore().y - 4).setFloor(Blocks.stone);
|
||||
world.tile(world.getCore().x + flip*2, world.getCore().y - 4).setBlock(ProductionBlocks.stonedrill);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -335,7 +333,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.ui.<ImageButton>find("sectionbuttonweapon").fireClick();
|
||||
ui.<ImageButton>find("sectionbuttonweapon").fireClick();
|
||||
}
|
||||
},
|
||||
placedTurretAmmo{
|
||||
@@ -345,10 +343,10 @@ public class Tutorial{
|
||||
|
||||
void onSwitch(){
|
||||
for(int i = 0; i < 4; i ++){
|
||||
world.tile(control.getCore().x + 2, control.getCore().y - 2 + i).setBlock(DistributionBlocks.conveyor, 1);
|
||||
world.tile(world.getCore().x + 2, world.getCore().y - 2 + i).setBlock(DistributionBlocks.conveyor, 1);
|
||||
}
|
||||
|
||||
control.getInput().recipe = null;
|
||||
control.input().recipe = null;
|
||||
}
|
||||
},
|
||||
turretExplanation{
|
||||
@@ -375,31 +373,7 @@ public class Tutorial{
|
||||
}
|
||||
},
|
||||
//TODO re-add tutorial on weapons
|
||||
/*
|
||||
purchaseWeapons{
|
||||
{
|
||||
desktopOnly = true;
|
||||
canBack = false;
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.control.addItem(Item.steel, 60);
|
||||
Vars.control.addItem(Item.iron, 60);
|
||||
}
|
||||
},
|
||||
switchWeapons{
|
||||
{
|
||||
canBack = false;
|
||||
desktopOnly = true;
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
if(!Vars.control.getWeapons().contains(Weapon.triblaster, true)){
|
||||
Vars.control.getWeapons().add(Weapon.triblaster);
|
||||
Vars.ui.hudfrag.updateWeapons();
|
||||
}
|
||||
}
|
||||
},*/
|
||||
|
||||
spawnWave{
|
||||
float warmup = 0f;
|
||||
{
|
||||
@@ -409,14 +383,14 @@ public class Tutorial{
|
||||
|
||||
void update(Tutorial t){
|
||||
warmup += Timers.delta();
|
||||
if(Vars.control.getEnemiesRemaining() == 0 && warmup > 60f){
|
||||
if(state.enemies == 0 && warmup > 60f){
|
||||
t.move(true);
|
||||
}
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
warmup = 0f;
|
||||
Vars.control.runWave();
|
||||
logic.runWave();
|
||||
}
|
||||
},
|
||||
pumpDesc{
|
||||
@@ -436,9 +410,9 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.ui.<ImageButton>find("sectionbuttonproduction").fireClick();
|
||||
Vars.control.addItem(Item.steel, 60);
|
||||
Vars.control.addItem(Item.iron, 60);
|
||||
ui.<ImageButton>find("sectionbuttonproduction").fireClick();
|
||||
state.inventory.addItem(Item.steel, 60);
|
||||
state.inventory.addItem(Item.iron, 60);
|
||||
}
|
||||
},
|
||||
conduitUse{
|
||||
@@ -454,8 +428,8 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.ui.<ImageButton>find("sectionbuttondistribution").fireClick();
|
||||
world.tile(blockPlaceX + control.getCore().x, blockPlaceY + control.getCore().y).setBlock(Blocks.air);
|
||||
ui.<ImageButton>find("sectionbuttondistribution").fireClick();
|
||||
world.tile(blockPlaceX + world.getCore().x, blockPlaceY + world.getCore().y).setBlock(Blocks.air);
|
||||
}
|
||||
},
|
||||
conduitUse2{
|
||||
@@ -471,7 +445,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
world.tile(blockPlaceX + control.getCore().x, blockPlaceY + control.getCore().y).setBlock(Blocks.air);
|
||||
world.tile(blockPlaceX + world.getCore().x, blockPlaceY + world.getCore().y).setBlock(Blocks.air);
|
||||
}
|
||||
},
|
||||
conduitUse3{
|
||||
@@ -487,7 +461,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
world.tile(blockPlaceX + control.getCore().x, blockPlaceY + control.getCore().y).setBlock(Blocks.air);
|
||||
world.tile(blockPlaceX + world.getCore().x, blockPlaceY + world.getCore().y).setBlock(Blocks.air);
|
||||
}
|
||||
},
|
||||
generator{
|
||||
@@ -502,10 +476,10 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
world.tile(blockPlaceX + control.getCore().x, blockPlaceY + control.getCore().y).setBlock(Blocks.air);
|
||||
Vars.ui.<ImageButton>find("sectionbuttonpower").fireClick();
|
||||
Vars.control.addItem(Item.steel, 60);
|
||||
Vars.control.addItem(Item.iron, 60);
|
||||
world.tile(blockPlaceX + world.getCore().x, blockPlaceY + world.getCore().y).setBlock(Blocks.air);
|
||||
ui.<ImageButton>find("sectionbuttonpower").fireClick();
|
||||
state.inventory.addItem(Item.steel, 60);
|
||||
state.inventory.addItem(Item.iron, 60);
|
||||
}
|
||||
},
|
||||
generatorExplain{
|
||||
@@ -526,7 +500,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.ui.<ImageButton>find("sectionbuttonpower").fireClick();
|
||||
ui.<ImageButton>find("sectionbuttonpower").fireClick();
|
||||
}
|
||||
},
|
||||
laserExplain{
|
||||
@@ -552,7 +526,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.ui.<ImageButton>find("sectionbuttonpower").fireClick();
|
||||
ui.<ImageButton>find("sectionbuttonpower").fireClick();
|
||||
}
|
||||
},
|
||||
healingTurretExplain{
|
||||
@@ -573,9 +547,9 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
void onSwitch(){
|
||||
Vars.control.addItem(Item.stone, 40);
|
||||
Vars.control.addItem(Item.iron, 40);
|
||||
Vars.ui.<ImageButton>find("sectionbuttoncrafting").fireClick();
|
||||
state.inventory.addItem(Item.stone, 40);
|
||||
state.inventory.addItem(Item.iron, 40);
|
||||
ui.<ImageButton>find("sectionbuttoncrafting").fireClick();
|
||||
|
||||
}
|
||||
},
|
||||
@@ -586,18 +560,18 @@ public class Tutorial{
|
||||
|
||||
void onSwitch(){
|
||||
for(int i = 0; i < 5; i ++){
|
||||
world.tile(control.getCore().x, control.getCore().y - 6 + i).setBlock(DistributionBlocks.conveyor, 1);
|
||||
world.tile(world.getCore().x, world.getCore().y - 6 + i).setBlock(DistributionBlocks.conveyor, 1);
|
||||
}
|
||||
|
||||
world.tile(control.getCore().x, control.getCore().y - 6 + 1).setBlock(DistributionBlocks.tunnel, 3);
|
||||
world.tile(control.getCore().x, control.getCore().y - 6 + 2).setBlock(DefenseBlocks.stonewall, 0);
|
||||
world.tile(control.getCore().x, control.getCore().y - 6 + 3).setBlock(DistributionBlocks.tunnel, 1);
|
||||
world.tile(world.getCore().x, world.getCore().y - 6 + 1).setBlock(DistributionBlocks.tunnel, 3);
|
||||
world.tile(world.getCore().x, world.getCore().y - 6 + 2).setBlock(DefenseBlocks.stonewall, 0);
|
||||
world.tile(world.getCore().x, world.getCore().y - 6 + 3).setBlock(DistributionBlocks.tunnel, 1);
|
||||
|
||||
world.tile(control.getCore().x+1, control.getCore().y - 8).setBlock(ProductionBlocks.irondrill);
|
||||
world.tile(control.getCore().x-1, control.getCore().y - 8).setBlock(ProductionBlocks.coaldrill);
|
||||
world.tile(world.getCore().x+1, world.getCore().y - 8).setBlock(ProductionBlocks.irondrill);
|
||||
world.tile(world.getCore().x-1, world.getCore().y - 8).setBlock(ProductionBlocks.coaldrill);
|
||||
|
||||
world.tile(control.getCore().x+1, control.getCore().y - 7).setBlock(DistributionBlocks.conveyor, 2);
|
||||
world.tile(control.getCore().x-1, control.getCore().y - 7).setBlock(DistributionBlocks.conveyor, 0);
|
||||
world.tile(world.getCore().x+1, world.getCore().y - 7).setBlock(DistributionBlocks.conveyor, 2);
|
||||
world.tile(world.getCore().x-1, world.getCore().y - 7).setBlock(DistributionBlocks.conveyor, 0);
|
||||
}
|
||||
},
|
||||
tunnelExplain{
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
|
||||
public class UpgradeInventory {
|
||||
private final Array<Weapon> weapons = new Array<>();
|
||||
|
||||
public boolean hasWeapon(Weapon weapon){
|
||||
return weapons.contains(weapon, true);
|
||||
}
|
||||
|
||||
public void addWeapon(Weapon weapon){
|
||||
weapons.add(weapon);
|
||||
}
|
||||
|
||||
public Array<Weapon> getWeapons(){
|
||||
return weapons;
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
weapons.clear();
|
||||
weapons.add(Weapon.blaster);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user