Implemented more enemies and a tier system

This commit is contained in:
Anuken
2017-09-23 20:48:18 -04:00
parent b3ef1e2f2f
commit 5f8e451750
59 changed files with 529 additions and 160 deletions

View File

@@ -8,13 +8,13 @@ import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.Constructor;
import io.anuke.mindustry.GameState.State;
import io.anuke.mindustry.ai.Pathfind;
import io.anuke.mindustry.entities.EnemySpawn;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.entities.enemies.TestEnemy;
import io.anuke.mindustry.entities.enemies.*;
import io.anuke.mindustry.input.AndroidInput;
import io.anuke.mindustry.input.GestureHandler;
import io.anuke.mindustry.input.Input;
@@ -91,9 +91,29 @@ public class Control extends Module{
player = new Player();
spawns = Array.with(
new EnemySpawn(Enemy.class){{
}},
new EnemySpawn(FastEnemy.class){{
}},
new EnemySpawn(FlamerEnemy.class){{
}},
new EnemySpawn(BlastEnemy.class){{
}},
new EnemySpawn(RapidEnemy.class){{
}},
new EnemySpawn(TankEnemy.class){{
}},
new EnemySpawn(MortarEnemy.class){{
}}
);
printEnemies(100);
@@ -169,15 +189,17 @@ public class Control extends Module{
for(EnemySpawn spawn : spawns){
for(int lane = 0; lane < World.spawnpoints.size; lane ++){
int fl = lane;
Tile tile = World.spawnpoints.get(lane);
int spawnamount = spawn.evaluate(wave, lane);
for(int i = 0; i < spawnamount; i ++){
int index = i;
Timers.run(index*30f, ()->{
Timers.run(index*50f, ()->{
try{
Enemy enemy = (Enemy)ClassReflection.newInstance(spawn.type);
Constructor c = ClassReflection.getConstructor(spawn.type, int.class);
Enemy enemy = (Enemy)c.newInstance(fl);
enemy.set(tile.worldx(), tile.worldy());
Effects.effect("spawn", enemy);
enemy.add();

View File

@@ -23,6 +23,15 @@ public class EffectLoader{
});
});
Effects.create("blastsmoke", 26, e -> {
Angles.randLenVectors(e.id, 12, 1f + e.ifract()*23f, (x, y)->{
float size = 2f+e.fract()*6f;
Draw.color(Color.LIGHT_GRAY, Color.DARK_GRAY, e.ifract());
Draw.rect("circle", e.x + x, e.y + y, size, size);
Draw.reset();
});
});
Effects.create("shellexplosion", 15, e -> {
Draw.thickness(1.3f - e.ifract());
Draw.color(Hue.mix(Color.WHITE, Color.ORANGE, e.ifract()));
@@ -30,6 +39,13 @@ public class EffectLoader{
Draw.reset();
});
Effects.create("blastexplosion", 16, e -> {
Draw.thickness(1.2f - e.ifract());
Draw.color(Hue.mix(Color.WHITE, Color.SCARLET, e.ifract()));
Draw.circle(e.x, e.y, 1.5f + e.ifract() * 9f);
Draw.reset();
});
Effects.create("place", 16, e -> {
Draw.thickness(3f - e.ifract() * 2f);
Draw.square(e.x, e.y, Vars.tilesize / 2f + e.ifract() * 3f);

View File

@@ -40,6 +40,7 @@ public class Renderer extends RendererModule{
pixelate();
Draw.addSurface("shadow", Core.cameraScale);
Shaders.create();
}
@Override

View File

@@ -0,0 +1,28 @@
package io.anuke.mindustry;
import com.badlogic.gdx.graphics.Color;
import io.anuke.ucore.graphics.Shader;
import io.anuke.ucore.util.Tmp;
public class Shaders{
public static void create(){
new Outline();
}
public static class Outline extends Shader{
public Color color = new Color();
public Outline(){
super("outline", "default");
}
@Override
public void apply(){
shader.setUniformf("u_color", color);
shader.setUniformf("u_texsize", Tmp.v1.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
}
}
}

View File

@@ -15,7 +15,7 @@ public class Vars{
//respawn time in frames
public static final float respawnduration = 60*4;
//time between waves in frames
public static final float wavespace = 25*60*(android ? 2 : 1);
public static final float wavespace = 35*60*(android ? 2 : 1);
//how far away from spawn points the player can't place blocks
public static final float enemyspawnspace = 65;
//scale of the font

View File

@@ -58,7 +58,7 @@ public class Bullet extends BulletEntity{
@Override
public int getDamage(){
return type.damage;
return damage == -1 ? type.damage : damage;
}
}

View File

@@ -38,7 +38,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Draw.reset();
}
},
shell = new BulletType(1.1f, 110){
shell = new BulletType(1.1f, 80){
{
lifetime = 110f;
hitsize = 8f;
@@ -75,15 +75,43 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
});
}
},
blast = new BulletType(1.1f, 80){
{
lifetime = 0f;
hitsize = 8f;
speed = 0f;
}
public void despawned(Bullet b){
removed(b);
}
public void removed(Bullet b){
Effects.shake(3f, 3f, b);
Effects.effect("blastsmoke", b);
Effects.effect("blastexplosion", b);
Angles.circle(30, f->{
Angles.translation(f, 6f);
Bullet o = new Bullet(blastshot, b.owner, b.x + Angles.x(), b.y + Angles.y(), f).add();
o.damage = b.damage/9;
});
}
public void draw(Bullet b){}
},
shellshot = new BulletType(1.5f, 6){
{
lifetime = 7f;
}
public void draw(Bullet b){
// Draw.color("orange");
// Draw.rect("bullet", b.x, b.y, b.angle());
// Draw.reset();
public void draw(Bullet b){}
},
blastshot = new BulletType(1.6f, 6){
{
lifetime = 7f;
}
public void draw(Bullet b){}
},
small = new BulletType(1.5f, 1){
public void draw(Bullet b){

View File

@@ -0,0 +1,27 @@
package io.anuke.mindustry.entities.enemies;
import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.BulletType;
public class BlastEnemy extends Enemy{
public BlastEnemy(int spawn) {
super(spawn);
maxhealth = 15;
speed = 0.65f;
bullet = null;
turretrotatespeed = 0f;
heal();
}
void move(){
super.move();
if(target != null && target.distanceTo(this) < 10f){
Bullet b = new Bullet(BulletType.blast, this, x, y, 0).add();
b.damage = BulletType.blast.damage + (tier-1) * 50;
damage(999);
}
}
}

View File

@@ -1,25 +1,35 @@
package io.anuke.mindustry.entities.enemies;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import io.anuke.mindustry.Shaders.Outline;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.ai.Pathfind;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.World;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.*;
import io.anuke.ucore.util.Mathf;
public class Enemy extends DestructibleEntity{
public final static Color[] tierColors = {Color.YELLOW, Color.MAGENTA, Color.RED};
protected float speed = 0.3f;
protected float reload = 40;
protected float range = 60;
protected float length = 4;
protected float rotatespeed = 8f;
protected float rotatespeed = 7f;
protected float turretrotatespeed = 0.2f;
protected BulletType bullet = BulletType.small;
protected String shootsound = "enemyshoot";
protected int damage;
public Tile[] path;
public int spawn;
@@ -28,7 +38,7 @@ public class Enemy extends DestructibleEntity{
public Vector2 direction = new Vector2();
public float xvelocity, yvelocity;
public Entity target;
public StatusEffect effect = StatusEffect.none;
public int tier = Mathf.random(1, 3);
public Enemy(int spawn){
@@ -61,7 +71,7 @@ public class Enemy extends DestructibleEntity{
}
if(target != null){
if(target != null && bullet != null){
if(Timers.get(this, "reload", reload*Vars.multiplier)){
shoot();
Effects.sound(shootsound, this);
@@ -72,7 +82,7 @@ public class Enemy extends DestructibleEntity{
void shoot(){
vector.set(length, 0).rotate(direction.angle());
Bullet out = new Bullet(bullet, this, x+vector.x, y+vector.y, direction.angle()).add();
out.damage = (int)(bullet.damage*Vars.multiplier);
out.damage = (int)(damage*Vars.multiplier);
}
public void findClosestNode(){
@@ -95,6 +105,20 @@ public class Enemy extends DestructibleEntity{
node = cindex;
}
@Override
public void added(){
if(bullet != null){
damage = (int)(bullet.damage * (1 + (tier - 1) * 0.5f));
}
maxhealth *= tier;
speed += 0.04f*tier + Mathf.range(0.1f);
reload /= Math.max(tier /1.5f, 1f);
range += tier*5;
heal();
}
@Override
public boolean collides(SolidEntity other){
return (other instanceof Bullet) && !(((Bullet)other).owner instanceof Enemy);
@@ -111,8 +135,9 @@ public class Enemy extends DestructibleEntity{
@Override
public void removed(){
if(!dead)
if(!dead){
Vars.control.enemyDeath();
}
}
@Override
@@ -129,13 +154,21 @@ public class Enemy extends DestructibleEntity{
direction.limit(speed*rotatespeed);
}else{
float angle = angleTo(target);
direction.lerp(vector.set(0, 1).setAngle(angle), 0.25f);
direction.lerp(vector.set(0, 1).setAngle(angle), turretrotatespeed * Timers.delta());
}
}
@Override
public void draw(){
Draw.color();
Draw.rect("mech1", x, y, direction.angle()-90);
String region = ClassReflection.getSimpleName(getClass()).toLowerCase() + "-t" + tier;
Draw.getShader(Outline.class).color.set(tierColors[tier-1]);
Draw.getShader(Outline.class).region = Draw.region(region);
Draw.shader(Outline.class);
Draw.rect(region, x, y, direction.angle()-90);
Draw.shader();
}
}

View File

@@ -1,7 +1,5 @@
package io.anuke.mindustry.entities.enemies;
import io.anuke.ucore.core.Draw;
public class FastEnemy extends Enemy{
public FastEnemy(int spawn) {
@@ -13,10 +11,5 @@ public class FastEnemy extends Enemy{
maxhealth = 20;
heal();
}
@Override
public void draw(){
Draw.rect("fastmech", x, y, direction.angle()-90);
}
}

View File

@@ -1,11 +1,10 @@
package io.anuke.mindustry.entities.enemies;
import io.anuke.mindustry.entities.BulletType;
import io.anuke.ucore.core.Draw;
public class FlameEnemy extends Enemy{
public class FlamerEnemy extends Enemy{
public FlameEnemy(int spawn) {
public FlamerEnemy(int spawn) {
super(spawn);
speed = 0.35f;
@@ -19,10 +18,5 @@ public class FlameEnemy extends Enemy{
heal();
}
@Override
public void draw(){
Draw.rect("firemech", x, y, direction.angle()-90);
}
}

View File

@@ -0,0 +1,19 @@
package io.anuke.mindustry.entities.enemies;
import io.anuke.mindustry.entities.BulletType;
public class MortarEnemy extends Enemy{
public MortarEnemy(int spawn) {
super(spawn);
maxhealth = 200;
speed = 0.2f;
reload = 100f;
bullet = BulletType.shell;
turretrotatespeed = 0.15f;
rotatespeed = 7f;
range = 120f;
}
}

View File

@@ -1,11 +1,10 @@
package io.anuke.mindustry.entities.enemies;
import io.anuke.mindustry.entities.BulletType;
import io.anuke.ucore.core.Draw;
public class BossEnemy extends Enemy{
public class RapidEnemy extends Enemy{
public BossEnemy(int spawn) {
public RapidEnemy(int spawn) {
super(spawn);
reload = 8;
@@ -18,10 +17,5 @@ public class BossEnemy extends Enemy{
range = 70;
}
@Override
public void draw(){
Draw.rect("bossmech", x, y, direction.angle()-90);
}
}

View File

@@ -0,0 +1,16 @@
package io.anuke.mindustry.entities.enemies;
import io.anuke.mindustry.entities.BulletType;
public class TankEnemy extends Enemy{
public TankEnemy(int spawn) {
super(spawn);
maxhealth = 400;
speed = 0.2f;
reload = 140f;
bullet = BulletType.iron;
}
}

View File

@@ -90,8 +90,8 @@ public class SaveIO{
private static final Array<Class<? extends Enemy>> enemyIDs = Array.with(
Enemy.class,
FastEnemy.class,
BossEnemy.class,
FlameEnemy.class
RapidEnemy.class,
FlamerEnemy.class
);
private static final ObjectMap<Class<? extends Enemy>, Byte> idEnemies = new ObjectMap<Class<? extends Enemy>, Byte>(){{

View File

@@ -39,10 +39,11 @@ public enum Recipe{
irondrill(production, ProductionBlocks.irondrill, stack(Item.stone, 40)),
coaldrill(production, ProductionBlocks.coaldrill, stack(Item.stone, 40), stack(Item.iron, 40)),
titaniumdrill(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
omnidrill(production, ProductionBlocks.omnidrill, stack(Item.titanium, 40), stack(Item.dirium, 40)),
smelter(production, ProductionBlocks.smelter, stack(Item.stone, 80), stack(Item.iron, 80)),
crucible(production, ProductionBlocks.crucible, stack(Item.titanium, 80), stack(Item.steel, 80)),
coalpurifier(production, ProductionBlocks.coalpurifier, stack(Item.steel, 20), stack(Item.iron, 20)),
titaniumpurifier(production, ProductionBlocks.titaniumpurifier, stack(Item.steel, 60), stack(Item.iron, 60)),
omnidrill(production, ProductionBlocks.omnidrill, stack(Item.titanium, 40), stack(Item.dirium, 40)),
conduit(distribution, ProductionBlocks.conduit, stack(Item.steel, 1)),
liquidrouter(distribution, ProductionBlocks.liquidrouter, stack(Item.steel, 5)),

View File

@@ -62,7 +62,7 @@ public class Generator{
floor = Blocks.coal;
}
if(Noise.nnoise(x, y, 9, 1) > 0.254){
if(Noise.nnoise(x + 9999, y + 9999, 8, 1) > 0.253){
floor = Blocks.titanium;
}
}

View File

@@ -115,7 +115,7 @@ public class ProductionBlocks{
coalpurifier = new Purifier("coalpurifier"){
{
formalName = "coal purifier";
formalName = "coal extractor";
input = Item.stone;
inputLiquid = Liquid.water;
output = Item.coal;
@@ -127,6 +127,24 @@ public class ProductionBlocks{
}
},
titaniumpurifier = new Purifier("titaniumpurifier"){
{
formalName = "titanium\nextractor";
input = Item.iron;
inputAmount = 11;
inputLiquid = Liquid.water;
liquidAmount = 40f;
liquidCapacity = 41f;
purifyTime = 90;
output = Item.titanium;
}
@Override
public String description(){
return "Takes in iron + water, outputs coal.";
}
},
stonedrill = new Drill("stonedrill"){{
resource = Blocks.stone;
result = Item.stone;

View File

@@ -18,12 +18,14 @@ public class Purifier extends Conduit{
public float liquidAmount = 19.99f;
public Item output = null;
public int itemCapacity = 100;
public int purifyTime = 90;
public int purifyTime = 80;
public Purifier(String name) {
super(name);
update = true;
rotate = false;
solid = true;
health = 60;
liquidCapacity = 20f;
}