More multiplayer setup, possible android support

This commit is contained in:
Anuken
2017-12-31 22:06:18 -05:00
parent 701c7f6e78
commit 62ae6dc159
13 changed files with 354 additions and 206 deletions
@@ -79,20 +79,22 @@ public class Player extends DestructibleEntity implements Syncable{
@Override
public void draw(){
if(Vars.debug && (!Vars.showPlayer || !Vars.showUI)) return;
if((Vars.debug && (!Vars.showPlayer || !Vars.showUI)) || (Vars.android && isLocal)) return;
String part = Vars.android ? "ship" : "mech";
if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate")){
Draw.rect("mech-"+mech.name(), (int)x, (int)y, angle-90);
Draw.rect(part+"-"+mech.name(), (int)x, (int)y, angle-90);
}else{
Draw.rect("mech-"+mech.name(), x, y, angle-90);
Draw.rect(part+"-"+mech.name(), x, y, angle-90);
}
}
@Override
public void update(){
if(!isLocal){
if(!isDead()) inter.update(this);
if(!isLocal || android){
if(!isDead() && !isLocal) inter.update(this);
return;
}
@@ -1,12 +1,9 @@
package io.anuke.mindustry.entities;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
@@ -18,6 +15,10 @@ import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Timer;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class TileEntity extends Entity{
public Tile tile;
public int[] items = new int[Item.getAllItems().size];
@@ -54,19 +55,28 @@ public class TileEntity extends Entity{
}
public void onDeath(){
if(tile.block() == ProductionBlocks.core){
Vars.control.coreDestroyed();
onDeath(false);
}
public void onDeath(boolean force){
if(Net.active() && Net.server()){
Vars.netServer.handleBlockDestroyed(this);
}
if(!dead) {
dead = true;
Block block = tile.block();
if(!Net.active() || Net.server() || force){
if(tile.block() == ProductionBlocks.core){
Vars.control.coreDestroyed();
}
block.onDestroyed(tile);
if(!dead) {
dead = true;
Block block = tile.block();
Vars.world.removeBlock(tile);
remove();
block.onDestroyed(tile);
Vars.world.removeBlock(tile);
remove();
}
}
}
@@ -80,6 +90,10 @@ public class TileEntity extends Entity{
int amount = tile.block().handleDamage(tile, damage);
health -= amount;
if(health <= 0) onDeath();
if(Net.active() && Net.server()){
Vars.netServer.handleBlockDamaged(this);
}
}
public boolean collide(Bullet other){