diff --git a/build.gradle b/build.gradle index ad166bb43d..e7ad56538a 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ allprojects { appName = 'Mindustry' gdxVersion = '1.9.8' aiVersion = '1.8.1' - uCoreVersion = 'cfc0943' + uCoreVersion = '0176aaa' getVersionString = { String buildVersion = getBuildVersion() diff --git a/core/assets/version.properties b/core/assets/version.properties index 0cf82d77cb..d8097b4855 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,7 +1,7 @@ #Autogenerated file. Do not modify. -#Thu Mar 15 21:41:26 EDT 2018 +#Fri Mar 16 00:30:24 EDT 2018 version=release -androidBuildCode=524 +androidBuildCode=525 name=Mindustry code=3.4 build=custom build diff --git a/core/src/io/anuke/mindustry/core/Logic.java b/core/src/io/anuke/mindustry/core/Logic.java index 17058fb7d8..8507d3c423 100644 --- a/core/src/io/anuke/mindustry/core/Logic.java +++ b/core/src/io/anuke/mindustry/core/Logic.java @@ -57,7 +57,7 @@ public class Logic extends Module { state.allyTeams.clear(); state.enemyTeams.clear(); state.enemyTeams.add(Team.red); - state.team = Team.none; + state.team = Team.blue; Timers.clear(); Entities.clear(); diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 9f4982cee6..646eb87641 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -44,7 +44,7 @@ public class Player extends Unit{ public int clientid = -1; public boolean isLocal = false; public Timer timer = new Timer(4); - public float footRotation, walktime; + public float walktime; private Vector2 movement = new Vector2(); private Translator tr = new Translator(); @@ -59,7 +59,6 @@ public class Player extends Unit{ @Override public void onRemoteShoot(BulletType type, float x, float y, float rotation, short data) { - //TODO shoot! Weapon weapon = Upgrade.getByID((byte)data); weapon.shoot(player, x, y, rotation); } @@ -101,7 +100,7 @@ public class Player extends Unit{ public void onDeath(){ dead = true; if(Net.active()){ - NetEvents.handlePlayerDeath(); + NetEvents.handleUnitDeath(this); } Effects.effect(Fx.explosion, this); @@ -145,12 +144,14 @@ public class Player extends Unit{ //Draw.alpha(hitTime / hitDuration); - for(int i : Mathf.signs){ - tr.trns(footRotation, ft * i); - Draw.rect(mname + "-leg", x + tr.x, y + tr.y, 12f * i, 12f - Mathf.clamp(ft*i, 0, 2), footRotation- 90); - } + if(!mech.flying) { + for (int i : Mathf.signs) { + tr.trns(baseRotation, ft * i); + Draw.rect(mname + "-leg", x + tr.x, y + tr.y, 12f * i, 12f - Mathf.clamp(ft * i, 0, 2), baseRotation - 90); + } - Draw.rect(mname + "-base", x, y,footRotation- 90); + Draw.rect(mname + "-base", x, y,baseRotation- 90); + } Draw.rect(mname, x, y, rotation -90); @@ -252,7 +253,7 @@ public class Player extends Unit{ if(!movement.isZero()){ walktime += Timers.delta(); - footRotation = Mathf.slerpDelta(footRotation, movement.angle(), 0.13f); + baseRotation = Mathf.slerpDelta(baseRotation, movement.angle(), 0.13f); } if(!shooting){ @@ -318,6 +319,7 @@ public class Player extends Unit{ data.putFloat(interpolator.target.y); } data.putFloat(rotation); + data.putFloat(baseRotation); data.putShort((short)health); data.put((byte)(dashing ? 1 : 0)); } @@ -326,14 +328,15 @@ public class Player extends Unit{ public void read(ByteBuffer data, long time) { float x = data.getFloat(); float y = data.getFloat(); - float angle = data.getFloat(); + float rot = data.getFloat(); + float baseRot = data.getFloat(); short health = data.getShort(); byte dashing = data.get(); this.health = health; this.dashing = dashing == 1; - interpolator.read(this.x, this.y, x, y, angle, time); + interpolator.read(this.x, this.y, x, y, rot, baseRot, time); } @Override diff --git a/core/src/io/anuke/mindustry/entities/SyncEntity.java b/core/src/io/anuke/mindustry/entities/SyncEntity.java index dcf5219dd5..3dea8724de 100644 --- a/core/src/io/anuke/mindustry/entities/SyncEntity.java +++ b/core/src/io/anuke/mindustry/entities/SyncEntity.java @@ -18,8 +18,11 @@ public abstract class SyncEntity extends DestructibleEntity{ protected Interpolator interpolator = new Interpolator(); /**smoothed position and rotation*/ private Vector3 spos = new Vector3(); - /**the general rotation.*/ + + /**rotation of the top, usually used as the 'shoot' direction.*/ public float rotation; + /**rotation of the base, usually leg rotation for mechs.*/ + public float baseRotation; /**Called when a death event is recieved remotely.*/ public abstract void onRemoteDeath(); @@ -42,6 +45,7 @@ public abstract class SyncEntity extends DestructibleEntity{ x = interpolator.pos.x; y = interpolator.pos.y; rotation = interpolator.rotation; + baseRotation = interpolator.baseRotation; } /**Same as draw, but for interpolated drawing at low tick speeds.*/ @@ -93,16 +97,17 @@ public abstract class SyncEntity extends DestructibleEntity{ //used for movement public Vector2 target = new Vector2(); public Vector2 last = new Vector2(); - public float targetrot; + public float targetrot, targetBaseRot; public float spacing = 1f; public float time; //current state public Vector2 pos = new Vector2(); - public float rotation; + public float rotation, baseRotation; - public void read(float cx, float cy, float x, float y, float angle, long sent){ - targetrot = angle; + public void read(float cx, float cy, float x, float y, float rotation, float baseRotation, long sent){ + targetrot = rotation; + targetBaseRot = baseRotation; time = 0f; last.set(cx, cy); target.set(x, y); @@ -117,6 +122,7 @@ public abstract class SyncEntity extends DestructibleEntity{ Mathf.lerp2(pos.set(last), target, time); rotation = Mathf.slerpDelta(rotation, targetrot, 0.6f); + baseRotation = Mathf.slerpDelta(baseRotation, targetBaseRot, 0.6f); if(target.dst(pos) > 128){ pos.set(target); diff --git a/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java b/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java new file mode 100644 index 0000000000..88062895e5 --- /dev/null +++ b/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java @@ -0,0 +1,34 @@ +package io.anuke.mindustry.entities.units; + +import io.anuke.ucore.graphics.Draw; +import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Translator; + +public abstract class GroundUnitType extends UnitType{ + protected Translator tr = new Translator(); + + public GroundUnitType(String name) { + super(name); + } + + @Override + public void draw(BaseUnit unit) { + float walktime = 0; //TODO! + + float ft = Mathf.sin(walktime, 6f, 2f); + + for (int i : Mathf.signs) { + tr.trns(unit.baseRotation, ft * i); + Draw.rect(name + "-leg", unit.x + tr.x, unit.y + tr.y, 12f * i, 12f - Mathf.clamp(ft * i, 0, 2), unit.baseRotation - 90); + } + + Draw.rect(name + "-base", unit.x, unit.y, unit.baseRotation- 90); + + Draw.rect(name, unit.x, unit.y, unit.rotation -90); + } + + @Override + public void behavior(BaseUnit unit) { + + } +} diff --git a/core/src/io/anuke/mindustry/entities/units/UnitType.java b/core/src/io/anuke/mindustry/entities/units/UnitType.java index ba9cee45e3..87bd5d2b51 100644 --- a/core/src/io/anuke/mindustry/entities/units/UnitType.java +++ b/core/src/io/anuke/mindustry/entities/units/UnitType.java @@ -2,12 +2,17 @@ package io.anuke.mindustry.entities.units; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.graphics.Fx; +import io.anuke.mindustry.net.Net; +import io.anuke.mindustry.net.NetEvents; +import io.anuke.ucore.core.Effects; +import io.anuke.ucore.core.Timers; import io.anuke.ucore.util.Mathf; import static io.anuke.mindustry.Vars.tilesize; import static io.anuke.mindustry.Vars.world; -public class UnitType { +public abstract class UnitType { private static byte lastid = 0; private static Array types = new Array<>(); @@ -22,6 +27,7 @@ public class UnitType { protected float rotatespeed = 0.1f; protected float mass = 1f; protected boolean isFlying; + protected float drag = 0.1f; public UnitType(String name){ this.id = lastid++; @@ -29,53 +35,56 @@ public class UnitType { types.add(this); } - public void draw(BaseUnit enemy){ + public abstract void draw(BaseUnit unit); + + public void drawOver(BaseUnit unit){ + //TODO doesn't do anything + } + + public void update(BaseUnit unit){ + if(Net.client()){ + unit.interpolate(); + return; + } + + //TODO logic + + unit.x += unit.velocity.x / mass; + unit.y += unit.velocity.y / mass; + + unit.velocity.scl(Mathf.clamp(1f-drag* Timers.delta())); + + behavior(unit); + + unit.x = Mathf.clamp(unit.x, 0, world.width() * tilesize); + unit.y = Mathf.clamp(unit.y, 0, world.height() * tilesize); + } + + public abstract void behavior(BaseUnit unit); + + public void updateTargeting(BaseUnit unit){ //TODO } - public void drawOver(BaseUnit enemy){ + public void onShoot(BaseUnit unit, BulletType type, float rotation){ //TODO } - public void update(BaseUnit enemy){ - //TODO - enemy.x = Mathf.clamp(enemy.x, 0, world.width() * tilesize); - enemy.y = Mathf.clamp(enemy.y, 0, world.height() * tilesize); + public void onDeath(BaseUnit unit){ + //TODO other things, such as enemies? + Effects.effect(Fx.explosion, unit); + + if(Net.server()){ + NetEvents.handleUnitDeath(unit); + } } - public void move(BaseUnit enemy){ - //TODO + public void onRemoteDeath(BaseUnit unit){ + onDeath(unit); + unit.remove(); } - public void behavior(BaseUnit enemy){ - //TODO - } - - public void updateTargeting(BaseUnit enemy){ - //TODO - } - - public void updateShooting(BaseUnit enemy){ - //TODO - } - - public void shoot(BaseUnit enemy){ - //TODO - } - - public void onShoot(BaseUnit enemy, BulletType type, float rotation){ - //TODO - } - - public void onDeath(BaseUnit enemy){ - //TODO - } - - public void onRemoteDeath(BaseUnit enemy){ - //TODO - } - - public void removed(BaseUnit enemy){ + public void removed(BaseUnit unit){ //TODO } diff --git a/core/src/io/anuke/mindustry/game/Team.java b/core/src/io/anuke/mindustry/game/Team.java index f16c48b30a..7490fcace9 100644 --- a/core/src/io/anuke/mindustry/game/Team.java +++ b/core/src/io/anuke/mindustry/game/Team.java @@ -4,8 +4,8 @@ import com.badlogic.gdx.graphics.Color; public enum Team { none(Color.DARK_GRAY), - blue(Color.BLUE), - red(Color.RED); + blue(Color.ROYAL), + red(Color.SCARLET); public final Color color; diff --git a/core/src/io/anuke/mindustry/net/NetEvents.java b/core/src/io/anuke/mindustry/net/NetEvents.java index 8b35586b76..7c63462956 100644 --- a/core/src/io/anuke/mindustry/net/NetEvents.java +++ b/core/src/io/anuke/mindustry/net/NetEvents.java @@ -28,11 +28,10 @@ public class NetEvents { Net.send(new GameOverPacket(), SendMode.tcp); } - - public static void handleUnitDeath(Unit enemy){ + public static void handleUnitDeath(Unit entity){ EntityDeathPacket packet = new EntityDeathPacket(); - packet.id = enemy.id; - packet.group = (byte)enemy.getGroup().getID(); + packet.id = entity.id; + packet.group = (byte)entity.getGroup().getID(); Net.send(packet, SendMode.tcp); } @@ -49,12 +48,6 @@ public class NetEvents { Net.send(packet, SendMode.udp); } - public static void handlePlayerDeath(){ - EntityDeathPacket packet = new EntityDeathPacket(); - packet.id = Vars.player.id; - Net.send(packet, SendMode.tcp); - } - public static void handleBlockConfig(Tile tile, byte data){ BlockConfigPacket packet = new BlockConfigPacket(); packet.data = data;