Launch button

This commit is contained in:
Anuken
2019-01-17 23:17:17 -05:00
parent 22a6c4e8af
commit 48facc0978
18 changed files with 369 additions and 476 deletions

View File

@@ -24,14 +24,15 @@ public class Fx implements ContentList{
vtolHover, unitDrop, unitPickup, unitLand, pickup, healWave, heal, landShock, reactorsmoke, nuclearsmoke, nuclearcloud,
redgeneratespark, generatespark, fuelburn, plasticburn, pulverize, pulverizeRed, pulverizeRedder, pulverizeSmall, pulverizeMedium,
producesmoke, smeltsmoke, formsmoke, blastsmoke, lava, doorclose, dooropen, dooropenlarge, doorcloselarge, purify, purifyoil, purifystone, generate,
mine, mineBig, mineHuge, smelt, teleportActivate, teleport, teleportOut, ripple, bubble, commandSend,
mine, mineBig, mineHuge, smelt, teleportActivate, teleport, teleportOut, ripple, bubble, launch,
healBlock, healBlockFull, healWaveMend, overdriveWave, overdriveBlockFull, shieldBreak, hitBulletSmall, hitFuse,
hitBulletBig, hitFlameSmall, hitLiquid, hitLaser, hitLancer, hitMeltdown, despawn, flakExplosion, blastExplosion,
plasticExplosion, artilleryTrail, incendTrail, missileTrail, absorb, flakExplosionBig, plasticExplosionFlak, burning, fire,
fireSmoke, steam, fireballsmoke, ballfire, freezing, melting, wet, oily, overdriven, dropItem, shockwave,
bigShockwave, nuclearShockwave, explosion, blockExplosion, blockExplosionSmoke, shootSmall, shootHeal, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke,
shootBigSmoke2, shootSmallFlame, shootLiquid, shellEjectSmall, shellEjectMedium,
shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot;
shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot,
launchFull;
@Override
public void load(){
@@ -1060,7 +1061,7 @@ public class Fx implements ContentList{
Draw.reset();
});
commandSend = new Effect(28, e -> {
launch = new Effect(28, e -> {
Draw.color(Palette.command);
Lines.stroke(e.fout() * 2f);
Lines.poly(e.x, e.y, 40, 4f + e.finpow() * 120f);
@@ -1108,5 +1109,12 @@ public class Fx implements ContentList{
Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90);
Draw.reset();
});
launchFull = new Effect(60, 9999999999f, e -> {
Draw.color();
Draw.alpha(e.fslope());
Fill.rect(Core.camera.position.x, Core.camera.position.y, Core.camera.width + 10, Core.camera.height + 10);
Draw.reset();
});
}
}

View File

@@ -16,7 +16,7 @@ public class Liquids implements ContentList{
effect = StatusEffects.wet;
}};
slag = new Liquid("slag", Color.valueOf("e37341")){{
slag = new Liquid("slag", Color.valueOf("ffcd66")){{
temperature = 1f;
viscosity = 0.8f;
tier = 2;

View File

@@ -20,7 +20,7 @@ public class Weapons implements ContentList{
blasterSmall = new Weapon("blaster"){{
length = 1.5f;
reload = 15f;
reload = 20f;
roundrobin = true;
ejectEffect = Fx.shellEjectSmall;
ammo = Bullets.standardCopper;
@@ -28,7 +28,7 @@ public class Weapons implements ContentList{
glaiveBlaster = new Weapon("bomber"){{
length = 1.5f;
reload = 10f;
reload = 13f;
roundrobin = true;
ejectEffect = Fx.shellEjectSmall;
ammo = Bullets.standardGlaive;
@@ -54,7 +54,7 @@ public class Weapons implements ContentList{
missiles = new Weapon("missiles"){{
length = 1.5f;
reload = 60f;
reload = 70f;
shots = 4;
inaccuracy = 2f;
roundrobin = true;

View File

@@ -18,6 +18,7 @@ public class Zones implements ContentList{
deployCost = ItemStack.with(Items.copper, 100);
startingItems = ItemStack.with(Items.copper, 50);
alwaysUnlocked = true;
conditionWave = 10;
rules = () -> new Rules(){{
waves = true;
waveTimer = true;

View File

@@ -165,7 +165,7 @@ public class ContentLoader{
}
if(id >= contentMap[type.ordinal()].size || id < 0){
throw new RuntimeException("No " + type.name() + " with ID '" + id + "' found!");
return null;
}
return (T)contentMap[type.ordinal()].get(id);
}

View File

@@ -16,7 +16,7 @@ public class GameState{
/**Wave countdown in ticks.*/
public float wavetime;
/**Whether the game is in game over state.*/
public boolean gameOver = false;
public boolean gameOver = false, launched = false;
/**The current game rules.*/
public Rules rules = new Rules();
/**Statistics for this save/game. Displayed after game over.*/
@@ -38,7 +38,7 @@ public class GameState{
}
public boolean isPaused(){
return is(State.paused) && !Net.active();
return (is(State.paused) || gameOver) && !Net.active();
}
public boolean is(State astate){

View File

@@ -62,7 +62,7 @@ public class Logic implements ApplicationListener{
public void reset(){
state.wave = 1;
state.wavetime = state.rules.waveSpacing;
state.gameOver = false;
state.gameOver = state.launched = false;
state.teams = new Teams();
state.rules = new Rules();
state.stats = new Stats();

View File

@@ -5,17 +5,21 @@ import io.anuke.arc.Core;
import io.anuke.arc.Events;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.IntArray;
import io.anuke.arc.collection.ObjectSet.ObjectSetIterator;
import io.anuke.arc.entities.Effects;
import io.anuke.arc.entities.EntityQuery;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.math.geom.Geometry;
import io.anuke.arc.math.geom.Point2;
import io.anuke.arc.util.Log;
import io.anuke.arc.util.Structs;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.Tmp;
import io.anuke.mindustry.ai.BlockIndexer;
import io.anuke.mindustry.ai.Pathfinder;
import io.anuke.mindustry.ai.WaveSpawner;
import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.EventType.TileChangeEvent;
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
@@ -27,6 +31,7 @@ import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
import io.anuke.mindustry.maps.Maps;
import io.anuke.mindustry.maps.generators.Generator;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Zone;
import io.anuke.mindustry.world.Block;
@@ -195,6 +200,24 @@ public class World implements ApplicationListener{
return generating;
}
public void launchZone(){
Effects.effect(Fx.launchFull, 0, 0);
for(Tile tile : new ObjectSetIterator<>(state.teams.get(defaultTeam).cores)){
Effects.effect(Fx.launch, tile);
}
Time.runTask(30f, () -> {
for(Tile tile : new ObjectSetIterator<>(state.teams.get(defaultTeam).cores)){
for(Item item : content.items()){
data.addItem(item, tile.entity.items.get(item));
}
world.removeBlock(tile);
}
state.launched = true;
});
}
public boolean isZone(){
return getZone() != null;
}

View File

@@ -26,7 +26,7 @@ public class Zone extends UnlockableContent{
/**Whether this zone has met its condition; if true, the player can leave.*/
public boolean metCondition(){
return state.wave > conditionWave;
return state.wave >= conditionWave;
}
@Override

View File

@@ -22,6 +22,7 @@ public class GameOverDialog extends FloatingDialog{
}
void rebuild(){
title.setText(state.launched ? "$launch.title" : "$gameover");
buttons.clear();
cont.clear();
@@ -56,7 +57,7 @@ public class GameOverDialog extends FloatingDialog{
cont.add("$stat.delivered");
cont.row();
for(Item item : content.items()){
if(state.stats.itemsDelivered.containsKey(item)){
if(state.stats.itemsDelivered.get(item, 0) > 0){
cont.table(items -> {
items.add(" [LIGHT_GRAY]" + state.stats.itemsDelivered.get(item, 0));
items.addImage(item.region).size(8 *3).pad(4);

View File

@@ -1,131 +0,0 @@
package io.anuke.mindustry.ui.fragments;
import io.anuke.arc.Core;
import io.anuke.arc.collection.ObjectSet;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.math.geom.Vector2;
import io.anuke.arc.scene.Element;
import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Align;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.consumers.Consume;
import static io.anuke.mindustry.Vars.*;
public class BlockConsumeFragment extends Fragment{
private Table table;
private Tile lastTile;
private boolean visible;
@Override
public void build(Group parent){
table = new Table();
table.visible(() -> !state.is(State.menu) && visible);
table.setTransform(true);
parent.addChild(new Element(){{update(() -> {
if(!Core.scene.hasMouse()){
Tile tile = world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
if(tile == null) return;
tile = tile.target();
if(tile != lastTile){
if(tile.getTeam() == players[0].getTeam() && tile.block().consumes.hasAny()){
show(tile);
}else if(visible){
hide();
}
lastTile = tile;
}
}
});}});
parent.setTransform(true);
parent.addChild(table);
}
public void show(Tile tile){
ObjectSet<Consume> consumers = new ObjectSet<>();
TileEntity entity = tile.entity;
Block block = tile.block();
table.clearChildren();
rebuild(block, entity);
visible = true;
table.update(() -> {
if(tile.entity == null || state.is(State.menu)){
hide();
return;
}
boolean rebuild = false;
for(Consume c : block.consumes.array()){
boolean valid = c.isOptional() || c.valid(block, entity);
if(consumers.contains(c) == valid){
if(valid){
consumers.remove(c);
}else{
consumers.add(c);
}
rebuild = true;
}
}
if(rebuild){
rebuild(block, entity);
}
Vector2 v = Core.input.mouseScreen(tile.drawx() - tile.block().size * tilesize / 2f + 0.25f, tile.drawy() + tile.block().size * tilesize / 2f);
table.pack();
table.setPosition(v.x, v.y, Align.topRight);
});
table.act(Core.graphics.getDeltaTime());
}
public void hide(){
table.clear();
table.update(() -> {});
visible = false;
}
private void rebuild(Block block, TileEntity entity){
table.clearChildren();
table.left();
int scale = mobile ? 4 : 3;
for(Consume c : block.consumes.array()){
if(!c.isOptional() && !c.valid(block, entity)){
boolean[] hovered = {false};
table.table("inventory", c::buildTooltip).visible(() -> hovered[0]).height(scale * 10 + 6).padBottom(-4).right().update(t -> {
if(t.getChildren().size == 0) t.remove();
}).get().act(0);
Table result = table.table(out -> {
out.addImage(c.getIcon()).size(10 * scale).color(Color.DARK_GRAY).padRight(-10 * scale).padBottom(-scale * 2);
out.addImage(c.getIcon()).size(10 * scale).color(Palette.accent);
out.addImage("icon-missing").size(10 * scale).color(Palette.remove).padLeft(-10 * scale);
}).size(10 * scale).get();
result.hovered(() -> hovered[0] = true);
if(!mobile){
result.exited(() -> hovered[0] = false);
}
table.row();
}
}
}
}

View File

@@ -196,6 +196,9 @@ public class HudFragment extends Fragment{
.update(label -> label.getColor().set(Color.ORANGE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 2f, 1f))));
});
parent.fill(t -> t.top().right().addRowImageTextButton("$launch", "icon-arrow-up", 8*3, () -> world.launchZone())
.size(94f, 70f).visible(() -> world.isZone() && world.getZone().metCondition()));
//'saving' indicator
parent.fill(t -> {
t.bottom().visible(() -> !state.is(State.menu) && control.saves.isSaving());

View File

@@ -3,20 +3,16 @@ package io.anuke.mindustry.ui.fragments;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.arc.scene.Group;
/**
* Fragment for displaying overlays such as block inventories. One is created for each input handler.
*/
/**Fragment for displaying overlays such as block inventories. One is created for each input handler.*/
public class OverlayFragment extends Fragment{
public final BlockInventoryFragment inv;
public final BlockConfigFragment config;
public final BlockConsumeFragment consume;
private Group group = new Group();
public OverlayFragment(InputHandler input){
inv = new BlockInventoryFragment(input);
config = new BlockConfigFragment(input);
consume = new BlockConsumeFragment();
}
@Override
@@ -26,9 +22,6 @@ public class OverlayFragment extends Fragment{
inv.build(group);
config.build(group);
consume.build(group);
//input.buildUI(group);
}
public void remove(){