Added event method, changed Fireball to projectile type

This commit is contained in:
Anuken
2018-05-09 10:52:51 -04:00
parent 55cd0c2bae
commit 83d1707b56
11 changed files with 109 additions and 79 deletions
@@ -86,7 +86,7 @@ public class Bullet extends BulletEntity<BulletType>{
public void update(){
super.update();
if (collidesTiles()) {
if (type.hitTiles && collidesTiles()) {
world.raycastEach(world.toTile(lastX), world.toTile(lastY), world.toTile(x), world.toTile(y), (x, y) -> {
Tile tile = world.tile(x, y);
@@ -7,9 +7,11 @@ import io.anuke.ucore.entities.BaseBulletType;
public abstract class BulletType extends BaseBulletType<Bullet>{
public float knockback;
public boolean hitTiles = true;
public StatusEffect status = StatusEffects.none;
public float statusIntensity = 0.5f;
//TODO use float damage
public BulletType(float speed, int damage){
this.speed = speed;
this.damage = damage;
@@ -78,7 +78,7 @@ public abstract class Unit extends SyncEntity implements SerializableEntity {
public Floor getFloorOn(){
Tile tile = world.tileWorld(x, y);
return (Floor)(tile == null || (!(tile.floor() instanceof Floor)) ? Blocks.defaultFloor : tile.floor());
return (Floor)(tile == null || (tile.floor() == null) ? Blocks.defaultFloor : tile.floor());
}
public void updateVelocityStatus(float drag, float maxVelocity){
@@ -4,8 +4,10 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.content.bullets.TurretBullets;
import io.anuke.mindustry.content.fx.ExplosionFx;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.game.Team;
@@ -34,10 +36,8 @@ public class DamageArea{
}
for(int i = 0; i < Mathf.clamp(flammability / 4, 0, 30); i ++){
Timers.run(i/2, () -> {
Fireball f = new Fireball(x, y, color, Mathf.random(360f));
f.add();
});
Timers.run(i/2, () ->
Bullet.create(TurretBullets.fireball, null, Team.none, x, y, Mathf.random(360f)));
}
float e = explosiveness;
@@ -1,67 +0,0 @@
package io.anuke.mindustry.entities.effect;
import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.content.fx.EnvironmentFx;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.TimedEntity;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.effectGroup;
import static io.anuke.mindustry.Vars.world;
public class Fireball extends TimedEntity {
private float rotation;
private float speed;
private Color color;
public Fireball(float x, float y, Color color, float rotation){
set(x, y);
this.rotation = rotation;
this.color = color;
lifetime = 30f + Mathf.random(40f);
speed = 0.6f + Mathf.random(2f);
}
@Override
public void update() {
super.update();
float speed = this.speed * fout();
x += Angles.trnsx(rotation, speed);
y += Angles.trnsy(rotation, speed);
if(Mathf.chance(0.04 * Timers.delta())){
Tile tile = world.tileWorld(x, y);
if(tile != null){
Fire.create(tile);
}
}
if(Mathf.chance(0.1 * Timers.delta())){
Effects.effect(EnvironmentFx.fireballsmoke, x, y);
}
if(Mathf.chance(0.1 * Timers.delta())){
Effects.effect(EnvironmentFx.ballfire, x, y);
}
}
@Override
public void draw() {
Draw.color(Palette.lightFlame, color, Color.GRAY, fin());
Fill.circle(x, y, 3f * fout());
Draw.reset();
}
@Override
public Fireball add(){
super.update();
return add(effectGroup);
}
}
@@ -8,10 +8,13 @@ import com.badlogic.gdx.utils.Pool.Poolable;
import com.badlogic.gdx.utils.Pools;
import io.anuke.mindustry.content.Liquids;
import io.anuke.mindustry.content.blocks.Blocks;
import io.anuke.mindustry.content.bullets.TurretBullets;
import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.content.fx.EnvironmentFx;
import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.SerializableEntity;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
@@ -105,7 +108,7 @@ public class Puddle extends Entity implements SerializableEntity, Poolable{
(liquid.flammability > 0.3f && dest.temperature > 0.7f)){ //flammable liquid + hot liquid
Fire.create(tile);
if(Mathf.chance(0.006 * amount)){
new Fireball(x, y, dest.flameColor, Mathf.random(360f)).add();
Bullet.create(TurretBullets.fireball, tile.entity, Team.none, x, y, Mathf.random(360f));
}
}else if(dest.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot puddle
if(Mathf.chance(0.5f * amount)){