Fully implemented dart ship factory

This commit is contained in:
Anuken
2018-06-26 12:44:40 -04:00
parent 7a049d64d8
commit e407ba3ad3
14 changed files with 634 additions and 621 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 499 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 123 KiB

View File

@@ -40,6 +40,8 @@ public class Mechs implements ContentList {
speed = 0.4f; speed = 0.4f;
maxSpeed = 3f; maxSpeed = 3f;
drag = 0.1f; drag = 0.1f;
weaponOffsetX = -1;
weaponOffsetY = -1;
}}; }};
trident = new Mech("trident-ship", true){{ trident = new Mech("trident-ship", true){{

View File

@@ -2,7 +2,7 @@ package io.anuke.mindustry.content.blocks;
import io.anuke.mindustry.content.Mechs; import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.production.MechFactory; import io.anuke.mindustry.world.blocks.units.MechFactory;
public class UpgradeBlocks extends BlockList { public class UpgradeBlocks extends BlockList {
public static Block deltaFactory, tauFactory, omegaFactory, dartFactory, tridentFactory, javelinFactory, halberdFactory; public static Block deltaFactory, tauFactory, omegaFactory, dartFactory, tridentFactory, javelinFactory, halberdFactory;

View File

@@ -198,6 +198,7 @@ public class Control extends Module{
player.color.set(Settings.getInt("color-" + index)); player.color.set(Settings.getInt("color-" + index));
player.isLocal = true; player.isLocal = true;
player.playerIndex = index; player.playerIndex = index;
player.isMobile = mobile;
players[index] = player; players[index] = player;
if(setTo != null){ if(setTo != null){

View File

@@ -136,6 +136,7 @@ public class NetServer extends Module{
player.usid = packet.usid; player.usid = packet.usid;
player.name = packet.name; player.name = packet.name;
player.uuid = uuid; player.uuid = uuid;
player.isMobile = packet.mobile;
player.mech = packet.mobile ? Mechs.starterMobile : Mechs.starterDesktop; player.mech = packet.mobile ? Mechs.starterMobile : Mechs.starterDesktop;
player.dead = true; player.dead = true;
player.setNet(player.x, player.y); player.setNet(player.x, player.y);
@@ -169,7 +170,7 @@ public class NetServer extends Module{
long elapsed = TimeUtils.timeSinceMillis(connection.lastRecievedTime); long elapsed = TimeUtils.timeSinceMillis(connection.lastRecievedTime);
float maxSpeed = packet.boosting ? player.mech.boostSpeed : player.mech.speed; float maxSpeed = packet.boosting && !player.mech.flying ? player.mech.boostSpeed : player.mech.speed;
//extra 1.1x multiplicaton is added just in case //extra 1.1x multiplicaton is added just in case
float maxMove = elapsed / 1000f * 60f * maxSpeed * 1.1f; float maxMove = elapsed / 1000f * 60f * maxSpeed * 1.1f;

View File

@@ -59,7 +59,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
public float pointerX, pointerY; public float pointerX, pointerY;
public String name = "name"; public String name = "name";
public String uuid, usid; public String uuid, usid;
public boolean isAdmin, isTransferring, isShooting, isBoosting; public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile;
public float boostHeat; public float boostHeat;
public Color color = new Color(); public Color color = new Color();
public Mech mech; public Mech mech;
@@ -76,7 +76,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
private Queue<BuildRequest> placeQueue = new ThreadQueue<>(); private Queue<BuildRequest> placeQueue = new ThreadQueue<>();
private Tile mining; private Tile mining;
private CarriableTrait carrying; private CarriableTrait carrying;
private Trail trail = new Trail(16); private Trail trail = new Trail(12);
private Vector2 movement = new Vector2(); private Vector2 movement = new Vector2();
private boolean moved; private boolean moved;
@@ -317,11 +317,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
Draw.rect(mech.region, x, y, rotation -90); Draw.rect(mech.region, x, y, rotation -90);
for (int i : Mathf.signs) { for (int i : Mathf.signs) {
float tra = rotation - 90, trY = - mech.weapon.getRecoil(this, i > 0)*1.5f; float tra = rotation - 90, trY = - mech.weapon.getRecoil(this, i > 0)*1.5f + mech.weaponOffsetY;
float w = i > 0 ? -12 : 12; float w = i > 0 ? -12 : 12;
Draw.rect(mech.weapon.equipRegion, Draw.rect(mech.weapon.equipRegion,
x + Angles.trnsx(tra, 0, trY), x + Angles.trnsx(tra, mech.weaponOffsetX * i, trY),
y + Angles.trnsy(tra, 0, trY), w, 12, rotation - 90); y + Angles.trnsy(tra, mech.weaponOffsetX * i, trY), w, 12, rotation - 90);
} }
float backTrns = 4f, itemSize = 5f; float backTrns = 4f, itemSize = 5f;
@@ -347,7 +347,9 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
@Override @Override
public void drawOver(){ public void drawOver(){
if(!isShooting() && !dead) { if(dead) return;
if(!isShooting()) {
drawBuilding(this); drawBuilding(this);
} }
@@ -469,7 +471,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
if(ui.chatfrag.chatOpen()) return; if(ui.chatfrag.chatOpen()) return;
float speed = isBoosting ? 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;
@@ -644,7 +646,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
} }
public boolean isShooting(){ public boolean isShooting(){
return isShooting && inventory.hasAmmo() && !isBoosting; return isShooting && inventory.hasAmmo() && (!isBoosting || mech.flying);
} }
public void setRespawning(){ public void setRespawning(){

View File

@@ -20,6 +20,8 @@ public class Mech extends Upgrade {
public float buildPower = 1f; public float buildPower = 1f;
public boolean canRepair = false; public boolean canRepair = false;
public float weaponOffsetX, weaponOffsetY;
public Weapon weapon = Weapons.blaster; public Weapon weapon = Weapons.blaster;
public int itemCapacity = 30; public int itemCapacity = 30;

View File

@@ -1,9 +1,10 @@
package io.anuke.mindustry.world.blocks.production; package io.anuke.mindustry.world.blocks.units;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote; import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.content.fx.Fx; import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.TileEntity;
@@ -29,6 +30,7 @@ import static io.anuke.mindustry.Vars.tilesize;
public class MechFactory extends Block{ public class MechFactory extends Block{
protected Mech mech; protected Mech mech;
protected float buildTime = 60*5;
protected TextureRegion openRegion; protected TextureRegion openRegion;
@@ -68,9 +70,13 @@ public class MechFactory extends Block{
if(entity.player != null) { if(entity.player != null) {
TextureRegion region = mech.iconRegion; TextureRegion region = mech.iconRegion;
if(entity.player.mech == mech){
region = (entity.player.isMobile ? Mechs.starterMobile : Mechs.starterDesktop).iconRegion;
}
Shaders.build.region = region; Shaders.build.region = region;
Shaders.build.progress = entity.progress; Shaders.build.progress = entity.progress;
Shaders.build.time = -entity.time / 10f; Shaders.build.time = -entity.time / 4f;
Shaders.build.color.set(Palette.accent); Shaders.build.color.set(Palette.accent);
Graphics.shader(Shaders.build, false); Graphics.shader(Shaders.build, false);
@@ -84,7 +90,7 @@ public class MechFactory extends Block{
tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size), tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size),
tile.drawy(), tile.drawy(),
90, 90,
size * Vars.tilesize / 2f); size * Vars.tilesize / 2f + 1f);
Draw.reset(); Draw.reset();
} }
@@ -104,8 +110,7 @@ public class MechFactory extends Block{
if(entity.player != null){ if(entity.player != null){
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f); entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
entity.progress += 1f / Vars.respawnduration; entity.progress += 1f / buildTime;
entity.time += entity.heat; entity.time += entity.heat;
@@ -146,10 +151,17 @@ public class MechFactory extends Block{
MechFactoryEntity entity = tile.entity(); MechFactoryEntity entity = tile.entity();
Effects.effect(Fx.spawn, entity); Effects.effect(Fx.spawn, entity);
Mech result = ((MechFactory)tile.block()).mech;
if(entity.player.mech == result){
entity.player.mech = (entity.player.isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
}else{
entity.player.mech = result;
}
entity.player.mech = ((MechFactory)tile.block()).mech;
entity.progress = 0; entity.progress = 0;
entity.player.heal(); entity.player.heal();
entity.open = true;
entity.player.setDead(false); entity.player.setDead(false);
entity.player = null; entity.player = null;
} }