Implemented lightning turret
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Fri Apr 06 10:14:01 EDT 2018
|
#Fri Apr 06 15:12:13 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=856
|
androidBuildCode=856
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ public class AmmoTypes {
|
|||||||
|
|
||||||
lancerLaser = new AmmoType(TurretBullets.lancerLaser),
|
lancerLaser = new AmmoType(TurretBullets.lancerLaser),
|
||||||
|
|
||||||
|
lightning = new AmmoType(TurretBullets.lightning),
|
||||||
|
|
||||||
oil = new AmmoType(Liquids.oil, TurretBullets.oilShot, 0.3f, 1f),
|
oil = new AmmoType(Liquids.oil, TurretBullets.oilShot, 0.3f, 1f),
|
||||||
|
|
||||||
water = new AmmoType(Liquids.water, TurretBullets.waterShot, 0.3f, 1f),
|
water = new AmmoType(Liquids.water, TurretBullets.waterShot, 0.3f, 1f),
|
||||||
|
|||||||
@@ -107,8 +107,18 @@ public class WeaponBlocks{
|
|||||||
heatColor = Color.RED;
|
heatColor = Color.RED;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
teslaturret = new PowerTurret("teslaturret"){{
|
teslaturret = new LaserTurret("teslaturret"){{
|
||||||
|
shootType = AmmoTypes.lightning;
|
||||||
|
reload = 100f;
|
||||||
|
chargeTime = 70f;
|
||||||
|
shootShake = 1f;
|
||||||
|
chargeMaxDelay = 30f;
|
||||||
|
chargeEffects = 7;
|
||||||
|
shootEffect = ShootFx.lightningShoot;
|
||||||
|
chargeEffect = ShootFx.lancerLaserCharge;
|
||||||
|
chargeBeginEffect = ShootFx.lancerLaserChargeBegin;
|
||||||
|
heatColor = Color.RED;
|
||||||
|
recoil = 3f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
liquidturret = new LiquidTurret("liquidturret") {{
|
liquidturret = new LiquidTurret("liquidturret") {{
|
||||||
|
|||||||
@@ -173,6 +173,8 @@ public class TurretBullets {
|
|||||||
lightning = new BulletType(0.001f, 5) {
|
lightning = new BulletType(0.001f, 5) {
|
||||||
{
|
{
|
||||||
lifetime = 1;
|
lifetime = 1;
|
||||||
|
despawneffect = Fx.none;
|
||||||
|
hiteffect = BulletFx.hitLancer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -182,7 +184,7 @@ public class TurretBullets {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bullet b) {
|
public void init(Bullet b) {
|
||||||
new Lightning(b.team, b, b.x, b.y, b.angle(), 30);
|
new Lightning(b.team, hiteffect, damage, b.x, b.y, b.angle(), 40).add();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -186,5 +186,16 @@ public class ShootFx {
|
|||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
Fill.circle(e.x, e.y, e.fin() * 2f);
|
Fill.circle(e.x, e.y, e.fin() * 2f);
|
||||||
|
}),
|
||||||
|
|
||||||
|
lightningShoot= new Effect(12f, e -> {
|
||||||
|
Draw.color(Color.WHITE, Palette.lancerLaser, e.fin());
|
||||||
|
Lines.stroke(e.fout() * 1.2f + 0.5f);
|
||||||
|
|
||||||
|
Angles.randLenVectors(e.id, 7, 25f * e.finpow(), e.rotation, 50f, (x, y) -> {
|
||||||
|
Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fin()*5f + 2f);
|
||||||
|
});
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,76 @@
|
|||||||
package io.anuke.mindustry.entities.effect;
|
package io.anuke.mindustry.entities.effect;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.ucore.entities.Entity;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.entities.SolidEntity;
|
import io.anuke.ucore.entities.SolidEntity;
|
||||||
|
import io.anuke.ucore.entities.TimedEntity;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.graphics.Lines;
|
||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class Lightning extends Entity {
|
public class Lightning extends TimedEntity {
|
||||||
private Array<Vector2> lines = new Array<Vector2>();
|
private static Array<SolidEntity> entities = new Array<>();
|
||||||
|
private static Rectangle rect = new Rectangle();
|
||||||
|
private static float wetDamageMultiplier = 2;
|
||||||
|
|
||||||
|
private Array<Vector2> lines = new Array<>();
|
||||||
|
private float angle;
|
||||||
|
|
||||||
|
public Lightning(Team team, Effect effect, int damage, float x, float y, float targetAngle, int length){
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.lifetime = 10f;
|
||||||
|
this.angle = targetAngle;
|
||||||
|
|
||||||
public Lightning(Team team, SolidEntity damager, float x, float y, float angle, int length){
|
|
||||||
float step = 3f;
|
float step = 3f;
|
||||||
|
float range = 6f;
|
||||||
|
float attractRange = 20f;
|
||||||
|
|
||||||
|
entities.clear();
|
||||||
|
|
||||||
|
Units.getNearbyEnemies(team, rect, entities::add);
|
||||||
|
|
||||||
for(int i = 0; i < length; i ++){
|
for(int i = 0; i < length; i ++){
|
||||||
lines.add(new Vector2(x, y));
|
lines.add(new Vector2(x, y));
|
||||||
|
|
||||||
|
float fx = x, fy = y;
|
||||||
float x2 = x + Angles.trnsx(angle, step);
|
float x2 = x + Angles.trnsx(angle, step);
|
||||||
float y2 = y + Angles.trnsy(angle, step);
|
float y2 = y + Angles.trnsy(angle, step);
|
||||||
|
float fangle = angle;
|
||||||
angle += Mathf.range(30f);
|
angle += Mathf.range(30f);
|
||||||
|
|
||||||
|
rect.setSize(attractRange).setCenter(x, y);
|
||||||
|
|
||||||
|
Units.getNearbyEnemies(team, rect, entity -> {
|
||||||
|
float dst = entity.distanceTo(x2, y2);
|
||||||
|
if(dst < attractRange) {
|
||||||
|
angle = Mathf.slerp(angle, Angles.angle(x2, y2, entity.x, entity.y), (attractRange - dst) / attractRange / 4f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle hitbox = entity.hitbox.getRect(entity.x, entity.y, range);
|
||||||
|
|
||||||
|
if(hitbox.contains(x2, y2) || hitbox.contains(fx, fy)){
|
||||||
|
int result = damage;
|
||||||
|
|
||||||
|
if(entity.status.current() == StatusEffects.wet)
|
||||||
|
result = (int)(result * wetDamageMultiplier);
|
||||||
|
|
||||||
|
entity.damage(result);
|
||||||
|
Effects.effect(effect, x2, y2, fangle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if(Mathf.chance(0.1)){
|
if(Mathf.chance(0.1)){
|
||||||
new Lightning(team, damager, x2, y2, angle + Mathf.range(100f), length/2).add();
|
new Lightning(team, effect, damage, x2, y2, angle + Mathf.range(100f), length/3).add();
|
||||||
}
|
}
|
||||||
|
|
||||||
x = x2;
|
x = x2;
|
||||||
@@ -31,4 +79,18 @@ public class Lightning extends Entity {
|
|||||||
|
|
||||||
lines.add(new Vector2(x, y));
|
lines.add(new Vector2(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw() {
|
||||||
|
float lx = x, ly = y;
|
||||||
|
Draw.color(Palette.lancerLaser, Color.WHITE, fin());
|
||||||
|
for(int i = 0; i < lines.size; i ++){
|
||||||
|
Vector2 v = lines.get(i);
|
||||||
|
Lines.stroke(fout() * 3f + 1f-(float)i/lines.size);
|
||||||
|
Lines.line(lx, ly, v.x, v.y);
|
||||||
|
lx = v.x;
|
||||||
|
ly = v.y;
|
||||||
|
}
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user