Better spawn animations

This commit is contained in:
Anuken
2019-09-03 22:55:46 -04:00
parent a7bfe18f4a
commit dc21adfda5
4 changed files with 93 additions and 82 deletions

View File

@@ -251,7 +251,7 @@ public class Block extends BlockStorage{
public void drawPlace(int x, int y, int rotation, boolean valid){
}
protected float drawPlaceText(String text, int x, int y, boolean valid){
public float drawPlaceText(String text, int x, int y, boolean valid){
if(renderer.pixelator.enabled()) return 0;
Color color = valid ? Pal.accent : Pal.remove;

View File

@@ -0,0 +1,69 @@
package io.anuke.mindustry.world.blocks;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.*;
import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*;
public class RespawnBlock{
public static void drawRespawn(Tile tile, float heat, float progress, float time, Player player, Mech to){
Draw.color(Pal.darkMetal);
Lines.stroke(2f * heat);
Fill.poly(tile.drawx(), tile.drawy(), 4, 10f * heat);
Draw.reset();
if(player != null){
TextureRegion region = to.iconRegion;
Draw.color(0f, 0f, 0f, 0.4f * progress);
Draw.rect("circle-shadow", tile.drawx(), tile.drawy(), region.getWidth() / 3f, region.getWidth() / 3f);
Draw.color();
Shaders.build.region = region;
Shaders.build.progress = progress;
Shaders.build.color.set(Pal.accent);
Shaders.build.time = -time / 10f;
Draw.shader(Shaders.build, true);
Draw.rect(region, tile.drawx(), tile.drawy());
Draw.shader();
Draw.color(Pal.accentBack);
float pos = Mathf.sin(time, 6f, 8f);
Lines.lineAngleCenter(tile.drawx() + pos, tile.drawy(), 90, 16f - Math.abs(pos) * 2f);
Draw.reset();
}
Lines.stroke(2f * heat);
Draw.color(Pal.accentBack);
Lines.poly(tile.drawx(), tile.drawy(), 4, 8f * heat);
float oy = -7f, len = 6f * heat;
Lines.stroke(5f);
Draw.color(Pal.darkMetal);
Lines.line(tile.drawx() - len, tile.drawy() + oy, tile.drawx() + len, tile.drawy() + oy, CapStyle.none);
for(int i : Mathf.signs){
Fill.tri(tile.drawx() + len * i, tile.drawy() + oy - Lines.getStroke()/2f, tile.drawx() + len * i, tile.drawy() + oy + Lines.getStroke()/2f, tile.drawx() + (len + Lines.getStroke() * heat) * i, tile.drawy() + oy);
}
Lines.stroke(3f);
Draw.color(Pal.accent);
Lines.line(tile.drawx() - len, tile.drawy() + oy, tile.drawx() - len + len*2 * progress, tile.drawy() + oy, CapStyle.none);
for(int i : Mathf.signs){
Fill.tri(tile.drawx() + len * i, tile.drawy() + oy - Lines.getStroke()/2f, tile.drawx() + len * i, tile.drawy() + oy + Lines.getStroke()/2f, tile.drawx() + (len + Lines.getStroke() * heat) * i, tile.drawy() + oy);
}
Draw.reset();
if(Net.server() && player != null){
tile.block().drawPlaceText(player.name, tile.x, tile.y - (Math.max((tile.block().size-1)/2, 0)), true);
}
}
}

View File

@@ -3,9 +3,7 @@ package io.anuke.mindustry.world.blocks.storage;
import io.anuke.annotations.Annotations.*;
import io.anuke.arc.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.traits.*;
@@ -16,6 +14,7 @@ import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.meta.*;
import static io.anuke.mindustry.Vars.*;
@@ -32,6 +31,7 @@ public class CoreBlock extends StorageBlock{
flags = EnumSet.of(BlockFlag.target, BlockFlag.producer);
activeSound = Sounds.respawning;
activeSoundVolume = 1f;
layer = Layer.overlay;
}
@Remote(called = Loc.server)
@@ -84,41 +84,11 @@ public class CoreBlock extends StorageBlock{
}
@Override
public void draw(Tile tile){
public void drawLayer(Tile tile){
CoreEntity entity = tile.entity();
Draw.rect(region, tile.drawx(), tile.drawy());
if(entity.heat > 0){
Draw.color(Pal.darkMetal);
Lines.stroke(2f * entity.heat);
Lines.poly(tile.drawx(), tile.drawy(), 4, 8f * entity.heat);
Draw.reset();
}
if(entity.spawnPlayer != null){
Unit player = entity.spawnPlayer;
TextureRegion region = player.getIconRegion();
Shaders.build.region = region;
Shaders.build.progress = entity.progress;
Shaders.build.color.set(Pal.accent);
Shaders.build.time = -entity.time / 10f;
Draw.shader(Shaders.build, true);
Draw.rect(region, tile.drawx(), tile.drawy());
Draw.shader();
Draw.color(Pal.accent);
Lines.lineAngleCenter(
tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size),
tile.drawy(),
90,
size * Vars.tilesize / 2f);
Draw.reset();
if(entity.heat > 0.001f){
RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.spawnPlayer, mech);
}
}

View File

@@ -1,32 +1,24 @@
package io.anuke.mindustry.world.blocks.units;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.arc.Core;
import io.anuke.annotations.Annotations.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.math.geom.Geometry;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.entities.Effects;
import io.anuke.mindustry.entities.traits.SpawnerTrait;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.entities.type.TileEntity;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.type.Mech;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.meta.StatUnit;
import io.anuke.arc.math.*;
import io.anuke.arc.math.geom.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.traits.*;
import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.meta.*;
import java.io.*;
import static io.anuke.mindustry.Vars.mobile;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.*;
public class MechPad extends Block{
protected Mech mech;
@@ -37,6 +29,7 @@ public class MechPad extends Block{
update = true;
solid = false;
hasPower = true;
layer = Layer.overlay;
}
@Override
@@ -110,32 +103,11 @@ public class MechPad extends Block{
}
@Override
public void draw(Tile tile){
public void drawLayer(Tile tile){
MechFactoryEntity entity = tile.entity();
Draw.rect(Core.atlas.find(name), tile.drawx(), tile.drawy());
if(entity.player != null){
TextureRegion region = (!entity.sameMech && entity.player.mech == mech ? Mechs.starter.iconRegion : mech.iconRegion);
Shaders.build.region = region;
Shaders.build.progress = entity.progress;
Shaders.build.time = -entity.time / 5f;
Shaders.build.color.set(Pal.accent);
Draw.shader(Shaders.build);
Draw.rect(region, tile.drawx(), tile.drawy());
Draw.shader();
Draw.color(Pal.accent);
Lines.lineAngleCenter(
tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size),
tile.drawy(),
90,
size * Vars.tilesize / 2f + 1f);
Draw.reset();
RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.player, (!entity.sameMech && entity.player.mech == mech ? Mechs.starter : mech));
}
}