Added mining
This commit is contained in:
@@ -30,6 +30,7 @@ import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@@ -386,7 +387,9 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
||||
|
||||
//call tap events
|
||||
if(pointer == 0 && !selecting && mode == none){
|
||||
tileTapped(cursor.target());
|
||||
if(!tileTapped(cursor.target())){
|
||||
tryBeginMine(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -161,7 +161,8 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(cursor.floor().drops != null && cursor.floor().drops.item.hardness <= player.mech.drillPower
|
||||
&& cursor.block() == Blocks.air){
|
||||
&& cursor.block() == Blocks.air && player.distanceTo(cursor.worldx(), cursor.worldy()) <= Player.mineDistance &&
|
||||
player.inventory.canAcceptItem(cursor.floor().drops.item)){
|
||||
cursorType = drill;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,8 +123,9 @@ public abstract class InputHandler extends InputAdapter{
|
||||
/**Tries to begin mining a tile, returns true if successful.*/
|
||||
boolean tryBeginMine(Tile tile){
|
||||
if(tile.floor().drops != null && tile.floor().drops.item.hardness <= player.mech.drillPower
|
||||
&& tile.block() == Blocks.air){
|
||||
player.setMineTile(tile);
|
||||
&& tile.block() == Blocks.air && player.distanceTo(tile.worldx(), tile.worldy()) <= Player.mineDistance){
|
||||
//if a block is clicked twice, reset it
|
||||
player.setMineTile(player.getMineTile() == tile ? null : tile);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user