Launch animation

This commit is contained in:
Anuken
2020-06-01 23:17:55 -04:00
parent 69d0751e65
commit 789cc3cdb9
12 changed files with 136 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ mindustry.entities.comp.PlayerComp=8
mindustry.entities.comp.PuddleComp=9 mindustry.entities.comp.PuddleComp=9
mindustry.entities.comp.TileComp=10 mindustry.entities.comp.TileComp=10
mindustry.type.Weather.WeatherComp=11 mindustry.type.Weather.WeatherComp=11
mindustry.world.blocks.campaign.CoreLauncher.LaunchCoreComp=20
mindustry.world.blocks.campaign.LaunchPad.LaunchPayloadComp=12 mindustry.world.blocks.campaign.LaunchPad.LaunchPayloadComp=12
oculon=13 oculon=13
phantom=14 phantom=14

View File

@@ -0,0 +1 @@
{fields:[{name:lifetime,type:float,size:4},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@@ -0,0 +1 @@
{version:1,fields:[{name:block,type:mindustry.world.Block,size:-1},{name:lifetime,type:float,size:4},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@@ -0,0 +1 @@
{version:2,fields:[{name:block,type:mindustry.world.Block,size:-1},{name:lifetime,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@@ -83,6 +83,8 @@ public class Vars implements Loadable{
public static final float turnDuration = 5 * Time.toMinutes; public static final float turnDuration = 5 * Time.toMinutes;
/** min armor fraction damage; e.g. 0.05 = at least 5% damage */ /** min armor fraction damage; e.g. 0.05 = at least 5% damage */
public static final float minArmorDamage = 0.05f; public static final float minArmorDamage = 0.05f;
/** launch animation duration */
public static final float launchDuration = 140f;
/** tile used in certain situations, instead of null */ /** tile used in certain situations, instead of null */
public static Tile emptyTile; public static Tile emptyTile;
/** for map generator dialog */ /** for map generator dialog */

View File

@@ -1786,8 +1786,10 @@ public class Blocks implements ContentList{
coreSilo = new CoreLauncher("core-silo"){{ coreSilo = new CoreLauncher("core-silo"){{
requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150)); requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150));
size = 5; size = 5;
itemCapacity = 1000; itemCapacity = 500;
hasPower = true; hasPower = true;
consumes.items(ItemStack.with(Items.copper, 500));
consumes.power(4f); consumes.power(4f);
}}; }};

View File

@@ -180,6 +180,12 @@ public class Fx{
Fill.circle(e.x, e.y, (1f + 6f * e.rotation) - e.fin()*2f); Fill.circle(e.x, e.y, (1f + 6f * e.rotation) - e.fin()*2f);
}), }),
rocketSmokeLarge = new Effect(220, e -> {
color(Color.gray);
alpha(Mathf.clamp(e.fout()*1.6f - Interp.pow3In.apply(e.rotation)*1.2f));
Fill.circle(e.x, e.y, (1f + 6f * e.rotation * 1.3f) - e.fin()*2f);
}),
magmasmoke = new Effect(110, e -> { magmasmoke = new Effect(110, e -> {
color(Color.gray); color(Color.gray);
Fill.circle(e.x, e.y, e.fslope() * 6f); Fill.circle(e.x, e.y, e.fslope() * 6f);

View File

@@ -62,11 +62,6 @@ public abstract class UnlockableContent extends MappableContent{
return false; return false;
} }
/** Override to make content always unlocked. */
public boolean alwaysUnlocked(){
return alwaysUnlocked;
}
public final boolean unlocked(){ public final boolean unlocked(){
return Vars.data.isUnlocked(this); return Vars.data.isUnlocked(this);
} }

View File

@@ -128,7 +128,7 @@ public class GlobalData{
/** Returns whether or not this piece of content is unlocked yet. */ /** Returns whether or not this piece of content is unlocked yet. */
public boolean isUnlocked(UnlockableContent content){ public boolean isUnlocked(UnlockableContent content){
return content.alwaysUnlocked() || unlocked.contains(content.name); return content.alwaysUnlocked || unlocked.contains(content.name);
} }
/** /**
@@ -137,7 +137,7 @@ public class GlobalData{
* Results are not saved until you call {@link #save()}. * Results are not saved until you call {@link #save()}.
*/ */
public void unlockContent(UnlockableContent content){ public void unlockContent(UnlockableContent content){
if(content.alwaysUnlocked()) return; if(content.alwaysUnlocked) return;
//fire unlock event so other classes can use it //fire unlock event so other classes can use it
if(unlocked.add(content.name)){ if(unlocked.add(content.name)){

View File

@@ -22,6 +22,7 @@ import mindustry.graphics.g3d.PlanetRenderer.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.type.Sector.*; import mindustry.type.Sector.*;
import mindustry.ui.*; import mindustry.ui.*;
import mindustry.world.blocks.campaign.CoreLauncher.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
import static mindustry.graphics.g3d.PlanetRenderer.*; import static mindustry.graphics.g3d.PlanetRenderer.*;
@@ -35,6 +36,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
private int launchRange; private int launchRange;
private float zoom = 1f, selectAlpha = 1f; private float zoom = 1f, selectAlpha = 1f;
private @Nullable Sector selected, hovered, launchSector; private @Nullable Sector selected, hovered, launchSector;
private CoreLauncherEntity launcher;
private Mode mode = look; private Mode mode = look;
public PlanetDialog(){ public PlanetDialog(){
@@ -96,7 +98,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
return super.show(); return super.show();
} }
public void show(Sector sector, int range){ public void show(Sector sector, int range, CoreLauncherEntity launcher){
this.launcher = launcher;
selected = null; selected = null;
hovered = null; hovered = null;
@@ -193,6 +196,9 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
} }
void setup(){ void setup(){
zoom = planets.zoom = 1f;
selectAlpha = 1f;
cont.clear(); cont.clear();
titleTable.remove(); titleTable.remove();
@@ -324,8 +330,18 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
ui.showInfo("You need a naval loadout to launch here."); ui.showInfo("You need a naval loadout to launch here.");
return; return;
} }
control.playSector(sector);
hide(); hide();
if(mode == launch){
launcher.launch();
zoom = 0.5f;
ui.hudfrag.showLaunchDirect();
Time.runTask(launchDuration, () -> control.playSector(sector));
}else{
control.playSector(sector);
}
}).growX().padTop(2f).height(50f).minWidth(170f); }).growX().padTop(2f).height(50f).minWidth(170f);
} }

View File

@@ -509,6 +509,14 @@ public class HudFragment extends Fragment{
} }
} }
public void showLaunchDirect(){
Image image = new Image();
image.getColor().a = 0f;
image.setFillParent(true);
image.actions(Actions.fadeIn(launchDuration / 60f, Interp.pow2In), Actions.delay(8f / 60f), Actions.remove());
Core.scene.add(image);
}
public void showLaunch(){ public void showLaunch(){
Image image = new Image(); Image image = new Image();
image.getColor().a = 0f; image.getColor().a = 0f;

View File

@@ -1,9 +1,15 @@
package mindustry.world.blocks.campaign; package mindustry.world.blocks.campaign;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.*; import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.ui.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.meta.*;
import static mindustry.Vars.state; import static mindustry.Vars.state;
@@ -16,7 +22,8 @@ public class CoreLauncher extends Block{
hasItems = true; hasItems = true;
configurable = true; configurable = true;
update = true; update = true;
buildPlaceability = BuildPlaceability.sectorCaptured; //will be enabled when needed (if at all)
//buildPlaceability = BuildPlaceability.sectorCaptured;
} }
public class CoreLauncherEntity extends TileEntity{ public class CoreLauncherEntity extends TileEntity{
@@ -28,10 +35,92 @@ public class CoreLauncher extends Block{
@Override @Override
public boolean configTapped(){ public boolean configTapped(){
if(state.isCampaign()){
Vars.ui.planet.show(state.rules.sector, range); if(state.isCampaign() && consValid()){
Vars.ui.planet.show(state.rules.sector, range, this);
cons.trigger();
} }
return false; return false;
} }
public void launch(){
LaunchCorec ent = LaunchCoreEntity.create();
ent.set(this);
ent.block(Blocks.coreShard);
ent.lifetime(Vars.launchDuration);
ent.add();
}
}
@EntityDef(value = LaunchCorec.class, serialize = false)
@Component
static abstract class LaunchCoreComp implements Drawc, Timedc{
@Import float x, y;
transient Interval in = new Interval();
Block block;
@Override
public void draw(){
float alpha = fout(Interp.pow5Out);
float scale = (1f - alpha) * 1.4f + 1f;
float cx = cx(), cy = cy();
float rotation = fin() * (140f + Mathf.randomSeedRange(id(), 50f));
Draw.z(Layer.effect + 0.001f);
Draw.color(Pal.engine);
float rad = 0.2f + fslope();
float rscl = (block.size - 1) * 0.85f;
Fill.light(cx, cy, 10, 25f * (rad + scale-1f) * rscl, Tmp.c2.set(Pal.engine).a(alpha), Tmp.c1.set(Pal.engine).a(0f));
Draw.alpha(alpha);
for(int i = 0; i < 4; i++){
Drawf.tri(cx, cy, 6f * rscl, 40f * (rad + scale-1f) * rscl, i * 90f + rotation);
}
Draw.color();
Draw.z(Layer.weather - 1);
TextureRegion region = block.icon(Cicon.full);
float rw = region.getWidth() * Draw.scl * scale, rh = region.getHeight() * Draw.scl * scale;
Draw.alpha(alpha);
Draw.rect(region, cx, cy, rw, rh, rotation - 45);
Tmp.v1.trns(225f, fin(Interp.pow3In) * 250f);
Draw.z(Layer.flyingUnit + 1);
Draw.color(0, 0, 0, 0.22f * alpha);
Draw.rect(region, cx + Tmp.v1.x, cy + Tmp.v1.y, rw, rh, rotation - 45);
Draw.reset();
}
float cx(){
return x + fin(Interp.pow2In) * (12f + Mathf.randomSeedRange(id() + 3, 4f));
}
float cy(){
return y + fin(Interp.pow5In) * (100f + Mathf.randomSeedRange(id() + 2, 30f));
}
@Override
public void update(){
float r = 4f;
if(in.get(3f - fin()*2f)){
Fx.rocketSmokeLarge.at(cx() + Mathf.range(r), cy() + Mathf.range(r), fin());
}
}
@Override
public void remove(){
//TODO something
}
} }
} }