Launchpad block

This commit is contained in:
Anuken 2019-01-09 11:44:33 -05:00
parent 048b7bd32f
commit 33afab7294
17 changed files with 3161 additions and 3078 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

View File

@ -392,16 +392,13 @@ content.liquid.name = Liquids
content.unit.name = Units
content.recipe.name = Blocks
content.mech.name = Mechs
item.stone.name = Stone
item.stone.description = A common raw material. Used for separating and refining into other materials, or melting into lava.
item.copper.name = Copper
item.copper.description = A useful structure material. Used extensively in all types of blocks.
item.lead.name = Lead
item.lead.description = A basic starter material. Used extensively in electronics and liquid transportation blocks.
item.coal.name = Coal
item.coal.description = A common and readily available fuel.
item.dense-alloy.name = Dense Alloy
item.dense-alloy.description = A tough alloy made with lead and copper. Used in advanced transportation blocks and high-tier drills.
item.graphite.name = Graphite
item.titanium.name = Titanium
item.titanium.description = A rare super-light metal used extensively in liquid transportation, drills and aircraft.
item.thorium.name = Thorium
@ -422,6 +419,8 @@ item.blast-compound.name = Blast Compound
item.blast-compound.description = A volatile compound used in bombs and explosives. While it can burned as fuel, this is not advised.
item.pyratite.name = Pyratite
item.pyratite.description = An extremely flammable substance used in incendiary weapons.
item.bioglass.name = Bioglass
item.scrap.name = Scrap
liquid.water.name = Water
liquid.lava.name = Lava
liquid.oil.name = Oil
@ -491,8 +490,8 @@ block.blackrock.name = Black Rock
block.icerock.name = icerock
block.copper-wall.name = Copper Wall
block.copper-wall-large.name = Large Copper Wall
block.dense-alloy-wall.name = Dense Alloy Wall
block.dense-alloy-wall-large.name = Large Dense Alloy Wall
block.titanium-wall.name = Titanium Wall
block.titanium-wall-large.name = Large Titanium Wall
block.phase-wall.name = Phase Wall
block.phase-wall-large.name = Large Phase Wall
block.thorium-wall.name = Thorium Wall
@ -601,6 +600,7 @@ block.spectre.name = Spectre
block.meltdown.name = Meltdown
block.container.name = Container
block.core.description = The most important building in the game.
block.launch-pad.name = Launch Pad
team.blue.name = blue
team.red.name = red
team.orange.name = orange

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 335 KiB

View File

