diff --git a/core/assets/version.properties b/core/assets/version.properties index b6ac80d4e9..420fa77dbb 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,5 +1,5 @@ #Autogenerated file. Do not modify. -#Thu Apr 05 21:32:39 EDT 2018 +#Thu Apr 05 22:24:14 EDT 2018 version=release androidBuildCode=851 name=Mindustry diff --git a/core/src/io/anuke/mindustry/content/StatusEffects.java b/core/src/io/anuke/mindustry/content/StatusEffects.java index a59d3f5a1b..40864ec971 100644 --- a/core/src/io/anuke/mindustry/content/StatusEffects.java +++ b/core/src/io/anuke/mindustry/content/StatusEffects.java @@ -1,9 +1,12 @@ package io.anuke.mindustry.content; +import io.anuke.mindustry.content.fx.EnvironmentFx; import io.anuke.mindustry.entities.StatusController.TransitionResult; import io.anuke.mindustry.entities.StatusEffect; import io.anuke.mindustry.entities.Unit; +import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Timers; +import io.anuke.ucore.util.Mathf; public class StatusEffects { public static final StatusEffect @@ -18,6 +21,8 @@ public class StatusEffects { @Override public TransitionResult getTransition(Unit unit, StatusEffect to, float time, float newTime, TransitionResult result){ if(to == oiled){ + unit.damage(1f, false); + Effects.effect(EnvironmentFx.burning, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); return result.set(this, Math.min(time + newTime, baseDuration + oiled.baseDuration)); } @@ -26,7 +31,12 @@ public class StatusEffects { @Override public void update(Unit unit, float time){ - unit.damage(0.04f * Timers.delta()); + unit.damage(0.04f * Timers.delta(), false); + + if(Mathf.chance(Timers.delta() * 0.2f)){ + Effects.effect(EnvironmentFx.burning, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + } + } }, @@ -37,7 +47,11 @@ public class StatusEffects { @Override public void update(Unit unit, float time){ - unit.velocity.scl(0.6f); + unit.velocity.scl(0.7f); + + if(Mathf.chance(Timers.delta() * 0.15f)){ + Effects.effect(EnvironmentFx.freezing, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + } } }, @@ -48,6 +62,10 @@ public class StatusEffects { @Override public void update(Unit unit, float time){ + if(Mathf.chance(Timers.delta() * 0.15f)){ + Effects.effect(EnvironmentFx.wet, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + } + unit.velocity.scl(0.999f); } }, @@ -69,13 +87,21 @@ public class StatusEffects { @Override public void update(Unit unit, float time){ unit.velocity.scl(0.8f); - unit.damage(0.1f * Timers.delta()); + unit.damage(0.1f * Timers.delta(), false); + + if(Mathf.chance(Timers.delta() * 0.2f)){ + Effects.effect(EnvironmentFx.melting, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + } } }, oiled = new StatusEffect(4*60f){ @Override public void update(Unit unit, float time){ + if(Mathf.chance(Timers.delta() * 0.15f)){ + Effects.effect(EnvironmentFx.oily, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + } + unit.velocity.scl(1.001f); } diff --git a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java index 8ccb1acfd3..7b79307dd3 100644 --- a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java @@ -99,6 +99,7 @@ public class TurretBullets { drag = 0.07f; hiteffect = BulletFx.hitFlameSmall; despawneffect = Fx.none; + status = StatusEffects.burning; } @Override @@ -142,6 +143,7 @@ public class TurretBullets { { status = StatusEffects.wet; statusIntensity = 0.5f; + knockback = 0.65f; } }, cryoShot = new LiquidShot(Liquids.cryofluid) { @@ -187,7 +189,7 @@ public class TurretBullets { despawneffect = Fx.none; hiteffect = BulletFx.hitLiquid; drag = 0.01f; - knockback = 0.65f; + knockback = 0.5f; } @Override diff --git a/core/src/io/anuke/mindustry/content/fx/BlockFx.java b/core/src/io/anuke/mindustry/content/fx/BlockFx.java index 09589d2a02..d3b73f7f14 100644 --- a/core/src/io/anuke/mindustry/content/fx/BlockFx.java +++ b/core/src/io/anuke/mindustry/content/fx/BlockFx.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Colors; +import io.anuke.mindustry.graphics.Palette; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; @@ -71,35 +72,35 @@ public class BlockFx { }), pulverize = new Effect(40, e -> { Angles.randLenVectors(e.id, 5, 3f + e.fin()*8f, (x, y)->{ - Draw.color(Fx.stoneGray); + Draw.color(Palette.stoneGray); Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45); Draw.reset(); }); }), pulverizeRed = new Effect(40, e -> { Angles.randLenVectors(e.id, 5, 3f + e.fin()*8f, (x, y)->{ - Draw.color(Color.valueOf("ffa480"), Fx.stoneGray, e.fin()); + Draw.color(Color.valueOf("ffa480"), Palette.stoneGray, e.fin()); Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45); Draw.reset(); }); }), pulverizeRedder = new Effect(40, e -> { Angles.randLenVectors(e.id, 5, 3f + e.fin()*9f, (x, y)->{ - Draw.color(Color.valueOf("ff7b69"), Fx.stoneGray, e.fin()); + Draw.color(Color.valueOf("ff7b69"), Palette.stoneGray, e.fin()); Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2.5f + 0.5f, 45); Draw.reset(); }); }), pulverizeSmall = new Effect(30, e -> { Angles.randLenVectors(e.id, 3, e.fin()*5f, (x, y)->{ - Draw.color(Fx.stoneGray); + Draw.color(Palette.stoneGray); Fill.poly(e.x + x, e.y + y, 4, e.fout() * 1f + 0.5f, 45); Draw.reset(); }); }), pulverizeMedium = new Effect(30, e -> { Angles.randLenVectors(e.id, 5, 3f + e.fin()*8f, (x, y)->{ - Draw.color(Fx.stoneGray); + Draw.color(Palette.stoneGray); Fill.poly(e.x + x, e.y + y, 4, e.fout() * 1f + 0.5f, 45); Draw.reset(); }); diff --git a/core/src/io/anuke/mindustry/content/fx/EnvironmentFx.java b/core/src/io/anuke/mindustry/content/fx/EnvironmentFx.java new file mode 100644 index 0000000000..015f20277b --- /dev/null +++ b/core/src/io/anuke/mindustry/content/fx/EnvironmentFx.java @@ -0,0 +1,65 @@ +package io.anuke.mindustry.content.fx; + +import com.badlogic.gdx.graphics.Color; +import io.anuke.mindustry.content.Liquids; +import io.anuke.mindustry.graphics.Palette; +import io.anuke.ucore.core.Effects.Effect; +import io.anuke.ucore.graphics.Draw; +import io.anuke.ucore.graphics.Fill; +import io.anuke.ucore.util.Angles; +import io.anuke.ucore.util.Mathf; + +public class EnvironmentFx { + + public static final Effect + + burning = new Effect(35f, e -> { + Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); + + Angles.randLenVectors(e.id, 3, 2f + e.fin()*7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.1f + e.fout() * 1.4f); + }); + + Draw.color(); + }), + + freezing = new Effect(40f, e -> { + Draw.color(Liquids.cryofluid.color); + + Angles.randLenVectors(e.id, 2, 1f + e.fin()*2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1.2f); + }); + + Draw.color(); + }), + + melting = new Effect(40f, e -> { + Draw.color(Liquids.lava.color, Color.WHITE, e.fout()/5f + Mathf.randomSeedRange(e.id, 0.12f)); + + Angles.randLenVectors(e.id, 2, 1f + e.fin()*3f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, .2f + e.fout() * 1.2f); + }); + + Draw.color(); + }), + + wet = new Effect(40f, e -> { + Draw.color(Liquids.water.color); + + Angles.randLenVectors(e.id, 2, 1f + e.fin()*2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1f); + }); + + Draw.color(); + }), + + oily = new Effect(42f, e -> { + Draw.color(Liquids.oil.color); + + Angles.randLenVectors(e.id, 2, 1f + e.fin()*2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1f); + }); + + Draw.color(); + }); +} diff --git a/core/src/io/anuke/mindustry/content/fx/ExplosionFx.java b/core/src/io/anuke/mindustry/content/fx/ExplosionFx.java index a456d53249..68a5f48c27 100644 --- a/core/src/io/anuke/mindustry/content/fx/ExplosionFx.java +++ b/core/src/io/anuke/mindustry/content/fx/ExplosionFx.java @@ -12,15 +12,6 @@ import io.anuke.ucore.util.Mathf; public class ExplosionFx { public static final Effect - generatorexplosion = new Effect(28, 40f, e -> { - Angles.randLenVectors(e.id, 16, 10f + e.fin()*8f, (x, y) -> { - float size = e.fout()*12f + 1f; - Draw.color(Color.WHITE, Color.PURPLE, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - Draw.reset(); - }); - }), - shockwave = new Effect(10f, 80f, e -> { Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin()); Lines.stroke(e.fout()*2f + 0.2f); diff --git a/core/src/io/anuke/mindustry/content/fx/Fx.java b/core/src/io/anuke/mindustry/content/fx/Fx.java index f40d5cf667..4007e7eff4 100644 --- a/core/src/io/anuke/mindustry/content/fx/Fx.java +++ b/core/src/io/anuke/mindustry/content/fx/Fx.java @@ -10,8 +10,7 @@ import static io.anuke.mindustry.Vars.respawnduration; import static io.anuke.mindustry.Vars.tilesize; public class Fx{ - public static Color beam = Color.valueOf("9bffbe"); - public static Color stoneGray = Color.valueOf("8f8f8f"); + public static final Effect diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 789754a8c1..c42d5cbab2 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -80,6 +80,11 @@ public class Player extends Unit{ return mech.flying; } + @Override + public float getSize() { + return 8; + } + @Override public void damage(float amount){ if(debug || mech.flying) return; diff --git a/core/src/io/anuke/mindustry/entities/StatusController.java b/core/src/io/anuke/mindustry/entities/StatusController.java index 867ae0247c..6b78effd53 100644 --- a/core/src/io/anuke/mindustry/entities/StatusController.java +++ b/core/src/io/anuke/mindustry/entities/StatusController.java @@ -19,21 +19,23 @@ public class StatusController { }else { current.getTransition(unit, effect, time, newTime, globalResult); + time = globalResult.time; if (globalResult.result != current) { current.onTransition(unit, globalResult.result); - time = globalResult.time; current = globalResult.result; } } } public void update(Unit unit){ - if(time > 0){ - time = Math.max(time - Timers.delta(), 0); - } + time = Math.max(time - Timers.delta(), 0); - current.update(unit, time); + if(time <= 0){ + current = StatusEffects.none; + }else{ + current.update(unit, time); + } } public void set(StatusEffect current, float time){ diff --git a/core/src/io/anuke/mindustry/entities/Unit.java b/core/src/io/anuke/mindustry/entities/Unit.java index 5af7fc5cda..8a0e619625 100644 --- a/core/src/io/anuke/mindustry/entities/Unit.java +++ b/core/src/io/anuke/mindustry/entities/Unit.java @@ -12,6 +12,21 @@ public abstract class Unit extends SyncEntity { public Vector2 velocity = new Vector2(); public float hitTime; + @Override + public void damage(float amount){ + super.damage(amount); + hitTime = hitDuration; + } + + public void damage(float amount, boolean withEffect){ + if(withEffect){ + damage(amount); + }else{ + super.damage(amount); + } + } + public abstract float getMass(); public abstract boolean isFlying(); + public abstract float getSize(); } diff --git a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java index 4d5b13395d..273a6197e8 100644 --- a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java @@ -32,6 +32,12 @@ public class BaseUnit extends Unit { rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed); } + //TODO + @Override + public float getSize() { + return 8; + } + @Override public void move(float x, float y){ baseRotation = Mathf.slerpDelta(baseRotation, Mathf.atan2(x, y), type.baseRotateSpeed); @@ -73,12 +79,6 @@ public class BaseUnit extends Unit { return other instanceof Bullet && state.teams.areEnemies((((Bullet) other).team), team); } - @Override - public void damage(float amount){ - super.damage(amount); - hitTime = hitDuration; - } - @Override public void onRemoteShoot(BulletType type, float x, float y, float rotation, short data) { new Bullet(type, this, x, y, rotation).add().damage = data; diff --git a/core/src/io/anuke/mindustry/graphics/Palette.java b/core/src/io/anuke/mindustry/graphics/Palette.java index fa92c8796b..a6f5e3e298 100644 --- a/core/src/io/anuke/mindustry/graphics/Palette.java +++ b/core/src/io/anuke/mindustry/graphics/Palette.java @@ -17,4 +17,6 @@ public class Palette { public static final Color lightishGray = Color.valueOf("a2a2a2"); public static final Color lancerLaser = Color.valueOf("a9d8ff"); + + public static final Color stoneGray = Color.valueOf("8f8f8f"); } diff --git a/core/src/io/anuke/mindustry/io/versions/Save16.java b/core/src/io/anuke/mindustry/io/versions/Save16.java index 2afd702163..b9bc62be41 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save16.java +++ b/core/src/io/anuke/mindustry/io/versions/Save16.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.TimeUtils; import io.anuke.mindustry.content.Weapons; import io.anuke.mindustry.content.blocks.Blocks; import io.anuke.mindustry.content.blocks.StorageBlocks; +import io.anuke.mindustry.entities.StatusEffect; import io.anuke.mindustry.entities.units.BaseUnit; import io.anuke.mindustry.entities.units.UnitType; import io.anuke.mindustry.game.Difficulty; @@ -66,11 +67,14 @@ public class Save16 extends SaveFileVersion { float playerx = stream.readFloat(); float playery = stream.readFloat(); - int playerhealth = stream.readInt(); + short playerhealth = stream.readShort(); + byte peffect = stream.readByte(); + float petime = stream.readFloat(); if(!headless) { player.x = playerx; player.y = playery; + player.status.set(StatusEffect.getByID(peffect), petime); player.health = playerhealth; state.mode = GameMode.values()[mode]; Core.camera.position.set(playerx, playery, 0); @@ -121,11 +125,14 @@ public class Save16 extends SaveFileVersion { float x = stream.readFloat(); float y = stream.readFloat(); int health = stream.readShort(); + byte effect = stream.readByte(); + float etime = stream.readFloat(); BaseUnit enemy = new BaseUnit(UnitType.getByID(type), team); enemy.health = health; enemy.x = x; enemy.y = y; + enemy.status.set(StatusEffect.getByID(effect), etime); enemy.add(group); } } @@ -220,6 +227,9 @@ public class Save16 extends SaveFileVersion { stream.writeShort((short)player.health); //player health + stream.writeByte(player.status.current().id); //status effect info + stream.writeFloat(player.status.getTime()); + stream.writeByte(control.upgrades().getWeapons().size - 1); //amount of weapons //start at 1, because the first weapon is always the starter - ignore that @@ -265,6 +275,8 @@ public class Save16 extends SaveFileVersion { stream.writeFloat(unit.x); //x stream.writeFloat(unit.y); //y stream.writeShort((short)unit.health); //health + stream.writeByte(unit.status.current().id); + stream.writeFloat(unit.status.getTime()); } } diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 1bc4fe3e46..89d2df0455 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -40,7 +40,7 @@ public class Block extends BaseBlock { /**display name*/ public final String formalName; /**played on destroy*/ - public Effect explosionEffect = ExplosionFx.generatorexplosion; + public Effect explosionEffect = ExplosionFx.explosion; //TODO better explosion effect /**played on destroy*/ public String explosionSound = "break"; /**whether this block has a tile entity that updates*/ diff --git a/core/src/io/anuke/mindustry/world/blocks/types/power/PowerGenerator.java b/core/src/io/anuke/mindustry/world/blocks/types/power/PowerGenerator.java index 6080003658..61de4ca904 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/power/PowerGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/power/PowerGenerator.java @@ -1,15 +1,13 @@ package io.anuke.mindustry.world.blocks.types.power; import com.badlogic.gdx.math.GridPoint2; -import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.content.fx.BlockFx; -import io.anuke.mindustry.content.fx.ExplosionFx; +import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.world.Edges; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.PowerBlock; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Timers; -import io.anuke.ucore.util.Mathf; public class PowerGenerator extends PowerBlock { @@ -63,16 +61,7 @@ public class PowerGenerator extends PowerBlock { float x = tile.worldx(), y = tile.worldy(); Effects.effect(BlockFx.blastsmoke, x, y); - - Timers.run(Mathf.random(8f + Mathf.random(6f)), () -> { - Effects.shake(6f, 8f, x, y); - Effects.effect(ExplosionFx.generatorexplosion, x, y); - Effects.effect(ExplosionFx.shockwave, x, y); - - //TODO better explosion effect! - - Effects.sound(explosionSound, x, y); - }); + //TODO better effect } @Override