From abb6cb9e9f8ac2d0fdac98ccd3cc6868f0f32b1f Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 16 Nov 2017 23:16:25 -0500 Subject: [PATCH] Added rotated effects for chain guns --- build.gradle | 2 +- .../src/io/anuke/mindustry/EffectCreator.java | 9 +++++++ .../anuke/mindustry/entities/BulletType.java | 7 ++++++ core/src/io/anuke/mindustry/io/SaveIO.java | 1 - .../src/io/anuke/mindustry/ui/LoadDialog.java | 5 ++-- .../mindustry/world/blocks/WeaponBlocks.java | 25 ++++++++++++++++--- .../src/io/anuke/ucore/function/DelayRun.java | 15 +++++++++++ .../anuke/ucore/function/EffectProvider.java | 2 +- core/src/io/anuke/ucore/function/Event.java | 5 ++++ .../ucore/function/ISegmentConsumer.java | 5 ++++ .../anuke/ucore/function/SegmentConsumer.java | 2 +- .../anuke/ucore/function/TriPosConsumer.java | 5 ++++ 12 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 core/src/io/anuke/ucore/function/DelayRun.java create mode 100644 core/src/io/anuke/ucore/function/Event.java create mode 100644 core/src/io/anuke/ucore/function/ISegmentConsumer.java create mode 100644 core/src/io/anuke/ucore/function/TriPosConsumer.java diff --git a/build.gradle b/build.gradle index 652715624f..8072bd94a8 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.anuken:ucore:deacbf0568' + compile 'com.github.anuken:ucore:ea3563b5e4' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/src/io/anuke/mindustry/EffectCreator.java b/core/src/io/anuke/mindustry/EffectCreator.java index 305bf1102e..c24be63794 100644 --- a/core/src/io/anuke/mindustry/EffectCreator.java +++ b/core/src/io/anuke/mindustry/EffectCreator.java @@ -25,6 +25,15 @@ public class EffectCreator{ }); }); + Effects.create("chainshot", 9f, e -> { + Draw.color(Color.WHITE, lightOrange, e.ifract()); + Draw.thick(e.fract()*4f); + Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*7f); + Draw.thick(e.fract()*2f); + Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*10f); + Draw.reset(); + }); + Effects.create("shockwave", 10f, e -> { Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.ifract()); Draw.thick(e.fract()*2f + 0.2f); diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java index d8ab81c1d8..326ddaafdc 100644 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/BulletType.java @@ -34,6 +34,13 @@ public abstract class BulletType extends BaseBulletType{ Draw.reset(); } }, + chain = new BulletType(2f, 8){ + public void draw(Bullet b){ + Draw.color("gray"); + Draw.rect("bullet", b.x, b.y, b.angle()); + Draw.reset(); + } + }, sniper = new BulletType(3f, 23){ public void draw(Bullet b){ Draw.color(Color.LIGHT_GRAY); diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index 86df113714..8842ca4301 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -78,7 +78,6 @@ import io.anuke.ucore.entities.Entity; * Item ID (byte) * Item amount (int) * Additional tile entity data (varies, check the TileEntity classes) - * */ public class SaveIO{ /**Save file version ID. Should be incremented every breaking release.*/ diff --git a/core/src/io/anuke/mindustry/ui/LoadDialog.java b/core/src/io/anuke/mindustry/ui/LoadDialog.java index e7268bd152..b7df1b8ee1 100644 --- a/core/src/io/anuke/mindustry/ui/LoadDialog.java +++ b/core/src/io/anuke/mindustry/ui/LoadDialog.java @@ -1,6 +1,5 @@ package io.anuke.mindustry.ui; -import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer.Task; @@ -53,8 +52,8 @@ public class LoadDialog extends FloatingDialog{ button.add(info).padBottom(2).padTop(6); button.row(); - button.addImage("white", Color.GRAY) - .growX().height(3f).pad(4f).units(Unit.dp); + //button.addImage("white", Color.GRAY) + //.growX().height(3f).pad(4f).units(Unit.dp); button.row(); modifyButton(button, slot); diff --git a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java index 58efe43eb3..16ef70742c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.blocks; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.BulletType; @@ -11,6 +12,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.defense.LaserTurret; import io.anuke.mindustry.world.blocks.types.defense.PowerTurret; import io.anuke.mindustry.world.blocks.types.defense.Turret; +import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Timers; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; @@ -168,13 +170,30 @@ public class WeaponBlocks{ inaccuracy = 7f; formalName = "chain turret"; range = 60f; - reload = 40f; - bullet = BulletType.shell; - ammo = Item.coal; + reload = 10f; + bullet = BulletType.chain; + ammo = Item.stone; //TODO health = 430; ammoMultiplier = 10; width = height = 2; } + + @Override + protected void shoot(Tile tile){ + TurretEntity entity = tile.entity(); + Vector2 offset = getPlaceOffset(); + + float len = 8; + float space = 4f; + + Angles.vector.set(len, -space).rotate(entity.rotation); + bullet(tile, entity.rotation); + Effects.effect("chainshot", tile.worldx() + Angles.x() + offset.x, tile.worldy()+ Angles.y() + offset.y, entity.rotation); + + Angles.vector.set(len, space).rotate(entity.rotation); + bullet(tile, entity.rotation); + Effects.effect("chainshot", tile.worldx() + Angles.x() + offset.x, tile.worldy()+ Angles.y() + offset.y, entity.rotation); + } }, titanturret = new Turret("titancannon"){ diff --git a/core/src/io/anuke/ucore/function/DelayRun.java b/core/src/io/anuke/ucore/function/DelayRun.java new file mode 100644 index 0000000000..3e822d8c11 --- /dev/null +++ b/core/src/io/anuke/ucore/function/DelayRun.java @@ -0,0 +1,15 @@ +package io.anuke.ucore.function; + +import com.badlogic.gdx.utils.Pool.Poolable; + +public class DelayRun implements Poolable{ + public float delay; + public Callable run; + public Callable finish; + + @Override + public void reset(){ + delay = 0; + run = finish = null; + } +} diff --git a/core/src/io/anuke/ucore/function/EffectProvider.java b/core/src/io/anuke/ucore/function/EffectProvider.java index 780badc1e0..141601399b 100644 --- a/core/src/io/anuke/ucore/function/EffectProvider.java +++ b/core/src/io/anuke/ucore/function/EffectProvider.java @@ -3,5 +3,5 @@ package io.anuke.ucore.function; import com.badlogic.gdx.graphics.Color; public interface EffectProvider{ - public void createEffect(String name, Color color, float x, float y); + public void createEffect(String name, Color color, float x, float y, float rotation); } diff --git a/core/src/io/anuke/ucore/function/Event.java b/core/src/io/anuke/ucore/function/Event.java new file mode 100644 index 0000000000..be41ff63c9 --- /dev/null +++ b/core/src/io/anuke/ucore/function/Event.java @@ -0,0 +1,5 @@ +package io.anuke.ucore.function; + +public interface Event{ + +} diff --git a/core/src/io/anuke/ucore/function/ISegmentConsumer.java b/core/src/io/anuke/ucore/function/ISegmentConsumer.java new file mode 100644 index 0000000000..2fa6163dba --- /dev/null +++ b/core/src/io/anuke/ucore/function/ISegmentConsumer.java @@ -0,0 +1,5 @@ +package io.anuke.ucore.function; + +public interface ISegmentConsumer{ + public void accept(int x, int y, int x2, int y2); +} diff --git a/core/src/io/anuke/ucore/function/SegmentConsumer.java b/core/src/io/anuke/ucore/function/SegmentConsumer.java index c4a722114f..f2f028ca51 100644 --- a/core/src/io/anuke/ucore/function/SegmentConsumer.java +++ b/core/src/io/anuke/ucore/function/SegmentConsumer.java @@ -1,5 +1,5 @@ package io.anuke.ucore.function; public interface SegmentConsumer{ - public void accept(int x, int y, int x2, int y2); + public void accept(float x, float y, float x2, float y2); } diff --git a/core/src/io/anuke/ucore/function/TriPosConsumer.java b/core/src/io/anuke/ucore/function/TriPosConsumer.java new file mode 100644 index 0000000000..7e4aa73f63 --- /dev/null +++ b/core/src/io/anuke/ucore/function/TriPosConsumer.java @@ -0,0 +1,5 @@ +package io.anuke.ucore.function; + +public interface TriPosConsumer{ + public void accept(int x, int y, int z); +}