Added TeslaOrb entity and implemented tesla turrets

This commit is contained in:
Anuken
2017-09-21 14:07:58 -04:00
parent d3b613feb2
commit ec0b4b5dc4
38 changed files with 557 additions and 315 deletions

View File

@@ -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;

View File

@@ -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)),

View File

@@ -0,0 +1,127 @@
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.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;
import io.anuke.ucore.util.Mathf;
public enum Weapon{
blaster(15, BulletType.shot, "Shoots a slow, weak bullet."){
{
unlocked = true;
}
@Override
public void shoot(Player p){
super.shoot(p);
Effects.effect("shoot3", p.x + vector.x, p.y+vector.y);
}
},
triblaster(13, BulletType.shot, "Shoots 3 bullets in a spread.", stack(Item.iron, 40)){
@Override
public void shoot(Player p){
float ang = mouseAngle(p);
float space = 12;
bullet(p, p.x, p.y, ang);
bullet(p, p.x, p.y, ang+space);
bullet(p, p.x, p.y, ang-space);
Effects.effect("shoot", p.x + vector.x, p.y+vector.y);
}
},
multigun(6, BulletType.shot2, "Shoots inaccurate bullets with a high\nrate of fire.", stack(Item.iron, 60), stack(Item.steel, 20)){
@Override
public void shoot(Player p){
float ang = mouseAngle(p);
MathUtils.random.setSeed(Gdx.graphics.getFrameId());
bullet(p, p.x, p.y, ang + Mathf.range(8));
Effects.effect("shoot2", p.x + vector.x, p.y+vector.y);
}
},
flamethrower(5, BulletType.flame, "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);
//????
MathUtils.random.setSeed(Gdx.graphics.getFrameId());
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);
}
};
public float reload;
public BulletType type;
public String shootsound = "shoot";
public boolean unlocked;
public ItemStack[] requirements;
public String description = "no desc for you";
Vector2 vector = new Vector2();
private Weapon(float reload, BulletType type, String desc, ItemStack... requirements){
this.reload = reload;
this.type = type;
this.requirements = requirements;
this.description = desc;
}
public void shoot(Player p){
bullet(p, p.x, p.y, mouseAngle(p));
}
float mouseAngle(Entity owner){
return Angles.mouseAngle(owner.x, owner.y);
}
void bullet(Entity owner, float x, float y, float angle){
vector.set(3, 0).rotate(mouseAngle(owner));
new Bullet(type, owner, x+vector.x, y+vector.y, angle).add();
}
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
}