Added weapon upgrades, bugfixes
This commit is contained in:
@@ -59,7 +59,7 @@ project(":core") {
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: '../core/lib', include: '*.jar')
|
// compile fileTree(dir: '../core/lib', include: '*.jar')
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 7.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.1 KiB |
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
mindsutry.png
|
mindustry.png
|
||||||
size: 256,32
|
size: 256,32
|
||||||
format: RGBA8888
|
format: RGBA8888
|
||||||
filter: Nearest,Nearest
|
filter: Nearest,Nearest
|
||||||
@@ -228,6 +228,13 @@ ironwall
|
|||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
junction
|
||||||
|
rotate: false
|
||||||
|
xy: 178, 13
|
||||||
|
size: 8, 8
|
||||||
|
orig: 8, 8
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
laser
|
laser
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 95, 7
|
xy: 95, 7
|
||||||
@@ -251,7 +258,7 @@ machineturret
|
|||||||
index: -1
|
index: -1
|
||||||
mech1
|
mech1
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 178, 13
|
xy: 188, 13
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -265,7 +272,7 @@ megarepairturret
|
|||||||
index: -1
|
index: -1
|
||||||
player
|
player
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 188, 13
|
xy: 198, 13
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -279,7 +286,7 @@ repairturret
|
|||||||
index: -1
|
index: -1
|
||||||
router
|
router
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 198, 13
|
xy: 208, 13
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -307,77 +314,77 @@ sniperturret
|
|||||||
index: -1
|
index: -1
|
||||||
steelconveyor
|
steelconveyor
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 208, 13
|
xy: 218, 13
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
steelconveyormove
|
steelconveyormove
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 218, 13
|
xy: 228, 13
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
steelwall
|
steelwall
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 228, 13
|
xy: 238, 13
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stone
|
stone
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 238, 13
|
xy: 98, 3
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stone1
|
stone1
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 98, 3
|
xy: 108, 3
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stone2
|
stone2
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 108, 3
|
xy: 118, 3
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stone3
|
stone3
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 118, 3
|
xy: 128, 3
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stoneblock
|
stoneblock
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 128, 3
|
xy: 138, 3
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stonedrill
|
stonedrill
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 138, 3
|
xy: 148, 3
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stonedrillhead
|
stonedrillhead
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 138, 3
|
xy: 148, 3
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stonewall
|
stonewall
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 148, 3
|
xy: 158, 3
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -389,3 +396,17 @@ turret
|
|||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
weapon-blaster
|
||||||
|
rotate: false
|
||||||
|
xy: 168, 3
|
||||||
|
size: 8, 8
|
||||||
|
orig: 8, 8
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
weapon-trishot
|
||||||
|
rotate: false
|
||||||
|
xy: 178, 3
|
||||||
|
size: 8, 8
|
||||||
|
orig: 8, 8
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
|||||||
BIN
core/assets/sprites/mindustry.png
Normal file
BIN
core/assets/sprites/mindustry.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
@@ -34,6 +34,8 @@ io.anuke.ucore.scene.ui.TextButton$TextButtonStyle: {
|
|||||||
},
|
},
|
||||||
io.anuke.ucore.scene.ui.ImageButton$ImageButtonStyle: {
|
io.anuke.ucore.scene.ui.ImageButton$ImageButtonStyle: {
|
||||||
default: {down: button-down, up: button },
|
default: {down: button-down, up: button },
|
||||||
|
static: {up: button },
|
||||||
|
static-down: {up: button-down },
|
||||||
blue: {down: button-blue-down, up: button-blue },
|
blue: {down: button-blue-down, up: button-blue },
|
||||||
toggle: {checked: button-down, down: button-down, up: button },
|
toggle: {checked: button-down, down: button-down, up: button },
|
||||||
togglemap: {checked: button-map-down, down: button-map-down, up: button-map },
|
togglemap: {checked: button-map-down, down: button-map-down, up: button-map },
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ import io.anuke.ucore.util.Timers;
|
|||||||
public class GameState{
|
public class GameState{
|
||||||
|
|
||||||
public static void reset(){
|
public static void reset(){
|
||||||
|
for(Weapon weapon : Weapon.values()){
|
||||||
|
weapons.put(weapon, weapon.unlocked);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentWeapon = Weapon.blaster;
|
||||||
|
|
||||||
wave = 1;
|
wave = 1;
|
||||||
wavetime = waveSpacing();
|
wavetime = waveSpacing();
|
||||||
Entities.clear();
|
Entities.clear();
|
||||||
@@ -25,6 +31,7 @@ public class GameState{
|
|||||||
spawnpoints.clear();
|
spawnpoints.clear();
|
||||||
|
|
||||||
ui.updateItems();
|
ui.updateItems();
|
||||||
|
ui.updateWeapons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void play(){
|
public static void play(){
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
import com.badlogic.gdx.Input.Buttons;
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
|
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
|
import io.anuke.mindustry.entities.Weapon;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.Blocks;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
@@ -18,10 +19,33 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
public class Input{
|
public class Input{
|
||||||
|
|
||||||
public static void doInput(){
|
public static void doInput(){
|
||||||
|
|
||||||
//player is dead
|
//player is dead
|
||||||
if(player.health <= 0) return;
|
if(player.health <= 0) return;
|
||||||
|
|
||||||
|
if(Inputs.scrolled()){
|
||||||
|
Weapon[] val = Weapon.values();
|
||||||
|
int index = 0;
|
||||||
|
for(int i = 0; i < val.length; i ++)
|
||||||
|
if(val[i] == currentWeapon){
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < val.length; i ++){
|
||||||
|
index += Inputs.scroll();
|
||||||
|
if(index >= 0 && index < val.length){
|
||||||
|
if(weapons.get(val[index])){
|
||||||
|
currentWeapon = (val[index]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.updateWeapons();
|
||||||
|
}
|
||||||
|
|
||||||
if(Inputs.keyUp("rotate"))
|
if(Inputs.keyUp("rotate"))
|
||||||
rotation++;
|
rotation++;
|
||||||
|
|
||||||
|
|||||||
@@ -39,4 +39,10 @@ public class Inventory{
|
|||||||
items.put(req.item, items.get(req.item, 0)-req.amount);
|
items.put(req.item, items.get(req.item, 0)-req.amount);
|
||||||
ui.updateItems();
|
ui.updateItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeItems(ItemStack... reqs){
|
||||||
|
for(ItemStack req : reqs)
|
||||||
|
items.put(req.item, items.get(req.item, 0)-req.amount);
|
||||||
|
ui.updateItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ public class Renderer{
|
|||||||
float offset = 7;
|
float offset = 7;
|
||||||
|
|
||||||
float fraction = Mathf.clamp((float) health / maxhealth);
|
float fraction = Mathf.clamp((float) health / maxhealth);
|
||||||
|
float w = (len * 2 * fraction);
|
||||||
|
|
||||||
Draw.thickness(3f);
|
Draw.thickness(3f);
|
||||||
Draw.color(Color.GRAY);
|
Draw.color(Color.GRAY);
|
||||||
@@ -166,7 +167,8 @@ public class Renderer{
|
|||||||
Draw.color(Color.BLACK);
|
Draw.color(Color.BLACK);
|
||||||
Draw.line(x - len + 1, y - offset, x + len, y - offset);
|
Draw.line(x - len + 1, y - offset, x + len, y - offset);
|
||||||
Draw.color(Color.RED);
|
Draw.color(Color.RED);
|
||||||
Draw.line(x - len + 1, y - offset, x - len + (int)(len * 2 * fraction), y - offset);
|
if(w >= 1)
|
||||||
|
Draw.line(x - len + 1, y - offset, x - len + w, y - offset);
|
||||||
Draw.clear();
|
Draw.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import java.util.function.BooleanSupplier;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.Weapon;
|
||||||
import io.anuke.mindustry.resource.*;
|
import io.anuke.mindustry.resource.*;
|
||||||
|
import io.anuke.mindustry.ui.*;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Settings;
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.graphics.Hue;
|
import io.anuke.ucore.graphics.Hue;
|
||||||
@@ -25,12 +26,10 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
|||||||
import io.anuke.ucore.util.Timers;
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
public class UI extends SceneModule{
|
public class UI extends SceneModule{
|
||||||
Table itemtable;
|
Table itemtable, weapontable;
|
||||||
SettingsDialog prefs;
|
SettingsDialog prefs;
|
||||||
KeybindDialog keys;
|
KeybindDialog keys;
|
||||||
Dialog about, menu, restart, tutorial, levels;
|
Dialog about, menu, restart, tutorial, levels, upgrades;
|
||||||
//Texture conveyor = new Texture("sprites/conveyor.png"), conveyort = new Texture("sprites/conveyort.png");
|
|
||||||
int selectedMap = 0;
|
|
||||||
|
|
||||||
BooleanSupplier play = () -> {
|
BooleanSupplier play = () -> {
|
||||||
return playing;
|
return playing;
|
||||||
@@ -100,35 +99,16 @@ public class UI extends SceneModule{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
//TODO oh my god just move these dialogs to different files
|
||||||
|
|
||||||
levels = new Dialog("Level Select");
|
upgrades = new UpgradeDialog();
|
||||||
levels.addCloseButton();
|
|
||||||
levels.getButtonTable().addButton("Play", ()->{
|
|
||||||
levels.hide();
|
|
||||||
World.loadMap(selectedMap);
|
|
||||||
GameState.play();
|
|
||||||
});
|
|
||||||
|
|
||||||
for(int i = 0; i < maps.length; i ++){
|
levels = new LevelDialog();
|
||||||
levels.content().add(maps[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
levels.content().row();
|
|
||||||
|
|
||||||
for(int i = 0; i < maps.length; i ++){
|
|
||||||
int index = i;
|
|
||||||
ImageButton image = new ImageButton(new TextureRegion(mapTextures[i]), "togglemap");
|
|
||||||
mapgroup.add(image);
|
|
||||||
image.clicked(()->{
|
|
||||||
selectedMap = index;
|
|
||||||
});
|
|
||||||
image.getImageCell().size(150, 150);
|
|
||||||
levels.content().add(image).size(180);
|
|
||||||
}
|
|
||||||
|
|
||||||
prefs = new SettingsDialog();
|
prefs = new SettingsDialog();
|
||||||
|
|
||||||
|
menu = new MenuDialog();
|
||||||
|
|
||||||
prefs.sliderPref("difficulty", "Difficulty", 1, 0, 2, i -> {
|
prefs.sliderPref("difficulty", "Difficulty", 1, 0, 2, i -> {
|
||||||
return i == 0 ? "Easy" : i == 1 ? "Normal" : "Hard";
|
return i == 0 ? "Easy" : i == 1 ? "Normal" : "Hard";
|
||||||
});
|
});
|
||||||
@@ -143,25 +123,7 @@ public class UI extends SceneModule{
|
|||||||
|
|
||||||
about = new TextDialog("About", aboutText);
|
about = new TextDialog("About", aboutText);
|
||||||
|
|
||||||
tutorial = new TextDialog("Tutorial", tutorialText)
|
tutorial = new TutorialDialog();
|
||||||
.setDialog();
|
|
||||||
|
|
||||||
tutorial.hidden(()->{
|
|
||||||
playing = true;
|
|
||||||
paused = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
tutorial.getButtonTable().addButton("OK", ()->{
|
|
||||||
tutorial.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
tutorial.content().pad(8);
|
|
||||||
|
|
||||||
tutorial.content().row();
|
|
||||||
tutorial.content().addCheck("Don't show again", b->{
|
|
||||||
Settings.putBool("tutorial", !b);
|
|
||||||
Settings.save();
|
|
||||||
}).padTop(4);
|
|
||||||
|
|
||||||
restart = new Dialog("The core was destroyed.", "dialog"){
|
restart = new Dialog("The core was destroyed.", "dialog"){
|
||||||
public Dialog show(Scene scene){
|
public Dialog show(Scene scene){
|
||||||
@@ -179,41 +141,9 @@ public class UI extends SceneModule{
|
|||||||
GameState.reset();
|
GameState.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
menu = new Dialog("Paused", "dialog");
|
weapontable = fill();
|
||||||
menu.content().addButton("Back", ()->{
|
weapontable.bottom();
|
||||||
menu.hide();
|
weapontable.setVisible(play);
|
||||||
paused = false;
|
|
||||||
}).width(200);
|
|
||||||
|
|
||||||
menu.content().row();
|
|
||||||
menu.content().addButton("Settings", ()->{
|
|
||||||
prefs.show();
|
|
||||||
}).width(200);
|
|
||||||
|
|
||||||
menu.content().row();
|
|
||||||
menu.content().addButton("Controls", ()->{
|
|
||||||
keys.show();
|
|
||||||
}).width(200);
|
|
||||||
|
|
||||||
menu.content().row();
|
|
||||||
menu.content().addButton("Back to menu", ()->{
|
|
||||||
new Dialog("Confirm", "dialog"){
|
|
||||||
{
|
|
||||||
text("Are you sure you want to quit?");
|
|
||||||
button("Ok", true);
|
|
||||||
button("Cancel", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void result(Object object){
|
|
||||||
if(object == Boolean.TRUE){
|
|
||||||
menu.hide();
|
|
||||||
paused = false;
|
|
||||||
playing = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.show(scene);
|
|
||||||
|
|
||||||
}).width(200);
|
|
||||||
|
|
||||||
build.begin(scene);
|
build.begin(scene);
|
||||||
|
|
||||||
@@ -319,12 +249,6 @@ public class UI extends SceneModule{
|
|||||||
table.add().size(size);
|
table.add().size(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(sec == Section.distribution){
|
|
||||||
table.row();
|
|
||||||
table.add().size(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
table.setVisible(()->{
|
table.setVisible(()->{
|
||||||
return button.isChecked();
|
return button.isChecked();
|
||||||
});
|
});
|
||||||
@@ -337,7 +261,14 @@ public class UI extends SceneModule{
|
|||||||
add(stack).colspan(3);
|
add(stack).colspan(3);
|
||||||
get().pad(10f);
|
get().pad(10f);
|
||||||
|
|
||||||
}}.right().bottom();
|
end();
|
||||||
|
}}.right().bottom().uniformX();
|
||||||
|
|
||||||
|
row();
|
||||||
|
|
||||||
|
new button("Upgrades", ()->{
|
||||||
|
upgrades.show();
|
||||||
|
}).uniformX().fillX();
|
||||||
|
|
||||||
get().setVisible(play);
|
get().setVisible(play);
|
||||||
|
|
||||||
@@ -446,6 +377,46 @@ public class UI extends SceneModule{
|
|||||||
build.end();
|
build.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateWeapons(){
|
||||||
|
weapontable.clearChildren();
|
||||||
|
|
||||||
|
for(Weapon weapon : Weapon.values()){
|
||||||
|
if(weapons.get(weapon) == Boolean.TRUE){
|
||||||
|
ImageButton button = new ImageButton(Draw.region("weapon-"+weapon.name()), "static");
|
||||||
|
button.getImageCell().size(40);
|
||||||
|
button.setDisabled(true);
|
||||||
|
if(weapon != currentWeapon)
|
||||||
|
button.setColor(Color.GRAY);
|
||||||
|
weapontable.add(button).size(48, 52);
|
||||||
|
|
||||||
|
Table tiptable = new Table();
|
||||||
|
String description = weapon.description;
|
||||||
|
|
||||||
|
tiptable.background("button");
|
||||||
|
tiptable.add("[PURPLE]" + weapon.name(), 0.75f).left().padBottom(2f);
|
||||||
|
|
||||||
|
tiptable.row();
|
||||||
|
tiptable.row();
|
||||||
|
tiptable.add("[ORANGE]" + description).left();
|
||||||
|
tiptable.pad(10f);
|
||||||
|
|
||||||
|
Tooltip tip = new Tooltip(tiptable);
|
||||||
|
|
||||||
|
tip.setInstant(true);
|
||||||
|
|
||||||
|
button.addListener(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showPrefs(){
|
||||||
|
prefs.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showControls(){
|
||||||
|
keys.show();
|
||||||
|
}
|
||||||
|
|
||||||
public void showMenu(){
|
public void showMenu(){
|
||||||
menu.show();
|
menu.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
|
import io.anuke.mindustry.entities.Weapon;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
import io.anuke.mindustry.resource.Recipe;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -17,8 +18,8 @@ public class Vars{
|
|||||||
public static final float respawntime = 60*4;
|
public static final float respawntime = 60*4;
|
||||||
public static final float wavespace = 20*60;
|
public static final float wavespace = 20*60;
|
||||||
public static final float enemyspawnspace = 65;
|
public static final float enemyspawnspace = 65;
|
||||||
public static final float breakduration = 40;
|
public static final float breakduration = 30;
|
||||||
public static boolean debug = false;
|
public static boolean debug = true;
|
||||||
|
|
||||||
public static final Vector2 vector = new Vector2();
|
public static final Vector2 vector = new Vector2();
|
||||||
|
|
||||||
@@ -28,6 +29,8 @@ public class Vars{
|
|||||||
public static UI ui;
|
public static UI ui;
|
||||||
|
|
||||||
public static final ObjectMap<Item, Integer> items = new ObjectMap<>();
|
public static final ObjectMap<Item, Integer> items = new ObjectMap<>();
|
||||||
|
public static final ObjectMap<Weapon, Boolean> weapons = new ObjectMap<Weapon, Boolean>();
|
||||||
|
public static Weapon currentWeapon;
|
||||||
|
|
||||||
public static Player player;
|
public static Player player;
|
||||||
|
|
||||||
@@ -39,6 +42,7 @@ public class Vars{
|
|||||||
public static int worldsize = 128;
|
public static int worldsize = 128;
|
||||||
public static int pixsize = worldsize*tilesize;
|
public static int pixsize = worldsize*tilesize;
|
||||||
public static Tile[][] tiles = new Tile[worldsize][worldsize];
|
public static Tile[][] tiles = new Tile[worldsize][worldsize];
|
||||||
|
|
||||||
public static Recipe recipe;
|
public static Recipe recipe;
|
||||||
public static int rotation;
|
public static int rotation;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public class Player extends DestructibleEntity{
|
|||||||
float speed = 1f;
|
float speed = 1f;
|
||||||
float rotation;
|
float rotation;
|
||||||
float reload;
|
float reload;
|
||||||
Weapon weapon = Weapon.blaster;
|
|
||||||
|
|
||||||
public Player(){
|
public Player(){
|
||||||
hitsize = 5;
|
hitsize = 5;
|
||||||
@@ -74,14 +73,14 @@ public class Player extends DestructibleEntity{
|
|||||||
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse();
|
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse();
|
||||||
|
|
||||||
if(shooting && reload <= 0){
|
if(shooting && reload <= 0){
|
||||||
weapon.shoot(this);
|
currentWeapon.shoot(this);
|
||||||
Sounds.play("shoot");
|
Sounds.play("shoot");
|
||||||
reload = weapon.reload;
|
reload = currentWeapon.reload;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector.limit(speed);
|
vector.limit(speed);
|
||||||
|
|
||||||
move(vector.x*delta, vector.y*delta);
|
move(vector.x*delta, vector.y*delta, 4);
|
||||||
|
|
||||||
if(!shooting){
|
if(!shooting){
|
||||||
direction.add(vector.scl(delta));
|
direction.add(vector.scl(delta));
|
||||||
|
|||||||
@@ -1,28 +1,54 @@
|
|||||||
package io.anuke.mindustry.entities;
|
package io.anuke.mindustry.entities;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.ucore.entities.Entity;
|
import io.anuke.ucore.entities.Entity;
|
||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
|
|
||||||
public enum Weapon{
|
public enum Weapon{
|
||||||
blaster(15, BulletType.shot){
|
blaster(15, BulletType.shot, "Shoots a slow, weak bullet."){
|
||||||
{
|
{
|
||||||
unlocked = true;
|
unlocked = true;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
trishot(15, BulletType.shot, "Shoots 3 bullets in a spread.", stack(Item.iron, 40)){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shoot(Player p){
|
||||||
|
float ang = mouseAngle(p);
|
||||||
|
float space = 12;
|
||||||
|
|
||||||
|
bullet(p, p.x, p.y, ang);
|
||||||
|
bullet(p, p.x, p.y, ang+space);
|
||||||
|
bullet(p, p.x, p.y, ang-space);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
public float reload;
|
public float reload;
|
||||||
public BulletType type;
|
public BulletType type;
|
||||||
public boolean unlocked;
|
public boolean unlocked;
|
||||||
|
public ItemStack[] requirements;
|
||||||
|
public String description = "no desc for you";
|
||||||
|
|
||||||
private Weapon(float reload, BulletType type){
|
private Weapon(float reload, BulletType type, String desc, ItemStack... requirements){
|
||||||
this.reload = reload;
|
this.reload = reload;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.requirements = requirements;
|
||||||
|
this.description = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shoot(Player p){
|
public void shoot(Player p){
|
||||||
bullet(p, p.x, p.y);
|
bullet(p, p.x, p.y, mouseAngle(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
void bullet(Entity owner, float x, float y){
|
float mouseAngle(Entity owner){
|
||||||
new Bullet(type, owner, x, y, Angles.mouseAngle(owner.x, owner.y)).add();
|
return Angles.mouseAngle(owner.x, owner.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bullet(Entity owner, float x, float y, float angle){
|
||||||
|
new Bullet(type, owner, x, y, angle).add();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack stack(Item item, int amount){
|
||||||
|
return new ItemStack(item, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public enum Recipe{
|
|||||||
conveyor(distribution, ProductionBlocks.conveyor, stack(Item.stone, 1)),
|
conveyor(distribution, ProductionBlocks.conveyor, stack(Item.stone, 1)),
|
||||||
fastconveyor(distribution, ProductionBlocks.steelconveyor, stack(Item.steel, 1)),
|
fastconveyor(distribution, ProductionBlocks.steelconveyor, stack(Item.steel, 1)),
|
||||||
router(distribution, ProductionBlocks.router, stack(Item.stone, 3)),
|
router(distribution, ProductionBlocks.router, stack(Item.stone, 3)),
|
||||||
|
junction(distribution, ProductionBlocks.junction, stack(Item.iron, 5)),
|
||||||
|
|
||||||
turret(defense, WeaponBlocks.turret, stack(Item.stone, 6)),
|
turret(defense, WeaponBlocks.turret, stack(Item.stone, 6)),
|
||||||
dturret(defense, WeaponBlocks.doubleturret, stack(Item.stone, 12)),
|
dturret(defense, WeaponBlocks.doubleturret, stack(Item.stone, 12)),
|
||||||
|
|||||||
48
core/src/io/anuke/mindustry/ui/LevelDialog.java
Normal file
48
core/src/io/anuke/mindustry/ui/LevelDialog.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.GameState;
|
||||||
|
import io.anuke.mindustry.World;
|
||||||
|
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||||
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
|
||||||
|
public class LevelDialog extends Dialog{
|
||||||
|
private int selectedMap;
|
||||||
|
|
||||||
|
public LevelDialog(){
|
||||||
|
super("Level Select");
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
||||||
|
|
||||||
|
addCloseButton();
|
||||||
|
getButtonTable().addButton("Play", ()->{
|
||||||
|
hide();
|
||||||
|
World.loadMap(selectedMap);
|
||||||
|
GameState.play();
|
||||||
|
});
|
||||||
|
|
||||||
|
for(int i = 0; i < maps.length; i ++){
|
||||||
|
content().add(maps[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
|
||||||
|
for(int i = 0; i < maps.length; i ++){
|
||||||
|
int index = i;
|
||||||
|
ImageButton image = new ImageButton(new TextureRegion(mapTextures[i]), "togglemap");
|
||||||
|
mapgroup.add(image);
|
||||||
|
image.clicked(()->{
|
||||||
|
selectedMap = index;
|
||||||
|
});
|
||||||
|
image.getImageCell().size(150, 150);
|
||||||
|
content().add(image).size(180);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
core/src/io/anuke/mindustry/ui/MenuDialog.java
Normal file
40
core/src/io/anuke/mindustry/ui/MenuDialog.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
||||||
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
|
|
||||||
|
public class MenuDialog extends Dialog{
|
||||||
|
|
||||||
|
public MenuDialog(){
|
||||||
|
super("Paused", "dialog");
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
content().addButton("Back", ()->{
|
||||||
|
hide();
|
||||||
|
paused = false;
|
||||||
|
}).width(200);
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
content().addButton("Settings", ()->{
|
||||||
|
ui.showPrefs();
|
||||||
|
}).width(200);
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
content().addButton("Controls", ()->{
|
||||||
|
ui.showControls();
|
||||||
|
}).width(200);
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
content().addButton("Back to menu", ()->{
|
||||||
|
new ConfirmDialog("Confirm", "Are you sure you want to quit?", ()->{
|
||||||
|
hide();
|
||||||
|
paused = false;
|
||||||
|
playing = false;
|
||||||
|
});
|
||||||
|
}).width(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
core/src/io/anuke/mindustry/ui/TutorialDialog.java
Normal file
35
core/src/io/anuke/mindustry/ui/TutorialDialog.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import io.anuke.ucore.core.Settings;
|
||||||
|
import io.anuke.ucore.scene.ui.TextDialog;
|
||||||
|
|
||||||
|
public class TutorialDialog extends TextDialog{
|
||||||
|
|
||||||
|
public TutorialDialog(){
|
||||||
|
super("Tutorial", tutorialText);
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
setDialog();
|
||||||
|
|
||||||
|
hidden(()->{
|
||||||
|
playing = true;
|
||||||
|
paused = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
getButtonTable().addButton("OK", ()->{
|
||||||
|
hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
content().pad(8);
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
content().addCheck("Don't show again", b->{
|
||||||
|
Settings.putBool("tutorial", !b);
|
||||||
|
Settings.save();
|
||||||
|
}).padTop(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
119
core/src/io/anuke/mindustry/ui/UpgradeDialog.java
Normal file
119
core/src/io/anuke/mindustry/ui/UpgradeDialog.java
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.Inventory;
|
||||||
|
import io.anuke.mindustry.entities.Weapon;
|
||||||
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
|
import io.anuke.ucore.scene.ui.*;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
|
public class UpgradeDialog extends Dialog{
|
||||||
|
|
||||||
|
public UpgradeDialog() {
|
||||||
|
super("Upgrades");
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
addCloseButton();
|
||||||
|
|
||||||
|
hidden(()->{
|
||||||
|
paused = false;
|
||||||
|
});
|
||||||
|
shown(()->{
|
||||||
|
paused = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
getButtonTable().addButton("Ok", ()->{
|
||||||
|
hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
Table weptab = new Table();
|
||||||
|
weptab.background("button");
|
||||||
|
weptab.pad(20);
|
||||||
|
|
||||||
|
for(Weapon weapon : Weapon.values()){
|
||||||
|
TextButton button = new TextButton(weapon.name());
|
||||||
|
|
||||||
|
Image img = new Image(Draw.region("weapon-"+weapon.name()));
|
||||||
|
button.add(img).size(8*5);
|
||||||
|
button.getCells().reverse();
|
||||||
|
button.row();
|
||||||
|
button.pack();
|
||||||
|
|
||||||
|
button.update(()->{
|
||||||
|
|
||||||
|
if(weapons.get(weapon) == Boolean.TRUE){
|
||||||
|
button.setDisabled(true);
|
||||||
|
button.setColor(Color.GRAY);
|
||||||
|
button.setTouchable(Touchable.disabled);
|
||||||
|
}else{
|
||||||
|
button.setColor(Color.WHITE);
|
||||||
|
button.setDisabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.setDisabled(!Inventory.hasItems(weapon.requirements));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
weptab.add(button).width(160);
|
||||||
|
|
||||||
|
Table tiptable = new Table();
|
||||||
|
|
||||||
|
Runnable run = ()->{
|
||||||
|
tiptable.clearChildren();
|
||||||
|
|
||||||
|
String description = weapon.description;
|
||||||
|
|
||||||
|
tiptable.background("button");
|
||||||
|
tiptable.add("[PURPLE]" + weapon.name(), 0.75f).left().padBottom(2f);
|
||||||
|
|
||||||
|
if(weapons.get(weapon) != Boolean.TRUE){
|
||||||
|
ItemStack[] req = weapon.requirements;
|
||||||
|
for(ItemStack s : req){
|
||||||
|
tiptable.row();
|
||||||
|
int amount = Math.min(items.get(s.item, 0), s.amount);
|
||||||
|
tiptable.add(
|
||||||
|
(amount >= s.amount ? "[YELLOW]" : "[RED]")
|
||||||
|
+s.item + ": " + amount + " / " +s.amount, 0.5f).left();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tiptable.row();
|
||||||
|
tiptable.add().size(10);
|
||||||
|
tiptable.row();
|
||||||
|
tiptable.add("[ORANGE]" + description).left();
|
||||||
|
tiptable.row();
|
||||||
|
if(weapons.get(weapon) == Boolean.TRUE)
|
||||||
|
tiptable.add("[LIME]Purchased!").left();
|
||||||
|
tiptable.pad(10f);
|
||||||
|
};
|
||||||
|
|
||||||
|
run.run();
|
||||||
|
|
||||||
|
Tooltip tip = new Tooltip(tiptable, run);
|
||||||
|
|
||||||
|
tip.setInstant(true);
|
||||||
|
|
||||||
|
button.addListener(tip);
|
||||||
|
|
||||||
|
button.clicked(()->{
|
||||||
|
Inventory.removeItems(weapon.requirements);
|
||||||
|
weapons.put(weapon, true);
|
||||||
|
ui.updateWeapons();
|
||||||
|
run.run();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
content().add("Weapons");
|
||||||
|
content().row();
|
||||||
|
content().add(weptab);
|
||||||
|
content().row();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -36,11 +36,11 @@ public class Block{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleItem(Tile tile, Item item, Tile source){
|
public void handleItem(Tile tile, Item item, Tile source){
|
||||||
tile.entity.addItem(item, 1);
|
tile.entity.addItem(item, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Item item){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ public class Block{
|
|||||||
|
|
||||||
for(int j = 0; j < 4; j ++){
|
for(int j = 0; j < 4; j ++){
|
||||||
Tile other = tiles[i];
|
Tile other = tiles[i];
|
||||||
if(other != null && other.block().accept(item)
|
if(other != null && other.block().accept(item, other, tile)
|
||||||
//don't output to things facing this thing
|
//don't output to things facing this thing
|
||||||
&& !(other.block().rotate && (other.rotation + 2) % 4 == i)){
|
&& !(other.block().rotate && (other.rotation + 2) % 4 == i)){
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public class Block{
|
|||||||
|
|
||||||
if(todump != null && item != todump) continue;
|
if(todump != null && item != todump) continue;
|
||||||
|
|
||||||
if(tile.entity.hasItem(item) && other != null && other.block().accept(item) &&
|
if(tile.entity.hasItem(item) && other != null && other.block().accept(item, other, tile) &&
|
||||||
//don't output to things facing this thing
|
//don't output to things facing this thing
|
||||||
!(other.block().rotate && (other.rotation + 2) % 4 == i)){
|
!(other.block().rotate && (other.rotation + 2) % 4 == i)){
|
||||||
other.block().handleItem(other, item, tile);
|
other.block().handleItem(other, item, tile);
|
||||||
@@ -119,7 +119,7 @@ public class Block{
|
|||||||
*/
|
*/
|
||||||
protected boolean offloadDir(Tile tile, Item item){
|
protected boolean offloadDir(Tile tile, Item item){
|
||||||
Tile other = tile.getNearby()[tile.rotation];
|
Tile other = tile.getNearby()[tile.rotation];
|
||||||
if(other != null && other.block().accept(item)){
|
if(other != null && other.block().accept(item, other, tile)){
|
||||||
other.block().handleItem(other, item, tile);
|
other.block().handleItem(other, item, tile);
|
||||||
//other.entity.addCovey(item, ch == 1 ? 0.5f : ch ==2 ? 1f : 0f);
|
//other.entity.addCovey(item, ch == 1 ? 0.5f : ch ==2 ? 1f : 0f);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class Conveyor extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Item item){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class Conveyor extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleItem(Tile tile, Item item, Tile source){
|
public void handleItem(Tile tile, Item item, Tile source){
|
||||||
int ch = Math.abs(source.relativeTo(tile.x, tile.y) - tile.rotation);
|
int ch = Math.abs(source.relativeTo(tile.x, tile.y) - tile.rotation);
|
||||||
int ang = ((source.relativeTo(tile.x, tile.y) - tile.rotation));
|
int ang = ((source.relativeTo(tile.x, tile.y) - tile.rotation));
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class Crafter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Item item){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return item == Item.iron || item == Item.coal;
|
return item == Item.iron || item == Item.coal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ public class ProductionBlocks{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleItem(Tile tile, Item item, Tile source){
|
public void handleItem(Tile tile, Item item, Tile source){
|
||||||
Inventory.addItem(item, 1);
|
Inventory.addItem(item, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Item item){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -44,14 +44,14 @@ public class ProductionBlocks{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
if(Timers.get(tile, 10) && tile.entity.totalItems() > 0){
|
if(Timers.get(tile, 2) && tile.entity.totalItems() > 0){
|
||||||
tryDump(tile, tile.rotation++, null);
|
tryDump(tile, tile.rotation++, null);
|
||||||
tile.rotation %= 4;
|
tile.rotation %= 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Item item){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +61,37 @@ public class ProductionBlocks{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
junction = new Block("junction"){
|
||||||
|
{
|
||||||
|
update = true;
|
||||||
|
solid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleItem(Tile tile, Item item, Tile source){
|
||||||
|
int dir = source.relativeTo(tile.x, tile.y);
|
||||||
|
dir = (dir+4)%4;
|
||||||
|
Tile to = tile.getNearby()[dir];
|
||||||
|
Timers.run(15, ()->{
|
||||||
|
to.block().handleItem(to, item, tile);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
|
int dir = source.relativeTo(dest.x, dest.y);
|
||||||
|
dir = (dir+4)%4;
|
||||||
|
Tile to = dest.getNearby()[dir];
|
||||||
|
return to != null && to.block() != junction && to.block().accept(item, dest, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description(){
|
||||||
|
return "Serves as a conveyor junction.";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
smelter = new Crafter("smelter"){{
|
smelter = new Crafter("smelter"){{
|
||||||
health = 70;
|
health = 70;
|
||||||
requirements = new Item[]{Item.coal, Item.iron};
|
requirements = new Item[]{Item.coal, Item.iron};
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class Turret extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Item item){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return item == ammo;
|
return item == ammo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package io.anuke.mindustry.client;
|
|||||||
import com.badlogic.gdx.ApplicationListener;
|
import com.badlogic.gdx.ApplicationListener;
|
||||||
import com.badlogic.gdx.backends.gwt.GwtApplication;
|
import com.badlogic.gdx.backends.gwt.GwtApplication;
|
||||||
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
|
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
|
||||||
import io.anuke.mindustry.Mindustry;
|
|
||||||
import com.google.gwt.dom.client.*;
|
import com.google.gwt.dom.client.*;
|
||||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.Mindustry;
|
||||||
|
|
||||||
public class HtmlLauncher extends GwtApplication {
|
public class HtmlLauncher extends GwtApplication {
|
||||||
static final int WIDTH = 800;
|
static final int WIDTH = 800;
|
||||||
static final int HEIGHT = 600;
|
static final int HEIGHT = 600;
|
||||||
|
|||||||
Reference in New Issue
Block a user