Added range indicators, mobile build cancel button
This commit is contained in:
@@ -90,6 +90,10 @@ public class Recipes implements ContentList{
|
|||||||
//UNITS
|
//UNITS
|
||||||
|
|
||||||
//bodies
|
//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));
|
//new Recipe(units, UpgradeBlocks.deltaFactory, new ItemStack(Items.tungsten, 30), new ItemStack(Items.lead, 50), new ItemStack(Items.silicon, 30));
|
||||||
|
|
||||||
//actual unit related stuff
|
//actual unit related stuff
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.anuke.mindustry.world.Block;
|
|||||||
import io.anuke.mindustry.world.blocks.production.MechFactory;
|
import io.anuke.mindustry.world.blocks.production.MechFactory;
|
||||||
|
|
||||||
public class UpgradeBlocks extends BlockList {
|
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
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
@@ -24,6 +24,11 @@ public class UpgradeBlocks extends BlockList {
|
|||||||
size = 3;
|
size = 3;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
dartFactory = new MechFactory("dart-ship-factory"){{
|
||||||
|
mech = Mechs.dart;
|
||||||
|
size = 2;
|
||||||
|
}};
|
||||||
|
|
||||||
tridentFactory = new MechFactory("trident-ship-factory"){{
|
tridentFactory = new MechFactory("trident-ship-factory"){{
|
||||||
mech = Mechs.trident;
|
mech = Mechs.trident;
|
||||||
size = 2;
|
size = 2;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class Palette {
|
|||||||
public static final Color breakInvalid = Color.valueOf("d44b3d");
|
public static final Color breakInvalid = Color.valueOf("d44b3d");
|
||||||
public static final Color range = Color.valueOf("f4ba6e");
|
public static final Color range = Color.valueOf("f4ba6e");
|
||||||
public static final Color power = Color.valueOf("fbd367");
|
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 redSpark = Color.valueOf("fbb97f");
|
||||||
public static final Color orangeSpark = Color.valueOf("d2b29c");
|
public static final Color orangeSpark = Color.valueOf("d2b29c");
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
|||||||
private PlaceMode mode = none;
|
private PlaceMode mode = none;
|
||||||
/**Whether no recipe was available when switching to break mode.*/
|
/**Whether no recipe was available when switching to break mode.*/
|
||||||
private Recipe lastRecipe;
|
private Recipe lastRecipe;
|
||||||
|
/**Last placed request. Used for drawing block overlay.*/
|
||||||
|
private PlaceRequest lastPlaced;
|
||||||
|
|
||||||
public AndroidInput(Player player){
|
public AndroidInput(Player player){
|
||||||
super(player);
|
super(player);
|
||||||
@@ -191,6 +193,18 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
|||||||
new table(){{
|
new table(){{
|
||||||
abottom().aleft();
|
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"){{
|
new table("pane"){{
|
||||||
margin(5);
|
margin(5);
|
||||||
defaults().size(60f);
|
defaults().size(60f);
|
||||||
@@ -268,7 +282,7 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
|||||||
drawRequest(request);
|
drawRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw normals
|
//draw list of requests
|
||||||
for(PlaceRequest request : selection){
|
for(PlaceRequest request : selection){
|
||||||
Tile tile = request.tile();
|
Tile tile = request.tile();
|
||||||
|
|
||||||
@@ -285,6 +299,11 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
|
|
||||||
drawRequest(request);
|
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();
|
Graphics.shader();
|
||||||
@@ -427,6 +446,9 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//reset last placed for convenience
|
||||||
|
lastPlaced = null;
|
||||||
|
|
||||||
}else if(mode == breaking){
|
}else if(mode == breaking){
|
||||||
//normalize area
|
//normalize area
|
||||||
NormalizeResult result = PlaceUtils.normalizeArea(lineStartX, lineStartY, tile.x, tile.y, rotation, false, maxLength);
|
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));
|
removeRequest(getRequest(cursor));
|
||||||
}else if(mode == placing && isPlacing() && validPlace(cursor.x, cursor.y, recipe.result, rotation) && !checkOverlapPlacement(cursor.x, cursor.y, recipe.result)){
|
}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
|
//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)){
|
}else if(mode == breaking && validBreak(cursor.x, cursor.y) && !hasRequest(cursor)){
|
||||||
//add to selection queue if it's a valid BREAK position
|
//add to selection queue if it's a valid BREAK position
|
||||||
selection.add(new PlaceRequest(cursor.worldx(), cursor.worldy()));
|
selection.add(new PlaceRequest(cursor.worldx(), cursor.worldy()));
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
cursor.worldy() + recipe.result.offset(), rotation * 90 - 90);
|
cursor.worldy() + recipe.result.offset(), rotation * 90 - 90);
|
||||||
}
|
}
|
||||||
drawPlace(cursor.x, cursor.y, recipe.result, rotation);
|
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();
|
Draw.reset();
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public abstract class Turret extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
Draw.color(Palette.place);
|
Draw.color(Palette.placing);
|
||||||
Lines.stroke(1f);
|
Lines.stroke(1f);
|
||||||
Lines.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range);
|
Lines.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ public class ItemBridge extends Block {
|
|||||||
@Override
|
@Override
|
||||||
public void drawPlace(int x, int y, int rotation, boolean valid) {
|
public void drawPlace(int x, int y, int rotation, boolean valid) {
|
||||||
Lines.stroke(2f);
|
Lines.stroke(2f);
|
||||||
Draw.color(Palette.place);
|
Draw.color(Palette.placing);
|
||||||
for(int i = 0; i < 4; i ++){
|
for(int i = 0; i < 4; i ++){
|
||||||
Lines.dashLine(
|
Lines.dashLine(
|
||||||
x * tilesize + Geometry.d4[i].x * tilesize/2f,
|
x * tilesize + Geometry.d4[i].x * (tilesize/2f + 2),
|
||||||
y * tilesize + Geometry.d4[i].y * tilesize/2f,
|
y * tilesize + Geometry.d4[i].y * (tilesize/2f + 2),
|
||||||
x * tilesize + Geometry.d4[i].x * range * tilesize,
|
x * tilesize + Geometry.d4[i].x * range * tilesize,
|
||||||
y * tilesize + Geometry.d4[i].y * range * tilesize,
|
y * tilesize + Geometry.d4[i].y * range * tilesize,
|
||||||
range);
|
range);
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class PowerDistributor extends PowerBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
Draw.color(Palette.place);
|
Draw.color(Palette.placing);
|
||||||
Lines.stroke(1f);
|
Lines.stroke(1f);
|
||||||
|
|
||||||
Lines.poly(Edges.getPixelPolygon(laserRange), x * tilesize - tilesize/2, y * tilesize - tilesize/2, tilesize);
|
Lines.poly(Edges.getPixelPolygon(laserRange), x * tilesize - tilesize/2, y * tilesize - tilesize/2, tilesize);
|
||||||
|
|||||||
Reference in New Issue
Block a user