Added TeslaOrb entity and implemented tesla turrets
This commit is contained in:
@@ -11,12 +11,12 @@ import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.mindustry.ai.Pathfind;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.Weapon;
|
||||
import io.anuke.mindustry.entities.enemies.*;
|
||||
import io.anuke.mindustry.input.AndroidInput;
|
||||
import io.anuke.mindustry.input.GestureHandler;
|
||||
import io.anuke.mindustry.input.Input;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.World;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
|
||||
@@ -21,6 +21,7 @@ public class Inventory{
|
||||
items.put(Item.steel, 2000000);
|
||||
items.put(Item.coal, 2000000);
|
||||
items.put(Item.titanium, 2000000);
|
||||
items.put(Item.dirium, 2000000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.mindustry.entities.Weapon;
|
||||
import io.anuke.mindustry.input.AndroidInput;
|
||||
import io.anuke.mindustry.resource.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
@@ -551,8 +550,8 @@ public class UI extends SceneModule{
|
||||
weapontable.clearChildren();
|
||||
|
||||
for(Weapon weapon : control.getWeapons()){
|
||||
ImageButton button = new ImageButton(Draw.region("weapon-"+weapon.name()), "static");
|
||||
button.getImageCell().size(40);
|
||||
ImageButton button = new ImageButton(Draw.region(weapon.name()), "static");
|
||||
button.getImageCell().size(14*3);
|
||||
button.setDisabled(true);
|
||||
|
||||
if(weapon != player.weapon)
|
||||
|
||||
@@ -108,6 +108,17 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
Draw.reset();
|
||||
}
|
||||
},
|
||||
plasmaflame = new BulletType(0.8f, 15){
|
||||
{
|
||||
lifetime = 65f;
|
||||
}
|
||||
public void draw(Bullet b){
|
||||
Draw.color(Color.valueOf("c2efd7"), Color.valueOf("72deaf"), b.time/lifetime);
|
||||
float size = 7f-b.time/lifetime*6f;
|
||||
Draw.rect("circle", b.x, b.y, size, size);
|
||||
Draw.reset();
|
||||
}
|
||||
},
|
||||
flameshot = new BulletType(0.5f, 3){
|
||||
public void draw(Bullet b){
|
||||
Draw.color(Color.ORANGE, Color.SCARLET, b.time/lifetime);
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.resource.Recipe;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.DestructibleEntity;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
|
||||
5
core/src/io/anuke/mindustry/entities/StatusEffect.java
Normal file
5
core/src/io/anuke/mindustry/entities/StatusEffect.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
public enum StatusEffect{
|
||||
none;
|
||||
}
|
||||
127
core/src/io/anuke/mindustry/entities/effect/TeslaOrb.java
Normal file
127
core/src/io/anuke/mindustry/entities/effect/TeslaOrb.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
public class TeslaOrb extends Entity{
|
||||
private Array<Vector2> points = new Array<>();
|
||||
private ObjectSet<Enemy> hit = new ObjectSet<>();
|
||||
private int damage = 0;
|
||||
private float range = 0;
|
||||
private float lifetime = 30f;
|
||||
private float life = 0f;
|
||||
|
||||
public TeslaOrb(float x, float y, float range, int damage){
|
||||
set(x, y);
|
||||
this.damage = damage;
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
void shock(){
|
||||
float stopchance = 0.1f;
|
||||
float curx = x, cury = y;
|
||||
float shake = 3f;
|
||||
|
||||
outer:
|
||||
while(true){
|
||||
if(Mathf.chance(stopchance)){
|
||||
break;
|
||||
}
|
||||
Array<SolidEntity> enemies = Entities.getNearby(curx, cury, range);
|
||||
|
||||
for(SolidEntity entity : enemies){
|
||||
if(entity instanceof Enemy && entity.distanceTo(curx, cury) < range
|
||||
&& !hit.contains((Enemy)entity)){
|
||||
hit.add((Enemy)entity);
|
||||
points.add(new Vector2(entity.x + Mathf.range(shake), entity.y + Mathf.range(shake)));
|
||||
damageEnemy((Enemy)entity);
|
||||
curx = entity.x;
|
||||
cury = entity.y;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(points.size == 0){
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
void damageEnemy(Enemy enemy){
|
||||
//TODO
|
||||
enemy.damage(damage);
|
||||
Effects.effect("laserhit", enemy.x + Mathf.range(2f), enemy.y + Mathf.range(2f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
life += Timers.delta();
|
||||
|
||||
if(life >= lifetime){
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOver(){
|
||||
if(points.size == 0) return;
|
||||
|
||||
float range = 1f;
|
||||
|
||||
Vector2 previous = Tmp.v1.set(x, y);
|
||||
|
||||
for(Vector2 enemy : points){
|
||||
|
||||
|
||||
float x1 = previous.x + Mathf.range(range),
|
||||
y1 = previous.y + Mathf.range(range),
|
||||
x2 = enemy.x + Mathf.range(range),
|
||||
y2 = enemy.y + Mathf.range(range);
|
||||
|
||||
Draw.color(Color.WHITE);
|
||||
Draw.alpha(1f-life/lifetime);
|
||||
|
||||
Draw.thick(3f - life/lifetime*2f);
|
||||
Draw.line(x1, y1, x2, y2);
|
||||
|
||||
float rad = 7f - life/lifetime*5f;
|
||||
|
||||
Draw.rect("circle", x2, y2, rad, rad);
|
||||
|
||||
if(previous.epsilonEquals(x, y, 0.001f)){
|
||||
Draw.rect("circle", x, y, rad, rad);
|
||||
}
|
||||
|
||||
//Draw.color(Color.WHITE);
|
||||
|
||||
//Draw.thick(2f - life/lifetime*2f);
|
||||
//Draw.line(x1, y1, x2, y2);
|
||||
|
||||
Draw.reset();
|
||||
|
||||
previous = enemy;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void added(){
|
||||
Timers.run(1f, ()->{
|
||||
shock();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.ai.Pathfind;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.World;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
@@ -30,6 +28,7 @@ public class Enemy extends DestructibleEntity{
|
||||
public Vector2 direction = new Vector2();
|
||||
public float xvelocity, yvelocity;
|
||||
public Entity target;
|
||||
public StatusEffect effect = StatusEffect.none;
|
||||
|
||||
|
||||
public Enemy(int spawn){
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.badlogic.gdx.Input.Buttons;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
|
||||
import io.anuke.mindustry.Inventory;
|
||||
import io.anuke.mindustry.entities.Weapon;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.World;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
|
||||
@@ -15,9 +15,9 @@ import com.badlogic.gdx.utils.TimeUtils;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.entities.Weapon;
|
||||
import io.anuke.mindustry.entities.enemies.*;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.World;
|
||||
|
||||
@@ -3,7 +3,8 @@ package io.anuke.mindustry.resource;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
public enum Liquid{
|
||||
water(Color.ROYAL);
|
||||
water(Color.ROYAL),
|
||||
plasma(Color.CORAL);
|
||||
|
||||
public final Color color;
|
||||
|
||||
|
||||
@@ -27,9 +27,11 @@ public enum Recipe{
|
||||
sniperturret(defense, WeaponBlocks.sniperturret, stack(Item.iron, 30), stack(Item.steel, 20)),
|
||||
laserturret(defense, WeaponBlocks.laserturret, stack(Item.steel, 20), stack(Item.titanium, 20)),
|
||||
mortarturret(defense, WeaponBlocks.mortarturret, stack(Item.steel, 40), stack(Item.titanium, 30)),
|
||||
waveturret(defense, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 20), stack(Item.dirium, 20)),
|
||||
plasmaturret(defense, WeaponBlocks.plasmaturret, stack(Item.steel, 40), stack(Item.titanium, 30), stack(Item.dirium, 25)),
|
||||
|
||||
healturret(defense, WeaponBlocks.repairturret, stack(Item.iron, 45)),
|
||||
megahealturret(defense, WeaponBlocks.megarepairturret, stack(Item.iron, 30), stack(Item.steel, 40)),
|
||||
healturret(defense, WeaponBlocks.repairturret, stack(Item.iron, 50)),
|
||||
megahealturret(defense, WeaponBlocks.megarepairturret, stack(Item.iron, 30), stack(Item.steel, 50)),
|
||||
|
||||
drill(production, ProductionBlocks.stonedrill, stack(Item.stone, 6)),
|
||||
irondrill(production, ProductionBlocks.irondrill, stack(Item.stone, 40)),
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package io.anuke.mindustry.resource;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
@@ -23,7 +24,7 @@ public enum Weapon{
|
||||
Effects.effect("shoot3", p.x + vector.x, p.y+vector.y);
|
||||
}
|
||||
},
|
||||
trishot(13, BulletType.shot, "Shoots 3 bullets in a spread.", stack(Item.iron, 40)){
|
||||
triblaster(13, BulletType.shot, "Shoots 3 bullets in a spread.", stack(Item.iron, 40)){
|
||||
|
||||
@Override
|
||||
public void shoot(Player p){
|
||||
@@ -63,9 +64,36 @@ public enum Weapon{
|
||||
|
||||
bullet(p, p.x, p.y, ang + Mathf.range(12));
|
||||
}
|
||||
},
|
||||
//TODO
|
||||
railgun(40, BulletType.sniper, "Shoots a stream of fire.", stack(Item.steel, 60), stack(Item.coal, 60)){
|
||||
|
||||
{
|
||||
shootsound = "flame2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shoot(Player p){
|
||||
float ang = mouseAngle(p);
|
||||
|
||||
bullet(p, p.x, p.y, ang);
|
||||
}
|
||||
},
|
||||
//TODO
|
||||
mortar(20, BulletType.shell, "Shoots a stream of fire.", stack(Item.steel, 60), stack(Item.coal, 60)){
|
||||
|
||||
{
|
||||
shootsound = "flame2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shoot(Player p){
|
||||
float ang = mouseAngle(p);
|
||||
bullet(p, p.x, p.y, ang);
|
||||
}
|
||||
};
|
||||
float reload;
|
||||
BulletType type;
|
||||
public float reload;
|
||||
public BulletType type;
|
||||
public String shootsound = "shoot";
|
||||
public boolean unlocked;
|
||||
public ItemStack[] requirements;
|
||||
@@ -7,8 +7,8 @@ import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.GameState;
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.mindustry.Inventory;
|
||||
import io.anuke.mindustry.entities.Weapon;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.function.Listenable;
|
||||
@@ -45,8 +45,8 @@ public class UpgradeDialog extends Dialog{
|
||||
for(Weapon weapon : Weapon.values()){
|
||||
TextButton button = new TextButton(weapon.name());
|
||||
|
||||
Image img = new Image(Draw.region("weapon-"+weapon.name()));
|
||||
button.add(img).size(8*5);
|
||||
Image img = new Image(Draw.region(weapon.name()));
|
||||
button.add(img).size(14*4);
|
||||
button.getCells().reverse();
|
||||
button.row();
|
||||
button.pack();
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Generator{
|
||||
floor = Blocks.iron;
|
||||
}
|
||||
|
||||
if(Noise.nnoise(x, y, 6, 1) > 0.242){
|
||||
if(Noise.nnoise(x, y, 6, 1) > 0.24){
|
||||
floor = Blocks.coal;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.effect.TeslaOrb;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -10,6 +12,7 @@ import io.anuke.mindustry.world.blocks.types.LaserTurret;
|
||||
import io.anuke.mindustry.world.blocks.types.RepairTurret;
|
||||
import io.anuke.mindustry.world.blocks.types.Turret;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class WeaponBlocks{
|
||||
@@ -130,6 +133,40 @@ public class WeaponBlocks{
|
||||
}
|
||||
},
|
||||
|
||||
//TODO
|
||||
teslaturret = new Turret("waveturret"){
|
||||
{
|
||||
formalName = "tesla turret";
|
||||
range = 70;
|
||||
reload = 20f;
|
||||
bullet = BulletType.shell;
|
||||
ammo = Item.stone;
|
||||
health = 1100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shoot(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
Angles.translation(entity.rotation, 4);
|
||||
|
||||
new TeslaOrb(tile.worldx() + Angles.x(), tile.worldy() + Angles.y(),
|
||||
70, (int)(10*Vars.multiplier)).add();
|
||||
}
|
||||
},
|
||||
|
||||
//TODO
|
||||
plasmaturret = new Turret("plasmaturret"){
|
||||
{
|
||||
inaccuracy = 7f;
|
||||
formalName = "plasma turret";
|
||||
range = 60f;
|
||||
reload = 3f;
|
||||
bullet = BulletType.plasmaflame;
|
||||
ammo = Item.stone;
|
||||
health = 180;
|
||||
}
|
||||
},
|
||||
|
||||
repairturret = new RepairTurret("repairturret"){
|
||||
{
|
||||
formalName = "heal turret";
|
||||
|
||||
@@ -27,6 +27,7 @@ public class Turret extends Block{
|
||||
|
||||
protected float range = 50f;
|
||||
protected float reload = 10f;
|
||||
protected float inaccuracy = 0f;
|
||||
protected String shootsound = "shoot";
|
||||
protected BulletType bullet = BulletType.iron;
|
||||
protected Item ammo;
|
||||
@@ -131,8 +132,10 @@ public class Turret extends Block{
|
||||
protected void shoot(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
|
||||
vector.set(0, 4).setAngle(entity.rotation);
|
||||
Bullet out = new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, entity.rotation).add();
|
||||
float inac = Mathf.range(inaccuracy);
|
||||
|
||||
vector.set(0, 4).setAngle(entity.rotation + inac);
|
||||
Bullet out = new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, entity.rotation + inac).add();
|
||||
out.damage = (int)(bullet.damage*Vars.multiplier);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user