New mobile text dialog / Cleanup / Minimap fix / Collision optimization
This commit is contained in:
@@ -45,6 +45,8 @@ public class Blocks extends BlockList implements ContentList{
|
||||
}
|
||||
};
|
||||
|
||||
//Registers build blocks from size 1-6
|
||||
//no reference is needed here since they can be looked up by name later
|
||||
for(int i = 1; i <= 6; i++){
|
||||
new BuildBlock("build" + i);
|
||||
}
|
||||
|
||||
@@ -218,12 +218,6 @@ public class Logic extends Module{
|
||||
if(group.isEmpty()) continue;
|
||||
|
||||
EntityQuery.collideGroups(bulletGroup, group);
|
||||
EntityQuery.collideGroups(group, playerGroup);
|
||||
|
||||
for(EntityGroup other : unitGroups){
|
||||
if(other.isEmpty()) continue;
|
||||
EntityQuery.collideGroups(group, other);
|
||||
}
|
||||
}
|
||||
|
||||
EntityQuery.collideGroups(bulletGroup, playerGroup);
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Base64Coder;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
import io.anuke.ucore.util.Log;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static io.anuke.mindustry.Vars.mobile;
|
||||
|
||||
public abstract class Platform {
|
||||
/**Each separate game platform should set this instance to their own implementation.*/
|
||||
public static Platform instance = new Platform() {};
|
||||
@@ -17,7 +25,34 @@ public abstract class Platform {
|
||||
addDialog(field, 16);
|
||||
}
|
||||
/**See addDialog().*/
|
||||
public void addDialog(TextField field, int maxLength){}
|
||||
public void addDialog(TextField field, int maxLength){
|
||||
if(!mobile) return; //this is mobile only, desktop doesn't need dialogs
|
||||
|
||||
field.tapped(() -> {
|
||||
Log.info("yappd");
|
||||
Dialog dialog = new Dialog("", "dialog");
|
||||
dialog.setFillParent(true);
|
||||
dialog.content().top();
|
||||
dialog.content().defaults().height(65f);
|
||||
TextField to = dialog.content().addField(field.getText(), t-> {}).pad(15).width(250f).get();
|
||||
to.setMaxLength(maxLength);
|
||||
to.keyDown(Keys.ENTER, () -> dialog.content().find("okb").fireClick());
|
||||
dialog.content().addButton("$text.ok", () -> {
|
||||
field.clearText();
|
||||
field.appendText(to.getText());
|
||||
field.change();
|
||||
dialog.hide();
|
||||
Gdx.input.setOnscreenKeyboardVisible(false);
|
||||
}).width(90f).name("okb");
|
||||
|
||||
dialog.show();
|
||||
Timers.runTask(1f, () -> {
|
||||
to.setCursorPosition(to.getText().length());
|
||||
Core.scene.setKeyboardFocus(to);
|
||||
Gdx.input.setOnscreenKeyboardVisible(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**Update discord RPC.*/
|
||||
public void updateRPC(){}
|
||||
/**Called when the game is exited.*/
|
||||
|
||||
@@ -80,7 +80,7 @@ public class MinimapRenderer implements Disposable{
|
||||
for(Unit unit : units){
|
||||
float rx = (unit.x - rect.x) / rect.width * w, ry = (unit.y - rect.y) / rect.width * h;
|
||||
Draw.color(unit.getTeam().color);
|
||||
Draw.rect("white", x + rx, y + ry, w / (sz * 2), h / (sz * 2));
|
||||
Draw.crect(Draw.getBlankRegion(), x + rx, y + ry, w / (sz * 2), h / (sz * 2));
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
package io.anuke.mindustry.maps.generation.pathfinding;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Queue;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
|
||||
public class FlowPathFinder extends TilePathfinder{
|
||||
protected float[][] weights;
|
||||
|
||||
public FlowPathFinder(Tile[][] tiles){
|
||||
super(tiles);
|
||||
this.weights = new float[tiles.length][tiles[0].length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void search(Tile start, Tile end, Array<Tile> out){
|
||||
|
||||
}
|
||||
|
||||
public void search(Tile start, Predicate<Tile> result, Array<Tile> out){
|
||||
Queue<Tile> queue = new Queue<>();
|
||||
|
||||
for(int i = 0; i < weights.length; i++){
|
||||
for(int j = 0; j < weights[0].length; j++){
|
||||
if(result.test(tiles[i][j])){
|
||||
weights[i][j] = 100000;
|
||||
queue.addLast(tiles[i][j]);
|
||||
}else{
|
||||
weights[i][j] = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(queue.size > 0){
|
||||
Tile tile = queue.first();
|
||||
for(GridPoint2 point : Geometry.d4){
|
||||
int nx = tile.x + point.x, ny = tile.y + point.y;
|
||||
if(inBounds(nx, ny) && weights[nx][ny] < weights[tile.x][tile.y] - 1f && tiles[nx][ny].passable()){
|
||||
weights[nx][ny] = weights[tile.x][tile.y] - 1;
|
||||
queue.addLast(tiles[nx][ny]);
|
||||
if(result.test(tiles[nx][ny])){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.add(start);
|
||||
while(true){
|
||||
Tile tile = out.peek();
|
||||
|
||||
Tile max = null;
|
||||
float maxf = weights[tile.x][tile.y];
|
||||
for(GridPoint2 point : Geometry.d4){
|
||||
int nx = tile.x + point.x, ny = tile.y + point.y;
|
||||
if(inBounds(nx, ny) && (weights[nx][ny] > maxf)){
|
||||
max = tiles[nx][ny];
|
||||
maxf = weights[nx][ny];
|
||||
|
||||
if(MathUtils.isEqual(maxf, 100000)){
|
||||
out.add(max);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(max == null){
|
||||
break;
|
||||
}
|
||||
out.add(max);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package io.anuke.mindustry.maps.generation.pathfinding;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
|
||||
public abstract class TilePathfinder{
|
||||
protected Tile[][] tiles;
|
||||
|
||||
public TilePathfinder(Tile[][] tiles){
|
||||
this.tiles = tiles;
|
||||
}
|
||||
|
||||
protected boolean inBounds(int x, int y){
|
||||
return Structs.inBounds(x, y, tiles);
|
||||
}
|
||||
|
||||
public abstract void search(Tile start, Tile end, Array<Tile> out);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class UnitFactory extends Block{
|
||||
if(!Net.client()){
|
||||
BaseUnit unit = factory.type.create(tile.getTeam());
|
||||
unit.setSpawner(tile);
|
||||
unit.set(tile.drawx(), tile.drawy());
|
||||
unit.set(tile.drawx() + Mathf.range(4), tile.drawy() + Mathf.range(4));
|
||||
unit.add();
|
||||
unit.getVelocity().y = factory.launchVelocity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user