Launch animation
This commit is contained in:
@@ -83,6 +83,8 @@ public class Vars implements Loadable{
|
||||
public static final float turnDuration = 5 * Time.toMinutes;
|
||||
/** min armor fraction damage; e.g. 0.05 = at least 5% damage */
|
||||
public static final float minArmorDamage = 0.05f;
|
||||
/** launch animation duration */
|
||||
public static final float launchDuration = 140f;
|
||||
/** tile used in certain situations, instead of null */
|
||||
public static Tile emptyTile;
|
||||
/** for map generator dialog */
|
||||
|
||||
@@ -1786,8 +1786,10 @@ public class Blocks implements ContentList{
|
||||
coreSilo = new CoreLauncher("core-silo"){{
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150));
|
||||
size = 5;
|
||||
itemCapacity = 1000;
|
||||
itemCapacity = 500;
|
||||
hasPower = true;
|
||||
|
||||
consumes.items(ItemStack.with(Items.copper, 500));
|
||||
consumes.power(4f);
|
||||
}};
|
||||
|
||||
|
||||
@@ -180,6 +180,12 @@ public class Fx{
|
||||
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 -> {
|
||||
color(Color.gray);
|
||||
Fill.circle(e.x, e.y, e.fslope() * 6f);
|
||||
|
||||
@@ -62,11 +62,6 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Override to make content always unlocked. */
|
||||
public boolean alwaysUnlocked(){
|
||||
return alwaysUnlocked;
|
||||
}
|
||||
|
||||
public final boolean unlocked(){
|
||||
return Vars.data.isUnlocked(this);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class GlobalData{
|
||||
|
||||
/** Returns whether or not this piece of content is unlocked yet. */
|
||||
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()}.
|
||||
*/
|
||||
public void unlockContent(UnlockableContent content){
|
||||
if(content.alwaysUnlocked()) return;
|
||||
if(content.alwaysUnlocked) return;
|
||||
|
||||
//fire unlock event so other classes can use it
|
||||
if(unlocked.add(content.name)){
|
||||
|
||||
@@ -22,6 +22,7 @@ import mindustry.graphics.g3d.PlanetRenderer.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.type.Sector.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.campaign.CoreLauncher.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.graphics.g3d.PlanetRenderer.*;
|
||||
@@ -35,6 +36,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
private int launchRange;
|
||||
private float zoom = 1f, selectAlpha = 1f;
|
||||
private @Nullable Sector selected, hovered, launchSector;
|
||||
private CoreLauncherEntity launcher;
|
||||
private Mode mode = look;
|
||||
|
||||
public PlanetDialog(){
|
||||
@@ -96,7 +98,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
return super.show();
|
||||
}
|
||||
|
||||
public void show(Sector sector, int range){
|
||||
public void show(Sector sector, int range, CoreLauncherEntity launcher){
|
||||
this.launcher = launcher;
|
||||
selected = null;
|
||||
hovered = null;
|
||||
|
||||
@@ -193,6 +196,9 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
zoom = planets.zoom = 1f;
|
||||
selectAlpha = 1f;
|
||||
|
||||
cont.clear();
|
||||
titleTable.remove();
|
||||
|
||||
@@ -324,8 +330,18 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
ui.showInfo("You need a naval loadout to launch here.");
|
||||
return;
|
||||
}
|
||||
control.playSector(sector);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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(){
|
||||
Image image = new Image();
|
||||
image.getColor().a = 0f;
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package mindustry.world.blocks.campaign;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.state;
|
||||
|
||||
@@ -16,7 +22,8 @@ public class CoreLauncher extends Block{
|
||||
hasItems = true;
|
||||
configurable = true;
|
||||
update = true;
|
||||
buildPlaceability = BuildPlaceability.sectorCaptured;
|
||||
//will be enabled when needed (if at all)
|
||||
//buildPlaceability = BuildPlaceability.sectorCaptured;
|
||||
}
|
||||
|
||||
public class CoreLauncherEntity extends TileEntity{
|
||||
@@ -28,10 +35,92 @@ public class CoreLauncher extends Block{
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user