Deploy animation

This commit is contained in:
Anuken
2019-09-11 16:54:18 -04:00
parent d9c7665aca
commit 44842d3221
5 changed files with 92 additions and 16 deletions
+15 -14
View File
@@ -1,19 +1,17 @@
package io.anuke.mindustry.content; package io.anuke.mindustry.content;
import io.anuke.arc.Core; import io.anuke.arc.*;
import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.Angles; import io.anuke.arc.math.*;
import io.anuke.arc.math.Mathf; import io.anuke.arc.util.*;
import io.anuke.arc.util.Tmp; import io.anuke.mindustry.entities.Effects.*;
import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.entities.effect.GroundEffectEntity.*;
import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect; import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.entities.type.BaseUnit; import io.anuke.mindustry.game.*;
import io.anuke.mindustry.game.ContentList; import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.graphics.Drawf; import io.anuke.mindustry.type.Item.*;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Item.Icon;
import static io.anuke.mindustry.Vars.tilesize; import static io.anuke.mindustry.Vars.tilesize;
@@ -32,7 +30,7 @@ public class Fx implements ContentList{
bigShockwave, nuclearShockwave, explosion, blockExplosion, blockExplosionSmoke, shootSmall, shootHeal, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke, bigShockwave, nuclearShockwave, explosion, blockExplosion, blockExplosionSmoke, shootSmall, shootHeal, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke,
shootBigSmoke2, shootSmallFlame, shootPyraFlame, shootLiquid, shellEjectSmall, shellEjectMedium, shootBigSmoke2, shootSmallFlame, shootPyraFlame, shootLiquid, shellEjectSmall, shellEjectMedium,
shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot, shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot,
unitSpawn, spawnShockwave, magmasmoke, impactShockwave, impactcloud, impactsmoke, dynamicExplosion, padlaunch, commandSend; unitSpawn, spawnShockwave, magmasmoke, impactShockwave, impactcloud, impactsmoke, dynamicExplosion, padlaunch, commandSend, coreLand;
@Override @Override
public void load(){ public void load(){
@@ -1209,5 +1207,8 @@ public class Fx implements ContentList{
Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90); Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90);
Draw.reset(); Draw.reset();
}); });
coreLand = new Effect(120f, e -> {
});
} }
} }
@@ -151,6 +151,20 @@ public class Control implements ApplicationListener, Loadable{
Events.on(ZoneConfigureCompleteEvent.class, e -> { Events.on(ZoneConfigureCompleteEvent.class, e -> {
ui.hudfrag.showToast(Core.bundle.format("zone.config.complete", e.zone.configureWave)); ui.hudfrag.showToast(Core.bundle.format("zone.config.complete", e.zone.configureWave));
}); });
Events.on(Trigger.newGame, () -> {
TileEntity core = player.getClosestCore();
if(core == null) return;
app.post(() -> ui.hudfrag.showLand());
renderer.zoomIn(Fx.coreLand.lifetime);
app.post(() -> Effects.effect(Fx.coreLand, core.x, core.y, 0, core.block));
Time.run(Fx.coreLand.lifetime, () -> {
Effects.effect(Fx.launch, core);
Effects.shake(5f, 5f, core);
});
});
} }
@Override @Override
@@ -204,6 +218,7 @@ public class Control implements ApplicationListener, Loadable{
if(settings.getBool("savecreate") && !world.isInvalidMap()){ if(settings.getBool("savecreate") && !world.isInvalidMap()){
control.saves.addSave(map.name() + " " + new SimpleDateFormat("MMM dd h:mm", Locale.getDefault()).format(new Date())); control.saves.addSave(map.name() + " " + new SimpleDateFormat("MMM dd h:mm", Locale.getDefault()).format(new Date()));
} }
Events.fire(Trigger.newGame);
}); });
} }
@@ -222,6 +237,7 @@ public class Control implements ApplicationListener, Loadable{
state.set(State.playing); state.set(State.playing);
control.saves.zoneSave(); control.saves.zoneSave();
logic.play(); logic.play();
Events.fire(Trigger.newGame);
}); });
} }
@@ -274,6 +290,7 @@ public class Control implements ApplicationListener, Loadable{
state.rules.waveSpacing = 60f * 30; state.rules.waveSpacing = 60f * 30;
state.rules.buildCostMultiplier = 0.3f; state.rules.buildCostMultiplier = 0.3f;
state.rules.tutorial = true; state.rules.tutorial = true;
Events.fire(Trigger.newGame);
}); });
} }
+43 -1
View File
@@ -22,6 +22,7 @@ import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.game.*; import io.anuke.mindustry.game.*;
import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.defense.ForceProjector.*; import io.anuke.mindustry.world.blocks.defense.ForceProjector.*;
import static io.anuke.arc.Core.*; import static io.anuke.arc.Core.*;
@@ -38,6 +39,8 @@ public class Renderer implements ApplicationListener{
private Color clearColor; private Color clearColor;
private float targetscale = Scl.scl(4); private float targetscale = Scl.scl(4);
private float camerascale = targetscale; private float camerascale = targetscale;
private float landscale = 0f, landTime;
private float minZoomScl = Scl.scl(0.01f);
private Rectangle rect = new Rectangle(), rect2 = new Rectangle(); private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
private float shakeIntensity, shaketime; private float shakeIntensity, shaketime;
@@ -99,14 +102,21 @@ public class Renderer implements ApplicationListener{
@Override @Override
public void update(){ public void update(){
//TODO hack, find source of this bug
Color.white.set(1f, 1f, 1f, 1f); Color.white.set(1f, 1f, 1f, 1f);
camerascale = Mathf.lerpDelta(camerascale, targetscale, 0.1f); camerascale = Mathf.lerpDelta(camerascale, targetscale, 0.1f);
if(landTime > 0){
landTime -= Time.delta();
landscale = Interpolation.pow5In.apply(minZoomScl, Scl.scl(4f), 1f - landTime / Fx.coreLand.lifetime);
camerascale = landscale;
}
camera.width = graphics.getWidth() / camerascale; camera.width = graphics.getWidth() / camerascale;
camera.height = graphics.getHeight() / camerascale; camera.height = graphics.getHeight() / camerascale;
if(state.is(State.menu)){ if(state.is(State.menu)){
landTime = 0f;
graphics.clear(Color.black); graphics.clear(Color.black);
}else{ }else{
Vector2 position = Tmp.v3.set(player); Vector2 position = Tmp.v3.set(player);
@@ -282,10 +292,37 @@ public class Renderer implements ApplicationListener{
playerGroup.draw(p -> !p.isDead() && !p.isLocal, Player::drawName); playerGroup.draw(p -> !p.isDead() && !p.isLocal, Player::drawName);
drawLanding();
Draw.color(); Draw.color();
Draw.flush(); Draw.flush();
} }
private void drawLanding(){
if(landTime > 0 && player.getClosestCore() != null){
float fract = landTime / Fx.coreLand.lifetime;
TileEntity entity = player.getClosestCore();
TextureRegion reg = entity.block.icon(Block.Icon.full);
float scl = Scl.scl(4f) / camerascale;
float s = reg.getWidth() * Draw.scl * scl * 4f * fract;
Draw.color(Pal.lightTrail);
Draw.rect("circle-shadow", entity.x, entity.y, s, s);
Angles.randLenVectors(1, (1f- fract), 100, 1000f * scl * (1f-fract), (x, y, fin, fout) -> {
Lines.stroke(scl * fin);
Lines.lineAngle(entity.x + x, entity.y + y, Mathf.angle(x, y), (fin * 20 + 1f) * scl);
});
Draw.color();
Draw.mixcol(Color.white, fract);
Draw.rect(reg, entity.x, entity.y, reg.getWidth() * Draw.scl * scl, reg.getHeight() * Draw.scl * scl, fract * 135f);
Draw.reset();
}
}
private void drawGroundShadows(){ private void drawGroundShadows(){
Draw.color(0, 0, 0, 0.4f); Draw.color(0, 0, 0, 0.4f);
float rad = 1.6f; float rad = 1.6f;
@@ -361,6 +398,11 @@ public class Renderer implements ApplicationListener{
clampScale(); clampScale();
} }
public void zoomIn(float duration){
landscale = minZoomScl;
landTime = duration;
}
public void takeMapScreenshot(){ public void takeMapScreenshot(){
drawGroundShadows(); drawGroundShadows();
@@ -16,7 +16,8 @@ public class EventType{
impactPower, impactPower,
thoriumReactorOverheat, thoriumReactorOverheat,
itemLaunch, itemLaunch,
fireExtinguish fireExtinguish,
newGame
} }
public static class WinEvent{} public static class WinEvent{}
@@ -520,6 +520,21 @@ public class HudFragment extends Fragment{
Core.scene.add(image); Core.scene.add(image);
} }
public void showLand(){
Image image = new Image();
image.getColor().a = 1f;
image.touchable(Touchable.disabled);
image.setFillParent(true);
image.actions(Actions.fadeOut(0.8f), Actions.remove());
image.update(() -> {
image.toFront();
if(state.is(State.menu)){
image.remove();
}
});
Core.scene.add(image);
}
private void showLaunchConfirm(){ private void showLaunchConfirm(){
FloatingDialog dialog = new FloatingDialog("$launch"); FloatingDialog dialog = new FloatingDialog("$launch");
dialog.update(() -> { dialog.update(() -> {