Basic android support
This commit is contained in:
@@ -20,7 +20,7 @@ public class Vars{
|
||||
//respawn time in frames
|
||||
public static final float respawnduration = 60*4;
|
||||
//time between waves in frames (on normal mode)
|
||||
public static final float wavespace = 10*60*(android ? 1 : 1); //TODO revert
|
||||
public static final float wavespace = 60*60*(android ? 1 : 1); //TODO revert
|
||||
//waves can last no longer than 3 minutes, otherwise the next one spawns
|
||||
public static final float maxwavespace = 60*60*4f;
|
||||
//advance time the pathfinding starts at
|
||||
|
||||
@@ -26,6 +26,8 @@ import io.anuke.ucore.entities.BaseBulletType;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class NetClient extends Module {
|
||||
@@ -193,6 +195,25 @@ public class NetClient extends Module {
|
||||
|
||||
Net.handle(BlockSyncPacket.class, packet -> {
|
||||
//TODO implementation, load data...
|
||||
DataInputStream stream = new DataInputStream(packet.stream);
|
||||
|
||||
try{
|
||||
while(stream.available() > 0){
|
||||
int pos = stream.readInt();
|
||||
|
||||
Tile tile = Vars.world.tile(pos % Vars.world.width(), pos / Vars.world.width());
|
||||
|
||||
byte times = stream.readByte();
|
||||
|
||||
for(int i = 0; i < times; i ++){
|
||||
tile.entity.timer.getTimes()[i] = stream.readFloat();
|
||||
}
|
||||
|
||||
tile.entity.read(stream);
|
||||
}
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class NetServer extends Module{
|
||||
/**Maps connection IDs to players.*/
|
||||
IntMap<Player> connections = new IntMap<>();
|
||||
float serverSyncTime = 4, itemSyncTime = 10, blockSyncTime = 120;
|
||||
|
||||
@@ -241,8 +242,12 @@ public class NetServer extends Module{
|
||||
for(int i = 0; i < connections.size; i ++){
|
||||
int id = connections.get(i);
|
||||
Player player = this.connections.get(i);
|
||||
if(player == null) continue;
|
||||
int x = Mathf.scl2(player.x, Vars.tilesize);
|
||||
int y = Mathf.scl2(player.y, Vars.tilesize);
|
||||
int w = 14;
|
||||
int h = 10;
|
||||
sendBlockSync(id, x, y, w, h);
|
||||
}
|
||||
|
||||
//TODO sync to each player entity
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
@@ -12,6 +9,8 @@ import io.anuke.mindustry.ui.PressGroup;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MenuFragment implements Fragment{
|
||||
|
||||
public void build(){
|
||||
@@ -72,6 +71,8 @@ public class MenuFragment implements Fragment{
|
||||
new imagebutton("icon-editor", isize, () -> ui.showEditor()).text("$text.editor").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tools", isize, () -> ui.showJoinGame()).text("$text.joingame").padTop(4f);
|
||||
|
||||
if(Mindustry.donationsCallable != null){
|
||||
new imagebutton("icon-donate", isize, () -> {
|
||||
|
||||
Reference in New Issue
Block a user