Added basic respawning
This commit is contained in:
@@ -5,7 +5,6 @@ import arc.graphics.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.pooling.*;
|
import arc.util.pooling.*;
|
||||||
@@ -45,7 +44,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
|||||||
return unit instanceof Minerc;
|
return unit instanceof Minerc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Tilec closestCore(){
|
public @Nullable CoreEntity closestCore(){
|
||||||
return state.teams.closestCore(x(), y(), team);
|
return state.teams.closestCore(x(), y(), team);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,17 +63,14 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
|||||||
clearUnit();
|
clearUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoreEntity core = closestCore();
|
||||||
|
|
||||||
if(!dead()){
|
if(!dead()){
|
||||||
x(unit.x());
|
x(unit.x());
|
||||||
y(unit.y());
|
y(unit.y());
|
||||||
unit.team(team);
|
unit.team(team);
|
||||||
}else if(!team.cores().isEmpty()){
|
}else if(core != null){
|
||||||
//try to respawn
|
core.requestSpawn((Playerc)this);
|
||||||
Array<CoreEntity> cores = team.cores();
|
|
||||||
|
|
||||||
if(!cores.isEmpty()){
|
|
||||||
//TODO respawning
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
textFadeTime -= Time.delta() / (60 * 5);
|
textFadeTime -= Time.delta() / (60 * 5);
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ import arc.*;
|
|||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import mindustry.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
|
|
||||||
import static mindustry.Vars.renderer;
|
import static mindustry.Vars.renderer;
|
||||||
|
|
||||||
@@ -87,5 +92,63 @@ public class Drawf{
|
|||||||
Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length / 2f, width, length, width / 2f, oy, rotation - 90);
|
Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length / 2f, width, length, width / 2f, oy, rotation - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void drawRespawn(Tilec tile, float heat, float progress, float time, UnitType to, @Nullable Playerc player){
|
||||||
|
float x = tile.x(), y = tile.y();
|
||||||
|
progress = Mathf.clamp(progress);
|
||||||
|
|
||||||
|
Draw.color(Pal.darkMetal);
|
||||||
|
Lines.stroke(2f * heat);
|
||||||
|
Fill.poly(x, y, 4, 10f * heat);
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
if(player != null){
|
||||||
|
TextureRegion region = to.icon(Cicon.full);
|
||||||
|
|
||||||
|
Draw.color(0f, 0f, 0f, 0.4f * progress);
|
||||||
|
Draw.rect("circle-shadow", x, y, 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, x, y);
|
||||||
|
Draw.shader();
|
||||||
|
|
||||||
|
Draw.color(Pal.accentBack);
|
||||||
|
|
||||||
|
float pos = Mathf.sin(time, 6f, 8f);
|
||||||
|
|
||||||
|
Lines.lineAngleCenter(x + pos, y, 90, 16f - Math.abs(pos) * 2f);
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Lines.stroke(2f * heat);
|
||||||
|
|
||||||
|
Draw.color(Pal.accentBack);
|
||||||
|
Lines.poly(x, y, 4, 8f * heat);
|
||||||
|
|
||||||
|
float oy = -7f, len = 6f * heat;
|
||||||
|
Lines.stroke(5f);
|
||||||
|
Draw.color(Pal.darkMetal);
|
||||||
|
Lines.line(x - len, y + oy, x + len, y + oy, CapStyle.none);
|
||||||
|
for(int i : Mathf.signs){
|
||||||
|
Fill.tri(x + len * i, y + oy - Lines.getStroke()/2f, x + len * i, y + oy + Lines.getStroke()/2f, x + (len + Lines.getStroke() * heat) * i, y + oy);
|
||||||
|
}
|
||||||
|
|
||||||
|
Lines.stroke(3f);
|
||||||
|
Draw.color(Pal.accent);
|
||||||
|
Lines.line(x - len, y + oy, x - len + len*2 * progress, y + oy, CapStyle.none);
|
||||||
|
for(int i : Mathf.signs){
|
||||||
|
Fill.tri(x + len * i, y + oy - Lines.getStroke()/2f, x + len * i, y + oy + Lines.getStroke()/2f, x + (len + Lines.getStroke() * heat) * i, y + oy);
|
||||||
|
}
|
||||||
|
Draw.reset();
|
||||||
|
|
||||||
|
if(Vars.net.active() && player != null){
|
||||||
|
tile.block().drawPlaceText(player.name(), tile.tileX(), tile.tileY() - (Math.max((tile.block().size-1)/2, 0)), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import mindustry.world.modules.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class CoreBlock extends StorageBlock{
|
public class CoreBlock extends StorageBlock{
|
||||||
public UnitType mech = UnitTypes.starter;
|
public UnitType unitType = UnitTypes.phantom;
|
||||||
|
|
||||||
public CoreBlock(String name){
|
public CoreBlock(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -35,17 +35,19 @@ public class CoreBlock extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(called = Loc.server)
|
@Remote(called = Loc.server)
|
||||||
public static void onUnitRespawn(Tilec tile, Playerc player){
|
public static void onPlayerSpawn(Tile tile, Playerc player){
|
||||||
if(player == null || tile == null) return;
|
if(player == null || tile == null) return;
|
||||||
|
|
||||||
//TODO really fix
|
CoreEntity entity = tile.ent();
|
||||||
Fx.spawn.at(tile);
|
CoreBlock block = (CoreBlock)tile.block();
|
||||||
//progress = 0;
|
Fx.spawn.at(entity);
|
||||||
//spawnPlayer = player;
|
entity.progress = 0;
|
||||||
//TODO fix
|
|
||||||
//spawnPlayer.onRespawn(tile);
|
Unitc unit = block.unitType.create(tile.team());
|
||||||
//spawnPlayer.applyImpulse(0, 8f);
|
unit.set(entity);
|
||||||
//spawnPlayer = null;
|
unit.impulse(0f, 8f);
|
||||||
|
unit.controller(player);
|
||||||
|
unit.add();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,10 +69,21 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
public class CoreEntity extends TileEntity{
|
public class CoreEntity extends TileEntity{
|
||||||
// protected Playerc spawnPlayer;
|
// protected Playerc spawnPlayer;
|
||||||
//protected float progress;
|
protected float time, heat, progress;
|
||||||
protected float time;
|
|
||||||
protected float heat;
|
|
||||||
protected int storageCapacity;
|
protected int storageCapacity;
|
||||||
|
protected boolean shouldBuild;
|
||||||
|
protected Playerc lastRequested;
|
||||||
|
|
||||||
|
public void requestSpawn(Playerc player){
|
||||||
|
shouldBuild = true;
|
||||||
|
if(lastRequested == null){
|
||||||
|
lastRequested = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(progress >= 1f){
|
||||||
|
Call.onPlayerSpawn(tile, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawLight(){
|
public void drawLight(){
|
||||||
@@ -183,8 +196,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void drawLayer(){
|
public void drawLayer(){
|
||||||
if(heat > 0.001f){
|
if(heat > 0.001f){
|
||||||
//TODO implement
|
Drawf.drawRespawn(this, heat, progress, time, unitType, lastRequested);
|
||||||
//RespawnBlock.drawRespawn(tile, heat, progress, time, spawnPlayer, mech);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,31 +212,23 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
//TODO implement
|
|
||||||
/*
|
if(shouldBuild){
|
||||||
if(spawnPlayer != null){
|
heat = Mathf.lerpDelta(heat, 1f, 0.1f);
|
||||||
if(!spawnPlayer.dead() || !spawnPlayer.isAdded()){
|
time += delta();
|
||||||
spawnPlayer = null;
|
progress += 1f / state.rules.respawnTime * delta();
|
||||||
return;
|
}else{
|
||||||
|
progress = 0f;
|
||||||
|
heat = Mathf.lerpDelta(heat, 0f, 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnPlayer.set(x, y);
|
shouldBuild = false;
|
||||||
heat = Mathf.lerpDelta(heat, 1f, 0.1f);
|
lastRequested = null;
|
||||||
time += delta();
|
|
||||||
progress += 1f / state.rules.respawnTime * delta();
|
|
||||||
|
|
||||||
if(progress >= 1f){
|
|
||||||
Call.onUnitRespawn(tile, spawnPlayer);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
heat = Mathf.lerpDelta(heat, 0f, 0.1f);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldActiveSound(){
|
public boolean shouldActiveSound(){
|
||||||
//TODO
|
return shouldBuild;
|
||||||
return false;//spawnPlayer != null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user