Progress on implementing unit teams
This commit is contained in:
@@ -3,7 +3,6 @@ package io.anuke.mindustry.entities;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetEvents;
|
||||
import io.anuke.mindustry.resource.Mech;
|
||||
@@ -63,9 +62,15 @@ public class Player extends Unit{
|
||||
return mech.mass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlying(){
|
||||
return mech.flying;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int amount){
|
||||
if(debug || mech.flying) return;
|
||||
hitTime = hitDuration;
|
||||
|
||||
health -= amount;
|
||||
if(health <= 0 && !dead && isLocal){ //remote players don't die normally
|
||||
@@ -118,15 +123,10 @@ public class Player extends Unit{
|
||||
public void drawSmooth(){
|
||||
if((debug && (!showPlayer || !showUI)) || dead) return;
|
||||
|
||||
Graphics.beginShaders(Shaders.outline);
|
||||
|
||||
boolean snap = snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal;
|
||||
|
||||
String mname = mech.name;
|
||||
|
||||
Shaders.outline.color.set(getColor());
|
||||
Shaders.outline.lighten = 0f;
|
||||
|
||||
float px = x, py =y;
|
||||
|
||||
if(snap){
|
||||
@@ -136,6 +136,8 @@ public class Player extends Unit{
|
||||
|
||||
float ft = Mathf.sin(walktime, 6f, 2f);
|
||||
|
||||
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);
|
||||
@@ -152,8 +154,7 @@ public class Player extends Unit{
|
||||
Draw.rect(weapon.name + "-equip", x + tr.x, y + tr.y, w, 8, rotation - 90);
|
||||
}
|
||||
|
||||
|
||||
Graphics.endShaders();
|
||||
Draw.alpha(1f);
|
||||
|
||||
x = px;
|
||||
y = py;
|
||||
@@ -161,6 +162,12 @@ public class Player extends Unit{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(hitTime > 0){
|
||||
hitTime -= Timers.delta();
|
||||
}
|
||||
|
||||
if(hitTime < 0) hitTime = 0;
|
||||
|
||||
if(!isLocal){
|
||||
interpolate();
|
||||
return;
|
||||
|
||||
@@ -12,4 +12,5 @@ public abstract class Unit extends SyncEntity {
|
||||
public float hitTime;
|
||||
|
||||
public abstract float getMass();
|
||||
public abstract boolean isFlying();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.anuke.ucore.util.Timer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static io.anuke.mindustry.Vars.enemyGroup;
|
||||
import static io.anuke.mindustry.Vars.unitGroups;
|
||||
|
||||
public class BaseUnit extends Unit {
|
||||
public UnitType type;
|
||||
@@ -27,6 +27,11 @@ public class BaseUnit extends Unit {
|
||||
return type.mass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlying() {
|
||||
return type.isFlying;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
type.update(this);
|
||||
@@ -76,7 +81,7 @@ public class BaseUnit extends Unit {
|
||||
|
||||
@Override
|
||||
public BaseUnit add(){
|
||||
return add(enemyGroup);
|
||||
return add(unitGroups[team.ordinal()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user