Added sandbox mode and new fortress enemy
This commit is contained in:
@@ -20,6 +20,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
static Color lightRed = Hue.mix(Color.WHITE, Color.FIREBRICK, 0.1f);
|
||||
static Color lightOrange = Color.valueOf("f68021");
|
||||
static Color whiteOrange = Hue.mix(lightOrange, Color.WHITE, 0.6f);
|
||||
static Color whiteYellow = Hue.mix(Color.YELLOW, Color.WHITE, 0.6f);
|
||||
|
||||
public static final BulletType
|
||||
|
||||
@@ -128,7 +129,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
Effects.effect(Fx.shellsmoke, b);
|
||||
Effects.effect(Fx.shellexplosion, b);
|
||||
|
||||
DamageArea.damage(b.owner instanceof Enemy, b.x, b.y, 25f, (int)(damage * 2f/3f));
|
||||
DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 25f, (int)(damage * 2f/3f));
|
||||
}
|
||||
},
|
||||
titanshell = new BulletType(1.8f, 60){
|
||||
@@ -162,6 +163,37 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 25f, (int)(damage * 2f/3f));
|
||||
}
|
||||
},
|
||||
yellowshell = new BulletType(1.2f, 20){
|
||||
{
|
||||
lifetime = 60f;
|
||||
hitsize = 11f;
|
||||
}
|
||||
|
||||
public void draw(Bullet b){
|
||||
Draw.color(whiteYellow);
|
||||
Draw.rect("titanshell", b.x, b.y, b.angle());
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public void update(Bullet b){
|
||||
if(Timers.get(b, "smoke", 4)){
|
||||
Effects.effect(Fx.smoke, b.x + Mathf.range(2), b.y + Mathf.range(2));
|
||||
}
|
||||
}
|
||||
|
||||
public void despawned(Bullet b){
|
||||
removed(b);
|
||||
}
|
||||
|
||||
public void removed(Bullet b){
|
||||
Effects.shake(3f, 3f, b);
|
||||
|
||||
Effects.effect(Fx.shellsmoke, b);
|
||||
Effects.effect(Fx.shockwaveSmall, b);
|
||||
|
||||
DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 25f, (int)(damage * 2f/3f));
|
||||
}
|
||||
},
|
||||
blast = new BulletType(1.1f, 80){
|
||||
{
|
||||
lifetime = 0f;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class DamageArea{
|
||||
public static void damage(boolean enemies, float x, float y, float radius, int damage){
|
||||
|
||||
if(enemies){
|
||||
Entities.getNearby(x, y, radius*2, entity->{
|
||||
Entities.getNearby(Entities.getGroup(Enemy.class), x, y, radius*2, entity->{
|
||||
if(entity instanceof Enemy){
|
||||
Enemy enemy = (Enemy)entity;
|
||||
if(enemy.distanceTo(x, y) > radius){
|
||||
|
||||
@@ -13,6 +13,7 @@ public class Fx{
|
||||
static Color lightRed = Hue.mix(Color.WHITE, Color.FIREBRICK, 0.1f);
|
||||
static Color lightOrange = Color.valueOf("f68021");
|
||||
static Color whiteOrange = Hue.mix(lightOrange, Color.WHITE, 0.6f);
|
||||
static Color whiteYellow = Hue.mix(Color.YELLOW, Color.WHITE, 0.6f);
|
||||
|
||||
public static final Effect
|
||||
|
||||
@@ -34,6 +35,28 @@ public class Fx{
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
mortarshot = new Effect(10f, e -> {
|
||||
Draw.color(Color.WHITE, Color.DARK_GRAY, e.ifract());
|
||||
Draw.thick(e.fract()*6f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*10f);
|
||||
Draw.thick(e.fract()*5f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*14f);
|
||||
Draw.thick(e.fract()*1f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*16f);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
railshot = new Effect(9f, e -> {
|
||||
Draw.color(Color.WHITE, Color.DARK_GRAY, e.ifract());
|
||||
Draw.thick(e.fract()*5f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*8f);
|
||||
Draw.thick(e.fract()*4f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*12f);
|
||||
Draw.thick(e.fract()*1f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*14f);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
titanshot = new Effect(12f, e -> {
|
||||
Draw.color(Color.WHITE, lightOrange, e.ifract());
|
||||
Draw.thick(e.fract()*7f);
|
||||
@@ -45,6 +68,17 @@ public class Fx{
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
largeCannonShot = new Effect(11f, e -> {
|
||||
Draw.color(Color.WHITE, whiteYellow, e.ifract());
|
||||
Draw.thick(e.fract()*6f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*12f);
|
||||
Draw.thick(e.fract()*3f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*16f);
|
||||
Draw.thick(e.fract()*1f);
|
||||
Draw.lineAngle(e.x, e.y, e.rotation, e.fract()*18f);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
shockwave = new Effect(10f, e -> {
|
||||
Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.ifract());
|
||||
Draw.thick(e.fract()*2f + 0.2f);
|
||||
|
||||
@@ -11,8 +11,10 @@ import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.effect.Fx;
|
||||
import io.anuke.mindustry.entities.effect.Shaders;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.UCore;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.*;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
@@ -24,18 +26,21 @@ public class Enemy extends DestructibleEntity{
|
||||
protected float reload = 32;
|
||||
protected float range = 60;
|
||||
protected float length = 4;
|
||||
protected float rotatespeed = 7f;
|
||||
protected float rotatespeed = 0.1f;
|
||||
protected float turretrotatespeed = 0.2f;
|
||||
protected boolean alwaysRotate = false;
|
||||
protected BulletType bullet = BulletType.small;
|
||||
protected String shootsound = "enemyshoot";
|
||||
protected int damage;
|
||||
protected Enemy spawner;
|
||||
protected int spawned = 0;
|
||||
protected float angle;
|
||||
protected boolean targetCore = false;
|
||||
|
||||
public int spawn;
|
||||
public int node = -1;
|
||||
public Tile[] path;
|
||||
|
||||
public Vector2 direction = new Vector2();
|
||||
public float xvelocity, yvelocity;
|
||||
public Entity target;
|
||||
public int tier = 1;
|
||||
@@ -63,7 +68,7 @@ public class Enemy extends DestructibleEntity{
|
||||
|
||||
if(nearCore){
|
||||
vec = Tmp.v2.setZero();
|
||||
target = core.entity;
|
||||
if(targetCore) target = core.entity;
|
||||
}else{
|
||||
vec = Vars.world.pathfinder().find(this);
|
||||
vec.sub(x, y).setLength(speed);
|
||||
@@ -94,7 +99,6 @@ public class Enemy extends DestructibleEntity{
|
||||
|
||||
move(vec.x * Timers.delta(), vec.y * Timers.delta());
|
||||
|
||||
|
||||
updateTargeting(nearCore);
|
||||
}
|
||||
|
||||
@@ -107,6 +111,10 @@ public class Enemy extends DestructibleEntity{
|
||||
target = Entities.getClosest(Entities.defaultGroup(), x, y, range, e -> e instanceof Player);
|
||||
}
|
||||
}
|
||||
|
||||
if(target instanceof Enemy){
|
||||
UCore.log(target);
|
||||
}
|
||||
|
||||
if(target != null && bullet != null){
|
||||
updateShooting();
|
||||
@@ -125,8 +133,8 @@ public class Enemy extends DestructibleEntity{
|
||||
}
|
||||
|
||||
void shoot(BulletType bullet, float rotation){
|
||||
vector.set(length, 0).rotate(direction.angle() + rotation);
|
||||
Bullet out = new Bullet(bullet, this, x + vector.x, y + vector.y, direction.angle() + rotation).add();
|
||||
Angles.translation(angle + rotation, length);
|
||||
Bullet out = new Bullet(bullet, this, x + Angles.x(), y + Angles.y(), this.angle + rotation).add();
|
||||
out.damage = (int) (damage * Vars.multiplier);
|
||||
}
|
||||
|
||||
@@ -195,6 +203,9 @@ public class Enemy extends DestructibleEntity{
|
||||
public void removed(){
|
||||
if(!dead){
|
||||
Vars.control.enemyDeath();
|
||||
if(spawner != null){
|
||||
spawner.spawned --;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,11 +219,9 @@ public class Enemy extends DestructibleEntity{
|
||||
yvelocity = (y - lasty) / Timers.delta();
|
||||
|
||||
if(target == null || alwaysRotate){
|
||||
direction.add(xvelocity * Timers.delta() / 3f, yvelocity * Timers.delta() / 3f);
|
||||
direction.limit(speed * rotatespeed);
|
||||
angle = Mathf.slerp(angle, 180f+Mathf.atan2(xvelocity, yvelocity), rotatespeed * Timers.delta());
|
||||
}else{
|
||||
float angle = angleTo(target);
|
||||
direction.lerp(vector.set(1f, 0f).rotate(angle), turretrotatespeed * Timers.delta());
|
||||
angle = Mathf.slerp(angle, angleTo(target), turretrotatespeed * Timers.delta());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +235,7 @@ public class Enemy extends DestructibleEntity{
|
||||
Shaders.outline.apply();
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(region, x, y, direction.angle() - 90);
|
||||
Draw.rect(region, x, y, this.angle - 90);
|
||||
|
||||
Graphics.flush();
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package io.anuke.mindustry.entities.enemies;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.effect.Fx;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
|
||||
public class FortressEnemy extends Enemy{
|
||||
static int maxSpawn = 6;
|
||||
|
||||
float spawnTime = 240;
|
||||
boolean deployed;
|
||||
|
||||
public FortressEnemy(int spawn) {
|
||||
super(spawn);
|
||||
|
||||
speed = 0.1f;
|
||||
reload = 90;
|
||||
maxhealth = 700;
|
||||
range = 70f;
|
||||
bullet = BulletType.yellowshell;
|
||||
hitbox.setSize(9f);
|
||||
turretrotatespeed = rotatespeed = 0.08f;
|
||||
length = 7f;
|
||||
|
||||
heal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(){
|
||||
super.move();
|
||||
|
||||
if(deployed){
|
||||
|
||||
if(Timers.get(this, "spawn", spawnTime) && spawned < maxSpawn){
|
||||
Angles.translation(angle, 20f);
|
||||
|
||||
FastEnemy enemy = new FastEnemy(spawn);
|
||||
enemy.tier = this.tier;
|
||||
enemy.spawner = this;
|
||||
enemy.set(x + Angles.x(), y + Angles.y());
|
||||
Effects.effect(Fx.spawn, enemy);
|
||||
enemy.add();
|
||||
spawned ++;
|
||||
}
|
||||
}else if(distanceTo(Vars.control.getCore().worldx(),
|
||||
Vars.control.getCore().worldy()) <= 120f){
|
||||
deployed = true;
|
||||
speed = 0.001f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shoot(BulletType type){
|
||||
super.shoot(bullet);
|
||||
Effects.effect(Fx.largeCannonShot, x + Angles.x(), y + Angles.y(), angle);
|
||||
Effects.shake(3f, 3f, this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,7 @@ public class HealerEnemy extends Enemy{
|
||||
bullet = BulletType.shot;
|
||||
range = 30f;
|
||||
alwaysRotate = false;
|
||||
targetCore = false;
|
||||
|
||||
heal();
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ public class TankEnemy extends Enemy{
|
||||
}
|
||||
|
||||
void shoot(){
|
||||
vector.set(length, 0).rotate(direction.angle());
|
||||
Angles.translation(angle, 8f);
|
||||
|
||||
Angles.shotgun(3, 8f, direction.angle(), f->{
|
||||
Angles.shotgun(3, 8f, angle, f->{
|
||||
Bullet out = new Bullet(bullet, this, x+vector.x, y+vector.y, f).add();
|
||||
out.damage = (int)(damage*Vars.multiplier);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user