1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-13 15:43:44 +03:00

Added range indicators, mobile build cancel button

This commit is contained in:
Anuken 2018-06-25 20:38:42 -04:00
parent b911ef98bb
commit c7bc6e9128
8 changed files with 41 additions and 8 deletions

View File

@ -90,6 +90,10 @@ public class Recipes implements ContentList{
//UNITS
//bodies
new Recipe(units, UpgradeBlocks.tridentFactory, new ItemStack(Items.lead, 150), new ItemStack(Items.silicon, 200), new ItemStack(Items.titanium, 240))
.setDesktop(); //trident is desktop only, because it's the starter mobile ship
//new Recipe(units, UpgradeBlocks.deltaFactory, new ItemStack(Items.tungsten, 30), new ItemStack(Items.lead, 50), new ItemStack(Items.silicon, 30));
//actual unit related stuff

View File

@ -5,7 +5,7 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.production.MechFactory;
public class UpgradeBlocks extends BlockList {
public static Block deltaFactory, tauFactory, omegaFactory, tridentFactory, javelinFactory, halberdFactory;
public static Block deltaFactory, tauFactory, omegaFactory, dartFactory, tridentFactory, javelinFactory, halberdFactory;
@Override
public void load() {
@ -24,6 +24,11 @@ public class UpgradeBlocks extends BlockList {
size = 3;
}};
dartFactory = new MechFactory("dart-ship-factory"){{
mech = Mechs.dart;
size = 2;
}};
tridentFactory = new MechFactory("trident-ship-factory"){{
mech = Mechs.trident;
size = 2;

View File

@ -49,6 +49,7 @@ public class Palette {
public static final Color breakInvalid = Color.valueOf("d44b3d");
public static final Color range = Color.valueOf("f4ba6e");
public static final Color power = Color.valueOf("fbd367");
public static final Color placing = Color.valueOf("616161");
public static final Color redSpark = Color.valueOf("fbb97f");
public static final Color orangeSpark = Color.valueOf("d2b29c");

View File

@ -71,6 +71,8 @@ public class AndroidInput extends InputHandler implements GestureListener{
private PlaceMode mode = none;
/**Whether no recipe was available when switching to break mode.*/
private Recipe lastRecipe;
/**Last placed request. Used for drawing block overlay.*/
private PlaceRequest lastPlaced;
public AndroidInput(Player player){
super(player);
@ -191,6 +193,18 @@ public class AndroidInput extends InputHandler implements GestureListener{
new table(){{
abottom().aleft();
new table("pane"){{
margin(5);
defaults().size(60f);
//Add a 'cancel building' button.
new imagebutton("icon-cancel", "toggle", 16 * 2f, () -> player.clearBuilding());
visible(() -> player.getPlaceQueue().size > 0);
}}.left().colspan(2).end();
row();
new table("pane"){{
margin(5);
defaults().size(60f);
@ -268,7 +282,7 @@ public class AndroidInput extends InputHandler implements GestureListener{
drawRequest(request);
}
//draw normals
//draw list of requests
for(PlaceRequest request : selection){
Tile tile = request.tile();
@ -285,6 +299,11 @@ public class AndroidInput extends InputHandler implements GestureListener{
drawRequest(request);
//draw last placed request
if(!request.remove && request == lastPlaced){
recipe.result.drawPlace(tile.x, tile.y, rotation, validPlace(tile.x, tile.y, recipe.result, rotation));
}
}
Graphics.shader();
@ -427,6 +446,9 @@ public class AndroidInput extends InputHandler implements GestureListener{
}
}
//reset last placed for convenience
lastPlaced = null;
}else if(mode == breaking){
//normalize area
NormalizeResult result = PlaceUtils.normalizeArea(lineStartX, lineStartY, tile.x, tile.y, rotation, false, maxLength);
@ -501,7 +523,7 @@ public class AndroidInput extends InputHandler implements GestureListener{
removeRequest(getRequest(cursor));
}else if(mode == placing && isPlacing() && validPlace(cursor.x, cursor.y, recipe.result, rotation) && !checkOverlapPlacement(cursor.x, cursor.y, recipe.result)){
//add to selection queue if it's a valid place position
selection.add(new PlaceRequest(cursor.worldx(), cursor.worldy(), recipe, rotation));
selection.add(lastPlaced = new PlaceRequest(cursor.worldx(), cursor.worldy(), recipe, rotation));
}else if(mode == breaking && validBreak(cursor.x, cursor.y) && !hasRequest(cursor)){
//add to selection queue if it's a valid BREAK position
selection.add(new PlaceRequest(cursor.worldx(), cursor.worldy()));

View File

@ -118,6 +118,7 @@ public class DesktopInput extends InputHandler{
cursor.worldy() + recipe.result.offset(), rotation * 90 - 90);
}
drawPlace(cursor.x, cursor.y, recipe.result, rotation);
recipe.result.drawPlace(cursor.x, cursor.y, rotation, validPlace(cursor.x, cursor.y, recipe.result, rotation));
}
Draw.reset();

View File

@ -140,7 +140,7 @@ public abstract class Turret extends Block{
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color(Palette.place);
Draw.color(Palette.placing);
Lines.stroke(1f);
Lines.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range);
}

View File

@ -65,11 +65,11 @@ public class ItemBridge extends Block {
@Override
public void drawPlace(int x, int y, int rotation, boolean valid) {
Lines.stroke(2f);
Draw.color(Palette.place);
Draw.color(Palette.placing);
for(int i = 0; i < 4; i ++){
Lines.dashLine(
x * tilesize + Geometry.d4[i].x * tilesize/2f,
y * tilesize + Geometry.d4[i].y * tilesize/2f,
x * tilesize + Geometry.d4[i].x * (tilesize/2f + 2),
y * tilesize + Geometry.d4[i].y * (tilesize/2f + 2),
x * tilesize + Geometry.d4[i].x * range * tilesize,
y * tilesize + Geometry.d4[i].y * range * tilesize,
range);

View File

@ -146,7 +146,7 @@ public class PowerDistributor extends PowerBlock{
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color(Palette.place);
Draw.color(Palette.placing);
Lines.stroke(1f);
Lines.poly(Edges.getPixelPolygon(laserRange), x * tilesize - tilesize/2, y * tilesize - tilesize/2, tilesize);