Added ground mech flight

This commit is contained in:
Anuken
2018-08-21 12:22:49 -04:00
parent 6dcbe4fabb
commit 34f2704dc7
7 changed files with 48 additions and 34 deletions

View File

@ -21,6 +21,7 @@ public class Mechs implements ContentList{
alpha = new Mech("alpha-mech", false){{ alpha = new Mech("alpha-mech", false){{
drillPower = 1; drillPower = 1;
mineSpeed = 1.5f;
speed = 0.5f; speed = 0.5f;
boostSpeed = 0.85f; boostSpeed = 0.85f;
weapon = Weapons.blaster; weapon = Weapons.blaster;
@ -56,6 +57,7 @@ public class Mechs implements ContentList{
dart = new Mech("dart-ship", true){{ dart = new Mech("dart-ship", true){{
drillPower = 1; drillPower = 1;
mineSpeed = 0.9f;
speed = 0.4f; speed = 0.4f;
maxSpeed = 3f; maxSpeed = 3f;
drag = 0.1f; drag = 0.1f;

View File

@ -47,8 +47,8 @@ public class Weapons implements ContentList{
roundrobin = true; roundrobin = true;
shots = 6; shots = 6;
inaccuracy = 10f; inaccuracy = 10f;
recoil = 2f;
velocityRnd = 0.7f; velocityRnd = 0.7f;
shake = 2f;
ejectEffect = ShootFx.shellEjectSmall; ejectEffect = ShootFx.shellEjectSmall;
ammo = AmmoTypes.shotgunTungsten; ammo = AmmoTypes.shotgunTungsten;
}}; }};

View File

@ -292,23 +292,23 @@ public class Renderer extends RendererModule{
float trnsX = -12, trnsY = -13; float trnsX = -12, trnsY = -13;
Graphics.end(); //Graphics.end();
Core.batch.getTransformMatrix().translate(trnsX, trnsY, 0); //Core.batch.getTransformMatrix().translate(trnsX, trnsY, 0);
Graphics.begin(); //Graphics.begin();
for(EntityGroup<? extends BaseUnit> group : unitGroups){ for(EntityGroup<? extends BaseUnit> group : unitGroups){
if(!group.isEmpty()){ if(!group.isEmpty()){
drawAndInterpolate(group, unit -> unit.isFlying() && !unit.isDead(), Unit::drawShadow); drawAndInterpolate(group, unit -> unit.isFlying() && !unit.isDead(), baseUnit -> baseUnit.drawShadow(trnsX, trnsY));
} }
} }
if(!playerGroup.isEmpty()){ if(!playerGroup.isEmpty()){
drawAndInterpolate(playerGroup, unit -> unit.isFlying() && !unit.isDead(), Unit::drawShadow); drawAndInterpolate(playerGroup, unit -> unit.isFlying() && !unit.isDead(), player -> player.drawShadow(trnsX, trnsY));
} }
Graphics.end(); //Graphics.end();
Core.batch.getTransformMatrix().translate(-trnsX, -trnsY, 0); //Core.batch.getTransformMatrix().translate(-trnsX, -trnsY, 0);
Graphics.begin(); //Graphics.begin();
//TODO this actually isn't necessary //TODO this actually isn't necessary
Draw.color(0, 0, 0, 0.15f); Draw.color(0, 0, 0, 0.15f);

View File

@ -32,6 +32,7 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.EntityGroup; import io.anuke.ucore.entities.EntityGroup;
import io.anuke.ucore.entities.trait.SolidTrait; import io.anuke.ucore.entities.trait.SolidTrait;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Hue;
import io.anuke.ucore.graphics.Lines; import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.*; import io.anuke.ucore.util.*;
@ -194,7 +195,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
@Override @Override
public boolean isFlying(){ public boolean isFlying(){
return mech.flying || noclip || isCarried(); return mech.flying || boostHeat > 0.2f || isCarried();
} }
@Override @Override
@ -258,31 +259,19 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
} }
@Override @Override
public void drawShadow(){ public void drawShadow(float offsetX, float offsetY){
Draw.rect(mech.iconRegion, x , y, rotation - 90); float x = snappedX(), y = snappedY();
} float scl = mech.flying ? 1f : boostHeat/2f;
@Override Draw.rect(mech.iconRegion, x + offsetX*scl, y + offsetY*scl, rotation - 90);
public void drawAll(){
boolean snap = snapCamera && isLocal;
float px = x, py = y;
if(snap){
x = (int) (x + 0.0001f);
y = (int) (y + 0.0001f);
}
super.drawAll();
x = px;
y = py;
} }
@Override @Override
public void draw(){ public void draw(){
if((debug && (!showPlayer || !showUI)) || dead) return; if((debug && (!showPlayer || !showUI)) || dead) return;
float x = snappedX(), y = snappedY();
if(!movement.isZero() && moved && !state.isPaused()){ if(!movement.isZero() && moved && !state.isPaused()){
walktime += Timers.delta() * movement.len() / 0.7f * getFloorOn().speedMultiplier; walktime += Timers.delta() * movement.len() / 0.7f * getFloorOn().speedMultiplier;
baseRotation = Mathf.slerpDelta(baseRotation, movement.angle(), 0.13f); baseRotation = Mathf.slerpDelta(baseRotation, movement.angle(), 0.13f);
@ -350,6 +339,16 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
Draw.alpha(1f); Draw.alpha(1f);
} }
@Override
public void drawStats(){
float x = snappedX(), y = snappedY();
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Timers.time(), healthf()*5f, 1f - healthf()));
Draw.alpha(hitTime);
Draw.rect(getPowerCellRegion(), x, y, rotation - 90);
Draw.color();
}
@Override @Override
public void drawOver(){ public void drawOver(){
if(dead) return; if(dead) return;
@ -360,12 +359,20 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
float wobblyness = 0.6f; float wobblyness = 0.6f;
trail.update(x + Angles.trnsx(rotation + 180f, 5f) + Mathf.range(wobblyness), trail.update(x + Angles.trnsx(rotation + 180f, 5f) + Mathf.range(wobblyness),
y + Angles.trnsy(rotation + 180f, 5f) + Mathf.range(wobblyness)); y + Angles.trnsy(rotation + 180f, 5f) + Mathf.range(wobblyness));
trail.draw(mech.trailColor, 5f * (isFlying() ? 1f : boostHeat)); trail.draw(Hue.mix(mech.trailColor, mech.trailColorTo, boostHeat, Tmp.c1), 5f * (isFlying() ? 1f : boostHeat));
}else{ }else{
trail.clear(); trail.clear();
} }
} }
float snappedX(){
return snapCamera && isLocal ? (int) (x + 0.0001f) : x;
}
float snappedY(){
return snapCamera && isLocal ? (int) (y + 0.0001f) : y;
}
public void drawName(){ public void drawName(){
GlyphLayout layout = Pools.obtain(GlyphLayout.class); GlyphLayout layout = Pools.obtain(GlyphLayout.class);
@ -482,11 +489,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
Tile tile = world.tileWorld(x, y); Tile tile = world.tileWorld(x, y);
//if player is in solid block //if player is in solid block
if(!mech.flying && tile != null && tile.solid() && !noclip){ if(tile != null && tile.solid() && !isFlying()){
damage(health + 1); //die instantly damage(health + 1); //die instantly
} }
float speed = isBoosting && !mech.flying ? debug ? 5f : mech.boostSpeed : mech.speed; float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed;
//fraction of speed when at max load //fraction of speed when at max load
float carrySlowdown = 0.7f; float carrySlowdown = 0.7f;

View File

@ -315,8 +315,8 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
} }
} }
public void drawShadow(){ public void drawShadow(float offsetX, float offsetY){
Draw.rect(getIconRegion(), x , y, rotation - 90); Draw.rect(getIconRegion(), x + offsetX, y + offsetY, rotation - 90);
} }
public void drawView(){ public void drawView(){

View File

@ -28,6 +28,9 @@ public class Palette{
lightishGray = Color.valueOf("a2a2a2"), lightishGray = Color.valueOf("a2a2a2"),
darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f), darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f),
boostTo = Color.valueOf("ffad4d"),
boostFrom = Color.valueOf("ff7f57"),
lancerLaser = Color.valueOf("a9d8ff"), lancerLaser = Color.valueOf("a9d8ff"),
stoneGray = Color.valueOf("8f8f8f"), stoneGray = Color.valueOf("8f8f8f"),

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.content.Weapons; import io.anuke.mindustry.content.Weapons;
import io.anuke.mindustry.game.UnlockableContent; import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.ui.ContentDisplay; import io.anuke.mindustry.ui.ContentDisplay;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Table;
@ -24,7 +25,8 @@ public class Mech extends Upgrade implements UnlockableContent{
public float carryWeight = 10f; public float carryWeight = 10f;
public float buildPower = 1f; public float buildPower = 1f;
public boolean canRepair = false; public boolean canRepair = false;
public Color trailColor = Color.valueOf("ffd37f"); public Color trailColor = Palette.boostFrom;
public Color trailColorTo = Palette.boostTo;
public float weaponOffsetX, weaponOffsetY; public float weaponOffsetX, weaponOffsetY;