Changed to use new effects system

This commit is contained in:
Anuken
2017-11-18 20:40:04 -05:00
parent abb6cb9e9f
commit 858791de3b
36 changed files with 678 additions and 504 deletions
@@ -2,7 +2,10 @@ package io.anuke.mindustry.entities;
import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.entities.effect.DamageArea;
import io.anuke.mindustry.entities.effect.EMP;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
@@ -14,6 +17,9 @@ import io.anuke.ucore.util.Mathf;
public abstract class BulletType extends BaseBulletType<Bullet>{
static Color glowy = Color.valueOf("fdc056");
static Color lightGold = Hue.mix(Color.GOLD, Color.WHITE, 0.4f);
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);
public static final BulletType
@@ -36,8 +42,8 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
},
chain = new BulletType(2f, 8){
public void draw(Bullet b){
Draw.color("gray");
Draw.rect("bullet", b.x, b.y, b.angle());
Draw.color(whiteOrange);
Draw.rect("chainbullet", b.x, b.y, b.angle());
Draw.reset();
}
},
@@ -51,7 +57,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public void update(Bullet b){
if(Timers.get(b, "smoke", 4)){
Effects.effect("railsmoke", b.x, b.y);
Effects.effect(Fx.railsmoke, b.x, b.y);
}
}
},
@@ -72,7 +78,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public void update(Bullet b){
if(Timers.get(b, "smoke", 2)){
Effects.effect("empspark", b.x + Mathf.range(2), b.y + Mathf.range(2));
Effects.effect(Fx.empspark, b.x + Mathf.range(2), b.y + Mathf.range(2));
}
}
@@ -84,19 +90,20 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Timers.run(5f, ()->{
new EMP(b.x, b.y, b.damage).add();
});
Effects.effect("empshockwave", b);
Effects.effect(Fx.empshockwave, b);
Effects.shake(3f, 3f, b);
}
},
//TODO use DamageArea instead
shell = new BulletType(1.1f, 85){
//TODO better visuals for shell
shell = new BulletType(1.1f, 60){
{
lifetime = 110f;
hitsize = 8f;
hitsize = 11f;
}
public void draw(Bullet b){
float rad = 8f;
Draw.color(Color.ORANGE);
Draw.color(Color.GRAY);
Draw.rect("circle", b.x, b.y, rad, rad);
rad += Mathf.sin(Timers.time(), 3f, 1f);
@@ -107,7 +114,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public void update(Bullet b){
if(Timers.get(b, "smoke", 7)){
Effects.effect("smoke", b.x + Mathf.range(2), b.y + Mathf.range(2));
Effects.effect(Fx.smoke, b.x + Mathf.range(2), b.y + Mathf.range(2));
}
}
@@ -118,13 +125,41 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public void removed(Bullet b){
Effects.shake(3f, 3f, b);
Effects.effect("shellsmoke", b);
Effects.effect("shellexplosion", b);
Effects.effect(Fx.shellsmoke, b);
Effects.effect(Fx.shellexplosion, b);
Angles.circle(25, f->{
Angles.translation(f, 5f);
new Bullet(shellshot, b.owner, b.x + Angles.x(), b.y + Angles.y(), f).add();
});
DamageArea.damage(b.owner instanceof Enemy, b.x, b.y, 25f, (int)(damage * 2f/3f));
}
},
titanshell = new BulletType(1.8f, 60){
{
lifetime = 70f;
hitsize = 11f;
}
public void draw(Bullet b){
Draw.color(whiteOrange);
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){
@@ -141,8 +176,8 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public void removed(Bullet b){
Effects.shake(3f, 3f, b);
Effects.effect("blastsmoke", b);
Effects.effect("blastexplosion", b);
Effects.effect(Fx.blastsmoke, b);
Effects.effect(Fx.blastexplosion, b);
Angles.circle(30, f->{
Angles.translation(f, 6f);
@@ -239,6 +274,6 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
@Override
public void removed(Bullet b){
Effects.effect("hit", b);
Effects.effect(Fx.hit, b);
}
}
@@ -7,6 +7,7 @@ import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Weapon;
@@ -35,7 +36,7 @@ public class Player extends DestructibleEntity{
@Override
public void onDeath(){
remove();
Effects.effect("explosion", this);
Effects.effect(Fx.explosion, this);
Effects.shake(4f, 5f, this);
Effects.sound("die", this);
@@ -6,6 +6,7 @@ import java.io.IOException;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.resource.Item;
@@ -89,7 +90,7 @@ public class TileEntity extends Entity{
if(health != 0 && !(tile.block() instanceof Wall) &&
Mathf.chance(0.009f*Timers.delta()*(1f-(float)health/maxhealth))){
Effects.effect("smoke", x+Mathf.range(4), y+Mathf.range(4));
Effects.effect(Fx.smoke, x+Mathf.range(4), y+Mathf.range(4));
}
tile.block().update(tile);
@@ -1,8 +1,47 @@
package io.anuke.mindustry.entities.effect;
import io.anuke.ucore.entities.Entity;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.World;
import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.util.Mathf;
//TODO
public class DamageArea extends Entity{
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->{
if(entity instanceof Enemy){
Enemy enemy = (Enemy)entity;
if(enemy.distanceTo(x, y) > radius){
return;
}
int amount = calculateDamage(x, y, enemy.x, enemy.y, radius, damage);
enemy.damage(amount);
}
});
}else{
int trad = (int)(radius / Vars.tilesize);
for(int dx = -trad; dx <= trad; dx ++){
for(int dy= -trad; dy <= trad; dy ++){
Tile tile = World.tile(Mathf.scl2(x, Vars.tilesize) + dx, Mathf.scl2(y, Vars.tilesize) + dy);
if(tile != null && tile.entity != null && Vector2.dst(dx, dy, 0, 0) <= trad){
int amount = calculateDamage(x, y, tile.worldx(), tile.worldy(), radius, damage);
tile.entity.damage(amount);
}
}
}
}
}
static int calculateDamage(float x, float y, float tx, float ty, float radius, int damage){
float dist = Vector2.dst(x, y, tx, ty);
float scaled = 1f - dist/radius;
return (int)(damage * scaled);
}
}
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.World;
@@ -57,7 +58,7 @@ public class EMP extends TimedEntity{
p.setPower(tile, 0f);
}
Effects.effect("empspark", tile.entity);
Effects.effect(Fx.empspark, tile.entity);
tile.entity.damage(damage);
}
}
@@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
@@ -64,7 +65,7 @@ public class TeslaOrb extends Entity{
void damageEnemy(Enemy enemy){
//TODO
enemy.damage(damage);
Effects.effect("laserhit", enemy.x + Mathf.range(2f), enemy.y + Mathf.range(2f));
Effects.effect(Fx.laserhit, enemy.x + Mathf.range(2f), enemy.y + Mathf.range(2f));
}
@Override
@@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.Shaders;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.ai.Pathfind;
@@ -171,7 +172,7 @@ public class Enemy extends DestructibleEntity{
@Override
public void onDeath(){
Effects.effect("explosion", this);
Effects.effect(Fx.explosion, this);
Effects.shake(3f, 4f, this);
Effects.sound("explosion", this);
remove();