Implemented more enemies and a tier system
This commit is contained in:
@@ -58,7 +58,7 @@ public class Bullet extends BulletEntity{
|
||||
|
||||
@Override
|
||||
public int getDamage(){
|
||||
return type.damage;
|
||||
return damage == -1 ? type.damage : damage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-8
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-8
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user