diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 76b1d49e3d..f75b55b5db 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -80,8 +80,8 @@ public class Vars implements Loadable{ public static final float miningRange = 70f; /** range for building */ public static final float buildingRange = 220f; - /** ticks spent out of bound until self destruct. */ - public static final float boundsCountdown = 60 * 7; + /** duration of one turn. */ + public static final float turnDuration = 5 * Time.toMinutes; /** for map generator dialog */ public static boolean updateEditorOnChange = false; /** size of tiles in units */ diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index a0f2bc11b7..6efa5d774c 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -1189,6 +1189,23 @@ public class Fx{ Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90); }), + unitShieldBreak = new Effect(35, e -> { + if(!(e.data instanceof Unitc)) return; + + Unitc unit = e.data(); + + float radius = unit.hitSize() * 1.3f; + color(Pal.shield, e.fout()); + + randLenVectors(e.id, (int)(radius * 0.7f), radius, radius * e.finpow(), (x, y) -> { + Fill.poly(e.x + x, e.y + y, 3, e.fout() * 3f, Angles.angle(x, y)); + }); + + + stroke(1f * e.fout()); + Lines.circle(e.x, e.y, radius); + }), + coreLand = new Effect(120f, e -> { }); } diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 7e1126fb30..5f18d656ab 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -167,7 +167,7 @@ public class UnitTypes implements ContentList{ health = 400; buildSpeed = 0.4f; engineOffset = 6.5f; - hitsize = 7f; + hitsize = 8f; }}; /* diff --git a/core/src/mindustry/entities/def/ShieldComp.java b/core/src/mindustry/entities/def/ShieldComp.java index 0bb407c149..7a8a75b7a6 100644 --- a/core/src/mindustry/entities/def/ShieldComp.java +++ b/core/src/mindustry/entities/def/ShieldComp.java @@ -1,21 +1,31 @@ package mindustry.entities.def; +import arc.util.*; import mindustry.annotations.Annotations.*; +import mindustry.content.*; import mindustry.gen.*; @Component -abstract class ShieldComp implements Healthc{ +abstract class ShieldComp implements Healthc, Posc{ @Import float health, hitTime; @Import boolean dead; /** Absorbs health damage. */ float shield; + /** Shield opacity. */ + transient float shieldAlpha = 0f; @Replace @Override public void damage(float amount){ hitTime = 1f; + boolean hadShields = shield > 0.0001f; + + if(hadShields){ + shieldAlpha = 1f; + } + float shieldDamage = Math.min(shield, amount); shield -= shieldDamage; amount -= shieldDamage; @@ -25,6 +35,16 @@ abstract class ShieldComp implements Healthc{ if(health <= 0 && !dead){ kill(); } + + if(hadShields && shield <= 0.0001f){ + Fx.unitShieldBreak.at(x(), y(), 0, this); + } } } + + @Override + public void update(){ + shieldAlpha -= Time.delta() / 12f; + if(shieldAlpha < 0) shieldAlpha = 0f; + } } diff --git a/core/src/mindustry/game/GlobalData.java b/core/src/mindustry/game/GlobalData.java index 15b6228ae2..24a73a942e 100644 --- a/core/src/mindustry/game/GlobalData.java +++ b/core/src/mindustry/game/GlobalData.java @@ -20,7 +20,6 @@ import static mindustry.Vars.*; public class GlobalData{ private ObjectMap> unlocked = new ObjectMap<>(); private ObjectIntMap items = new ObjectIntMap<>(); - private Array satellites = new Array<>(); private boolean modified; public GlobalData(){ diff --git a/core/src/mindustry/game/Turns.java b/core/src/mindustry/game/Turns.java deleted file mode 100644 index 1e252bb2df..0000000000 --- a/core/src/mindustry/game/Turns.java +++ /dev/null @@ -1,4 +0,0 @@ -package mindustry.game; - -public class Turns{ -} diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index 430493087d..a15549f2bb 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -6,12 +6,14 @@ import arc.util.*; import mindustry.content.*; import mindustry.type.*; -import static mindustry.Vars.state; +import static mindustry.Vars.*; /** Updates the campaign universe. Has no relevance to other gamemodes. */ public class Universe{ private long seconds; private float secondCounter; + private int turn; + private float turnCounter; public Universe(){ load(); @@ -35,6 +37,7 @@ public class Universe{ public void update(){ secondCounter += Time.delta() / 60f; + if(secondCounter >= 1){ seconds += (int)secondCounter; secondCounter %= 1f; @@ -45,6 +48,15 @@ public class Universe{ } } + //update turn state - happens only in-game + turnCounter += Time.delta(); + + if(turnCounter >= turnDuration){ + turn ++; + turnCounter = 0; + onTurn(); + } + if(state.hasSector()){ //update sector light float light = state.getSector().getLight(); @@ -56,6 +68,10 @@ public class Universe{ } } + private void onTurn(){ + //create a random event here, e.g. invasion + } + public float secondsMod(float mod, float scale){ return (seconds / scale) % mod; } @@ -69,11 +85,16 @@ public class Universe{ } private void save(){ - Core.settings.putSave("utime", seconds); + Core.settings.put("utime", seconds); + Core.settings.put("turn", turn); + Core.settings.put("turntime", turnCounter); + Core.settings.save(); } private void load(){ seconds = Core.settings.getLong("utime"); + turn = Core.settings.getInt("turn"); + turnCounter = Core.settings.getFloat("turntime"); } } diff --git a/core/src/mindustry/graphics/Pal.java b/core/src/mindustry/graphics/Pal.java index 982b77c80b..02220b982e 100644 --- a/core/src/mindustry/graphics/Pal.java +++ b/core/src/mindustry/graphics/Pal.java @@ -8,6 +8,9 @@ public class Pal{ items = Color.valueOf("2ea756"), command = Color.valueOf("eab678"), + shield = Color.valueOf("7e8ffc").mul(1.3f).a(0.7f), + shieldIn = Color.black.cpy().a(0f), + bulletYellow = Color.valueOf("fff8e8"), bulletYellowBack = Color.valueOf("f9c27a"), diff --git a/core/src/mindustry/logic/LogicDialog.java b/core/src/mindustry/logic/LogicDialog.java new file mode 100644 index 0000000000..184c57a4a5 --- /dev/null +++ b/core/src/mindustry/logic/LogicDialog.java @@ -0,0 +1,12 @@ +package mindustry.logic; + +import mindustry.ui.dialogs.*; + +public class LogicDialog extends FloatingDialog{ + + public LogicDialog(){ + super(""); + clear(); + addCloseButton(); + } +} diff --git a/core/src/mindustry/world/blocks/experimental/LogicExecutor.java b/core/src/mindustry/logic/LogicExecutor.java similarity index 98% rename from core/src/mindustry/world/blocks/experimental/LogicExecutor.java rename to core/src/mindustry/logic/LogicExecutor.java index eada670acf..715740d3f6 100644 --- a/core/src/mindustry/world/blocks/experimental/LogicExecutor.java +++ b/core/src/mindustry/logic/LogicExecutor.java @@ -1,4 +1,4 @@ -package mindustry.world.blocks.experimental; +package mindustry.logic; import mindustry.gen.*; diff --git a/core/src/mindustry/logic/LogicNode.java b/core/src/mindustry/logic/LogicNode.java new file mode 100644 index 0000000000..1e9e2cc7dd --- /dev/null +++ b/core/src/mindustry/logic/LogicNode.java @@ -0,0 +1,4 @@ +package mindustry.logic; + +public class LogicNode{ +} diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 2e5e48f575..02ffc02d65 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -141,6 +141,16 @@ public class UnitType extends UnlockableContent{ if(drawCell) drawCell(unit); if(drawItems) drawItems(unit); drawLight(unit); + + if(unit.shieldAlpha() > 0){ + drawShield(unit); + } + } + + public void drawShield(Unitc unit){ + float alpha = unit.shieldAlpha(); + float radius = unit.hitSize() * 1.3f; + Fill.light(unit.x(), unit.y(), Lines.circleVertices(radius), radius, Tmp.c1.set(Pal.shieldIn), Tmp.c2.set(Pal.shield).lerp(Color.white, Mathf.clamp(unit.hitTime())).a(Pal.shield.a * alpha)); } public void drawControl(Unitc unit){