Removed camera clamp / Self-destruct timer / More blend tweaks

This commit is contained in:
Anuken
2019-01-30 19:48:41 -05:00
parent c046a1b474
commit 43bff5c34d
12 changed files with 71 additions and 27 deletions

View File

@@ -51,6 +51,10 @@ public class Vars{
public static final int maxNameLength = 40;
/**displayed item size when ingame, TODO remove.*/
public static final float itemSize = 5f;
/**extra padding around the world; units outside this bound will begin to self-destruct.*/
public static final float worldBounds = 100f;
/**ticks spent out of bound until self destruct.*/
public static final float boundsCountdown = 60*7;
/**size of tiles in units*/
public static final int tilesize = 8;
/**all choosable player colors in join/host dialog*/

View File

@@ -153,12 +153,12 @@ public class Blocks implements ContentList{
craters = new Floor("craters"){{
minimapColor = Color.valueOf("323232");
variants = 6;
hasEdges = false;
blendGroup = stone;
}};
charr = new Floor("char"){{
minimapColor = Color.valueOf("323232");
hasEdges = false;
blendGroup = stone;
}};
sandWater = new Floor("sand-water"){{

View File

@@ -126,9 +126,6 @@ public class Renderer implements ApplicationListener{
camera.position.lerpDelta(position, 0.08f);
}
camera.position.x = Mathf.clamp(camera.position.x, -tilesize / 2f, world.width() * tilesize - tilesize / 2f);
camera.position.y = Mathf.clamp(camera.position.y, -tilesize / 2f, world.height() * tilesize - tilesize / 2f);
updateShake(0.75f);
draw();

View File

@@ -19,10 +19,13 @@ import io.anuke.arc.util.Interval;
import io.anuke.arc.util.Pack;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.pooling.Pools;
import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.entities.effect.ScorchDecal;
import io.anuke.mindustry.entities.traits.*;
import io.anuke.mindustry.entities.traits.BuilderTrait;
import io.anuke.mindustry.entities.traits.ShooterTrait;
import io.anuke.mindustry.entities.traits.SpawnerTrait;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.graphics.Palette;
@@ -60,7 +63,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
public String name = "name";
public String uuid, usid;
public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile;
public float boostHeat, shootHeat;
public float boostHeat, shootHeat, destructTime;
public boolean achievedFlight;
public Color color = new Color();
public Mech mech;
@@ -490,6 +493,16 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
setDead(true);
}
if(!isDead() && isOutOfBounds()){
destructTime += Time.delta();
if(destructTime >= boundsCountdown){
kill();
}
}else{
destructTime = 0f;
}
if(isDead()){
isBoosting = false;
boostHeat = 0f;
@@ -545,8 +558,9 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
updateBuilding(this);
x = Mathf.clamp(x, 0, world.width() * tilesize - tilesize);
y = Mathf.clamp(y, 0, world.height() * tilesize - tilesize);
if(!mech.flying){
clampPosition();
}
}
protected void updateMech(){

View File

@@ -33,8 +33,8 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.world;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.tilesize;
public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait, InventoryTrait{
/**Total duration of hit flash effect*/
@@ -174,6 +174,20 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
inventory.writeSave(stream);
}
protected void clampPosition(){
x = Mathf.clamp(x, tilesize, world.width() * tilesize - tilesize);
y = Mathf.clamp(y, tilesize, world.height() * tilesize - tilesize);
}
public void kill(){
health = -1;
damage(1);
}
public boolean isOutOfBounds(){
return x < worldBounds || y < worldBounds || x > world.width() * tilesize + worldBounds || y > world.height() * tilesize + worldBounds;
}
public float calculateDamage(float amount){
return amount * Mathf.clamp(1f - getArmor() / 100f * status.getArmorMultiplier());
}

View File

@@ -301,8 +301,9 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
if(target != null) behavior();
x = Mathf.clamp(x, tilesize, world.width() * tilesize - tilesize);
y = Mathf.clamp(y, tilesize, world.height() * tilesize - tilesize);
if(!isFlying()){
clampPosition();
}
}
@Override

View File

@@ -48,11 +48,9 @@ public class DeployDialog extends FloatingDialog{
}
public void setup(){
try{
Class.forName("io.anuke.arc.recorder.GifRecorder");
}catch(Throwable t){
if(!System.getProperty("mindustry.debug", "false").equals("true")){
ui.showInfo("This is not ready for testing. Play custom games instead.");
hide();
Core.app.post(this::hide);
return;
}

View File

@@ -17,10 +17,7 @@ import io.anuke.arc.scene.ui.layout.Stack;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.arc.scene.utils.Elements;
import io.anuke.arc.util.Align;
import io.anuke.arc.util.Scaling;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.Tmp;
import io.anuke.arc.util.*;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.EventType.StateChangeEvent;
import io.anuke.mindustry.game.Team;
@@ -33,6 +30,8 @@ import io.anuke.mindustry.net.Packets.AdminAction;
import io.anuke.mindustry.ui.IntFormat;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import java.lang.StringBuilder;
import static io.anuke.mindustry.Vars.*;
public class HudFragment extends Fragment{
@@ -154,6 +153,7 @@ public class HudFragment extends Fragment{
t.table("button", top -> top.add("$paused").pad(6f));
});
//spawner warning
parent.fill(t -> {
t.touchable(Touchable.disabled);
t.visible(() -> !state.is(State.menu));
@@ -165,6 +165,20 @@ public class HudFragment extends Fragment{
}).get().color.a = 0f;
});
//out of bounds warning
parent.fill(t -> {
t.touchable(Touchable.disabled);
t.visible(() -> !state.is(State.menu));
t.table("flat", c -> c.add("")
.update(l ->{
l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f)));
l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - players[0].destructTime) / 60f)));
}).get().setAlignment(Align.center, Align.center))
.margin(6).update(u -> {
u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(players[0].isOutOfBounds()), 0.1f);
}).get().color.a = 0f;
});
parent.fill(t -> {
t.visible(() -> netServer.isWaitingForPlayers() && !state.is(State.menu));
t.table("button", c -> c.add("$waiting.players"));

View File

@@ -59,7 +59,7 @@ public class MenuFragment extends Fragment{
MobileButton
play = new MobileButton("icon-play-2", isize, "$play", ui.deploy::show),
maps = new MobileButton("icon-map", isize, "$maps", ui.maps::show),
custom = new MobileButton("icon-play-custom", isize, "customgame", this::showCustomSelect),
custom = new MobileButton("icon-play-custom", isize, "$customgame", this::showCustomSelect),
join = new MobileButton("icon-add", isize, "$joingame", ui.join::show),
editor = new MobileButton("icon-editor", isize, "$editor", () -> ui.loadAnd(ui.editor::show)),
tools = new MobileButton("icon-tools", isize, "$settings", ui.settings::show),

View File

@@ -55,8 +55,8 @@ public class Floor extends Block{
public boolean playerUnmineable = false;
/**Style of the edge stencil. Loaded by looking up "edge-stencil-{name}".*/
public String edgeStyle = "smooth";
/**Whether edges are used at all.*/
public boolean hasEdges = true;
/**Group of blocks that this block does not draw edges on.*/
public Block blendGroup = this;
protected TextureRegion[][] edges;
protected byte eq = 0;
@@ -83,7 +83,7 @@ public class Floor extends Block{
}
int size = (int)(tilesize / Draw.scl);
if(hasEdges && Core.atlas.has(name + "-edge")){
if(Core.atlas.has(name + "-edge")){
edges = Core.atlas.find(name + "-edge").split(size, size);
}
region = variantRegions[0];
@@ -135,7 +135,7 @@ public class Floor extends Block{
}
protected boolean doEdge(Floor other){
return (other.id > id || edges == null) && other.edgeOnto(this);
return (other.blendGroup.id > id || edges == null) && other.edgeOnto(this);
}
protected boolean edgeOnto(Floor other){

View File

@@ -20,6 +20,7 @@ public class OreBlock extends Floor{
this.variants = 3;
this.minimapColor = ore.color;
this.edge = base.name;
this.blendGroup = base;
oreBlockMap.getOr(ore, ObjectMap::new).put(base, this);
}