Implemented dirium, finished new turret, multiple bugfixes

This commit is contained in:
Anuken
2017-09-19 00:49:55 -04:00
parent 537641c8a3
commit 28bb82ef4b
32 changed files with 204 additions and 81 deletions

View File

@@ -59,6 +59,8 @@ public class Control extends ControlModule{
Inputs.addProcessor(new AndroidInput());
}
Effects.setShakeFalloff(10000f);
Draw.addSurface("shadow", Core.cameraScale);
atlas = new Atlas("sprites.atlas");
@@ -215,7 +217,7 @@ public class Control extends ControlModule{
}
public void coreDestroyed(){
Effects.shake(5, 6);
Effects.shake(5, 6, camera.position.x, camera.position.y);
Sounds.play("corexplode");
Tile core = World.core;
for(int i = 0; i < 16; i ++){
@@ -306,7 +308,7 @@ public class Control extends ControlModule{
}
if(Inputs.keyDown(Keys.SPACE)){
Effects.shake(6, 4);
Effects.shake(6, 4, Graphics.mouseWorld().x, Graphics.mouseWorld().y);
}
if(Inputs.keyDown(Keys.Y)){

View File

@@ -7,12 +7,29 @@ import com.badlogic.gdx.graphics.Color;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.graphics.Hue;
import io.anuke.ucore.util.Angles;
public class EffectLoader{
static Color lightRed = Hue.mix(Color.WHITE, Color.FIREBRICK, 0.1f);
public static void create(){
Effects.create("shellsmoke", 21, e -> {
Angles.randLenVectors(e.id, 8, 1f + e.ifract()*16f, (x, y)->{
float size = 2f+e.fract()*5f;
Draw.color(Color.LIGHT_GRAY, Color.DARK_GRAY, e.ifract());
Draw.rect("circle", e.x + x, e.y + y, size, size);
Draw.reset();
});
});
Effects.create("shellexplosion", 15, e -> {
Draw.thickness(1.3f - e.ifract());
Draw.color(Hue.mix(Color.WHITE, Color.ORANGE, e.ifract()));
Draw.circle(e.x, e.y, 1f + e.ifract() * 7f);
Draw.reset();
});
Effects.create("place", 16, e -> {
Draw.thickness(3f - e.ifract() * 2f);
Draw.square(e.x, e.y, Vars.tilesize / 2f + e.ifract() * 3f);
@@ -54,6 +71,13 @@ public class EffectLoader{
Draw.reset();
});
Effects.create("laserhit", 10, e -> {
Draw.thickness(1f);
Draw.color(Hue.mix(Color.WHITE, Color.SKY, e.ifract()));
Draw.spikes(e.x, e.y, e.ifract() * 2f, 2, 6);
Draw.reset();
});
Effects.create("shoot", 8, e -> {
Draw.thickness(1f);
Draw.color(Hue.mix(Color.WHITE, Color.GOLD, e.ifract()));

View File

@@ -4,11 +4,19 @@ import com.badlogic.gdx.graphics.Color;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.BaseBulletType;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public abstract class BulletType extends BaseBulletType<Bullet>{
public static final BulletType
none = new BulletType(0f, 0){
public void draw(Bullet b){
}
},
stone = new BulletType(1.5f, 2){
public void draw(Bullet b){
Draw.color("gray");
@@ -30,6 +38,52 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Draw.reset();
}
},
shell = new BulletType(1.1f, 110){
{
lifetime = 110f;
}
public void draw(Bullet b){
float rad = 8f;
Draw.color(Color.GRAY);
Draw.rect("circle", b.x, b.y, rad, rad);
rad += Mathf.sin(Timers.time(), 3f, 1f);
Draw.color(Color.ORANGE);
Draw.rect("circle", b.x, b.y, rad/1.7f, rad/1.7f);
Draw.reset();
}
public void update(Bullet b){
if(Timers.get(b, "smoke", 7)){
Effects.effect("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("shellsmoke", b);
Effects.effect("shellexplosion", b);
Angles.circle(20, f->{
Angles.translation(f, 5f);
new Bullet(shellshot, b.owner, b.x + Angles.x(), b.y + Angles.y(), f).add();
});
}
},
shellshot = new BulletType(1.5f, 5){
{
lifetime = 7f;
}
public void draw(Bullet b){
// Draw.color("orange");
// Draw.rect("bullet", b.x, b.y, b.angle());
// Draw.reset();
}
},
small = new BulletType(1.5f, 1){
public void draw(Bullet b){
Draw.color("orange");

View File

@@ -33,7 +33,7 @@ public class Player extends DestructibleEntity{
public void onDeath(){
remove();
Effects.effect("explosion", this);
Effects.shake(4f, 5f);
Effects.shake(4f, 5f, this);
Effects.sound("die", this);
Vars.control.setRespawnTime(respawnduration);

View File

@@ -49,7 +49,7 @@ public class TileEntity extends Entity{
}
tile.setBlock(Blocks.air);
Effects.shake(4f, 4f);
Effects.shake(4f, 4f, this);
Effects.effect("explosion", this);
Effects.sound("break", this);

View File

@@ -104,7 +104,7 @@ public class Enemy extends DestructibleEntity{
@Override
public void onDeath(){
Effects.effect("explosion", this);
Effects.shake(3f, 4f);
Effects.shake(3f, 4f, this);
Effects.sound("explosion", this);
remove();
dead = true;

View File

@@ -1,5 +1,5 @@
package io.anuke.mindustry.resource;
public enum Item{
stone, iron, coal, steel, titanium, hypanium;
stone, iron, coal, steel, titanium, dirium;
}

View File

@@ -26,7 +26,7 @@ public enum Recipe{
flameturret(defense, WeaponBlocks.flameturret, stack(Item.iron, 25), stack(Item.steel, 18)),
sniperturret(defense, WeaponBlocks.sniperturret, stack(Item.iron, 30), stack(Item.steel, 20)),
laserturret(defense, WeaponBlocks.laserturret, stack(Item.steel, 20), stack(Item.titanium, 20)),
mortarturret(defense, WeaponBlocks.mortarturret, stack(Item.steel, 25), stack(Item.titanium, 25)),
mortarturret(defense, WeaponBlocks.mortarturret, stack(Item.steel, 40), stack(Item.titanium, 30)),
healturret(defense, WeaponBlocks.repairturret, stack(Item.iron, 45)),
megahealturret(defense, WeaponBlocks.megarepairturret, stack(Item.iron, 30), stack(Item.steel, 40)),

View File

@@ -145,12 +145,12 @@ public class ProductionBlocks{
{
health = 90;
requirements = new Item[]{Item.titanium, Item.steel};
result = Item.hypanium;
result = Item.dirium;
}
@Override
public String description(){
return "Takes in steel + titanium, outputs hypanium.";
return "Takes in steel + titanium, outputs dirium.";
}
},

View File

@@ -1,9 +1,12 @@
package io.anuke.mindustry.world.blocks;
import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.LaserTurret;
import io.anuke.mindustry.world.blocks.types.RepairTurret;
import io.anuke.mindustry.world.blocks.types.Turret;
import io.anuke.ucore.core.Timers;
@@ -102,25 +105,27 @@ public class WeaponBlocks{
//TODO
mortarturret = new Turret("mortarturret"){
{
rotatespeed = 0.1f;
formalName = "flak turret";
range = 120;
reload = 120f;
bullet = BulletType.sniper;
ammo = Item.coal;
bullet = BulletType.shell;
ammo = Item.stone;
health = 110;
}
},
//TODO
laserturret = new Turret("laserturret"){
laserturret = new LaserTurret("laserturret"){
{
beamColor = Color.SKY;
formalName = "laser turret";
range = 60;
reload = 40f;
bullet = BulletType.sniper;
ammo = Item.coal;
reload = 4f;
damage = 9;
ammo = Item.stone;
health = 110;
}
},

View File

@@ -41,6 +41,13 @@ public class Crafter extends Block{
@Override
public boolean accept(Item item, Tile dest, Tile source){
return item == Item.iron || item == Item.coal;
boolean craft = false;
for(Item req : requirements){
if(item == req){
craft = true;
break;
}
}
return craft;
}
}

View File

@@ -8,32 +8,43 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
public class LaserTurret extends Turret{
protected Color beamColor = Color.WHITE.cpy();
protected String hiteffect = "hit";
protected String hiteffect = "laserhit";
protected int damage = 4;
protected float cone = 15f;
public LaserTurret(String name) {
super(name);
}
@Override
public String description(){
return "[turretinfo]Ammo: "+(ammo==null ? "N/A" : ammo.name())+"\nRange: " + (int)range + "\nDamage: " + damage;
}
@Override
public void shoot(Tile tile){
TurretEntity entity = tile.entity();
Enemy enemy = entity.target;
enemy.damage(damage);
Effects.effect(hiteffect, enemy.x + Mathf.range(3), enemy.y + Mathf.range(3));
if(Angles.angleDist(entity.rotation, Angles.angle(tile.worldx(), tile.worldy(), enemy.x, enemy.y)) < cone){
enemy.damage(damage);
Effects.effect(hiteffect, enemy.x + Mathf.range(3), enemy.y + Mathf.range(3));
}
}
@Override
public void drawOver(Tile tile){
TurretEntity entity = tile.entity();
if(entity.target != null){
if(entity.target != null &&
Angles.angleDist(entity.rotation, Angles.angle(tile.worldx(), tile.worldy(), entity.target.x, entity.target.y)) <= cone){
float x = tile.worldx(), y = tile.worldy();
float x2 = entity.target.x, y2 = entity.target.y;
@@ -50,9 +61,11 @@ public class LaserTurret extends Turret{
Draw.line(x, y, x2, y2);
Draw.thickness(1f);
Draw.rect("circle", x2, y2, 5f, 5f);
Draw.reset();
}
Draw.reset();
super.drawOver(tile);
}
}

View File

@@ -20,16 +20,20 @@ public class RepairTurret extends Turret{
public void update(Tile tile){
TurretEntity entity = tile.entity();
if(Timers.get(entity, "target", targetInterval)){
if(Timers.get(entity, "blocktarget", targetInterval)){
entity.blockTarget = World.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true);
}
if(entity.target != null){
float target = entity.angleTo(entity.target);
if(entity.blockTarget != null){
float target = entity.angleTo(entity.blockTarget);
entity.rotation = Mathf.slerp(entity.rotation, target, 0.16f*Timers.delta());
if(Timers.get(tile, reload) && Angles.angleDist(target, entity.rotation) < 10){
entity.target.health++;
if(Timers.get(tile, "reload", reload) && Angles.angleDist(target, entity.rotation) < shootCone){
entity.blockTarget.health++;
if(entity.blockTarget.health > entity.blockTarget.health)
entity.blockTarget.health = entity.blockTarget.maxhealth;
}
}
}
@@ -43,7 +47,7 @@ public class RepairTurret extends Turret{
public void drawOver(Tile tile){
TurretEntity entity = tile.entity();
if(entity.blockTarget != null){
if(entity.blockTarget != null && Angles.angleDist(entity.angleTo(entity.blockTarget), entity.rotation) < 10){
float x = tile.worldx(), y = tile.worldy();
float x2 = entity.blockTarget.x, y2 = entity.blockTarget.y;

View File

@@ -28,10 +28,12 @@ public class Turret extends Block{
protected float range = 50f;
protected float reload = 10f;
protected String shootsound = "shoot";
protected BulletType bullet;
protected BulletType bullet = BulletType.iron;
protected Item ammo;
protected int ammoMultiplier = 20;
protected int maxammo = 400;
protected float rotatespeed = 0.2f;
protected float shootCone = 8f;
public Turret(String name) {
super(name);
@@ -68,7 +70,7 @@ public class Turret extends Block{
@Override
public void drawPlace(int x, int y, boolean valid){
//TODO?
//Draw.color(Color.PURPLE);
Draw.color(Color.PURPLE);
Draw.thick(1f);
Draw.dashcircle(x*Vars.tilesize, y*Vars.tilesize, range);
}
@@ -92,22 +94,27 @@ public class Turret extends Block{
entity.removeItem(ammo, 1);
}
if(entity.target != null && entity.target.isDead())
entity.target = null;
if(entity.ammo > 0){
if(Timers.get(entity, "target", targetInterval)){
entity.target = (Enemy)Entities.getClosest(tile.worldx(), tile.worldy(), range, e->{
return e instanceof Enemy;
return e instanceof Enemy && !((Enemy)e).isDead();
});
}
if(entity.target != null){
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation,
Angles.predictAngle(tile.worldx(), tile.worldy(),
entity.target.x, entity.target.y, entity.target.xvelocity, entity.target.yvelocity, bullet.speed),
0.2f*Timers.delta());
float targetRot = Angles.predictAngle(tile.worldx(), tile.worldy(),
entity.target.x, entity.target.y, entity.target.xvelocity, entity.target.yvelocity, bullet.speed);
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation, targetRot,
rotatespeed*Timers.delta());
float reload = Vars.multiplier*this.reload;
if(Timers.get(tile, reload)){
if(Angles.angleDist(entity.rotation, targetRot) < shootCone && Timers.get(tile, "reload", reload)){
Effects.sound(shootsound, entity);
shoot(tile);
entity.ammo --;