Added VTOL animation
This commit is contained in:
@@ -6,7 +6,6 @@ import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.content.Weapons;
|
||||
import io.anuke.mindustry.content.fx.ExplosionFx;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.effect.DamageArea;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
@@ -271,10 +270,6 @@ public class Player extends Unit{
|
||||
weapon.update(player, false);
|
||||
}
|
||||
|
||||
if(dashing && timer.get(timerDash, 3) && movement.len() > 0){
|
||||
Effects.effect(Fx.dash, x + Angles.trnsx(rotation + 180f, 3f), y + Angles.trnsy(rotation + 180f, 3f));
|
||||
}
|
||||
|
||||
movement.limit(speed);
|
||||
|
||||
velocity.add(movement);
|
||||
@@ -326,6 +321,11 @@ public class Player extends Unit{
|
||||
|
||||
if(isLocal){
|
||||
super.writeSave(stream);
|
||||
|
||||
stream.writeByte(upgrades.size);
|
||||
for(Upgrade u : upgrades){
|
||||
stream.writeByte(u.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,13 +340,18 @@ public class Player extends Unit{
|
||||
|
||||
private void readSaveSuper(DataInputStream stream) throws IOException {
|
||||
super.readSave(stream);
|
||||
|
||||
byte uamount = stream.readByte();
|
||||
for (int i = 0; i < uamount; i++) {
|
||||
upgrades.add(Upgrade.getByID(stream.readByte()));
|
||||
}
|
||||
|
||||
add();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawn(ByteBuffer buffer) {
|
||||
buffer.put((byte)name.getBytes().length);
|
||||
buffer.put(name.getBytes());
|
||||
IOUtils.writeString(buffer, name);
|
||||
buffer.put(weapon.id);
|
||||
buffer.put(mech.id);
|
||||
buffer.put(isAdmin ? 1 : (byte)0);
|
||||
@@ -358,10 +363,7 @@ public class Player extends Unit{
|
||||
|
||||
@Override
|
||||
public void readSpawn(ByteBuffer buffer) {
|
||||
byte nlength = buffer.get();
|
||||
byte[] n = new byte[nlength];
|
||||
buffer.get(n);
|
||||
name = new String(n);
|
||||
name = IOUtils.readString(buffer);
|
||||
weapon = Upgrade.getByID(buffer.get());
|
||||
mech = Upgrade.getByID(buffer.get());
|
||||
isAdmin = buffer.get() == 1;
|
||||
@@ -410,14 +412,6 @@ public class Player extends Unit{
|
||||
|
||||
float tx = x + Angles.trnsx(rotation + 180f, 4f);
|
||||
float ty = y + Angles.trnsy(rotation + 180f, 4f);
|
||||
|
||||
if(mech.flying && i.target.dst(i.last) > 2f && timer.get(timerDash, 1)){
|
||||
Effects.effect(Fx.dash, tx, ty);
|
||||
}
|
||||
|
||||
if(dashing && !dead && timer.get(timerDash, 3) && i.target.dst(i.last) > 1f){
|
||||
Effects.effect(Fx.dash, tx, ty);
|
||||
}
|
||||
}
|
||||
|
||||
public Color getColor(){
|
||||
|
||||
@@ -20,9 +20,9 @@ public abstract class SyncEntity extends DestructibleEntity{
|
||||
private Vector3 spos = new Vector3();
|
||||
|
||||
/**rotation of the top, usually used as the 'shoot' direction.*/
|
||||
public float rotation;
|
||||
public float rotation = 90;
|
||||
/**rotation of the base, usually leg rotation for mechs.*/
|
||||
public float baseRotation;
|
||||
public float baseRotation = 90;
|
||||
|
||||
/**Called when a death event is recieved remotely.*/
|
||||
public abstract void onRemoteDeath();
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class Unit extends SyncEntity implements SerializableEntity {
|
||||
public UnitInventory inventory = new UnitInventory(100, 100);
|
||||
public Team team = Team.blue;
|
||||
|
||||
public Vector2 velocity = new Vector2();
|
||||
public Vector2 velocity = new Vector2(0f, 0.0001f);
|
||||
public float hitTime;
|
||||
public float drownTime;
|
||||
|
||||
@@ -148,6 +148,8 @@ public abstract class Unit extends SyncEntity implements SerializableEntity {
|
||||
}
|
||||
}
|
||||
|
||||
public void drawUnder(){}
|
||||
|
||||
public abstract boolean acceptsAmmo(Item item);
|
||||
public abstract void addAmmo(Item item);
|
||||
public abstract float getMass();
|
||||
|
||||
@@ -7,7 +7,10 @@ import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Timer;
|
||||
|
||||
@@ -40,6 +43,12 @@ public class BaseUnit extends Unit{
|
||||
rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed);
|
||||
}
|
||||
|
||||
public void effectAt(Effect effect, float rotation, float dx, float dy){
|
||||
Effects.effect(effect,
|
||||
x + Angles.trnsx(rotation, dx, dy),
|
||||
y + Angles.trnsy(rotation, dx, dy), Mathf.atan2(dx, dy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsAmmo(Item item) {
|
||||
return type.ammo.containsKey(item) && inventory.canAcceptAmmo(type.ammo.get(item));
|
||||
@@ -81,6 +90,12 @@ public class BaseUnit extends Unit{
|
||||
type.draw(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawUnder(){
|
||||
type.drawUnder(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float drawSize(){
|
||||
return 14;
|
||||
|
||||
@@ -2,20 +2,17 @@ package io.anuke.mindustry.entities.units;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.game.TeamInfo.TeamData;
|
||||
import io.anuke.mindustry.resource.AmmoType;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
public class FlyingUnitType extends UnitType {
|
||||
private static Vector2 vec = new Vector2();
|
||||
protected static Vector2 vec = new Vector2();
|
||||
|
||||
protected float boosterLength = 4.5f;
|
||||
|
||||
@@ -34,8 +31,8 @@ public class FlyingUnitType extends UnitType {
|
||||
unit.rotation = unit.velocity.angle();
|
||||
|
||||
if(unit.velocity.len() > 0.2f && unit.timer.get(timerBoost, 2f)){
|
||||
Effects.effect(Fx.dash, unit.x + Angles.trnsx(unit.rotation + 180f, boosterLength),
|
||||
unit.y + Angles.trnsy(unit.rotation + 180f, boosterLength));
|
||||
//Effects.effect(UnitFx.vtolHover, unit.x + Angles.trnsx(unit.rotation + 180f, boosterLength),
|
||||
// unit.y + Angles.trnsy(unit.rotation + 180f, boosterLength));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ public abstract class UnitType {
|
||||
|
||||
public abstract void draw(BaseUnit unit);
|
||||
|
||||
public void drawUnder(BaseUnit unit){}
|
||||
|
||||
public boolean isFlying(){
|
||||
return isFlying;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package io.anuke.mindustry.entities.units.types;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.content.AmmoTypes;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.FlyingUnitType;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Vtol extends FlyingUnitType {
|
||||
@@ -14,16 +19,70 @@ public class Vtol extends FlyingUnitType {
|
||||
setAmmo(AmmoTypes.basicIron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawUnder(BaseUnit unit) {
|
||||
|
||||
|
||||
for(int i : Mathf.signs) {
|
||||
|
||||
float rotation = unit.rotation - 90;
|
||||
float dx = 5f * i, dx2 = 6f * i;
|
||||
float dy = 4f, dy2 = -5f;
|
||||
|
||||
float rad = 1.5f + Mathf.absin(Timers.time(), 3f, 0.6f);
|
||||
float ds = 1.2f;
|
||||
|
||||
Draw.color(Palette.lightishOrange, Palette.lightFlame, Mathf.absin(Timers.time(), 3f, 0.3f));
|
||||
|
||||
Fill.circle(
|
||||
unit.x + Angles.trnsx(rotation, dx, dy),
|
||||
unit.y + Angles.trnsy(rotation, dx, dy), rad);
|
||||
|
||||
Fill.circle(
|
||||
unit.x + Angles.trnsx(rotation, dx2, dy2),
|
||||
unit.y + Angles.trnsy(rotation, dx2, dy2), rad);
|
||||
|
||||
Draw.color(Color.GRAY);
|
||||
|
||||
Fill.circle(
|
||||
unit.x + Angles.trnsx(rotation, dx, dy)/ds,
|
||||
unit.y + Angles.trnsy(rotation, dx, dy)/ds, 2f);
|
||||
|
||||
Fill.circle(
|
||||
unit.x + Angles.trnsx(rotation, dx2, dy2)/ds,
|
||||
unit.y + Angles.trnsy(rotation, dx2, dy2)/ds, 2f);
|
||||
|
||||
Draw.color(Color.WHITE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(BaseUnit unit) {
|
||||
Draw.alpha(unit.hitTime / Unit.hitDuration);
|
||||
|
||||
Draw.rect(name, unit.x, unit.y, unit.rotation - 90);
|
||||
for(int i : Mathf.signs){
|
||||
Draw.rect(name + "-booster-1", unit.x, unit.y, 12*i, 12, unit.rotation - 90);
|
||||
Draw.rect(name + "-booster-2", unit.x, unit.y, 12*i, 12, unit.rotation - 90);
|
||||
Draw.rect(name + "-booster-1", unit.x + i, unit.y, 12*i, 12, unit.rotation - 90);
|
||||
Draw.rect(name + "-booster-2", unit.x + i, unit.y, 12*i, 12, unit.rotation - 90);
|
||||
}
|
||||
|
||||
Draw.alpha(1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(BaseUnit unit) {
|
||||
super.update(unit);
|
||||
|
||||
unit.x += Mathf.sin(Timers.time() + unit.id*999, 25f, 0.07f);
|
||||
unit.y += Mathf.cos(Timers.time() + unit.id*999, 25f, 0.07f);
|
||||
unit.rotation += Mathf.sin(Timers.time() + unit.id*99, 10f, 8f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void behavior(BaseUnit unit) {
|
||||
//super.behavior(unit);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user