New breaking animation and colors
This commit is contained in:
@@ -36,6 +36,11 @@ public interface BlockBuilder {
|
||||
|
||||
/**Add another build requests to the tail of the queue.*/
|
||||
default void addBuildRequest(BuildRequest place){
|
||||
for(BuildRequest request : getPlaceQueue()){
|
||||
if(request.x == place.x && request.y == place.y){
|
||||
return;
|
||||
}
|
||||
}
|
||||
getPlaceQueue().addLast(place);
|
||||
}
|
||||
|
||||
@@ -76,9 +81,10 @@ public interface BlockBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
current.removeProgress += progress;
|
||||
current.progress += progress;
|
||||
unit.rotation = Mathf.slerpDelta(unit.rotation, unit.angleTo(tile.drawx(), tile.drawy()), 0.4f);
|
||||
|
||||
if(current.removeProgress >= 1f){
|
||||
if(current.progress >= 1f){
|
||||
Build.breakBlock(unit.team, current.x, current.y, true, true);
|
||||
}
|
||||
}else{
|
||||
@@ -107,6 +113,7 @@ public interface BlockBuilder {
|
||||
|
||||
entity.addProgress(core.items, 1f / entity.recipe.cost);
|
||||
unit.rotation = Mathf.slerpDelta(unit.rotation, unit.angleTo(entity), 0.4f);
|
||||
getCurrentRequest().progress = entity.progress();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +122,7 @@ public interface BlockBuilder {
|
||||
default void drawBuilding(Unit unit){
|
||||
Tile tile = world.tile(getCurrentRequest().x, getCurrentRequest().y);
|
||||
|
||||
Draw.color(unit.distanceTo(tile) > placeDistance ? "placeInvalid" : "accent");
|
||||
Draw.color(unit.distanceTo(tile) > placeDistance || getCurrentRequest().remove ? "break" : "accent");
|
||||
float focusLen = 3.8f + Mathf.absin(Timers.time(), 1.1f, 0.6f);
|
||||
float px = unit.x + Angles.trnsx(unit.rotation, focusLen);
|
||||
float py = unit.y + Angles.trnsy(unit.rotation, focusLen);
|
||||
@@ -146,7 +153,7 @@ public interface BlockBuilder {
|
||||
Lines.line(px, py, x1, y1);
|
||||
Lines.line(px, py, x3, y3);
|
||||
|
||||
Fill.circle(px, py, 1.5f + Mathf.absin(Timers.time(), 1f, 1.8f));
|
||||
Fill.circle(px, py, 1.6f + Mathf.absin(Timers.time(), 0.8f, 1.5f));
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
@@ -157,7 +164,7 @@ public interface BlockBuilder {
|
||||
public final Recipe recipe;
|
||||
public final boolean remove;
|
||||
|
||||
float removeProgress;
|
||||
float progress;
|
||||
float[] removeAccumulator;
|
||||
|
||||
/**This creates a build request.*/
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
@@ -23,6 +24,7 @@ import io.anuke.mindustry.world.blocks.types.Floor;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.*;
|
||||
|
||||
@@ -243,18 +245,37 @@ public class Player extends Unit implements BlockBuilder {
|
||||
public void drawBuildRequests(){
|
||||
for (BuildRequest request : getPlaceQueue()) {
|
||||
if(request.remove){
|
||||
Draw.color("placeInvalid");
|
||||
Draw.color("break");
|
||||
Draw.alpha(0.4f);
|
||||
Lines.stroke(1f);
|
||||
|
||||
float progress = request.progress;
|
||||
Tile tile = world.tile(request.x, request.y);
|
||||
float size = tile.block().size * tilesize/2f;
|
||||
float ss = -(progress*2f-1f);
|
||||
|
||||
for(int i = 0; i < 4; i ++){
|
||||
GridPoint2 p = Geometry.d8edge(i);
|
||||
|
||||
Fill.tri(tile.drawx() + size*p.x, tile.drawy() + size * p.y,
|
||||
tile.drawx() + size*p.x*ss, tile.drawy() + size * p.y,
|
||||
tile.drawx() + size*p.x, tile.drawy() + size * p.y*ss);
|
||||
}
|
||||
|
||||
Draw.alpha(1f);
|
||||
|
||||
Lines.poly(tile.drawx(), tile.drawy(),
|
||||
4, tile.block().size * tilesize /2f + Mathf.absin(Timers.time(), 3f, 1f));
|
||||
4, tile.block().size * tilesize /2f * (1f-progress) + Mathf.absin(Timers.time(), 3f, 1f));
|
||||
}else{
|
||||
Draw.color("accent");
|
||||
Lines.stroke((1f-request.progress));
|
||||
Lines.poly(request.x * tilesize + request.recipe.result.getPlaceOffset().x,
|
||||
request.y * tilesize + request.recipe.result.getPlaceOffset().y,
|
||||
4, request.recipe.result.size * tilesize /2f + Mathf.absin(Timers.time(), 3f, 1f));
|
||||
}
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user