Implemented flying for desktop, new ship bodies

This commit is contained in:
Anuken
2018-06-19 15:38:09 -04:00
parent 23f3f68767
commit 3c3147d665
13 changed files with 157 additions and 91 deletions

View File

@@ -7,7 +7,7 @@ import io.anuke.mindustry.type.Mech;
import io.anuke.mindustry.type.Upgrade;
public class Mechs implements ContentList {
public static Mech alpha, delta, tau, omega, standardShip;
public static Mech alpha, delta, tau, omega, dart, trident, javelin, halberd;
/**These are not new mechs, just re-assignments for convenience.*/
public static Mech starterDesktop, starterMobile;
@@ -39,14 +39,36 @@ public class Mechs implements ContentList {
maxSpeed = 1.0f;
}};
standardShip = new Mech("standard-ship", true){{
dart = new Mech("dart-ship", true){{
drillPower = -1;
speed = 0.4f;
maxSpeed = 3f;
drag = 0.1f;
}};
trident = new Mech("trident-ship", true){{
drillPower = 1;
speed = 0.4f;
maxSpeed = 3f;
drag = 0.1f;
}};
javelin = new Mech("javelin-ship", true){{
drillPower = -1;
speed = 0.4f;
maxSpeed = 3f;
drag = 0.1f;
}};
halberd = new Mech("halberd-ship", true){{
drillPower = 2;
speed = 0.4f;
maxSpeed = 3f;
drag = 0.1f;
}};
starterDesktop = alpha;
starterMobile = standardShip;
starterMobile = dart;
}
@Override

View File

@@ -131,6 +131,10 @@ public class Recipes implements ContentList{
new Recipe(units, UpgradeBlocks.deltaFactory, new ItemStack(Items.iron, 1));
new Recipe(units, UpgradeBlocks.tauFactory, new ItemStack(Items.iron, 1));
new Recipe(units, UpgradeBlocks.tridentFactory, new ItemStack(Items.iron, 1));
new Recipe(units, UpgradeBlocks.javelinFactory, new ItemStack(Items.iron, 1));
new Recipe(units, UpgradeBlocks.halberdFactory, new ItemStack(Items.iron, 1));
new Recipe(units, DebugBlocks.itemSource, new ItemStack(Items.steel, 10)).setDebug();
new Recipe(units, DebugBlocks.itemVoid, new ItemStack(Items.steel, 10)).setDebug();
new Recipe(units, DebugBlocks.liquidSource, new ItemStack(Items.steel, 10)).setDebug();

View File

@@ -5,7 +5,7 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.production.MechFactory;
public class UpgradeBlocks extends BlockList {
public static Block deltaFactory, tauFactory, omegaFactory;
public static Block deltaFactory, tauFactory, omegaFactory, tridentFactory, javelinFactory, halberdFactory;
@Override
public void load() {
@@ -23,5 +23,20 @@ public class UpgradeBlocks extends BlockList {
mech = Mechs.omega;
size = 3;
}};
tridentFactory = new MechFactory("trident-ship-factory"){{
mech = Mechs.trident;
size = 2;
}};
javelinFactory = new MechFactory("javelin-ship-factory"){{
mech = Mechs.javelin;
size = 2;
}};
halberdFactory = new MechFactory("halberd-ship-factory"){{
mech = Mechs.halberd;
size = 3;
}};
}
}

View File

@@ -144,9 +144,8 @@ public class Renderer extends RendererModule{
Graphics.clear(Color.BLACK);
}else{
Vector2 position = averagePosition();
boolean flying = players[0].isFlying();
if(!flying){
if(!mobile){
setCamera(position.x, position.y);
}

View File

@@ -411,7 +411,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
return;
}
if(mech.flying){
if(mobile){
updateFlying();
}else{
updateMech();
@@ -434,7 +434,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
Tile tile = world.tileWorld(x, y);
//if player is in solid block
if(tile != null && tile.solid() && !noclip) {
if(!mech.flying && tile != null && tile.solid() && !noclip) {
damage(health + 1); //die instantly
}
@@ -445,6 +445,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
speed *= ((1f-carrySlowdown) + (inventory.hasItem() ? (float)inventory.getItem().amount/inventory.capacity(): 1f) * carrySlowdown);
if(mech.flying){
//prevent strafing backwards, have a penalty for doing so
float angDist = Angles.angleDist(rotation, velocity.angle()) / 180f;
float penalty = 0.2f;
speed *= Mathf.lerp(1f, penalty, angDist);
}
//drop from carrier on key press
if(Inputs.keyTap("drop_unit") && getCarrier() != null){
getCarrier().dropCarry();
@@ -472,7 +479,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
velocity.add(movement);
updateVelocityStatus(0.4f, speed);
updateVelocityStatus(mech.drag, mech.maxSpeed);
if(!movement.isZero()){
walktime += Timers.delta() * velocity.len()*(1f/0.5f)/speed * getFloorOn().speedMultiplier;
@@ -526,7 +533,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
}
velocity.add(movement);
updateVelocityStatus(0.1f, mech.maxSpeed);
updateVelocityStatus(mech.drag, mech.maxSpeed);
//hovering effect
x += Mathf.sin(Timers.time() + id * 999, 25f, 0.08f);

View File

@@ -9,6 +9,7 @@ public class Mech extends Upgrade {
public float speed = 1.1f;
public float maxSpeed = 1.1f;
public float drag = 0.4f;
public float mass = 1f;
public float armor = 1f;

View File

@@ -17,7 +17,6 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Mathf;
@@ -29,13 +28,10 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.tilesize;
public class MechFactory extends Block{
protected float powerUse = 0.1f;
protected Mech mech;
public MechFactory(String name){
super(name);
hasItems = true;
hasPower = true;
update = true;
consumesTap = true;
solidifes = true;
@@ -90,8 +86,6 @@ public class MechFactory extends Block{
public void update(Tile tile) {
MechFactoryEntity entity = tile.entity();
float used = Math.min(powerCapacity, Timers.delta() * powerUse);
if(entity.open){
if(!Units.anyEntities(tile)){
entity.open = false;
@@ -101,13 +95,9 @@ public class MechFactory extends Block{
}
if(entity.player != null){
if(entity.power.amount >= used || true) {
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
entity.progress += 1f / Vars.respawnduration;
entity.power.amount -= used;
}else{
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.05f);
}
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
entity.progress += 1f / Vars.respawnduration;
entity.time += entity.heat;