Major bugfix, new incomplete placemodes
This commit is contained in:
@@ -30,6 +30,6 @@ After building, the output .JAR file should be in the output JAR file should be
|
|||||||
|
|
||||||
<a href="https://anuke.itch.io/mindustry"><img src="https://i.imgur.com/sk26hTV.png" width="auto" height="75"></a>
|
<a href="https://anuke.itch.io/mindustry"><img src="https://i.imgur.com/sk26hTV.png" width="auto" height="75"></a>
|
||||||
|
|
||||||
<a href="https://anuke.itch.io/mindustry"><img src="https://i.imgur.com/Zbks9.gif" width="auto" height="75"></a>
|
<a href="https://anuke.itch.io/mindustry"><img src="https://i.imgur.com/dAFMjEJ.gif" width="auto" height="75"></a>
|
||||||
|
|
||||||
<a href="https://play.google.com/store/apps/details?id=io.anuke.mindustry&hl=en"><img src="https://i.imgur.com/8dF6l81.png" width="auto" height="75"></a>
|
<a href="https://play.google.com/store/apps/details?id=io.anuke.mindustry&hl=en"><img src="https://i.imgur.com/8dF6l81.png" width="auto" height="75"></a>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ project(":core") {
|
|||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.github.Anuken:ucore:a1a3bd9'
|
compile 'com.github.Anuken:ucore:6eea0a3'
|
||||||
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"
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
core/assets-raw/sprites/ui/icon-areaDelete.png
Normal file
BIN
core/assets-raw/sprites/ui/icon-areaDelete.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 198 B |
BIN
core/assets-raw/sprites/ui/icon-hold.png
Normal file
BIN
core/assets-raw/sprites/ui/icon-hold.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 197 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 79 KiB |
@@ -2,7 +2,6 @@ package io.anuke.mindustry;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.profiling.GLProfiler;
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.core.*;
|
import io.anuke.mindustry.core.*;
|
||||||
@@ -14,7 +13,6 @@ import io.anuke.ucore.core.Inputs;
|
|||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.function.Callable;
|
import io.anuke.ucore.function.Callable;
|
||||||
import io.anuke.ucore.modules.ModuleCore;
|
import io.anuke.ucore.modules.ModuleCore;
|
||||||
import io.anuke.ucore.util.Profiler;
|
|
||||||
|
|
||||||
public class Mindustry extends ModuleCore {
|
public class Mindustry extends ModuleCore {
|
||||||
public static Callable donationsCallable;
|
public static Callable donationsCallable;
|
||||||
@@ -43,15 +41,11 @@ public class Mindustry extends ModuleCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postInit(){
|
public void postInit(){
|
||||||
if(Vars.debug && Vars.debugGL){
|
|
||||||
GLProfiler.enable();
|
|
||||||
}
|
|
||||||
Vars.control.reset();
|
Vars.control.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(){
|
public void render(){
|
||||||
Profiler.begin("total");
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
super.render();
|
super.render();
|
||||||
@@ -66,7 +60,5 @@ public class Mindustry extends ModuleCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Inputs.update();
|
Inputs.update();
|
||||||
|
|
||||||
Profiler.end("total");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
public class Vars{
|
public class Vars{
|
||||||
public static final boolean testAndroid = false;
|
public static final boolean testAndroid = true;
|
||||||
//shorthand for whether or not this is running on android
|
//shorthand for whether or not this is running on android
|
||||||
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
|
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
|
||||||
//shorthand for whether or not this is running on GWT
|
//shorthand for whether or not this is running on GWT
|
||||||
@@ -34,10 +34,6 @@ public class Vars{
|
|||||||
public static final int zoomScale = Math.round(Unit.dp.inPixels(1));
|
public static final int zoomScale = Math.round(Unit.dp.inPixels(1));
|
||||||
//if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available
|
//if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available
|
||||||
public static boolean debug = false;
|
public static boolean debug = false;
|
||||||
//whether to debug openGL info
|
|
||||||
public static boolean debugGL = false;
|
|
||||||
//whether profiling is shown
|
|
||||||
public static boolean profile = false;
|
|
||||||
//whether the player can clip through walls
|
//whether the player can clip through walls
|
||||||
public static boolean noclip = false;
|
public static boolean noclip = false;
|
||||||
//whether to draw chunk borders
|
//whether to draw chunk borders
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import io.anuke.mindustry.entities.enemies.BlastEnemy;
|
|||||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||||
import io.anuke.mindustry.entities.enemies.HealerEnemy;
|
import io.anuke.mindustry.entities.enemies.HealerEnemy;
|
||||||
import io.anuke.mindustry.input.AndroidInput;
|
import io.anuke.mindustry.input.AndroidInput;
|
||||||
import io.anuke.mindustry.input.Input;
|
import io.anuke.mindustry.input.DesktopInput;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
@@ -32,7 +32,6 @@ import io.anuke.ucore.entities.EntityGroup;
|
|||||||
import io.anuke.ucore.graphics.Atlas;
|
import io.anuke.ucore.graphics.Atlas;
|
||||||
import io.anuke.ucore.modules.Module;
|
import io.anuke.ucore.modules.Module;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Profiler;
|
|
||||||
|
|
||||||
public class Control extends Module{
|
public class Control extends Module{
|
||||||
int targetscale = baseCameraScale;
|
int targetscale = baseCameraScale;
|
||||||
@@ -65,10 +64,6 @@ public class Control extends Module{
|
|||||||
public Control(){
|
public Control(){
|
||||||
if(Mindustry.args.contains("-debug", false))
|
if(Mindustry.args.contains("-debug", false))
|
||||||
Vars.debug = true;
|
Vars.debug = true;
|
||||||
if(Mindustry.args.contains("-profile", false))
|
|
||||||
Vars.profile = true;
|
|
||||||
if(Mindustry.args.contains("-debugGL", false))
|
|
||||||
Vars.debugGL = true;
|
|
||||||
|
|
||||||
UCore.log("Total blocks loaded: " + Block.getAllBlocks().size);
|
UCore.log("Total blocks loaded: " + Block.getAllBlocks().size);
|
||||||
|
|
||||||
@@ -83,7 +78,7 @@ public class Control extends Module{
|
|||||||
if(android){
|
if(android){
|
||||||
input = new AndroidInput();
|
input = new AndroidInput();
|
||||||
}else{
|
}else{
|
||||||
input = new Input();
|
input = new DesktopInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
Inputs.addProcessor(input);
|
Inputs.addProcessor(input);
|
||||||
@@ -111,7 +106,8 @@ public class Control extends Module{
|
|||||||
"pause", Keys.SPACE,
|
"pause", Keys.SPACE,
|
||||||
"dash", Keys.SHIFT_LEFT,
|
"dash", Keys.SHIFT_LEFT,
|
||||||
"rotate_right", Keys.R,
|
"rotate_right", Keys.R,
|
||||||
"rotate_left", Keys.E
|
"rotate_left", Keys.E,
|
||||||
|
"area_delete_mode", Keys.Q
|
||||||
);
|
);
|
||||||
|
|
||||||
for(int i = 0; i < Vars.saveSlots; i ++){
|
for(int i = 0; i < Vars.saveSlots; i ++){
|
||||||
@@ -165,7 +161,7 @@ public class Control extends Module{
|
|||||||
renderer.clearTiles();
|
renderer.clearTiles();
|
||||||
|
|
||||||
player.x = core.worldx();
|
player.x = core.worldx();
|
||||||
player.y = core.worldy() - Vars.tilesize*2 - ((int)(Gdx.graphics.getWidth() / (float)Core.cameraScale * 2) % 2 == 0 ? 0.5f : 0);
|
player.y = core.worldy() - Vars.tilesize*2;
|
||||||
|
|
||||||
Core.camera.position.set(player.x, player.y, 0);
|
Core.camera.position.set(player.x, player.y, 0);
|
||||||
|
|
||||||
@@ -282,7 +278,7 @@ public class Control extends Module{
|
|||||||
|
|
||||||
int last = Settings.getInt("hiscore" + world.getMap().name());
|
int last = Settings.getInt("hiscore" + world.getMap().name());
|
||||||
|
|
||||||
if(wave > last){
|
if(wave > last && mode != GameMode.sandbox){
|
||||||
Settings.putInt("hiscore" + world.getMap().name(), wave);
|
Settings.putInt("hiscore" + world.getMap().name(), wave);
|
||||||
Settings.save();
|
Settings.save();
|
||||||
hiscore = true;
|
hiscore = true;
|
||||||
@@ -523,9 +519,6 @@ public class Control extends Module{
|
|||||||
runWave();
|
runWave();
|
||||||
}
|
}
|
||||||
|
|
||||||
Profiler.begin("entityUpdate");
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
Entities.update(Entities.defaultGroup());
|
Entities.update(Entities.defaultGroup());
|
||||||
Entities.update(bulletGroup);
|
Entities.update(bulletGroup);
|
||||||
Entities.update(enemyGroup);
|
Entities.update(enemyGroup);
|
||||||
@@ -533,8 +526,6 @@ public class Control extends Module{
|
|||||||
|
|
||||||
Entities.collideGroups(enemyGroup, bulletGroup);
|
Entities.collideGroups(enemyGroup, bulletGroup);
|
||||||
Entities.collideGroups(Entities.defaultGroup(), bulletGroup);
|
Entities.collideGroups(Entities.defaultGroup(), bulletGroup);
|
||||||
|
|
||||||
Profiler.end("entityUpdate");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
import static io.anuke.ucore.core.Core.camera;
|
import static io.anuke.ucore.core.Core.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.*;
|
import com.badlogic.gdx.graphics.*;
|
||||||
import com.badlogic.gdx.graphics.profiling.GLProfiler;
|
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||||
|
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.FloatArray;
|
import com.badlogic.gdx.utils.FloatArray;
|
||||||
@@ -22,16 +23,18 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.Blocks;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
import io.anuke.mindustry.world.blocks.types.StaticBlock;
|
import io.anuke.mindustry.world.blocks.types.StaticBlock;
|
||||||
import io.anuke.ucore.UCore;
|
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.entities.DestructibleEntity;
|
import io.anuke.ucore.entities.DestructibleEntity;
|
||||||
import io.anuke.ucore.entities.EffectEntity;
|
import io.anuke.ucore.entities.EffectEntity;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
import io.anuke.ucore.graphics.CacheBatch;
|
import io.anuke.ucore.graphics.CacheBatch;
|
||||||
|
import io.anuke.ucore.graphics.Hue;
|
||||||
import io.anuke.ucore.graphics.Surface;
|
import io.anuke.ucore.graphics.Surface;
|
||||||
import io.anuke.ucore.modules.RendererModule;
|
import io.anuke.ucore.modules.RendererModule;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.*;
|
import io.anuke.ucore.util.Angles;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
public class Renderer extends RendererModule{
|
public class Renderer extends RendererModule{
|
||||||
private final static int chunksize = 32;
|
private final static int chunksize = 32;
|
||||||
@@ -56,6 +59,8 @@ public class Renderer extends RendererModule{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
clearColor = Hue.lightness(0.4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -140,38 +145,75 @@ public class Renderer extends RendererModule{
|
|||||||
camera.position.add(-0.5f, 0, 0);
|
camera.position.add(-0.5f, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Profiler.begin("draw");
|
draw();
|
||||||
|
|
||||||
drawDefault();
|
|
||||||
|
|
||||||
Profiler.end("draw");
|
|
||||||
if(Profiler.updating())
|
|
||||||
Profiler.getTimes().put("draw", Profiler.getTimes().get("draw") - Profiler.getTimes().get("blockDraw") - Profiler.getTimes().get("entityDraw"));
|
|
||||||
|
|
||||||
if(Vars.debug && Vars.debugGL && Timers.get("profile", 60)){
|
|
||||||
UCore.log("shaders: " + GLProfiler.shaderSwitches, "calls: " + GLProfiler.drawCalls, "bindings: " + GLProfiler.textureBindings, "vertices: " + GLProfiler.vertexCount.average);
|
|
||||||
}
|
|
||||||
|
|
||||||
camera.position.set(lastx - deltax, lasty - deltay, 0);
|
camera.position.set(lastx - deltax, lasty - deltay, 0);
|
||||||
|
|
||||||
record(); //this only does something if GdxGifRecorder is on the class path, which it usually isn't
|
record(); //this only does something if GdxGifRecorder is on the class path, which it usually isn't
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FrameBuffer buffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
|
||||||
|
|
||||||
|
void drawTest(){
|
||||||
|
camera.update();
|
||||||
|
|
||||||
|
clearScreen(clearColor);
|
||||||
|
|
||||||
|
Core.batch.setProjectionMatrix(camera.combined);
|
||||||
|
|
||||||
|
Graphics.surface(pixelSurface, false);
|
||||||
|
|
||||||
|
Draw.color(1f, 1f, 1f, Mathf.absin(Timers.time(), 10f, 1f));
|
||||||
|
Draw.rect("blank", camera.position.x, camera.position.y, camera.viewportWidth, camera.viewportHeight);
|
||||||
|
Draw.color();
|
||||||
|
|
||||||
|
Graphics.surface(shadowSurface);
|
||||||
|
Draw.color(Color.RED);
|
||||||
|
Draw.alpha(0.5f);
|
||||||
|
Draw.rect("blank", camera.position.x, camera.position.y, 100, 100);
|
||||||
|
Draw.color();
|
||||||
|
Graphics.flushSurface();
|
||||||
|
|
||||||
|
Graphics.flushSurface();
|
||||||
|
Graphics.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawTest2(){
|
||||||
|
camera.update();
|
||||||
|
|
||||||
|
clearScreen(clearColor);
|
||||||
|
Core.batch.setProjectionMatrix(camera.combined);
|
||||||
|
|
||||||
|
Graphics.surface(pixelSurface, false);
|
||||||
|
|
||||||
|
Draw.color(1f, 1f, 1f, 0.3f);
|
||||||
|
Draw.rect("blank", camera.position.x, camera.position.y, camera.viewportWidth, camera.viewportHeight);
|
||||||
|
Draw.color();
|
||||||
|
|
||||||
|
Graphics.flushSurface();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
|
camera.update();
|
||||||
|
|
||||||
|
clearScreen(clearColor);
|
||||||
|
|
||||||
|
batch.setProjectionMatrix(camera.combined);
|
||||||
|
|
||||||
|
if(pixelate)
|
||||||
|
Graphics.surface(pixelSurface, false);
|
||||||
|
else
|
||||||
|
batch.begin();
|
||||||
|
|
||||||
//clears shield surface
|
//clears shield surface
|
||||||
Graphics.surface(shieldSurface);
|
Graphics.surface(shieldSurface);
|
||||||
Graphics.surface();
|
Graphics.surface();
|
||||||
|
|
||||||
boolean optimize = false;
|
boolean optimize = false;
|
||||||
|
|
||||||
Profiler.begin("blockDraw");
|
|
||||||
drawFloor();
|
drawFloor();
|
||||||
drawBlocks(false, optimize);
|
drawBlocks(false, optimize);
|
||||||
Profiler.end("blockDraw");
|
|
||||||
|
|
||||||
Profiler.begin("entityDraw");
|
|
||||||
|
|
||||||
Graphics.shader(Shaders.outline, false);
|
Graphics.shader(Shaders.outline, false);
|
||||||
Entities.draw(control.enemyGroup);
|
Entities.draw(control.enemyGroup);
|
||||||
@@ -179,8 +221,6 @@ public class Renderer extends RendererModule{
|
|||||||
|
|
||||||
Entities.draw(Entities.defaultGroup());
|
Entities.draw(Entities.defaultGroup());
|
||||||
|
|
||||||
Profiler.end("entityDraw");
|
|
||||||
|
|
||||||
if(!optimize) drawBlocks(true, false);
|
if(!optimize) drawBlocks(true, false);
|
||||||
|
|
||||||
Entities.draw(control.bulletGroup);
|
Entities.draw(control.bulletGroup);
|
||||||
@@ -192,6 +232,12 @@ public class Renderer extends RendererModule{
|
|||||||
if(Settings.getBool("indicators") && Vars.showUI){
|
if(Settings.getBool("indicators") && Vars.showUI){
|
||||||
drawEnemyMarkers();
|
drawEnemyMarkers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(pixelate)
|
||||||
|
Graphics.flushSurface();
|
||||||
|
|
||||||
|
batch.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -476,9 +522,10 @@ public class Renderer extends RendererModule{
|
|||||||
int tiley = control.input.getBlockY();
|
int tiley = control.input.getBlockY();
|
||||||
|
|
||||||
//draw placement box
|
//draw placement box
|
||||||
if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android)){
|
if((player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android)
|
||||||
|
&& control.input.drawPlace()) || (player.placeMode.delete && Inputs.keyDown("area_delete_mode"))){
|
||||||
|
|
||||||
player.placeMode.draw(tilex, tiley, control.input.getBlockEndX(), control.input.getBlockEndY()); //TODO proper end points
|
player.placeMode.draw(tilex, tiley, control.input.getBlockEndX(), control.input.getBlockEndY());
|
||||||
|
|
||||||
Draw.thickness(1f);
|
Draw.thickness(1f);
|
||||||
Draw.color(Color.SCARLET);
|
Draw.color(Color.SCARLET);
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import io.anuke.ucore.scene.ui.*;
|
|||||||
import io.anuke.ucore.scene.ui.Window.WindowStyle;
|
import io.anuke.ucore.scene.ui.Window.WindowStyle;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.Profiler;
|
|
||||||
|
|
||||||
public class UI extends SceneModule{
|
public class UI extends SceneModule{
|
||||||
Table loadingtable, desctable, configtable;
|
Table loadingtable, desctable, configtable;
|
||||||
@@ -99,6 +98,12 @@ public class UI extends SceneModule{
|
|||||||
Colors.put("healthstats", Color.SCARLET);
|
Colors.put("healthstats", Color.SCARLET);
|
||||||
Colors.put("interact", Color.ORANGE);
|
Colors.put("interact", Color.ORANGE);
|
||||||
Colors.put("accent", Color.valueOf("f4ba6e"));
|
Colors.put("accent", Color.valueOf("f4ba6e"));
|
||||||
|
Colors.put("place", Color.PURPLE);
|
||||||
|
Colors.put("placeInvalid", Color.RED);
|
||||||
|
Colors.put("placeRotate", Color.ORANGE);
|
||||||
|
Colors.put("break", Color.CORAL);
|
||||||
|
Colors.put("breakStart", Color.YELLOW);
|
||||||
|
Colors.put("breakInvalid", Color.RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadSkin(){
|
protected void loadSkin(){
|
||||||
@@ -133,8 +138,6 @@ public class UI extends SceneModule{
|
|||||||
public void update(){
|
public void update(){
|
||||||
if(Vars.debug && !Vars.showUI) return;
|
if(Vars.debug && !Vars.showUI) return;
|
||||||
|
|
||||||
Profiler.begin("ui");
|
|
||||||
|
|
||||||
if(nplay.visible()){
|
if(nplay.visible()){
|
||||||
scene.getBatch().getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
scene.getBatch().getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
scene.getBatch().begin();
|
scene.getBatch().begin();
|
||||||
@@ -144,9 +147,8 @@ public class UI extends SceneModule{
|
|||||||
scene.getBatch().end();
|
scene.getBatch().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.update();
|
scene.act();
|
||||||
|
scene.draw();
|
||||||
Profiler.end("ui");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,26 +5,21 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.math.*;
|
import com.badlogic.gdx.math.GridPoint2;
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.effect.Fx;
|
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.ucore.core.Effects;
|
|
||||||
import io.anuke.ucore.core.Sounds;
|
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
import io.anuke.ucore.entities.Entity;
|
import io.anuke.ucore.entities.Entity;
|
||||||
import io.anuke.ucore.entities.SolidEntity;
|
|
||||||
import io.anuke.ucore.modules.Module;
|
import io.anuke.ucore.modules.Module;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Profiler;
|
|
||||||
import io.anuke.ucore.util.Tmp;
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
public class World extends Module{
|
public class World extends Module{
|
||||||
@@ -43,9 +38,7 @@ public class World extends Module{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
Profiler.begin("pathfind");
|
|
||||||
pathfind.update();
|
pathfind.update();
|
||||||
Profiler.end("pathfind");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -190,7 +183,7 @@ public class World extends Module{
|
|||||||
Generator.generate(mapPixmaps[map.ordinal()], tiles);
|
Generator.generate(mapPixmaps[map.ordinal()], tiles);
|
||||||
|
|
||||||
//TODO multiblock core
|
//TODO multiblock core
|
||||||
placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0, false);
|
control.getInput().placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0, false);
|
||||||
|
|
||||||
if(map != Map.tutorial){
|
if(map != Map.tutorial){
|
||||||
setDefaultBlocks();
|
setDefaultBlocks();
|
||||||
@@ -239,146 +232,6 @@ public class World extends Module{
|
|||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO move to control or player?
|
|
||||||
public void placeBlock(int x, int y, Block result, int rotation, boolean effects){
|
|
||||||
Tile tile = tile(x, y);
|
|
||||||
|
|
||||||
//just in case
|
|
||||||
if(tile == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
tile.setBlock(result, rotation);
|
|
||||||
|
|
||||||
if(result.isMultiblock()){
|
|
||||||
int offsetx = -(result.width-1)/2;
|
|
||||||
int offsety = -(result.height-1)/2;
|
|
||||||
|
|
||||||
for(int dx = 0; dx < result.width; dx ++){
|
|
||||||
for(int dy = 0; dy < result.height; dy ++){
|
|
||||||
int worldx = dx + offsetx + x;
|
|
||||||
int worldy = dy + offsety + y;
|
|
||||||
if(!(worldx == x && worldy == y)){
|
|
||||||
Tile toplace = tile(worldx, worldy);
|
|
||||||
toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(effects) Effects.effect(Fx.place, worldx * Vars.tilesize, worldy * Vars.tilesize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(effects) Effects.effect(Fx.place, x * Vars.tilesize, y * Vars.tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Effects.shake(2f, 2f, player);
|
|
||||||
if(effects) Sounds.play("place");
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO move this to control?
|
|
||||||
public boolean validPlace(int x, int y, Block type){
|
|
||||||
|
|
||||||
for(SpawnPoint spawn : control.getSpawnPoints()){
|
|
||||||
if(Vector2.dst(x * tilesize, y * tilesize, spawn.start.worldx(), spawn.start.worldy()) < enemyspawnspace){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Tmp.r2.setSize(type.width * Vars.tilesize, type.height * Vars.tilesize);
|
|
||||||
Vector2 offset = type.getPlaceOffset();
|
|
||||||
Tmp.r2.setCenter(offset.x + x * Vars.tilesize, offset.y + y * Vars.tilesize);
|
|
||||||
|
|
||||||
for(SolidEntity e : Entities.getNearby(control.enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)){
|
|
||||||
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
|
||||||
|
|
||||||
if(Tmp.r2.overlaps(rect)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Vars.android && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tile tile = tile(x, y);
|
|
||||||
|
|
||||||
if(tile == null) return false;
|
|
||||||
|
|
||||||
if(!type.isMultiblock() && Vars.control.getTutorial().active() &&
|
|
||||||
Vars.control.getTutorial().showBlock()){
|
|
||||||
|
|
||||||
GridPoint2 point = Vars.control.getTutorial().getPlacePoint();
|
|
||||||
int rotation = Vars.control.getTutorial().getPlaceRotation();
|
|
||||||
Block block = Vars.control.getTutorial().getPlaceBlock();
|
|
||||||
|
|
||||||
if(type != block || point.x != x - control.getCore().x || point.y != y - control.getCore().y
|
|
||||||
|| (rotation != -1 && rotation != Vars.player.rotation)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else if(Vars.control.getTutorial().active()){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(type.isMultiblock()){
|
|
||||||
int offsetx = -(type.width-1)/2;
|
|
||||||
int offsety = -(type.height-1)/2;
|
|
||||||
for(int dx = 0; dx < type.width; dx ++){
|
|
||||||
for(int dy = 0; dy < type.height; dy ++){
|
|
||||||
Tile other = tile(x + dx + offsetx, y + dy + offsety);
|
|
||||||
if(other == null || other.block() != Blocks.air){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
if(tile.block() != type && type.canReplace(tile.block()) && tile.block().isMultiblock() == type.isMultiblock()){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return tile != null && tile.block() == Blocks.air;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void breakBlock(int x, int y){
|
|
||||||
Tile tile = tile(x, y);
|
|
||||||
|
|
||||||
if(tile == null) return;
|
|
||||||
|
|
||||||
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
|
|
||||||
Recipe result = null;
|
|
||||||
|
|
||||||
for(Recipe recipe : Recipe.values()){
|
|
||||||
if(recipe.result == block){
|
|
||||||
result = recipe;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result != null){
|
|
||||||
for(ItemStack stack : result.requirements){
|
|
||||||
Vars.control.addItem(stack.item, (int)(stack.amount * Vars.breakDropAmount));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tile.block().drops != null){
|
|
||||||
Vars.control.addItem(tile.block().drops.item, tile.block().drops.amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
Effects.shake(3f, 1f, player);
|
|
||||||
Sounds.play("break");
|
|
||||||
|
|
||||||
if(!tile.block().isMultiblock() && !tile.isLinked()){
|
|
||||||
tile.setBlock(Blocks.air);
|
|
||||||
Effects.effect(Fx.breakBlock, tile.worldx(), tile.worldy());
|
|
||||||
}else{
|
|
||||||
Tile target = tile.isLinked() ? tile.getLinked() : tile;
|
|
||||||
Array<Tile> removals = target.getLinkedTiles();
|
|
||||||
for(Tile toremove : removals){
|
|
||||||
//note that setting a new block automatically unlinks it
|
|
||||||
toremove.setBlock(Blocks.air);
|
|
||||||
Effects.effect(Fx.breakBlock, toremove.worldx(), toremove.worldy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeBlock(Tile tile){
|
public void removeBlock(Tile tile){
|
||||||
if(!tile.block().isMultiblock() && !tile.isLinked()){
|
if(!tile.block().isMultiblock() && !tile.isLinked()){
|
||||||
tile.setBlock(Blocks.air);
|
tile.setBlock(Blocks.air);
|
||||||
@@ -392,34 +245,6 @@ public class World extends Module{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validBreak(int x, int y){
|
|
||||||
Tile tile = tile(x, y);
|
|
||||||
|
|
||||||
if(tile == null || tile.block() == ProductionBlocks.core) return false;
|
|
||||||
|
|
||||||
if(tile.isLinked() && tile.getLinked().block() == ProductionBlocks.core){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Vars.control.getTutorial().active()){
|
|
||||||
|
|
||||||
if(Vars.control.getTutorial().showBlock()){
|
|
||||||
GridPoint2 point = Vars.control.getTutorial().getPlacePoint();
|
|
||||||
int rotation = Vars.control.getTutorial().getPlaceRotation();
|
|
||||||
Block block = Vars.control.getTutorial().getPlaceBlock();
|
|
||||||
|
|
||||||
if(block != Blocks.air || point.x != x - control.getCore().x || point.y != y - control.getCore().y
|
|
||||||
|| (rotation != -1 && rotation != Vars.player.rotation)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tile.breakable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntity findTileTarget(float x, float y, Tile tile, float range, boolean damaged){
|
public TileEntity findTileTarget(float x, float y, Tile tile, float range, boolean damaged){
|
||||||
Entity closest = null;
|
Entity closest = null;
|
||||||
float dst = 0;
|
float dst = 0;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class Player extends DestructibleEntity{
|
|||||||
public transient float breaktime = 0;
|
public transient float breaktime = 0;
|
||||||
public transient Recipe recipe;
|
public transient Recipe recipe;
|
||||||
public transient int rotation;
|
public transient int rotation;
|
||||||
public transient PlaceMode placeMode = PlaceMode.touch;
|
public transient PlaceMode placeMode = android ? PlaceMode.cursor : PlaceMode.hold;
|
||||||
|
|
||||||
public Player(){
|
public Player(){
|
||||||
hitbox.setSize(5);
|
hitbox.setSize(5);
|
||||||
@@ -86,7 +86,7 @@ public class Player extends DestructibleEntity{
|
|||||||
vector.x += speed;
|
vector.x += speed;
|
||||||
|
|
||||||
boolean shooting = !Inputs.keyDown("dash") && Inputs.buttonDown(Buttons.LEFT) && recipe == null
|
boolean shooting = !Inputs.keyDown("dash") && Inputs.buttonDown(Buttons.LEFT) && recipe == null
|
||||||
&& !ui.hasMouse() && !control.getInput().onConfigurable();
|
&& !ui.hasMouse() && !control.getInput().onConfigurable() && !Inputs.keyDown("area_delete_mode");
|
||||||
|
|
||||||
if(shooting && Timers.get(this, "reload", weapon.reload)){
|
if(shooting && Timers.get(this, "reload", weapon.reload)){
|
||||||
weapon.shoot(this);
|
weapon.shoot(this);
|
||||||
@@ -108,7 +108,8 @@ public class Player extends DestructibleEntity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!shooting){
|
if(!shooting){
|
||||||
angle = Mathf.lerpAngDelta(angle, vector.angle(), 0.13f);
|
if(!vector.isZero())
|
||||||
|
angle = Mathf.lerpAngDelta(angle, vector.angle(), 0.13f);
|
||||||
}else{
|
}else{
|
||||||
float angle = Angles.mouseAngle(x, y);
|
float angle = Angles.mouseAngle(x, y);
|
||||||
this.angle = Mathf.lerpAngDelta(this.angle, angle, 0.1f);
|
this.angle = Mathf.lerpAngDelta(this.angle, angle, 0.1f);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.badlogic.gdx.Input.Keys;
|
|||||||
import com.badlogic.gdx.input.GestureDetector;
|
import com.badlogic.gdx.input.GestureDetector;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
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.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
@@ -20,9 +19,10 @@ import io.anuke.ucore.scene.ui.layout.Unit;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class AndroidInput extends InputHandler{
|
public class AndroidInput extends InputHandler{
|
||||||
|
public float lmousex, lmousey;
|
||||||
public float mousex, mousey;
|
public float mousex, mousey;
|
||||||
public boolean brokeBlock = false;
|
public boolean brokeBlock = false;
|
||||||
private float lmousex, lmousey;
|
private boolean placing = true;
|
||||||
private float warmup;
|
private float warmup;
|
||||||
private float warmupDelay = 20;
|
private float warmupDelay = 20;
|
||||||
|
|
||||||
@@ -34,11 +34,12 @@ public class AndroidInput extends InputHandler{
|
|||||||
@Override public float getCursorEndY(){ return Gdx.input.getY(0); }
|
@Override public float getCursorEndY(){ return Gdx.input.getY(0); }
|
||||||
@Override public float getCursorX(){ return mousex; }
|
@Override public float getCursorX(){ return mousex; }
|
||||||
@Override public float getCursorY(){ return mousey; }
|
@Override public float getCursorY(){ return mousey; }
|
||||||
|
@Override public boolean drawPlace(){ return placing; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(int keycode){
|
public boolean keyDown(int keycode){
|
||||||
if(keycode == Keys.E){
|
if(keycode == Keys.E){
|
||||||
place();
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -46,26 +47,43 @@ public class AndroidInput extends InputHandler{
|
|||||||
@Override
|
@Override
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||||
brokeBlock = false;
|
brokeBlock = false;
|
||||||
|
if(placing && pointer == 0 && !player.placeMode.pan){
|
||||||
|
player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||||
|
placing = false;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||||
|
if(ui.hasMouse()) return false;
|
||||||
|
|
||||||
ui.hideTooltip();
|
ui.hideTooltip();
|
||||||
if(pointer == 0){
|
lmousex = screenX;
|
||||||
lmousex = screenX;
|
lmousey = screenY;
|
||||||
lmousey = screenY;
|
|
||||||
|
if(!player.placeMode.pan){
|
||||||
|
if(pointer == 0){
|
||||||
|
placing = true;
|
||||||
|
|
||||||
|
mousex = screenX;
|
||||||
|
mousey = screenY;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
placing = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
warmup = 0;
|
warmup = 0;
|
||||||
|
|
||||||
if(!GameState.is(State.menu)){
|
if(!GameState.is(State.menu)){
|
||||||
Tile cursor = Vars.world.tile(Mathf.scl2(Graphics.mouseWorld().x, tilesize), Mathf.scl2(Graphics.mouseWorld().y, tilesize));
|
Tile cursor = world.tile(Mathf.scl2(Graphics.mouseWorld().x, tilesize), Mathf.scl2(Graphics.mouseWorld().y, tilesize));
|
||||||
if(cursor != null && !Vars.ui.hasMouse()){
|
if(cursor != null && !ui.hasMouse()){
|
||||||
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
||||||
if(linked != null && linked.block() instanceof Configurable){
|
if(linked != null && linked.block() instanceof Configurable){
|
||||||
Vars.ui.showConfig(linked);
|
ui.showConfig(linked);
|
||||||
}else if(!Vars.ui.hasConfigMouse()){
|
}else if(!ui.hasConfigMouse()){
|
||||||
Vars.ui.hideConfig();
|
ui.hideConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,7 +103,7 @@ public class AndroidInput extends InputHandler{
|
|||||||
|
|
||||||
public Tile selected(){
|
public Tile selected(){
|
||||||
Vector2 vec = Graphics.world(mousex, mousey);
|
Vector2 vec = Graphics.world(mousex, mousey);
|
||||||
return Vars.world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize));
|
return world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void breakBlock(){
|
public void breakBlock(){
|
||||||
@@ -94,23 +112,18 @@ public class AndroidInput extends InputHandler{
|
|||||||
|
|
||||||
if(player.breaktime >= tile.block().breaktime){
|
if(player.breaktime >= tile.block().breaktime){
|
||||||
brokeBlock = true;
|
brokeBlock = true;
|
||||||
Vars.world.breakBlock(tile.x, tile.y);
|
breakBlock(tile.x, tile.y);
|
||||||
player.breaktime = 0f;
|
player.breaktime = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void place(){
|
public void tryPlaceBlock(int tilex, int tiley){
|
||||||
Vector2 vec = Graphics.world(mousex, mousey);
|
if(player.recipe != null && control.hasItems(player.recipe.requirements) && validPlace(tilex, tiley, player.recipe.result)){
|
||||||
|
|
||||||
int tilex = Mathf.scl2(vec.x, tilesize);
|
placeBlock(tilex, tiley, player.recipe.result, player.rotation, true);
|
||||||
int tiley = Mathf.scl2(vec.y, tilesize);
|
|
||||||
|
|
||||||
if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && Vars.world.validPlace(tilex, tiley, player.recipe.result)){
|
|
||||||
|
|
||||||
Vars.world.placeBlock(tilex, tiley, player.recipe.result, player.rotation, true);
|
|
||||||
|
|
||||||
for(ItemStack stack : player.recipe.requirements){
|
for(ItemStack stack : player.recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
control.removeItem(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,7 +145,7 @@ public class AndroidInput extends InputHandler{
|
|||||||
if(sel == null)
|
if(sel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(warmup > warmupDelay && Vars.world.validBreak(sel.x, sel.y)){
|
if(warmup > warmupDelay && validBreak(sel.x, sel.y)){
|
||||||
player.breaktime += Timers.delta();
|
player.breaktime += Timers.delta();
|
||||||
|
|
||||||
if(player.breaktime > selected().block().breaktime){
|
if(player.breaktime > selected().block().breaktime){
|
||||||
@@ -145,8 +158,6 @@ public class AndroidInput extends InputHandler{
|
|||||||
mousey = ly;
|
mousey = ly;
|
||||||
}else{
|
}else{
|
||||||
warmup = 0;
|
warmup = 0;
|
||||||
//lmousex = Gdx.input.getX(0);
|
|
||||||
//lmousey = Gdx.input.getY(0);
|
|
||||||
player.breaktime = 0;
|
player.breaktime = 0;
|
||||||
|
|
||||||
mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth());
|
mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth());
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.badlogic.gdx.Input.Buttons;
|
|||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
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.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
@@ -20,27 +19,27 @@ import io.anuke.ucore.core.Timers;
|
|||||||
import io.anuke.ucore.scene.utils.Cursors;
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class Input extends InputHandler{
|
public class DesktopInput extends InputHandler{
|
||||||
float mousex, mousey;
|
int mousex, mousey;
|
||||||
float endx, endy;
|
int endx, endy;
|
||||||
|
|
||||||
@Override public float getCursorEndX(){ return endx; }
|
@Override public float getCursorEndX(){ return endx; }
|
||||||
@Override public float getCursorEndY(){ return endy; }
|
@Override public float getCursorEndY(){ return endy; }
|
||||||
@Override public float getCursorX(){ return Graphics.screen(mousex, mousey).x; }
|
@Override public float getCursorX(){ return (int)(Graphics.screen(mousex, mousey).x + 2); }
|
||||||
@Override public float getCursorY(){ return Gdx.graphics.getHeight() - Graphics.screen(mousex, mousey).y; }
|
@Override public float getCursorY(){ return (int)(Gdx.graphics.getHeight() - 1 - Graphics.screen(mousex, mousey).y); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (int screenX, int screenY, int pointer, int button){
|
public boolean touchDown (int screenX, int screenY, int pointer, int button){
|
||||||
if(button == Buttons.LEFT){
|
if(button == Buttons.LEFT){
|
||||||
Vector2 vec = Graphics.world(screenX, screenY);
|
Vector2 vec = Graphics.world(screenX, screenY);
|
||||||
mousex = vec.x;
|
mousex = (int)vec.x;
|
||||||
mousey = vec.y;
|
mousey = (int)vec.y;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||||
player.placeMode.tapped(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,15 +48,14 @@ public class Input extends InputHandler{
|
|||||||
if(player.isDead()) return;
|
if(player.isDead()) return;
|
||||||
|
|
||||||
if(!Inputs.buttonDown(Buttons.LEFT)){
|
if(!Inputs.buttonDown(Buttons.LEFT)){
|
||||||
Vector2 vec = Graphics.world(Gdx.input.getX(), Gdx.input.getY());
|
mousex = (int)Graphics.mouseWorld().x;
|
||||||
mousex = vec.x;
|
mousey = (int)Graphics.mouseWorld().y;
|
||||||
mousey = vec.y;
|
|
||||||
}
|
}
|
||||||
endx = Gdx.input.getX();
|
endx = Gdx.input.getX();
|
||||||
endy = Gdx.input.getY();
|
endy = Gdx.input.getY();
|
||||||
|
|
||||||
if(Inputs.scrolled() && Inputs.keyDown("zoom_hold") && !GameState.is(State.menu) && !Vars.ui.onDialog()){
|
if(Inputs.scrolled() && Inputs.keyDown("zoom_hold") && !GameState.is(State.menu) && !ui.onDialog()){
|
||||||
Vars.renderer.scaleCamera(Inputs.scroll());
|
renderer.scaleCamera(Inputs.scroll());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.scrolled()){
|
if(Inputs.scrolled()){
|
||||||
@@ -72,6 +70,12 @@ public class Input extends InputHandler{
|
|||||||
player.rotation ++;
|
player.rotation ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Inputs.keyDown("area_delete_mode")){
|
||||||
|
player.placeMode = PlaceMode.areaDelete;
|
||||||
|
}else{
|
||||||
|
player.placeMode = PlaceMode.hold;
|
||||||
|
}
|
||||||
|
|
||||||
player.rotation = Mathf.mod(player.rotation, 4);
|
player.rotation = Mathf.mod(player.rotation, 4);
|
||||||
|
|
||||||
for(int i = 0; i < 9; i ++){
|
for(int i = 0; i < 9; i ++){
|
||||||
@@ -81,19 +85,19 @@ public class Input extends InputHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tile cursor = Vars.world.tile(tilex(), tiley());
|
Tile cursor = world.tile(tilex(), tiley());
|
||||||
|
|
||||||
if(Inputs.buttonUp(Buttons.LEFT) && cursor != null){
|
if(Inputs.buttonUp(Buttons.LEFT) && cursor != null){
|
||||||
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
||||||
if(linked != null && linked.block() instanceof Configurable){
|
if(linked != null && linked.block() instanceof Configurable){
|
||||||
Vars.ui.showConfig(linked);
|
ui.showConfig(linked);
|
||||||
}else if(!Vars.ui.hasConfigMouse()){
|
}else if(!ui.hasConfigMouse()){
|
||||||
Vars.ui.hideConfig();
|
ui.hideConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.buttonUp(Buttons.RIGHT)){
|
if(Inputs.buttonUp(Buttons.RIGHT)){
|
||||||
Vars.ui.hideConfig();
|
ui.hideConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.recipe != null && Inputs.buttonUp(Buttons.RIGHT)){
|
if(player.recipe != null && Inputs.buttonUp(Buttons.RIGHT)){
|
||||||
@@ -102,11 +106,11 @@ public class Input extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//block breaking
|
//block breaking
|
||||||
if(Inputs.buttonDown(Buttons.RIGHT) && cursor != null && Vars.world.validBreak(tilex(), tiley())){
|
if(Inputs.buttonDown(Buttons.RIGHT) && cursor != null && validBreak(tilex(), tiley())){
|
||||||
Tile tile = cursor;
|
Tile tile = cursor;
|
||||||
player.breaktime += Timers.delta();
|
player.breaktime += Timers.delta();
|
||||||
if(player.breaktime >= tile.getBreakTime()){
|
if(player.breaktime >= tile.getBreakTime()){
|
||||||
Vars.world.breakBlock(cursor.x, cursor.y);
|
breakBlock(cursor.x, cursor.y);
|
||||||
player.breaktime = 0f;
|
player.breaktime = 0f;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -117,16 +121,16 @@ public class Input extends InputHandler{
|
|||||||
|
|
||||||
public void tryPlaceBlock(int x, int y){
|
public void tryPlaceBlock(int x, int y){
|
||||||
if(player.recipe != null &&
|
if(player.recipe != null &&
|
||||||
Vars.world.validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() &&
|
validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() &&
|
||||||
Vars.control.hasItems(player.recipe.requirements)){
|
control.hasItems(player.recipe.requirements)){
|
||||||
|
|
||||||
Vars.world.placeBlock(x, y, player.recipe.result, player.rotation, true);
|
placeBlock(x, y, player.recipe.result, player.rotation, true);
|
||||||
|
|
||||||
for(ItemStack stack : player.recipe.requirements){
|
for(ItemStack stack : player.recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
control.removeItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Vars.control.hasItems(player.recipe.requirements)){
|
if(!control.hasItems(player.recipe.requirements)){
|
||||||
Cursors.restoreCursor();
|
Cursors.restoreCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.Mathf;
|
|
||||||
|
|
||||||
public class GestureHandler extends GestureAdapter{
|
public class GestureHandler extends GestureAdapter{
|
||||||
AndroidInput input;
|
AndroidInput input;
|
||||||
@@ -29,14 +28,10 @@ public class GestureHandler extends GestureAdapter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tap (float x, float y, int count, int button) {
|
public boolean tap (float x, float y, int count, int button) {
|
||||||
if(!ui.hasMouse() && player.recipe != null &&
|
if(!player.placeMode.pan){
|
||||||
Vars.control.hasItems(player.recipe.requirements) && !Vars.ui.hasMouse() && !input.brokeBlock){
|
|
||||||
|
|
||||||
player.placeMode.tapped(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize), Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize));
|
|
||||||
|
|
||||||
input.mousex = x;
|
input.mousex = x;
|
||||||
input.mousey = y;
|
input.mousey = y;
|
||||||
return true;
|
player.placeMode.tapped(input.getBlockX(), input.getBlockY());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,29 @@ package io.anuke.mindustry.input;
|
|||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.InputAdapter;
|
import com.badlogic.gdx.InputAdapter;
|
||||||
|
import com.badlogic.gdx.math.GridPoint2;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
|
import io.anuke.mindustry.entities.effect.Fx;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
|
import io.anuke.mindustry.resource.Recipe;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.SpawnPoint;
|
||||||
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.ProductionBlocks;
|
||||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
|
import io.anuke.ucore.core.Sounds;
|
||||||
|
import io.anuke.ucore.entities.Entities;
|
||||||
|
import io.anuke.ucore.entities.SolidEntity;
|
||||||
import io.anuke.ucore.scene.utils.Cursors;
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
public abstract class InputHandler extends InputAdapter{
|
public abstract class InputHandler extends InputAdapter{
|
||||||
public abstract void update();
|
public abstract void update();
|
||||||
@@ -24,6 +38,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
public int getBlockEndX(){ return Mathf.sclb(Graphics.world(getCursorEndX(), getCursorEndY()).x, Vars.tilesize, round2()); }
|
public int getBlockEndX(){ return Mathf.sclb(Graphics.world(getCursorEndX(), getCursorEndY()).x, Vars.tilesize, round2()); }
|
||||||
public int getBlockEndY(){ return Mathf.sclb(Graphics.world(getCursorEndX(), getCursorEndY()).y, Vars.tilesize, round2()); }
|
public int getBlockEndY(){ return Mathf.sclb(Graphics.world(getCursorEndX(), getCursorEndY()).y, Vars.tilesize, round2()); }
|
||||||
public void resetCursor(){}
|
public void resetCursor(){}
|
||||||
|
public boolean drawPlace(){ return true; }
|
||||||
|
|
||||||
public boolean onConfigurable(){
|
public boolean onConfigurable(){
|
||||||
Tile tile = Vars.world.tile(getBlockX(), getBlockY());
|
Tile tile = Vars.world.tile(getBlockX(), getBlockY());
|
||||||
@@ -36,10 +51,10 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
|
|
||||||
public void tryPlaceBlock(int x, int y){
|
public void tryPlaceBlock(int x, int y){
|
||||||
if(player.recipe != null &&
|
if(player.recipe != null &&
|
||||||
Vars.world.validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() &&
|
validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() &&
|
||||||
Vars.control.hasItems(player.recipe.requirements)){
|
Vars.control.hasItems(player.recipe.requirements)){
|
||||||
|
|
||||||
Vars.world.placeBlock(x, y, player.recipe.result, player.rotation, true);
|
placeBlock(x, y, player.recipe.result, player.rotation, true);
|
||||||
|
|
||||||
for(ItemStack stack : player.recipe.requirements){
|
for(ItemStack stack : player.recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
Vars.control.removeItem(stack);
|
||||||
@@ -51,7 +66,178 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void tryDeleteBlock(int x, int y){
|
||||||
|
if(cursorNear() && validBreak(x, y)){
|
||||||
|
breakBlock(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean round2(){
|
public boolean round2(){
|
||||||
return !(player.recipe != null && player.recipe.result.isMultiblock() && player.recipe.result.height % 2 == 0);
|
return !(player.recipe != null && player.recipe.result.isMultiblock() && player.recipe.result.height % 2 == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean validPlace(int x, int y, Block type){
|
||||||
|
|
||||||
|
for(SpawnPoint spawn : control.getSpawnPoints()){
|
||||||
|
if(Vector2.dst(x * tilesize, y * tilesize, spawn.start.worldx(), spawn.start.worldy()) < enemyspawnspace){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tmp.r2.setSize(type.width * Vars.tilesize, type.height * Vars.tilesize);
|
||||||
|
Vector2 offset = type.getPlaceOffset();
|
||||||
|
Tmp.r2.setCenter(offset.x + x * Vars.tilesize, offset.y + y * Vars.tilesize);
|
||||||
|
|
||||||
|
for(SolidEntity e : Entities.getNearby(control.enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)){
|
||||||
|
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
||||||
|
|
||||||
|
if(Tmp.r2.overlaps(rect)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Vars.android && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
|
if(tile == null) return false;
|
||||||
|
|
||||||
|
if(!type.isMultiblock() && Vars.control.getTutorial().active() &&
|
||||||
|
Vars.control.getTutorial().showBlock()){
|
||||||
|
|
||||||
|
GridPoint2 point = Vars.control.getTutorial().getPlacePoint();
|
||||||
|
int rotation = Vars.control.getTutorial().getPlaceRotation();
|
||||||
|
Block block = Vars.control.getTutorial().getPlaceBlock();
|
||||||
|
|
||||||
|
if(type != block || point.x != x - control.getCore().x || point.y != y - control.getCore().y
|
||||||
|
|| (rotation != -1 && rotation != Vars.player.rotation)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else if(Vars.control.getTutorial().active()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type.isMultiblock()){
|
||||||
|
int offsetx = -(type.width-1)/2;
|
||||||
|
int offsety = -(type.height-1)/2;
|
||||||
|
for(int dx = 0; dx < type.width; dx ++){
|
||||||
|
for(int dy = 0; dy < type.height; dy ++){
|
||||||
|
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
|
||||||
|
if(other == null || other.block() != Blocks.air){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
if(tile.block() != type && type.canReplace(tile.block()) && tile.block().isMultiblock() == type.isMultiblock()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return tile != null && tile.block() == Blocks.air;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean validBreak(int x, int y){
|
||||||
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
|
if(tile == null || tile.block() == ProductionBlocks.core) return false;
|
||||||
|
|
||||||
|
if(tile.isLinked() && tile.getLinked().block() == ProductionBlocks.core){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Vars.control.getTutorial().active()){
|
||||||
|
|
||||||
|
if(Vars.control.getTutorial().showBlock()){
|
||||||
|
GridPoint2 point = Vars.control.getTutorial().getPlacePoint();
|
||||||
|
int rotation = Vars.control.getTutorial().getPlaceRotation();
|
||||||
|
Block block = Vars.control.getTutorial().getPlaceBlock();
|
||||||
|
|
||||||
|
if(block != Blocks.air || point.x != x - control.getCore().x || point.y != y - control.getCore().y
|
||||||
|
|| (rotation != -1 && rotation != Vars.player.rotation)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tile.breakable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void placeBlock(int x, int y, Block result, int rotation, boolean effects){
|
||||||
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
|
//just in case
|
||||||
|
if(tile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tile.setBlock(result, rotation);
|
||||||
|
|
||||||
|
if(result.isMultiblock()){
|
||||||
|
int offsetx = -(result.width-1)/2;
|
||||||
|
int offsety = -(result.height-1)/2;
|
||||||
|
|
||||||
|
for(int dx = 0; dx < result.width; dx ++){
|
||||||
|
for(int dy = 0; dy < result.height; dy ++){
|
||||||
|
int worldx = dx + offsetx + x;
|
||||||
|
int worldy = dy + offsety + y;
|
||||||
|
if(!(worldx == x && worldy == y)){
|
||||||
|
Tile toplace = world.tile(worldx, worldy);
|
||||||
|
toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(effects) Effects.effect(Fx.place, worldx * Vars.tilesize, worldy * Vars.tilesize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(effects) Effects.effect(Fx.place, x * Vars.tilesize, y * Vars.tilesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(effects) Sounds.play("place");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(int x, int y){
|
||||||
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
|
if(tile == null) return;
|
||||||
|
|
||||||
|
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
|
||||||
|
Recipe result = null;
|
||||||
|
|
||||||
|
for(Recipe recipe : Recipe.values()){
|
||||||
|
if(recipe.result == block){
|
||||||
|
result = recipe;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result != null){
|
||||||
|
for(ItemStack stack : result.requirements){
|
||||||
|
Vars.control.addItem(stack.item, (int)(stack.amount * Vars.breakDropAmount));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tile.block().drops != null){
|
||||||
|
Vars.control.addItem(tile.block().drops.item, tile.block().drops.amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effects.shake(3f, 1f, player);
|
||||||
|
Sounds.play("break");
|
||||||
|
|
||||||
|
if(!tile.block().isMultiblock() && !tile.isLinked()){
|
||||||
|
tile.setBlock(Blocks.air);
|
||||||
|
Effects.effect(Fx.breakBlock, tile.worldx(), tile.worldy());
|
||||||
|
}else{
|
||||||
|
Tile target = tile.isLinked() ? tile.getLinked() : tile;
|
||||||
|
Array<Tile> removals = target.getLinkedTiles();
|
||||||
|
for(Tile toremove : removals){
|
||||||
|
//note that setting a new block automatically unlinks it
|
||||||
|
toremove.setBlock(Blocks.air);
|
||||||
|
Effects.effect(Fx.breakBlock, toremove.worldx(), toremove.worldy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ package io.anuke.mindustry.input;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.Colors;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Inputs;
|
import io.anuke.ucore.core.Inputs;
|
||||||
@@ -18,25 +21,32 @@ import io.anuke.ucore.util.Tmp;
|
|||||||
|
|
||||||
public enum PlaceMode{
|
public enum PlaceMode{
|
||||||
cursor{
|
cursor{
|
||||||
|
{
|
||||||
|
shown = true;
|
||||||
|
lockCamera = true;
|
||||||
|
pan = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void draw(int tilex, int tiley, int endx, int endy){
|
public void draw(int tilex, int tiley, int endx, int endy){
|
||||||
float x = tilex * Vars.tilesize;
|
float x = tilex * Vars.tilesize;
|
||||||
float y = tiley * Vars.tilesize;
|
float y = tiley * Vars.tilesize;
|
||||||
|
|
||||||
boolean valid = world.validPlace(tilex, tiley, player.recipe.result) && (android || control.getInput().cursorNear());
|
boolean valid = control.getInput().validPlace(tilex, tiley, player.recipe.result) && (android || control.getInput().cursorNear());
|
||||||
|
|
||||||
Vector2 offset = player.recipe.result.getPlaceOffset();
|
Vector2 offset = player.recipe.result.getPlaceOffset();
|
||||||
|
|
||||||
float si = MathUtils.sin(Timers.time() / 6f) + 1;
|
float si = MathUtils.sin(Timers.time() / 6f) + 1.5f;
|
||||||
|
|
||||||
Draw.color(valid ? Color.PURPLE : Color.SCARLET);
|
Draw.color(valid ? Colors.get("place") : Colors.get("placeInvalid"));
|
||||||
Draw.thickness(2f);
|
Draw.thickness(2f);
|
||||||
Draw.linecrect(x + offset.x, y + offset.y, tilesize * player.recipe.result.width + si, tilesize * player.recipe.result.height + si);
|
Draw.linecrect(x + offset.x, y + offset.y, tilesize * player.recipe.result.width + si,
|
||||||
|
tilesize * player.recipe.result.height + si);
|
||||||
|
|
||||||
player.recipe.result.drawPlace(tilex, tiley, player.rotation, valid);
|
player.recipe.result.drawPlace(tilex, tiley, player.rotation, valid);
|
||||||
Draw.thickness(2f);
|
Draw.thickness(2f);
|
||||||
|
|
||||||
if(player.recipe.result.rotate){
|
if(player.recipe.result.rotate){
|
||||||
Draw.color(Color.ORANGE);
|
Draw.color(Colors.get("placeRotate"));
|
||||||
Tmp.v1.set(7, 0).rotate(player.rotation * 90);
|
Tmp.v1.set(7, 0).rotate(player.rotation * 90);
|
||||||
Draw.line(x, y, x + Tmp.v1.x, y + Tmp.v1.y);
|
Draw.line(x, y, x + Tmp.v1.x, y + Tmp.v1.y);
|
||||||
}
|
}
|
||||||
@@ -46,24 +56,42 @@ public enum PlaceMode{
|
|||||||
else
|
else
|
||||||
Cursors.restoreCursor();
|
Cursors.restoreCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void tapped(int tilex, int tiley){
|
||||||
|
System.out.println("tap " + tilex + " " + tiley);
|
||||||
|
control.getInput().tryPlaceBlock(tilex, tiley);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
touch{
|
touch{
|
||||||
|
{
|
||||||
|
shown = true;
|
||||||
|
lockCamera = false;
|
||||||
|
showRotate = true;
|
||||||
|
showCancel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tapped(int x, int y){
|
||||||
|
control.getInput().tryPlaceBlock(x, y);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
areaDelete{
|
||||||
int maxlen = 10;
|
int maxlen = 10;
|
||||||
int tilex;
|
int tilex;
|
||||||
int tiley;
|
int tiley;
|
||||||
int endx;
|
int endx;
|
||||||
int endy;
|
int endy;
|
||||||
int rotation;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
shown = true;
|
||||||
lockCamera = true;
|
lockCamera = true;
|
||||||
|
delete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(int tilex, int tiley, int endx, int endy){
|
public void draw(int tilex, int tiley, int endx, int endy){
|
||||||
float t = Vars.tilesize;
|
float t = tilesize;
|
||||||
|
|
||||||
process(tilex, tiley, endx, endy);
|
process(tilex, tiley, endx, endy);
|
||||||
int tx = tilex, ty = tiley, ex = endx, ey = endy;
|
|
||||||
tilex = this.tilex; tiley = this.tiley;
|
tilex = this.tilex; tiley = this.tiley;
|
||||||
endx = this.endx; endy = this.endy;
|
endx = this.endx; endy = this.endy;
|
||||||
float x = this.tilex * t, y = this.tiley * t,
|
float x = this.tilex * t, y = this.tiley * t,
|
||||||
@@ -79,16 +107,124 @@ public enum PlaceMode{
|
|||||||
y2 += t/2;
|
y2 += t/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw.color(Colors.get("break"));
|
||||||
|
Draw.thick(1f);
|
||||||
|
for(int cx = tilex; cx <= endx; cx ++){
|
||||||
|
for(int cy = tiley; cy <= endy; cy ++){
|
||||||
|
Tile tile = Vars.world.tile(cx, cy);
|
||||||
|
if(tile != null && tile.getLinked() != null)
|
||||||
|
tile = tile.getLinked();
|
||||||
|
if(tile != null && control.getInput().validBreak(tile.x, tile.y)){
|
||||||
|
Vector2 offset = tile.block().getPlaceOffset();
|
||||||
|
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y,
|
||||||
|
tile.block().width * t, tile.block().height * t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.thick(2f);
|
||||||
|
Draw.color(control.getInput().cursorNear() ? Colors.get("break") : Colors.get("breakInvalid"));
|
||||||
|
Draw.linerect(x, y, x2 - x, y2 - y);
|
||||||
|
Draw.alpha(0.3f);
|
||||||
|
Draw.crect("blank", x, y, x2 - x, y2 - y);
|
||||||
|
Draw.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void released(int tilex, int tiley, int endx, int endy){
|
||||||
|
process(tilex, tiley, endx, endy);
|
||||||
|
tilex = this.tilex; tiley = this.tiley;
|
||||||
|
endx = this.endx; endy = this.endy;
|
||||||
|
|
||||||
|
for(int cx = tilex; cx <= endx; cx ++){
|
||||||
|
for(int cy = tiley; cy <= endy; cy ++){
|
||||||
|
control.getInput().tryDeleteBlock(cx, cy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void process(int tilex, int tiley, int endx, int endy){
|
||||||
|
|
||||||
|
if(Math.abs(endx - tilex) > maxlen){
|
||||||
|
endx = Mathf.sign(endx - tilex) * maxlen + tilex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Math.abs(endy - tiley) > maxlen){
|
||||||
|
endy = Mathf.sign(endy - tiley) * maxlen + tiley;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(endx < tilex){
|
||||||
|
int t = endx;
|
||||||
|
endx = tilex;
|
||||||
|
tilex = t;
|
||||||
|
}
|
||||||
|
if(endy < tiley){
|
||||||
|
int t = endy;
|
||||||
|
endy = tiley;
|
||||||
|
tiley = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.endx = endx;
|
||||||
|
this.endy = endy;
|
||||||
|
this.tilex = tilex;
|
||||||
|
this.tiley = tiley;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hold{ //TODO multiblock support!
|
||||||
|
int maxlen = 10;
|
||||||
|
int tilex;
|
||||||
|
int tiley;
|
||||||
|
int endx;
|
||||||
|
int endy;
|
||||||
|
int rotation;
|
||||||
|
|
||||||
|
{
|
||||||
|
lockCamera = true;
|
||||||
|
shown = true;
|
||||||
|
showCancel = true;
|
||||||
|
showRotate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(int tilex, int tiley, int endx, int endy){
|
||||||
|
if(Vars.android && !Gdx.input.isTouched(0)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float t = Vars.tilesize;
|
||||||
|
Block block = player.recipe.result;
|
||||||
|
Vector2 offset = block.getPlaceOffset();
|
||||||
|
|
||||||
|
process(tilex, tiley, endx, endy);
|
||||||
|
int tx = tilex, ty = tiley, ex = endx, ey = endy;
|
||||||
|
tilex = this.tilex; tiley = this.tiley;
|
||||||
|
endx = this.endx; endy = this.endy;
|
||||||
|
float x = this.tilex * t, y = this.tiley * t,
|
||||||
|
x2 = this.endx * t, y2 = this.endy * t;
|
||||||
|
|
||||||
|
if(x2 >= x){
|
||||||
|
x -= block.width * t/2;
|
||||||
|
x2 += block.width * t/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(y2 >= y){
|
||||||
|
y -= block.height * t/2;
|
||||||
|
y2 += block.height * t/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
x += offset.x;
|
||||||
|
y += offset.y;
|
||||||
|
x2 += offset.x;
|
||||||
|
y2 += offset.y;
|
||||||
|
|
||||||
if(tilex == endx && tiley == endy){
|
if(tilex == endx && tiley == endy){
|
||||||
cursor.draw(tilex, tiley, endx, endy);
|
cursor.draw(tilex, tiley, endx, endy);
|
||||||
}else{
|
}else{
|
||||||
Draw.thick(2f);
|
Draw.thick(2f);
|
||||||
Draw.color(control.getInput().cursorNear() ? Color.PURPLE : Color.RED);
|
Draw.color(control.getInput().cursorNear() ? Colors.get("place") : Colors.get("placeInvalid"));
|
||||||
Draw.linerect(x, y, x2 - x, y2 - y);
|
Draw.linerect(x, y, x2 - x, y2 - y);
|
||||||
Draw.alpha(0.3f);
|
Draw.alpha(0.3f);
|
||||||
Draw.crect("blank", x, y, x2 - x, y2 - y);
|
Draw.crect("blank", x, y, x2 - x, y2 - y);
|
||||||
|
|
||||||
Draw.color(Color.RED);
|
Draw.color(Colors.get("placeInvalid"));
|
||||||
|
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
for(int cx = 0; cx <= Math.abs(endx - tilex); cx ++){
|
for(int cx = 0; cx <= Math.abs(endx - tilex); cx ++){
|
||||||
@@ -96,17 +232,17 @@ public enum PlaceMode{
|
|||||||
int px = tx + cx * Mathf.sign(ex - tx),
|
int px = tx + cx * Mathf.sign(ex - tx),
|
||||||
py = ty + cy * Mathf.sign(ey - ty);
|
py = ty + cy * Mathf.sign(ey - ty);
|
||||||
|
|
||||||
if(!world.validPlace(px, py, player.recipe.result)
|
if(!control.getInput().validPlace(px, py, player.recipe.result)
|
||||||
|| !control.hasItems(player.recipe.requirements, amount)){
|
|| !control.hasItems(player.recipe.requirements, amount)){
|
||||||
Draw.square(px * t, py * t, t/2);
|
Draw.linecrect(px * t + offset.x, py * t + offset.y, t*block.width, t*block.height);
|
||||||
}
|
}
|
||||||
amount ++;
|
amount ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.recipe.result.rotate){
|
if(player.recipe.result.rotate){
|
||||||
float cx = tilex * t, cy = tiley * t;
|
float cx = tx * t, cy = ty * t;
|
||||||
Draw.color(Color.ORANGE);
|
Draw.color(Colors.get("placeRotate"));
|
||||||
Tmp.v1.set(7, 0).rotate(rotation * 90);
|
Tmp.v1.set(7, 0).rotate(rotation * 90);
|
||||||
Draw.line(cx, cy, cx + Tmp.v1.x, cy + Tmp.v1.y);
|
Draw.line(cx, cy, cx + Tmp.v1.x, cy + Tmp.v1.y);
|
||||||
}
|
}
|
||||||
@@ -114,11 +250,8 @@ public enum PlaceMode{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tapped(int tilex, int tiley, int endx, int endy){
|
public void released(int tilex, int tiley, int endx, int endy){
|
||||||
int prev = player.rotation;
|
|
||||||
process(tilex, tiley, endx, endy);
|
process(tilex, tiley, endx, endy);
|
||||||
//tilex = this.tilex; tiley = this.tiley;
|
|
||||||
//endx = this.endx; endy = this.endy;
|
|
||||||
|
|
||||||
player.rotation = this.rotation;
|
player.rotation = this.rotation;
|
||||||
|
|
||||||
@@ -129,9 +262,6 @@ public enum PlaceMode{
|
|||||||
tiley + y * Mathf.sign(endy - tiley));
|
tiley + y * Mathf.sign(endy - tiley));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.rotation = prev;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void process(int tilex, int tiley, int endx, int endy){
|
void process(int tilex, int tiley, int endx, int endy){
|
||||||
@@ -181,7 +311,7 @@ public enum PlaceMode{
|
|||||||
public void draw(int tilex, int tiley, int endx, int endy){
|
public void draw(int tilex, int tiley, int endx, int endy){
|
||||||
Tile tile = world.tile(tilex, tiley);
|
Tile tile = world.tile(tilex, tiley);
|
||||||
|
|
||||||
if(tile != null && world.validBreak(tilex, tiley)){
|
if(tile != null && control.getInput().validBreak(tilex, tiley)){
|
||||||
if(tile.isLinked())
|
if(tile.isLinked())
|
||||||
tile = tile.getLinked();
|
tile = tile.getLinked();
|
||||||
Vector2 offset = tile.block().getPlaceOffset();
|
Vector2 offset = tile.block().getPlaceOffset();
|
||||||
@@ -191,20 +321,29 @@ public enum PlaceMode{
|
|||||||
Draw.color(Color.YELLOW, Color.SCARLET, fract);
|
Draw.color(Color.YELLOW, Color.SCARLET, fract);
|
||||||
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize);
|
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize);
|
||||||
}else if(android && player.breaktime > 0){
|
}else if(android && player.breaktime > 0){
|
||||||
Draw.color(Color.YELLOW, Color.SCARLET, fract);
|
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract);
|
||||||
Draw.circle(tile.worldx(), tile.worldy(), 4 + (1f - fract) * 26);
|
Draw.polygon(25, tile.worldx() + offset.x, tile.worldy() + offset.y, 4 + (1f - fract) * 26);
|
||||||
}
|
}
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public boolean lockCamera;
|
public boolean lockCamera;
|
||||||
|
public boolean pan = false;
|
||||||
|
public boolean shown = false;
|
||||||
|
public boolean showRotate;
|
||||||
|
public boolean showCancel;
|
||||||
|
public boolean delete = false;
|
||||||
|
|
||||||
public void draw(int tilex, int tiley, int endx, int endy){
|
public void draw(int tilex, int tiley, int endx, int endy){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tapped(int tilex, int tiley, int endx, int endy){
|
public void released(int tilex, int tiley, int endx, int endy){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tapped(int x, int y){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import io.anuke.mindustry.world.GameMode;
|
|||||||
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.Settings;
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.function.StringSupplier;
|
|
||||||
import io.anuke.ucore.scene.actions.Actions;
|
import io.anuke.ucore.scene.actions.Actions;
|
||||||
import io.anuke.ucore.scene.builders.imagebutton;
|
import io.anuke.ucore.scene.builders.imagebutton;
|
||||||
import io.anuke.ucore.scene.builders.label;
|
import io.anuke.ucore.scene.builders.label;
|
||||||
@@ -25,7 +24,6 @@ import io.anuke.ucore.scene.ui.Label;
|
|||||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.Profiler;
|
|
||||||
|
|
||||||
public class HudFragment implements Fragment{
|
public class HudFragment implements Fragment{
|
||||||
private Table itemtable, respawntable;
|
private Table itemtable, respawntable;
|
||||||
@@ -137,26 +135,14 @@ public class HudFragment implements Fragment{
|
|||||||
new table(){{
|
new table(){{
|
||||||
abottom();
|
abottom();
|
||||||
aleft();
|
aleft();
|
||||||
new label((StringSupplier)()->"[purple]tiles: " + Vars.control.tileGroup.amount()).left();
|
new label(()->"[purple]tiles: " + Vars.control.tileGroup.amount()).left();
|
||||||
row();
|
row();
|
||||||
new label((StringSupplier)()->"[purple]enemies: " + Vars.control.enemyGroup.amount()).left();
|
new label(()->"[purple]enemies: " + Vars.control.enemyGroup.amount()).left();
|
||||||
row();
|
row();
|
||||||
new label((StringSupplier)()->"[orange]noclip: " + Vars.noclip).left();
|
new label(()->"[orange]noclip: " + Vars.noclip).left();
|
||||||
row();
|
row();
|
||||||
new label("[red]DEBUG MODE").scale(0.5f).left();
|
new label("[red]DEBUG MODE").scale(0.5f).left();
|
||||||
}}.end();
|
}}.end();
|
||||||
|
|
||||||
if(profile){
|
|
||||||
new table(){{
|
|
||||||
atop();
|
|
||||||
new table("button"){{
|
|
||||||
defaults().left().growX();
|
|
||||||
atop();
|
|
||||||
aleft();
|
|
||||||
new label((StringSupplier)()->Profiler.formatDisplayTimes());
|
|
||||||
}}.width(400f).units(Unit.dp).end();
|
|
||||||
}}.end();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,8 +174,6 @@ public class HudFragment implements Fragment{
|
|||||||
}}.left().end();
|
}}.left().end();
|
||||||
|
|
||||||
playButton(uheight);
|
playButton(uheight);
|
||||||
//get().padTop(Unit.dp.inPixels(1));
|
|
||||||
//get().padBottom(Unit.dp.inPixels(1));
|
|
||||||
}}.height(uheight).units(Unit.dp).fillX().expandX().end();
|
}}.height(uheight).units(Unit.dp).fillX().expandX().end();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ 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.PlaceMode;
|
import io.anuke.mindustry.input.PlaceMode;
|
||||||
import io.anuke.ucore.scene.builders.imagebutton;
|
import io.anuke.ucore.scene.builders.imagebutton;
|
||||||
import io.anuke.ucore.scene.builders.label;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
import io.anuke.ucore.scene.builders.table;
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||||
@@ -28,8 +27,8 @@ public class PlacementFragment implements Fragment{
|
|||||||
|
|
||||||
new table("pane"){{
|
new table("pane"){{
|
||||||
get().setTouchable(Touchable.enabled);
|
get().setTouchable(Touchable.enabled);
|
||||||
new label(()->"Placement Mode: [orange]" + player.placeMode.name()).pad(4).units(Unit.dp);
|
//new label(()->"Placement Mode: [orange]" + player.placeMode.name()).pad(4).units(Unit.dp);
|
||||||
row();
|
//row();
|
||||||
|
|
||||||
aleft();
|
aleft();
|
||||||
|
|
||||||
@@ -37,19 +36,28 @@ public class PlacementFragment implements Fragment{
|
|||||||
aleft();
|
aleft();
|
||||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
|
|
||||||
defaults().size(58, 62).pad(6).units(Unit.dp);
|
defaults().size(52, 56).pad(0).units(Unit.dp);
|
||||||
|
|
||||||
|
int d = 0;
|
||||||
|
|
||||||
for(PlaceMode mode : PlaceMode.values()){
|
for(PlaceMode mode : PlaceMode.values()){
|
||||||
|
if(!mode.shown) continue;
|
||||||
|
|
||||||
new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.inPixels(10*3), ()->{
|
new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.inPixels(10*3), ()->{
|
||||||
|
control.getInput().resetCursor();
|
||||||
player.placeMode = mode;
|
player.placeMode = mode;
|
||||||
}){{
|
}){{
|
||||||
group.add(get());
|
group.add(get());
|
||||||
}};
|
}}.padBottom(-5.5f).units(Unit.dp);
|
||||||
|
|
||||||
|
if(++d % 2 == 0){
|
||||||
|
row();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new imagebutton("icon-cancel", Unit.dp.inPixels(14*3), ()->{
|
new imagebutton("icon-cancel", Unit.dp.inPixels(14*3), ()->{
|
||||||
player.recipe = null;
|
player.recipe = null;
|
||||||
}).visible(()->player.recipe != null && player.placeMode == PlaceMode.touch);
|
}).visible(()->player.recipe != null && player.placeMode.showCancel);
|
||||||
|
|
||||||
new imagebutton("icon-rotate-arrow", Unit.dp.inPixels(14*3), ()->{
|
new imagebutton("icon-rotate-arrow", Unit.dp.inPixels(14*3), ()->{
|
||||||
player.rotation ++;
|
player.rotation ++;
|
||||||
@@ -57,7 +65,7 @@ public class PlacementFragment implements Fragment{
|
|||||||
}).update(i->{
|
}).update(i->{
|
||||||
i.getImage().setOrigin(Align.center);
|
i.getImage().setOrigin(Align.center);
|
||||||
i.getImage().setRotation(player.rotation*90);
|
i.getImage().setRotation(player.rotation*90);
|
||||||
}).visible(()->player.recipe != null && player.placeMode == PlaceMode.touch
|
}).visible(() -> player.recipe != null && player.placeMode.showRotate
|
||||||
&& player.recipe.result.rotate);
|
&& player.recipe.result.rotate);
|
||||||
|
|
||||||
}}.left().end();
|
}}.left().end();
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ public class ToolFragment implements Fragment{
|
|||||||
});
|
});
|
||||||
|
|
||||||
tools.addIButton("icon-check", Unit.dp.inPixels(42), ()->{
|
tools.addIButton("icon-check", Unit.dp.inPixels(42), ()->{
|
||||||
player.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY(),
|
player.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY());
|
||||||
control.getInput().getBlockEndX(), control.getInput().getBlockEndY());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Core.scene.add(tools);
|
Core.scene.add(tools);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import io.anuke.ucore.scene.ui.layout.Unit;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Tmp;
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
//TODO
|
|
||||||
public class Sorter extends Junction implements Configurable{
|
public class Sorter extends Junction implements Configurable{
|
||||||
|
|
||||||
public Sorter(String name) {
|
public Sorter(String name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user