@ -19,6 +19,7 @@ import io.anuke.mindustry.world.blocks.power.*;
import io.anuke.mindustry.world.blocks.production.*;
import io.anuke.mindustry.world.blocks.sandbox.*;
import io.anuke.mindustry.world.blocks.storage.CoreBlock;
import io.anuke.mindustry.world.blocks.storage.LaunchPad;
import io.anuke.mindustry.world.blocks.storage.SortedUnloader;
import io.anuke.mindustry.world.blocks.storage.Vault;
import io.anuke.mindustry.world.blocks.units.*;
@ -57,7 +58,7 @@ public class Blocks implements ContentList{
mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, plasmaDrill, waterExtractor, oilExtractor, cultivator,
//storage
core, vault, container, unloader,
core, vault, container, unloader, launchPad,
//turrets
duo, scorch, hail, wave, lancer, arc, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown,
@ -725,7 +726,7 @@ public class Blocks implements ContentList{
core = new CoreBlock("core"){{
health = 1100;
itemCapacity = 3000;
itemCapacity = 2000;
}};
vault = new Vault("vault"){{
@ -741,6 +742,13 @@ public class Blocks implements ContentList{
unloader = new SortedUnloader("unloader"){{
speed = 7f;
}};
launchPad = new LaunchPad("launch-pad"){{
size = 3;
itemCapacity = 100;
launchTime = 60f * 6;
consumes.power(0.1f);
}};
//endregion
//region turrets

View File

@ -42,6 +42,7 @@ public class Recipes implements ContentList{
new Recipe(effect, Blocks.container, new ItemStack(Items.titanium, 200));
new Recipe(effect, Blocks.vault, new ItemStack(Items.titanium, 500), new ItemStack(Items.thorium, 250));
new Recipe(effect, Blocks.launchPad, new ItemStack(Items.copper, 500));
//removed; no longer fits gameplay
/*new Recipe(effect, Blocks.core,

View File

@ -46,7 +46,7 @@ import static io.anuke.mindustry.Vars.*;
public class Control implements ApplicationListener{
public final Saves saves;
private Interval timerRPC = new Interval();
private Interval timer = new Interval(2);
private boolean hiscore = false;
private boolean wasPaused = false;
private InputHandler[] inputs = {};
@ -309,8 +309,13 @@ public class Control implements ApplicationListener{
input.update();
}
//autosave global data every second if it's modified
if(timer.get(1, 60)){
data.checkSave();
}
//auto-update rpc every 5 seconds
if(timerRPC.get(60 * 5)){
if(timer.get(60 * 5)){
Platform.instance.updateRPC();
}

View File

@ -25,16 +25,14 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
idle = new UnitState(){
public void update(){
if(!isCommanded()){
retarget(() -> {
targetClosest();
targetClosestEnemyFlag(BlockFlag.target);
retarget(() -> {
targetClosest();
targetClosestEnemyFlag(BlockFlag.target);
if(target != null){
setState(attack);
}
});
}
if(target != null){
setState(attack);
}
});
target = getClosestCore();
if(target != null){
@ -58,7 +56,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
retarget(() -> {
targetClosest();
if(target == null && isCommanded() && getCommand() == UnitCommand.patrol){
if(target == null){
setState(patrol);
return;
}
@ -67,7 +65,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
if(target == null) targetClosestEnemyFlag(BlockFlag.producer);
if(target == null) targetClosestEnemyFlag(BlockFlag.turret);
if(target == null && !isCommanded()){
if(target == null){
setState(idle);
}
});
@ -108,7 +106,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
}
public void update(){
if(health >= maxHealth() && !isCommanded()){
if(health >= maxHealth()){
state.set(attack);
}else if(!targetHasFlag(BlockFlag.repair)){
retarget(() -> {
@ -167,7 +165,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
@Override
public void behavior(){
if(health <= health * type.retreatPercent && !isCommanded() &&
if(health <= health * type.retreatPercent &&
Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){
setState(retreat);
}

View File

@ -70,7 +70,7 @@ public abstract class GroundUnit extends BaseUnit{
}
public void update(){
if(health >= maxHealth() && !isCommanded()){
if(health >= maxHealth()){
state.set(attack);
}
@ -182,7 +182,7 @@ public abstract class GroundUnit extends BaseUnit{
@Override
public void behavior(){
if(health <= health * type.retreatPercent && !isCommanded()){
if(health <= health * type.retreatPercent){
setState(retreat);
}

View File

@ -14,12 +14,18 @@ import io.anuke.mindustry.type.Item;
public class GlobalData{
private ObjectMap<ContentType, ObjectSet<String>> unlocked = new ObjectMap<>();
private ObjectIntMap<Item> items = new ObjectIntMap<>();
private boolean modified;
public GlobalData(){
Core.settings.setSerializer(ContentType.class, (stream, t) -> stream.writeInt(t.ordinal()), stream -> ContentType.values()[stream.readInt()]);
Core.settings.setSerializer(Item.class, (stream, t) -> stream.writeUTF(t.name), stream -> Vars.content.getByName(ContentType.item, stream.readUTF()));
}
public void addItem(Item item, int amount){
modified = true;
items.getAndIncrement(item, 0, amount);
}
public ObjectIntMap<Item> items(){
return items;
}
@ -43,6 +49,7 @@ public class GlobalData{
//fire unlock event so other classes can use it
if(ret){
modified = true;
content.onUnlock();
Events.fire(new UnlockEvent(content));
save();
@ -56,6 +63,13 @@ public class GlobalData{
save();
}
public void checkSave(){
if(modified){
save();
modified = false;
}
}
@SuppressWarnings("unchecked")
public void load(){
unlocked = Core.settings.getObject("unlocks", ObjectMap.class, ObjectMap::new);

View File

@ -139,8 +139,8 @@ public class WorldGenerator{
int sx = (short)Mathf.range(Short.MAX_VALUE/2);
int sy = (short)Mathf.range(Short.MAX_VALUE/2);
int width = 512;
int height = 512;
int width = 256;
int height = 256;
Array<Point2> spawns = new Array<>();
Array<Item> ores = Item.getAllOres();

View File

@ -14,8 +14,11 @@ public class DeployDialog extends FloatingDialog{
}
void setup(){
buttons().clear();
content().clear();
addCloseButton();
content().stack(new Table(){{
top().left().margin(10);
@ -29,7 +32,10 @@ public class DeployDialog extends FloatingDialog{
}
}
}}, new Table(){{
addButton("$text.play", () -> Vars.world.generator.playRandomMap()).margin(15);
addButton("$text.play", () -> {
hide();
Vars.world.generator.playRandomMap();
}).margin(15);
}}).grow();
}
}

View File

@ -59,7 +59,6 @@ public class MassDriver extends Block{
layer = Layer.turret;
hasPower = true;
consumes.powerBuffered(30f);
consumes.require(ConsumePower.class);
}
@Remote(targets = Loc.both, called = Loc.server, forward = true)

View File

@ -9,22 +9,19 @@ import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.UnitTypes;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.traits.SpawnerTrait;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.UnitType;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemType;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag;
@ -77,6 +74,11 @@ public class CoreBlock extends StorageBlock{
if(entity != null) entity.solid = solid;
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source){
return item.type == ItemType.material && super.acceptItem(item, tile, source);
}
@Override
public int getMaximumAccepted(Tile tile, Item item){
return itemCapacity * state.teams.get(tile.getTeam()).cores.size;
@ -124,7 +126,7 @@ public class CoreBlock extends StorageBlock{
public void draw(Tile tile){
CoreEntity entity = tile.entity();
Draw.rect(entity.solid ? Core.atlas.find(name) : openRegion, tile.drawx(), tile.drawy());
Draw.rect(entity.solid ? region : openRegion, tile.drawx(), tile.drawy());
Draw.alpha(entity.heat);
Draw.rect(topRegion, tile.drawx(), tile.drawy());

View File

@ -0,0 +1,42 @@
package io.anuke.mindustry.world.blocks.storage;
import io.anuke.arc.entities.Effects;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.data;
public class LaunchPad extends Block{
protected final int timerLaunch = timers++;
/**Time inbetween launches.*/
protected float launchTime;
public LaunchPad(String name){
super(name);
update = true;
hasPower = true;
hasItems = true;
solid = true;
}
@Override
public void update(Tile tile){
TileEntity entity = tile.entity;
if(entity.cons.valid()){
for(Item item : Vars.content.items()){
if(entity.items.get(item) >= itemCapacity && entity.timer.get(timerLaunch, launchTime)){
//TODO play animation of some sort
Effects.effect(Fx.dooropenlarge, tile);
data.addItem(item, entity.items.get(item));
entity.items.set(item, 0);
}
}
}
}
}

View File

@ -98,7 +98,7 @@ task scaleSprites4x(){
task scaleSprites(){
finalizedBy 'genSprites'
//dependsOn 'scaleSprites4x'
dependsOn 'scaleSprites4x'
}
task pack(){

View File

@ -12,6 +12,7 @@ import io.anuke.mindustry.world.blocks.Floor;
import io.anuke.mindustry.world.blocks.OreBlock;
import static io.anuke.mindustry.Vars.content;
import static io.anuke.mindustry.Vars.tilesize;
public class Generators {
@ -143,7 +144,7 @@ public class Generators {
Image image = ImagePacker.get(base.name + (i+1));
Image shadow = ImagePacker.get(item.name + (i+1));
int offset = 3;
int offset = image.width()/tilesize;
for (int x = 0; x < image.width(); x++) {
for (int y = offset; y < image.height(); y++) {