Added mobile camera clamping / Mech pad tap power validation

This commit is contained in:
Anuken 2019-04-19 23:32:46 -04:00
parent 9d67c36c32
commit 8a1da3c0ed
2 changed files with 17 additions and 3 deletions

View File

@ -452,7 +452,6 @@ public class MobileInput extends InputHandler implements GestureListener{
}
//endregion
//region input events
@Override
@ -591,6 +590,7 @@ public class MobileInput extends InputHandler implements GestureListener{
@Override
public void update(){
clampCamera();
if(state.is(State.menu) || player.isDead()){
selection.clear();
removals.clear();
@ -730,6 +730,20 @@ public class MobileInput extends InputHandler implements GestureListener{
return true;
}
void clampCamera(){
if(player.isDead()) return;
Vector2 v = Core.camera.position;
v.x = clerp(v.x, player.x - Core.camera.width/2f, player.x + Core.camera.width/2f);
v.y = clerp(v.y, player.y - Core.camera.height/2f, player.y + Core.camera.height/2f);
}
float clerp(float value, float min, float max){
final float alpha = 0.07f;
return value < min ? Mathf.lerpDelta(value, min, alpha) : value > max ? Mathf.lerpDelta(value, max, alpha) : value;
}
//endregion
private class PlaceRequest{

View File

@ -31,7 +31,7 @@ import static io.anuke.mindustry.Vars.tilesize;
public class MechPad extends Block{
protected Mech mech;
protected float buildTime = 60 * 5;
protected float requiredSatisfaction = 1f;
protected float requiredSatisfaction = 0.999f;
protected TextureRegion openRegion;
@ -125,7 +125,7 @@ public class MechPad extends Block{
if(checkValidTap(tile, player)){
Call.onMechFactoryTap(player, tile);
}else if(player.isLocal && mobile && !player.isDead() && entity.cons.valid() && entity.player == null){
}else if(player.isLocal && mobile && !player.isDead() && (entity.power.satisfaction >= requiredSatisfaction) && entity.player == null){
player.moveTarget = tile.entity;
}
}