Mobile mechs implemented
This commit is contained in:
@@ -6,6 +6,7 @@ import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.type.Recipe.RecipeVisibility;
|
||||
|
||||
import static io.anuke.mindustry.type.Category.*;
|
||||
|
||||
@@ -151,14 +152,15 @@ public class Recipes implements ContentList{
|
||||
//UNITS
|
||||
|
||||
//bodies
|
||||
new Recipe(units, UpgradeBlocks.dartPad, new ItemStack(Items.lead, 150), new ItemStack(Items.copper, 150), new ItemStack(Items.silicon, 200), new ItemStack(Items.titanium, 240)).setDesktop(); //dart is desktop only, because it's the starter mobile ship
|
||||
new Recipe(units, UpgradeBlocks.dartPad, new ItemStack(Items.lead, 150), new ItemStack(Items.copper, 150), new ItemStack(Items.silicon, 200), new ItemStack(Items.titanium, 240)).setVisible(RecipeVisibility.desktopOnly);
|
||||
new Recipe(units, UpgradeBlocks.tridentPad, new ItemStack(Items.lead, 250), new ItemStack(Items.copper, 250), new ItemStack(Items.silicon, 250), new ItemStack(Items.titanium, 300), new ItemStack(Items.plastanium, 200));
|
||||
new Recipe(units, UpgradeBlocks.javelinPad, new ItemStack(Items.lead, 350), new ItemStack(Items.silicon, 450), new ItemStack(Items.titanium, 500), new ItemStack(Items.plastanium, 400), new ItemStack(Items.phasematter, 200));
|
||||
new Recipe(units, UpgradeBlocks.glaivePad, new ItemStack(Items.lead, 450), new ItemStack(Items.silicon, 650), new ItemStack(Items.titanium, 700), new ItemStack(Items.plastanium, 600), new ItemStack(Items.surgealloy, 200));
|
||||
|
||||
new Recipe(units, UpgradeBlocks.tauPad, new ItemStack(Items.lead, 250), new ItemStack(Items.densealloy, 250), new ItemStack(Items.copper, 250), new ItemStack(Items.silicon, 250)).setDesktop();
|
||||
new Recipe(units, UpgradeBlocks.deltaPad, new ItemStack(Items.lead, 350), new ItemStack(Items.densealloy, 350), new ItemStack(Items.copper, 400), new ItemStack(Items.silicon, 450), new ItemStack(Items.thorium, 300)).setDesktop();
|
||||
new Recipe(units, UpgradeBlocks.omegaPad, new ItemStack(Items.lead, 450), new ItemStack(Items.densealloy, 550), new ItemStack(Items.silicon, 650), new ItemStack(Items.thorium, 600), new ItemStack(Items.surgealloy, 240)).setDesktop();
|
||||
new Recipe(units, UpgradeBlocks.alphaPad, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 100), new ItemStack(Items.copper, 150)).setVisible(RecipeVisibility.mobileOnly);
|
||||
new Recipe(units, UpgradeBlocks.tauPad, new ItemStack(Items.lead, 250), new ItemStack(Items.densealloy, 250), new ItemStack(Items.copper, 250), new ItemStack(Items.silicon, 250));
|
||||
new Recipe(units, UpgradeBlocks.deltaPad, new ItemStack(Items.lead, 350), new ItemStack(Items.densealloy, 350), new ItemStack(Items.copper, 400), new ItemStack(Items.silicon, 450), new ItemStack(Items.thorium, 300));
|
||||
new Recipe(units, UpgradeBlocks.omegaPad, new ItemStack(Items.lead, 450), new ItemStack(Items.densealloy, 550), new ItemStack(Items.silicon, 650), new ItemStack(Items.thorium, 600), new ItemStack(Items.surgealloy, 240));
|
||||
|
||||
//actual unit related stuff
|
||||
new Recipe(units, UnitBlocks.spiritFactory, new ItemStack(Items.copper, 70), new ItemStack(Items.lead, 110), new ItemStack(Items.silicon, 130));
|
||||
|
||||
@@ -5,10 +5,16 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.units.MechPad;
|
||||
|
||||
public class UpgradeBlocks extends BlockList{
|
||||
public static Block deltaPad, tauPad, omegaPad, dartPad, javelinPad, tridentPad, glaivePad;
|
||||
public static Block alphaPad, deltaPad, tauPad, omegaPad, dartPad, javelinPad, tridentPad, glaivePad;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
alphaPad = new MechPad("alpha-mech-pad"){{
|
||||
mech = Mechs.alpha;
|
||||
size = 2;
|
||||
powerCapacity = 50f;
|
||||
}};
|
||||
|
||||
deltaPad = new MechPad("delta-mech-pad"){{
|
||||
mech = Mechs.delta;
|
||||
size = 2;
|
||||
|
||||
@@ -572,7 +572,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(Recipe.getByResult(block) != null && Recipe.getByResult(block).desktopOnly && mobile){
|
||||
if(Recipe.getByResult(block) != null && !Recipe.getByResult(block).visibility.shown()){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.mindustry.world.blocks.storage.CoreBlock.CoreEntity;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
@@ -47,6 +48,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
private static final int timerShootRight = 1;
|
||||
private static final float liftoffBoost = 0.2f;
|
||||
|
||||
private static final Rectangle rect = new Rectangle();
|
||||
|
||||
//region instance variables
|
||||
|
||||
public float baseRotation;
|
||||
@@ -477,6 +480,21 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
shootHeat = Mathf.lerpDelta(shootHeat, isShooting() ? 1f : 0f, 0.06f);
|
||||
mech.updateAlt(this); //updated regardless
|
||||
|
||||
if(boostHeat > liftoffBoost + 0.1f){
|
||||
achievedFlight = true;
|
||||
}
|
||||
|
||||
if(boostHeat <= liftoffBoost + 0.05f && achievedFlight){
|
||||
if(tile != null){
|
||||
if(mech.shake > 1f){
|
||||
Effects.shake(mech.shake, mech.shake, this);
|
||||
}
|
||||
Effects.effect(UnitFx.unitLand, tile.floor().minimapColor, x, y, tile.floor().isLiquid ? 1f : 0.5f);
|
||||
}
|
||||
mech.onLand(this);
|
||||
achievedFlight = false;
|
||||
}
|
||||
|
||||
if(!isLocal){
|
||||
interpolate();
|
||||
updateBuilding(this); //building happens even with non-locals
|
||||
@@ -512,21 +530,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
protected void updateMech(){
|
||||
Tile tile = world.tileWorld(x, y);
|
||||
|
||||
if(boostHeat > liftoffBoost + 0.1f){
|
||||
achievedFlight = true;
|
||||
}
|
||||
|
||||
if(boostHeat <= liftoffBoost + 0.05f && achievedFlight){
|
||||
if(tile != null){
|
||||
if(mech.shake > 1f){
|
||||
Effects.shake(mech.shake, mech.shake, this);
|
||||
}
|
||||
Effects.effect(UnitFx.unitLand, tile.floor().minimapColor, x, y, tile.floor().isLiquid ? 1f : 0.5f);
|
||||
}
|
||||
mech.onLand(this);
|
||||
achievedFlight = false;
|
||||
}
|
||||
|
||||
isBoosting = Inputs.keyDown("dash") && !mech.flying;
|
||||
|
||||
//if player is in solid block
|
||||
@@ -534,7 +537,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
isBoosting = true;
|
||||
}
|
||||
|
||||
float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed;
|
||||
float speed = isBoosting ? mech.boostSpeed : mech.speed;
|
||||
//fraction of speed when at max load
|
||||
float carrySlowdown = 0.7f;
|
||||
|
||||
@@ -587,7 +590,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
float prex = x, prey = y;
|
||||
updateVelocityStatus();
|
||||
moved = distanceTo(prex, prey) > 0.01f;
|
||||
moved = distanceTo(prex, prey) > 0.001f;
|
||||
}else{
|
||||
velocity.setZero();
|
||||
x = Mathf.lerpDelta(x, getCarrier().getX(), 0.1f);
|
||||
@@ -645,26 +648,46 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
moveTarget = null;
|
||||
}
|
||||
|
||||
movement.set(targetX - x, targetY - y).limit(mech.speed);
|
||||
if(getCarrier() != null){
|
||||
velocity.setZero();
|
||||
x = Mathf.lerpDelta(x, getCarrier().getX(), 0.1f);
|
||||
y = Mathf.lerpDelta(y, getCarrier().getY(), 0.1f);
|
||||
}
|
||||
|
||||
movement.set(targetX - x, targetY - y).limit(isBoosting && !mech.flying ? mech.boostSpeed : mech.speed);
|
||||
movement.setAngle(Mathf.slerp(movement.angle(), velocity.angle(), 0.05f));
|
||||
|
||||
if(distanceTo(targetX, targetY) < attractDst){
|
||||
movement.setZero();
|
||||
}
|
||||
|
||||
float expansion = 3f;
|
||||
|
||||
getHitbox(rect);
|
||||
rect.x -= expansion;
|
||||
rect.y -= expansion;
|
||||
rect.width += expansion*2f;
|
||||
rect.height += expansion*2f;
|
||||
|
||||
isBoosting = EntityQuery.collisions().overlapsTile(rect);
|
||||
|
||||
velocity.add(movement.scl(Timers.delta()));
|
||||
|
||||
if(velocity.len() <= 0.2f){
|
||||
if(velocity.len() <= 0.2f && mech.flying){
|
||||
rotation += Mathf.sin(Timers.time() + id * 99, 10f, 1f);
|
||||
}else if(target == null){
|
||||
rotation = Mathf.slerpDelta(rotation, velocity.angle(), velocity.len() / 10f);
|
||||
}
|
||||
|
||||
float lx = x, ly = y;
|
||||
updateVelocityStatus();
|
||||
moved = distanceTo(lx, ly) > 0.001f && !isCarried();
|
||||
|
||||
//hovering effect
|
||||
x += Mathf.sin(Timers.time() + id * 999, 25f, 0.08f);
|
||||
y += Mathf.cos(Timers.time() + id * 999, 25f, 0.08f);
|
||||
if(mech.flying){
|
||||
//hovering effect
|
||||
x += Mathf.sin(Timers.time() + id * 999, 25f, 0.08f);
|
||||
y += Mathf.cos(Timers.time() + id * 999, 25f, 0.08f);
|
||||
}
|
||||
|
||||
//update shooting if not building, not mining and there's ammo left
|
||||
if(!isBuilding() && getMineTile() == null){
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.ui.ContentDisplay;
|
||||
@@ -28,7 +29,7 @@ public class Recipe extends UnlockableContent{
|
||||
public final Category category;
|
||||
public final float cost;
|
||||
|
||||
public boolean desktopOnly = false;
|
||||
public RecipeVisibility visibility = RecipeVisibility.all;
|
||||
//the only gamemode in which the recipe shows up
|
||||
public GameMode mode;
|
||||
public boolean isPad;
|
||||
@@ -67,7 +68,7 @@ public class Recipe extends UnlockableContent{
|
||||
arr.clear();
|
||||
for(Recipe r : content.recipes()){
|
||||
if(r.category == category && (control.unlocks().isUnlocked(r)) &&
|
||||
!((r.mode != null && r.mode != state.mode) || (r.desktopOnly && mobile) || (r.isPad && !state.mode.showPads))){
|
||||
!((r.mode != null && r.mode != state.mode) || !r.visibility.shown() || (r.isPad && !state.mode.showPads))){
|
||||
arr.add(r);
|
||||
}
|
||||
}
|
||||
@@ -94,8 +95,8 @@ public class Recipe extends UnlockableContent{
|
||||
return this;
|
||||
}
|
||||
|
||||
public Recipe setDesktop(){
|
||||
desktopOnly = true;
|
||||
public Recipe setVisible(RecipeVisibility visibility){
|
||||
this.visibility = visibility;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ public class Recipe extends UnlockableContent{
|
||||
|
||||
@Override
|
||||
public boolean isHidden(){
|
||||
return (desktopOnly && mobile) || hidden;
|
||||
return !visibility.shown() || hidden;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,4 +197,21 @@ public class Recipe extends UnlockableContent{
|
||||
this.blockDependencies = dependencies;
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum RecipeVisibility{
|
||||
mobileOnly(true, false),
|
||||
desktopOnly(false, true),
|
||||
all(true, true);
|
||||
|
||||
public final boolean mobile, desktop;
|
||||
|
||||
RecipeVisibility(boolean mobile, boolean desktop){
|
||||
this.mobile = mobile;
|
||||
this.desktop = desktop;
|
||||
}
|
||||
|
||||
public boolean shown(){
|
||||
return (Vars.mobile && mobile) || (!Vars.mobile && desktop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class BlocksFragment extends Fragment{
|
||||
|
||||
//add actual recipes
|
||||
for(Recipe r : recipes){
|
||||
if((r.mode != null && r.mode != state.mode) || (r.desktopOnly && mobile) || (r.isPad && !state.mode.showPads)) continue;
|
||||
if((r.mode != null && r.mode != state.mode) || !r.visibility.shown() || (r.isPad && !state.mode.showPads)) continue;
|
||||
|
||||
ImageButton image = new ImageButton(new TextureRegion(), "select");
|
||||
|
||||
|
||||
@@ -123,7 +123,6 @@ public class MechPad extends Block{
|
||||
|
||||
@Override
|
||||
public void tapped(Tile tile, Player player){
|
||||
if(mobile && !mech.flying) return;
|
||||
|
||||
if(checkValidTap(tile, player)){
|
||||
Call.onMechFactoryTap(player, tile);
|
||||
|
||||
Reference in New Issue
Block a user