Implemented 'railgun' turret / Hierarchy split / Color refactoring
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 370 B |
Binary file not shown.
|
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 377 B |
Binary file not shown.
|
After Width: | Height: | Size: 167 B |
+218
-204
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Tue Apr 03 22:20:20 EDT 2018
|
#Wed Apr 04 16:43:10 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=816
|
androidBuildCode=822
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ public class AmmoTypes {
|
|||||||
|
|
||||||
basicIron = new AmmoType(Items.iron, TurretBullets.basicIron, 5, 0.9f),
|
basicIron = new AmmoType(Items.iron, TurretBullets.basicIron, 5, 0.9f),
|
||||||
|
|
||||||
|
basicSteel = new AmmoType(Items.steel, TurretBullets.basicSteel, 5, 0.8f),
|
||||||
|
|
||||||
basicFlame = new AmmoType(Liquids.oil, TurretBullets.basicFlame, 0.3f, 0.9f);
|
basicFlame = new AmmoType(Liquids.oil, TurretBullets.basicFlame, 0.3f, 0.9f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import io.anuke.mindustry.resource.AmmoType;
|
|||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.LaserTurret;
|
import io.anuke.mindustry.world.blocks.types.defense.LaserTurret;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.turrets.BurstTurret;
|
import io.anuke.mindustry.world.blocks.types.defense.turrets.*;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.turrets.DoubleTurret;
|
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.turrets.LiquidTurret;
|
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.turrets.PowerTurret;
|
|
||||||
|
|
||||||
public class WeaponBlocks{
|
public class WeaponBlocks{
|
||||||
public static Block
|
public static Block
|
||||||
@@ -44,13 +41,31 @@ public class WeaponBlocks{
|
|||||||
ammoUseEffect = BulletFx.shellEjectSmall;
|
ammoUseEffect = BulletFx.shellEjectSmall;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
railgunturret = new Turret("railgunturret"){
|
railgunturret = new ItemTurret("railgunturret"){{
|
||||||
|
range = 100f;
|
||||||
},
|
ammoTypes = new AmmoType[]{AmmoTypes.basicSteel};
|
||||||
|
reload = 100f;
|
||||||
|
restitution = 0.03f;
|
||||||
|
ammoEjectBack = 2f;
|
||||||
|
recoil = 3f;
|
||||||
|
shootShake = 2f;
|
||||||
|
shootEffect = BulletFx.shootBig;
|
||||||
|
smokeEffect = BulletFx.shootBigSmoke;
|
||||||
|
ammoUseEffect = BulletFx.shellEjectBig;
|
||||||
|
}},
|
||||||
|
|
||||||
flakturret = new Turret("flakturret"){
|
flakturret = new ItemTurret("flakturret"){{
|
||||||
|
range = 100f;
|
||||||
},
|
ammoTypes = new AmmoType[]{AmmoTypes.basicSteel};
|
||||||
|
reload = 100f;
|
||||||
|
restitution = 0.03f;
|
||||||
|
ammoEjectBack = 2f;
|
||||||
|
recoil = 3f;
|
||||||
|
shootShake = 2f;
|
||||||
|
shootEffect = BulletFx.shootBig;
|
||||||
|
smokeEffect = BulletFx.shootBigSmoke;
|
||||||
|
ammoUseEffect = BulletFx.shellEjectBig;
|
||||||
|
}},
|
||||||
|
|
||||||
laserturret = new LaserTurret("laserturret"){
|
laserturret = new LaserTurret("laserturret"){
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,39 @@
|
|||||||
package io.anuke.mindustry.content.bullets;
|
package io.anuke.mindustry.content.bullets;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import io.anuke.mindustry.entities.Bullet;
|
import io.anuke.mindustry.entities.Bullet;
|
||||||
import io.anuke.mindustry.entities.BulletType;
|
import io.anuke.mindustry.entities.BulletType;
|
||||||
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.graphics.fx.BulletFx;
|
import io.anuke.mindustry.graphics.fx.BulletFx;
|
||||||
import io.anuke.mindustry.graphics.fx.Fx;
|
import io.anuke.mindustry.graphics.fx.Fx;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
|
||||||
public class TurretBullets {
|
public class TurretBullets {
|
||||||
|
|
||||||
public static final BulletType
|
public static final BulletType
|
||||||
|
|
||||||
basicIron = new BulletType(3f, 0) {
|
basicIron = new BulletType(3f, 0) {
|
||||||
@Override
|
@Override
|
||||||
public void draw(Bullet b) {
|
public void draw(Bullet b) {
|
||||||
Draw.color(Color.valueOf("f3d47f"));
|
Draw.color(Palette.bulletYellow);
|
||||||
Draw.rect("bullet", b.x, b.y, 9f, 5f + b.fract()*7f, b.angle() - 90);
|
Draw.rect("bullet", b.x, b.y, 9f, 5f + b.fract()*7f, b.angle() - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
basicSteel = new BulletType(6f, 0) {
|
||||||
|
{
|
||||||
|
hiteffect = BulletFx.hitBulletBig;
|
||||||
|
knockback = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Bullet b) {
|
||||||
|
Draw.color(Palette.bulletYellow);
|
||||||
|
Draw.rect("bullet", b.x, b.y, 11f, 9f + b.fract()*8f, b.angle() - 90);
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
basicFlame = new BulletType(2f, 4) {
|
basicFlame = new BulletType(2f, 4) {
|
||||||
{
|
{
|
||||||
hitsize = 7f;
|
hitsize = 7f;
|
||||||
|
|||||||
@@ -223,10 +223,8 @@ public class Renderer extends RendererModule{
|
|||||||
Graphics.beginShaders(Shaders.outline);
|
Graphics.beginShaders(Shaders.outline);
|
||||||
Graphics.shader(Shaders.hit, false);
|
Graphics.shader(Shaders.hit, false);
|
||||||
drawTeam(team, flying);
|
drawTeam(team, flying);
|
||||||
Draw.alpha(0f);
|
|
||||||
blocks.drawTeamBlocks(Layer.turret, team);
|
|
||||||
Draw.alpha(1f);
|
|
||||||
Graphics.shader();
|
Graphics.shader();
|
||||||
|
blocks.drawTeamBlocks(Layer.turret, team);
|
||||||
Graphics.endShaders();
|
Graphics.endShaders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.entities;
|
package io.anuke.mindustry.entities;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.IntSet;
|
import com.badlogic.gdx.utils.IntSet;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -11,6 +12,8 @@ import io.anuke.ucore.util.Timer;
|
|||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Bullet extends BulletEntity{
|
public class Bullet extends BulletEntity{
|
||||||
|
private static Vector2 vector = new Vector2();
|
||||||
|
|
||||||
public IntSet collided;
|
public IntSet collided;
|
||||||
public Timer timer = new Timer(3);
|
public Timer timer = new Timer(3);
|
||||||
public Team team;
|
public Team team;
|
||||||
@@ -68,6 +71,11 @@ public class Bullet extends BulletEntity{
|
|||||||
super.collision(other, x, y);
|
super.collision(other, x, y);
|
||||||
if(type.pierce)
|
if(type.pierce)
|
||||||
collided.add(other.id);
|
collided.add(other.id);
|
||||||
|
|
||||||
|
if(other instanceof Unit){
|
||||||
|
float k = ((BulletType)type).knockback;
|
||||||
|
((Unit) other).velocity.add(vector.set(other.x, other.y).sub(x, y).setLength(k));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.anuke.ucore.core.Effects;
|
|||||||
import io.anuke.ucore.entities.BaseBulletType;
|
import io.anuke.ucore.entities.BaseBulletType;
|
||||||
|
|
||||||
public abstract class BulletType extends BaseBulletType<Bullet>{
|
public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||||
|
public float knockback;
|
||||||
|
|
||||||
public BulletType(float speed, int damage){
|
public BulletType(float speed, int damage){
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.anuke.mindustry.graphics;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
|
||||||
|
public class Palette {
|
||||||
|
public static final Color bulletYellow = Color.valueOf("f3d47f");
|
||||||
|
|
||||||
|
public static final Color lightFlame = Color.valueOf("ffdd55");
|
||||||
|
public static final Color darkFlame = Color.valueOf("db401c");
|
||||||
|
|
||||||
|
public static final Color turretHeat = Color.valueOf("ab3400");
|
||||||
|
|
||||||
|
public static final Color lightOrange = Color.valueOf("f68021");
|
||||||
|
public static final Color lighterOrange = Color.valueOf("f6e096");
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.graphics.fx;
|
package io.anuke.mindustry.graphics.fx;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Fill;
|
import io.anuke.ucore.graphics.Fill;
|
||||||
@@ -10,15 +11,11 @@ import io.anuke.ucore.util.Angles;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class BulletFx {
|
public class BulletFx {
|
||||||
public static Color lightFlame = Color.valueOf("ffdd55");
|
|
||||||
public static Color darkFlame = Color.valueOf("db401c");
|
|
||||||
public static Color lightOrange = Color.valueOf("f68021");
|
|
||||||
public static Color lighterOrange = Color.valueOf("f6e096");
|
|
||||||
|
|
||||||
public static final Effect
|
public static final Effect
|
||||||
|
|
||||||
shootSmall = new Effect(8, e -> {
|
shootSmall = new Effect(8, e -> {
|
||||||
Draw.color(lighterOrange, lightOrange, e.ifract());
|
Draw.color(Palette.lighterOrange, Palette.lightOrange, e.ifract());
|
||||||
float w = 1f + 5 * e.fract();
|
float w = 1f + 5 * e.fract();
|
||||||
Shapes.tri(e.x, e.y, w, 15f * e.fract(), e.rotation);
|
Shapes.tri(e.x, e.y, w, 15f * e.fract(), e.rotation);
|
||||||
Shapes.tri(e.x, e.y, w, 3f * e.fract(), e.rotation + 180f);
|
Shapes.tri(e.x, e.y, w, 3f * e.fract(), e.rotation + 180f);
|
||||||
@@ -26,7 +23,7 @@ public class BulletFx {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
shootSmallSmoke = new Effect(20f, e -> {
|
shootSmallSmoke = new Effect(20f, e -> {
|
||||||
Draw.color(lighterOrange, Color.LIGHT_GRAY, Color.GRAY, e.ifract());
|
Draw.color(Palette.lighterOrange, Color.LIGHT_GRAY, Color.GRAY, e.ifract());
|
||||||
|
|
||||||
Angles.randLenVectors(e.id, 5, e.powfract()*6f, e.rotation, 20f, (x, y) -> {
|
Angles.randLenVectors(e.id, 5, e.powfract()*6f, e.rotation, 20f, (x, y) -> {
|
||||||
Fill.circle(e.x + x, e.y + y, e.fract()*1.5f);
|
Fill.circle(e.x + x, e.y + y, e.fract()*1.5f);
|
||||||
@@ -35,8 +32,26 @@ public class BulletFx {
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
shootBig = new Effect(9, e -> {
|
||||||
|
Draw.color(Palette.lighterOrange, Palette.lightOrange, e.ifract());
|
||||||
|
float w = 1.2f + 7 * e.fract();
|
||||||
|
Shapes.tri(e.x, e.y, w, 25f * e.fract(), e.rotation);
|
||||||
|
Shapes.tri(e.x, e.y, w, 4f * e.fract(), e.rotation + 180f);
|
||||||
|
Draw.reset();
|
||||||
|
}),
|
||||||
|
|
||||||
|
shootBigSmoke = new Effect(17f, e -> {
|
||||||
|
Draw.color(Palette.lighterOrange, Color.LIGHT_GRAY, Color.GRAY, e.ifract());
|
||||||
|
|
||||||
|
Angles.randLenVectors(e.id, 8, e.powfract()*19f, e.rotation, 10f, (x, y) -> {
|
||||||
|
Fill.circle(e.x + x, e.y + y, e.fract()*2f + 0.2f);
|
||||||
|
});
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
}),
|
||||||
|
|
||||||
shootSmallFlame = new Effect(30f, e -> {
|
shootSmallFlame = new Effect(30f, e -> {
|
||||||
Draw.color(lightFlame, darkFlame, Color.GRAY, e.ifract());
|
Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, e.ifract());
|
||||||
|
|
||||||
Angles.randLenVectors(e.id, 8, e.powfract()*26f, e.rotation, 10f, (x, y) -> {
|
Angles.randLenVectors(e.id, 8, e.powfract()*26f, e.rotation, 10f, (x, y) -> {
|
||||||
Fill.circle(e.x + x, e.y + y, 0.65f + e.fract()*1.5f);
|
Fill.circle(e.x + x, e.y + y, 0.65f + e.fract()*1.5f);
|
||||||
@@ -46,7 +61,7 @@ public class BulletFx {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
shellEjectSmall = new Effect(30f, e -> {
|
shellEjectSmall = new Effect(30f, e -> {
|
||||||
Draw.color(lightOrange, Color.LIGHT_GRAY, Color.GRAY, e.ifract());
|
Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Color.GRAY, e.ifract());
|
||||||
Draw.alpha(e.fract());
|
Draw.alpha(e.fract());
|
||||||
float rot = e.rotation + 90f;
|
float rot = e.rotation + 90f;
|
||||||
for(int i : Mathf.signs){
|
for(int i : Mathf.signs){
|
||||||
@@ -54,11 +69,32 @@ public class BulletFx {
|
|||||||
float lr = rot + e.ifract()*30f*i;
|
float lr = rot + e.ifract()*30f*i;
|
||||||
Draw.rect("white", e.x + Angles.trnsx(lr, len), e.y + Angles.trnsy(lr, len), 1f, 2f, rot + e.ifract()*50f*i);
|
Draw.rect("white", e.x + Angles.trnsx(lr, len), e.y + Angles.trnsy(lr, len), 1f, 2f, rot + e.ifract()*50f*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
|
}),
|
||||||
|
|
||||||
|
shellEjectBig = new Effect(30f, e -> {
|
||||||
|
Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Color.GRAY, e.ifract());
|
||||||
|
float rot = e.rotation + 90f;
|
||||||
|
for(int i : Mathf.signs){
|
||||||
|
float len = (2f + e.powfract()*10f) * i;
|
||||||
|
float lr = rot + e.ifract()*20f*i;
|
||||||
|
Draw.rect("white", e.x + Angles.trnsx(lr, len), e.y + Angles.trnsy(lr, len), 2f, 3f, rot);
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.ifract());
|
||||||
|
|
||||||
|
for(int i : Mathf.signs){
|
||||||
|
Angles.randLenVectors(e.id, 4, 1f + e.powfract()*11f, e.rotation + 90f*i, 20f, (x, y) -> {
|
||||||
|
Fill.circle(e.x + x, e.y + y, e.fract()*1.5f);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
hitBulletSmall = new Effect(14, e -> {
|
hitBulletSmall = new Effect(14, e -> {
|
||||||
Draw.color(Color.WHITE, lightOrange, e.ifract());
|
Draw.color(Color.WHITE, Palette.lightOrange, e.ifract());
|
||||||
Lines.stroke(0.5f + e.fract());
|
Lines.stroke(0.5f + e.fract());
|
||||||
|
|
||||||
Angles.randLenVectors(e.id, 5, e.ifract()*15f, e.rotation, 50f, (x, y) -> {
|
Angles.randLenVectors(e.id, 5, e.ifract()*15f, e.rotation, 50f, (x, y) -> {
|
||||||
@@ -69,8 +105,20 @@ public class BulletFx {
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
hitBulletBig = new Effect(13, e -> {
|
||||||
|
Draw.color(Color.WHITE, Palette.lightOrange, e.ifract());
|
||||||
|
Lines.stroke(0.5f + e.fract()*1.5f);
|
||||||
|
|
||||||
|
Angles.randLenVectors(e.id, 8, e.powfract()*30f, e.rotation, 50f, (x, y) -> {
|
||||||
|
float ang = Mathf.atan2(x, y);
|
||||||
|
Lines.lineAngle(e.x + x, e.y + y, ang, e.fract()*4 + 1.5f);
|
||||||
|
});
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
}),
|
||||||
|
|
||||||
hitFlameSmall = new Effect(14, e -> {
|
hitFlameSmall = new Effect(14, e -> {
|
||||||
Draw.color(lightFlame, darkFlame, e.ifract());
|
Draw.color(Palette.lightFlame, Palette.darkFlame, e.ifract());
|
||||||
Lines.stroke(0.5f + e.fract());
|
Lines.stroke(0.5f + e.fract());
|
||||||
|
|
||||||
Angles.randLenVectors(e.id, 5, e.ifract()*15f, e.rotation, 50f, (x, y) -> {
|
Angles.randLenVectors(e.id, 5, e.ifract()*15f, e.rotation, 50f, (x, y) -> {
|
||||||
@@ -82,7 +130,7 @@ public class BulletFx {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
despawn = new Effect(12, e -> {
|
despawn = new Effect(12, e -> {
|
||||||
Draw.color(lighterOrange, Color.GRAY, e.ifract());
|
Draw.color(Palette.lighterOrange, Color.GRAY, e.ifract());
|
||||||
Lines.stroke(e.fract());
|
Lines.stroke(e.fract());
|
||||||
|
|
||||||
Angles.randLenVectors(e.id, 7, e.ifract()*7f, e.rotation, 40f, (x, y) -> {
|
Angles.randLenVectors(e.id, 7, e.ifract()*7f, e.rotation, 40f, (x, y) -> {
|
||||||
|
|||||||
@@ -2,19 +2,24 @@ package io.anuke.mindustry.world.blocks.types.defense;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
|
||||||
import io.anuke.mindustry.entities.*;
|
import io.anuke.mindustry.entities.*;
|
||||||
import io.anuke.mindustry.graphics.Layer;
|
import io.anuke.mindustry.graphics.Layer;
|
||||||
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.graphics.fx.Fx;
|
import io.anuke.mindustry.graphics.fx.Fx;
|
||||||
import io.anuke.mindustry.resource.AmmoType;
|
import io.anuke.mindustry.resource.AmmoType;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
|
import io.anuke.ucore.core.Graphics;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Lines;
|
import io.anuke.ucore.graphics.Lines;
|
||||||
import io.anuke.ucore.util.*;
|
import io.anuke.ucore.util.Angles;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Strings;
|
||||||
|
import io.anuke.ucore.util.Translator;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@@ -22,17 +27,11 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class Turret extends Block{
|
public abstract class Turret extends Block{
|
||||||
protected static final int targetInterval = 15;
|
protected static final int targetInterval = 15;
|
||||||
|
|
||||||
protected final int timerTarget = timers++;
|
protected final int timerTarget = timers++;
|
||||||
|
|
||||||
protected int maxammo = 100;
|
|
||||||
//TODO implement this!
|
|
||||||
/**A value of 'null' means this turret does not need ammo.*/
|
|
||||||
protected AmmoType[] ammoTypes;
|
|
||||||
protected ObjectMap<Item, AmmoType> ammoMap = new ObjectMap<>();
|
|
||||||
|
|
||||||
protected int ammoPerShot = 1;
|
protected int ammoPerShot = 1;
|
||||||
protected float ammoEjectBack = 1f;
|
protected float ammoEjectBack = 1f;
|
||||||
protected float range = 50f;
|
protected float range = 50f;
|
||||||
@@ -41,6 +40,7 @@ public class Turret extends Block{
|
|||||||
protected int shots = 1;
|
protected int shots = 1;
|
||||||
protected float recoil = 1f;
|
protected float recoil = 1f;
|
||||||
protected float restitution = 0.02f;
|
protected float restitution = 0.02f;
|
||||||
|
protected float cooldown = 0.02f;
|
||||||
protected float rotatespeed = 0.2f;
|
protected float rotatespeed = 0.2f;
|
||||||
protected float shootCone = 5f;
|
protected float shootCone = 5f;
|
||||||
protected float shootShake = 0f;
|
protected float shootShake = 0f;
|
||||||
@@ -61,27 +61,6 @@ public class Turret extends Block{
|
|||||||
group = BlockGroup.turrets;
|
group = BlockGroup.turrets;
|
||||||
hasInventory = false;
|
hasInventory = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(){
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
if(ammoTypes != null) {
|
|
||||||
for (AmmoType type : ammoTypes) {
|
|
||||||
if(type.item == null) continue;
|
|
||||||
if (ammoMap.containsKey(type.item)) {
|
|
||||||
throw new RuntimeException("Turret \"" + name + "\" has two conflicting ammo entries on item type " + type.item + "!");
|
|
||||||
} else {
|
|
||||||
ammoMap.put(type.item, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBars(){
|
|
||||||
bars.replace(new BlockBar(BarType.inventory, true, tile -> (float)tile.<TurretEntity>entity().totalAmmo / maxammo));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStats(){
|
public void setStats(){
|
||||||
@@ -117,7 +96,19 @@ public class Turret extends Block{
|
|||||||
|
|
||||||
tr2.trns(entity.rotation, -entity.recoil);
|
tr2.trns(entity.rotation, -entity.recoil);
|
||||||
|
|
||||||
Draw.rect(name(), tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
String region = entity.target != null && Draw.hasRegion(name + "-shoot") ? name + "-shoot" : name;
|
||||||
|
|
||||||
|
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||||
|
|
||||||
|
if(Draw.hasRegion(name + "-heat")){
|
||||||
|
Graphics.setAdditiveBlending();
|
||||||
|
Draw.color(Palette.turretHeat);
|
||||||
|
Draw.alpha(entity.heat);
|
||||||
|
Draw.rect(name + "-heat", tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||||
|
Graphics.setNormalBlending();
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -134,37 +125,6 @@ public class Turret extends Block{
|
|||||||
Lines.dashCircle(x * tilesize, y * tilesize, range);
|
Lines.dashCircle(x * tilesize, y * tilesize, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleItem(Item item, Tile tile, Tile source) {
|
|
||||||
TurretEntity entity = tile.entity();
|
|
||||||
|
|
||||||
AmmoType type = ammoMap.get(item);
|
|
||||||
entity.totalAmmo += type.quantityMultiplier;
|
|
||||||
|
|
||||||
//find ammo entry by type
|
|
||||||
for(int i = 0; i < entity.ammo.size; i ++){
|
|
||||||
AmmoEntry entry = entity.ammo.get(i);
|
|
||||||
|
|
||||||
//if found, put it to the right
|
|
||||||
if(entry.type == type){
|
|
||||||
entry.amount += type.quantityMultiplier;
|
|
||||||
entity.ammo.swap(i, entity.ammo.size-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//must not be found
|
|
||||||
AmmoEntry entry = new AmmoEntry(type, (int)type.quantityMultiplier);
|
|
||||||
entity.ammo.add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
|
||||||
TurretEntity entity = tile.entity();
|
|
||||||
|
|
||||||
return ammoMap != null && ammoMap.get(item) != null && entity.totalAmmo + ammoMap.get(item).quantityMultiplier <= maxammo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
TurretEntity entity = tile.entity();
|
TurretEntity entity = tile.entity();
|
||||||
@@ -173,6 +133,7 @@ public class Turret extends Block{
|
|||||||
entity.target = null;
|
entity.target = null;
|
||||||
|
|
||||||
entity.recoil = Mathf.lerpDelta(entity.recoil, 0f, restitution);
|
entity.recoil = Mathf.lerpDelta(entity.recoil, 0f, restitution);
|
||||||
|
entity.heat = Mathf.lerpDelta(entity.heat, 0f, cooldown);
|
||||||
|
|
||||||
if(hasAmmo(tile)){
|
if(hasAmmo(tile)){
|
||||||
|
|
||||||
@@ -207,7 +168,7 @@ public class Turret extends Block{
|
|||||||
entry.amount -= ammoPerShot;
|
entry.amount -= ammoPerShot;
|
||||||
if(entry.amount == 0) entity.ammo.pop();
|
if(entry.amount == 0) entity.ammo.pop();
|
||||||
entity.totalAmmo -= ammoPerShot;
|
entity.totalAmmo -= ammoPerShot;
|
||||||
ejectEffects(tile);
|
Timers.run(reload/2f, () -> ejectEffects(tile));
|
||||||
return entry.type;
|
return entry.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,6 +202,7 @@ public class Turret extends Block{
|
|||||||
TurretEntity entity = tile.entity();
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
entity.recoil = recoil;
|
entity.recoil = recoil;
|
||||||
|
entity.heat = 1f;
|
||||||
|
|
||||||
useAmmo(tile);
|
useAmmo(tile);
|
||||||
|
|
||||||
@@ -248,12 +210,7 @@ public class Turret extends Block{
|
|||||||
|
|
||||||
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
|
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
|
||||||
|
|
||||||
Effects.effect(shootEffect, tile.drawx() + tr.x,
|
effects(tile);
|
||||||
tile.drawy() + tr.y, entity.rotation);
|
|
||||||
|
|
||||||
if (shootShake > 0) {
|
|
||||||
Effects.shake(shootShake, shootShake, tile.entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void bullet(Tile tile, BulletType type, float angle){
|
protected void bullet(Tile tile, BulletType type, float angle){
|
||||||
@@ -274,6 +231,7 @@ public class Turret extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void ejectEffects(Tile tile){
|
protected void ejectEffects(Tile tile){
|
||||||
|
if(!(tile.entity instanceof TurretEntity)) return;
|
||||||
TurretEntity entity = tile.entity();
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
Effects.effect(ammoUseEffect, tile.drawx() - Angles.trnsx(entity.rotation, ammoEjectBack),
|
Effects.effect(ammoUseEffect, tile.drawx() - Angles.trnsx(entity.rotation, ammoEjectBack),
|
||||||
@@ -302,6 +260,7 @@ public class Turret extends Block{
|
|||||||
public float reload;
|
public float reload;
|
||||||
public float rotation = 90;
|
public float rotation = 90;
|
||||||
public float recoil = 0f;
|
public float recoil = 0f;
|
||||||
|
public float heat;
|
||||||
public int shots;
|
public int shots;
|
||||||
public Unit target;
|
public Unit target;
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ package io.anuke.mindustry.world.blocks.types.defense.turrets;
|
|||||||
|
|
||||||
import io.anuke.mindustry.resource.AmmoType;
|
import io.anuke.mindustry.resource.AmmoType;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class BurstTurret extends Turret {
|
public class BurstTurret extends ItemTurret {
|
||||||
protected float burstSpacing = 5;
|
protected float burstSpacing = 5;
|
||||||
|
|
||||||
public BurstTurret(String name) {
|
public BurstTurret(String name) {
|
||||||
@@ -19,11 +18,15 @@ public class BurstTurret extends Turret {
|
|||||||
protected void shoot(Tile tile, AmmoType ammo){
|
protected void shoot(Tile tile, AmmoType ammo){
|
||||||
TurretEntity entity = tile.entity();
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
entity.heat = 1f;
|
||||||
|
|
||||||
for (int i = 0; i < shots; i++) {
|
for (int i = 0; i < shots; i++) {
|
||||||
Timers.run(burstSpacing * i, () -> {
|
Timers.run(burstSpacing * i, () -> {
|
||||||
if(!(tile.entity instanceof TurretEntity) ||
|
if(!(tile.entity instanceof TurretEntity) ||
|
||||||
!hasAmmo(tile)) return;
|
!hasAmmo(tile)) return;
|
||||||
|
|
||||||
|
entity.recoil = recoil;
|
||||||
|
|
||||||
tr.trns(entity.rotation, size * tilesize / 2);
|
tr.trns(entity.rotation, size * tilesize / 2);
|
||||||
useAmmo(tile);
|
useAmmo(tile);
|
||||||
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
|
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ package io.anuke.mindustry.world.blocks.types.defense.turrets;
|
|||||||
|
|
||||||
import io.anuke.mindustry.resource.AmmoType;
|
import io.anuke.mindustry.resource.AmmoType;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class DoubleTurret extends Turret {
|
public class DoubleTurret extends ItemTurret {
|
||||||
protected float shotWidth = 2f;
|
protected float shotWidth = 2f;
|
||||||
|
|
||||||
public DoubleTurret(String name) {
|
public DoubleTurret(String name) {
|
||||||
|
|||||||
@@ -1,9 +1,73 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.defense.turrets;
|
package io.anuke.mindustry.world.blocks.types.defense.turrets;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
import io.anuke.mindustry.resource.AmmoType;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.BarType;
|
||||||
|
import io.anuke.mindustry.world.BlockBar;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
||||||
|
|
||||||
public class ItemTurret extends Turret {
|
public class ItemTurret extends Turret {
|
||||||
|
protected int maxammo = 100;
|
||||||
|
//TODO implement this!
|
||||||
|
/**A value of 'null' means this turret does not need ammo.*/
|
||||||
|
protected AmmoType[] ammoTypes;
|
||||||
|
protected ObjectMap<Item, AmmoType> ammoMap = new ObjectMap<>();
|
||||||
|
|
||||||
public ItemTurret(String name) {
|
public ItemTurret(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleItem(Item item, Tile tile, Tile source) {
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
AmmoType type = ammoMap.get(item);
|
||||||
|
entity.totalAmmo += type.quantityMultiplier;
|
||||||
|
|
||||||
|
//find ammo entry by type
|
||||||
|
for(int i = 0; i < entity.ammo.size; i ++){
|
||||||
|
AmmoEntry entry = entity.ammo.get(i);
|
||||||
|
|
||||||
|
//if found, put it to the right
|
||||||
|
if(entry.type == type){
|
||||||
|
entry.amount += type.quantityMultiplier;
|
||||||
|
entity.ammo.swap(i, entity.ammo.size-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//must not be found
|
||||||
|
AmmoEntry entry = new AmmoEntry(type, (int)type.quantityMultiplier);
|
||||||
|
entity.ammo.add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
return ammoMap != null && ammoMap.get(item) != null && entity.totalAmmo + ammoMap.get(item).quantityMultiplier <= maxammo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBars(){
|
||||||
|
bars.add(new BlockBar(BarType.inventory, true, tile -> (float)tile.<TurretEntity>entity().totalAmmo / maxammo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(){
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
if(ammoTypes != null) {
|
||||||
|
for (AmmoType type : ammoTypes) {
|
||||||
|
if(type.item == null) continue;
|
||||||
|
if (ammoMap.containsKey(type.item)) {
|
||||||
|
throw new RuntimeException("Turret \"" + name + "\" has two conflicting ammo entries on item type " + type.item + "!");
|
||||||
|
} else {
|
||||||
|
ammoMap.put(type.item, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
||||||
|
|
||||||
public abstract class LiquidTurret extends Turret {
|
public abstract class LiquidTurret extends Turret {
|
||||||
|
protected AmmoType[] ammoTypes;
|
||||||
protected ObjectMap<Liquid, AmmoType> liquidAmmoMap = new ObjectMap<>();
|
protected ObjectMap<Liquid, AmmoType> liquidAmmoMap = new ObjectMap<>();
|
||||||
|
|
||||||
public LiquidTurret(String name) {
|
public LiquidTurret(String name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user