Optimized conveyors and all timer blocks, edited laser FX

This commit is contained in:
Anuken
2017-12-09 13:36:41 -05:00
parent 97019064a7
commit 2c7402f809
29 changed files with 467 additions and 358 deletions
@@ -4,7 +4,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectIntMap;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.effect.Fx;
@@ -19,10 +19,12 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Timer;
public class TileEntity extends Entity{
public Tile tile;
public ObjectMap<Item, Integer> items = new ObjectMap<>();
public ObjectIntMap<Item> items = new ObjectIntMap<>();
public Timer timer;
public int maxhealth, health;
public boolean dead = false;
public boolean added;
@@ -37,8 +39,10 @@ public class TileEntity extends Entity{
maxhealth = tile.block().health;
health = maxhealth;
timer = new Timer(tile.block().timers);
if(added){
add(Entities.getGroup(TileEntity.class));
add();
}
return this;
@@ -79,12 +83,12 @@ public class TileEntity extends Entity{
}
public boolean collide(Bullet other){
return other.owner instanceof Enemy; //TODO
return other.owner instanceof Enemy;
}
@Override
public void update(){
if(health != 0 && !(tile.block() instanceof Wall) &&
if(health != 0 && health < tile.block().health && !(tile.block() instanceof Wall) &&
Mathf.chance(0.009f*Timers.delta()*(1f-(float)health/maxhealth))){
Effects.effect(Fx.smoke, x+Mathf.range(4), y+Mathf.range(4));
@@ -120,4 +124,9 @@ public class TileEntity extends Entity{
public void removeItem(Item item, int amount){
items.put(item, items.get(item, 0) - amount);
}
@Override
public TileEntity add(){
return add(Entities.getGroup(TileEntity.class));
}
}
@@ -71,7 +71,7 @@ public class WaveCreator{
after = 12;
amount = 3;
spacing = 5;
scaling = 2;
scaling = 3;
}},
new EnemySpawn(EmpEnemy.class){{
@@ -107,7 +107,7 @@ public class WaveCreator{
new EnemySpawn(HealerEnemy.class){{
after = 16;
spacing = 5;
scaling = 1;
scaling = 2;
amount = 2;
}},
//end boss wave
@@ -117,14 +117,14 @@ public class WaveCreator{
after = 16 + 5;
amount = 1;
spacing = 5;
scaling = 1;
scaling = 2;
}},
new EnemySpawn(EmpEnemy.class){{
after = 16 + 5;
amount = 1;
spacing = 5;
scaling = 1;
scaling = 2;
}}
//end enchanced boss wave
);
@@ -17,7 +17,7 @@ public class Fx{
public static final Effect
generatorexplosion = new Effect(28, e -> {
generatorexplosion = new Effect(28, 40f, e -> {
Angles.randLenVectors(e.id, 16, 10f + e.ifract()*8f, (x, y)->{
float size = e.fract()*12f + 1f;
Draw.color(Color.WHITE, lightOrange, e.ifract());
@@ -44,7 +44,7 @@ public class Fx{
});
}),
nuclearcloud = new Effect(90, e -> {
nuclearcloud = new Effect(90, 200f, e -> {
Angles.randLenVectors(e.id, 10, e.powfract()*90f, (x, y)->{
float size = e.fract()*14f;
Draw.color(Color.LIME, Color.GRAY, e.ifract());
@@ -106,14 +106,14 @@ public class Fx{
Draw.reset();
}),
shockwave = new Effect(10f, e -> {
shockwave = new Effect(10f, 80f, e -> {
Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.ifract());
Draw.thick(e.fract()*2f + 0.2f);
Draw.circle(e.x, e.y, e.ifract()*28f);
Draw.reset();
}),
nuclearShockwave = new Effect(10f, e -> {
nuclearShockwave = new Effect(10f, 200f, e -> {
Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.ifract());
Draw.thick(e.fract()*3f + 0.2f);
Draw.polygon(40, e.x, e.y, e.ifract()*140f);
@@ -366,7 +366,7 @@ public class Fx{
Draw.reset();
}),
titanExplosion = new Effect(11, e -> {
titanExplosion = new Effect(11, 48f, e -> {
Draw.thickness(2f*e.fract()+0.5f);
Draw.color(Color.WHITE, Color.DARK_GRAY, e.powfract());
Draw.circle(e.x, e.y, 5f + e.powfract() * 8f);
@@ -11,15 +11,15 @@ import io.anuke.mindustry.entities.effect.Shaders;
import io.anuke.mindustry.world.Tile;
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;
import io.anuke.ucore.util.*;
public class Enemy extends DestructibleEntity{
public final static Color[] tierColors = { Color.valueOf("ffe451"), Color.valueOf("f48e20"), Color.valueOf("ff6757"), Color.valueOf("ff2d86") };
public final static int maxtier = 4;
public final static float maxIdle = 60*1.5f;
protected int timeid;
protected Timer timer = new Timer(5);
protected float speed = 0.4f;
protected float reload = 32;
protected float range = 60;
@@ -37,7 +37,7 @@ public class Enemy extends DestructibleEntity{
protected boolean stopNearCore = true;
protected float mass = 1f;
public float idletime = 0f;
public float idletime = 0f;
public int spawn;
public int node = -1;
public Tile[] path;
@@ -45,6 +45,9 @@ public class Enemy extends DestructibleEntity{
public float xvelocity, yvelocity;
public Entity target;
public int tier = 1;
protected final int timerTarget = timeid ++;
protected final int timerReload = timeid ++;
public Enemy() {
hitbox.setSize(5f);
@@ -110,7 +113,7 @@ public class Enemy extends DestructibleEntity{
target = null;
}
if(Timers.get(this, "target", 15) && !nearCore){
if(timer.get(timerTarget, 15) && !nearCore){
target = Vars.world.findTileTarget(x, y, null, range, false);
//no tile found
@@ -127,7 +130,7 @@ public class Enemy extends DestructibleEntity{
}
void updateShooting(){
if(Timers.get(this, "reload", reload * Vars.multiplier)){
if(timer.get(timerReload, reload * Vars.multiplier)){
shoot(bullet);
if(shootsound != null) Effects.sound(shootsound, this);
}