Added a bunch more turrets

This commit is contained in:
Anuken
2017-04-29 22:15:41 -04:00
parent 218ba8a942
commit 4c26efaef6
8 changed files with 286 additions and 137 deletions

View File

@@ -4,7 +4,6 @@ import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.aabb.Collider;
import io.anuke.moment.entities.Enemy;
import io.anuke.moment.entities.Player;
import io.anuke.moment.resource.Item;
@@ -67,8 +66,7 @@ public class Moment extends ModuleController<Moment>{
items.put(Item.stone, 200);
items.put(Item.iron, 200);
Collider.defaultDrag = 0.2f;
items.put(Item.steel, 200);
player = new Player().add();

View File

@@ -20,6 +20,13 @@ public enum BulletType{
Draw.clear();
}
},
sniper(3f, 17){
public void draw(Bullet b){
Draw.color("light gray");
Draw.rect("bullet", b.x, b.y, b.angle());
Draw.clear();
}
},
small(1.5f, 1){
public void draw(Bullet b){
Draw.color("orange");
@@ -27,6 +34,14 @@ public enum BulletType{
Draw.clear();
}
},
flame(0.6f, 4){
public void draw(Bullet b){
Draw.color(Color.YELLOW, Color.SCARLET, b.time/lifetime);
float size = 6f-b.time/lifetime*5f;
Draw.rect("circle", b.x, b.y, size, size);
Draw.clear();
}
},
shot(2.4f, 2){
{lifetime=40;}
public void draw(Bullet b){

View File

@@ -9,12 +9,16 @@ public enum Recipe{
irondrill(TileType.irondrill, stack(Item.stone, 30)),
coaldrill(TileType.coaldrill, stack(Item.stone, 30), stack(Item.iron, 30)),
conveyor(TileType.conveyor, stack(Item.stone, 1)),
fastconveyor(TileType.steelconveyor, stack(Item.steel, 1)),
router(TileType.router, stack(Item.stone, 3)),
smelter(TileType.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
healturret(TileType.healturret, stack(Item.iron, 20)),
turret(TileType.turret, stack(Item.stone, 4)),
dturret(TileType.doubleturret, stack(Item.stone, 6)),
machineturret(TileType.machineturret, stack(Item.iron, 8), stack(Item.stone, 6));
machineturret(TileType.machineturret, stack(Item.iron, 10), stack(Item.stone, 6)),
shotgunturret(TileType.shotgunturret, stack(Item.iron, 10), stack(Item.steel, 8)),
flameturret(TileType.flameturret, stack(Item.iron, 12), stack(Item.steel, 12)),
sniperturret(TileType.sniperturret, stack(Item.iron, 15), stack(Item.steel, 20));
public TileType result;
public ItemStack[] requirements;

View File

@@ -33,7 +33,7 @@ public class Generator{
}
if(color == white){
block = TileType.dirtblock;
block = TileType.stoneblock;
}else if(color == blue){

View File

@@ -179,7 +179,7 @@ public enum TileType{
}
public String description(){
return "Moves Items (faster than a normal conveyor!)";
return "Moves Items\nFaster than a normal conveyor";
}
@Override
@@ -273,7 +273,7 @@ public enum TileType{
doubleturret(true, true, false){
{
range = 40;
reload = 10f;
reload = 13f;
bullet = BulletType.stone;
ammo = Item.stone;
health = 50;
@@ -294,11 +294,19 @@ public enum TileType{
public String description(){
return "Shoots things.";
}
@Override
void shoot(Tile tile){
vector.set(4, -2).rotate(tile.entity.rotation);
bullet(tile, tile.entity.rotation);
vector.set(4, 2).rotate(tile.entity.rotation);
bullet(tile, tile.entity.rotation);
}
},
machineturret(true, true, false){
{
range = 65;
reload = 5f;
reload = 7f;
bullet = BulletType.iron;
ammo = Item.iron;
health = 65;
@@ -320,6 +328,91 @@ public enum TileType{
return "Shoots things.";
}
},
flameturret(true, true, false){
{
range = 30f;
reload = 6f;
bullet = BulletType.flame;
ammo = Item.coal;
health = 75;
}
public void update(Tile tile){
updateTurret(tile);
}
public void draw(Tile tile){
Draw.rect("block", tile.worldx(), tile.worldy());
}
public void drawOver(Tile tile){
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
}
public String description(){
return "Burns things.";
}
},
sniperturret(true, true, false){
{
range = 100;
reload = 60f;
bullet = BulletType.sniper;
ammo = Item.steel;
health = 60;
}
public void update(Tile tile){
updateTurret(tile);
}
public void draw(Tile tile){
Draw.rect("block", tile.worldx(), tile.worldy());
}
public void drawOver(Tile tile){
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
}
public String description(){
return "Shoots things.";
}
},
shotgunturret(true, true, false){
{
range = 65;
reload = 40f;
bullet = BulletType.iron;
ammo = Item.iron;
health = 70;
}
public void update(Tile tile){
updateTurret(tile);
}
public void draw(Tile tile){
Draw.rect("block", tile.worldx(), tile.worldy());
}
public void drawOver(Tile tile){
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
}
public String description(){
return "Shoots things.";
}
@Override
void shoot(Tile tile){
vector.set(0, 4).setAngle(tile.entity.rotation);
for(int i = 0; i < 6; i ++)
Timers.run(i, ()->{
bullet(tile, tile.entity.rotation + Mathf.range(6));
});
}
},
healturret(true, true, false){
{
range = 30;
@@ -415,24 +508,34 @@ public enum TileType{
tile.entity.shots += 20;
tile.entity.removeItem(ammo, 1);
}
if(tile.entity.shots > 0){
//TODO readd
//if(tile.entity.shots > 0){
Enemy enemy = findTarget(tile, range);
if(enemy != null){
tile.entity.rotation = MathUtils.lerpAngleDeg(tile.entity.rotation, Angles.predictAngle(tile.worldx(), tile.worldy(), enemy.x, enemy.y, enemy.xvelocity, enemy.yvelocity, bullet.speed - 0.1f), 0.2f);
if(Timers.get(tile, reload)){
new Bullet(bullet, tile.entity, tile.worldx(), tile.worldy(), tile.entity.rotation).add();
shoot(tile);
tile.entity.shots--;
}
}
}
//}
}
void shoot(Tile tile){
vector.set(0, 4).setAngle(tile.entity.rotation);
new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, tile.entity.rotation).add();
}
void bullet(Tile tile, float angle){
new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, angle).add();
}
Enemy findTarget(Tile tile, float range){
Entity closest = null;
float dst = 0;
Array<SolidEntity> array = Entities.getNearby(tile.worldx(), tile.worldy(), 100);
Array<SolidEntity> array = Entities.getNearby(tile.worldx(), tile.worldy(), range*2);
for(Entity e : array){