Implemented Fortress enemy spawning, added level save display

This commit is contained in:
Anuken 2017-11-26 23:20:43 -05:00
parent cb9acb7a52
commit 0c6578c229
15 changed files with 45 additions and 16 deletions

View File

@ -111,10 +111,15 @@ public class Control extends Module{
spawns = Array.with(
new EnemySpawn(TitanEnemy.class){{
after = 4;
after = 5;
spacing = 2;
scaling = 5;
}},
new EnemySpawn(FortressEnemy.class){{
after = 12;
spacing = 3;
scaling = 5;
}},
new EnemySpawn(HealerEnemy.class){{
scaling = 3;
spacing = 2;
@ -442,6 +447,7 @@ public class Control extends Module{
if(Inputs.keyUp(Keys.C)){
enemyGroup.clear();
enemies = 0;
}
if(Inputs.keyUp(Keys.F)){

View File

@ -13,6 +13,7 @@ public class BlastEnemy extends Enemy{
speed = 0.65f;
bullet = null;
turretrotatespeed = 0f;
mass = 0.8f;
heal();
}

View File

@ -36,6 +36,7 @@ public class Enemy extends DestructibleEntity{
protected int spawned = 0;
protected float angle;
protected boolean targetCore = false;
protected float mass = 1f;
public int spawn;
public int node = -1;
@ -80,18 +81,18 @@ public class Enemy extends DestructibleEntity{
float avoidSpeed = 0.1f;
Entities.getNearby(Entities.getGroup(Enemy.class), x, y, range, other -> {
Enemy enemy = (Enemy)other;
float dst = other.distanceTo(this);
if(other == this)
return;
if(dst < shiftRange){
float scl = Mathf.clamp(1.4f - dst / shiftRange);
float scl = Mathf.clamp(1.4f - dst / shiftRange) * enemy.mass * 1f/mass;
shift.add((x - other.x) * scl, (y - other.y) * scl);
}else if(dst < avoidRange){
Tmp.v2.set((x - other.x), (y - other.y)).setLength(avoidSpeed);
shift.add(Tmp.v2);
}
});
shift.limit(1f);

View File

@ -7,6 +7,7 @@ public class FastEnemy extends Enemy{
speed = 0.7f;
reload = 30;
mass = 0.2f;
maxhealth = 30;
heal();

View File

@ -13,6 +13,7 @@ public class FlamerEnemy extends Enemy{
reload = 6;
bullet = BulletType.flameshot;
shootsound = "flame";
mass = 1.5f;
range = 40;

View File

@ -16,14 +16,15 @@ public class FortressEnemy extends Enemy{
public FortressEnemy(int spawn) {
super(spawn);
speed = 0.1f;
speed = 0.12f;
reload = 90;
maxhealth = 700;
range = 70f;
bullet = BulletType.yellowshell;
hitbox.setSize(9f);
hitbox.setSize(10f);
turretrotatespeed = rotatespeed = 0.08f;
length = 7f;
mass = 7f;
heal();
}

View File

@ -24,6 +24,7 @@ public class HealerEnemy extends Enemy{
range = 30f;
alwaysRotate = false;
targetCore = false;
mass = 1.1f;
heal();
}

View File

@ -12,8 +12,9 @@ public class MortarEnemy extends Enemy{
reload = 100f;
bullet = BulletType.shell;
turretrotatespeed = 0.15f;
rotatespeed = 7f;
rotatespeed = 0.05f;
range = 120f;
mass = 1.2f;
heal();
}

View File

@ -9,11 +9,12 @@ public class RapidEnemy extends Enemy{
reload = 8;
bullet = BulletType.purple;
rotatespeed = 30f;
rotatespeed = 0.08f;
maxhealth = 260;
speed = 0.27f;
heal();
hitbox.setSize(8f);
mass = 3f;
range = 70;
}

View File

@ -13,8 +13,10 @@ public class TankEnemy extends Enemy{
maxhealth = 350;
speed = 0.2f;
reload = 90f;
rotatespeed = 0.06f;
bullet = BulletType.small;
length = 3f;
mass = 1.4f;
}
void shoot(){

View File

@ -10,12 +10,13 @@ public class TitanEnemy extends Enemy{
public TitanEnemy(int spawn) {
super(spawn);
speed = 0.1f;
speed = 0.14f;
reload = 30;
maxhealth = 400;
range = 60f;
bullet = BulletType.small;
hitbox.setSize(7f);
mass = 4f;
heal();

View File

@ -37,6 +37,7 @@ import io.anuke.ucore.entities.Entities;
* Wave countdown time (float)
*
* Gamemode Ordinal (byte)
* Map ordinal (byte)
*
* Player X (float)
* Player Y (float)
@ -63,7 +64,6 @@ import io.anuke.ucore.entities.Entities;
*
*
* --MAP DATA--
* Map ID (byte)
* Seed (int)
* Amount of tiles (int)
* (tile list)
@ -82,7 +82,7 @@ import io.anuke.ucore.entities.Entities;
*/
public class SaveIO{
/**Save file version ID. Should be incremented every breaking release.*/
private static final int fileVersionID = 10;
private static final int fileVersionID = 11;
//TODO automatic registration of types?
private static final Array<Class<? extends Enemy>> enemyIDs = Array.with(
@ -138,6 +138,7 @@ public class SaveIO{
stream.readInt(); //read version
stream.readLong(); //read last saved time
stream.readByte(); //read the gamemode
stream.readByte(); //read the map
return stream.readInt(); //read the wave
}catch (IOException e){
throw new RuntimeException(e);
@ -155,6 +156,18 @@ public class SaveIO{
}
}
public static Map getMap(int slot){
try(DataInputStream stream = new DataInputStream(fileFor(slot).read())){
stream.readInt(); //read version
stream.readLong(); //read last saved time
stream.readByte(); //read the gamemode
return Map.values()[stream.readByte()]; //read the map
}catch (IOException e){
throw new RuntimeException(e);
}
}
public static FileHandle fileFor(int slot){
return Gdx.files.local("mindustry-saves/" + slot + ".mins");
}
@ -169,6 +182,7 @@ public class SaveIO{
//--GENERAL STATE--
stream.writeByte(Vars.control.getMode().ordinal()); //gamemode
stream.writeByte(Vars.world.getMap().ordinal()); //map ID
stream.writeInt(Vars.control.getWave()); //wave
stream.writeFloat(Vars.control.getWaveCountdown()); //wave countdown
@ -219,9 +233,6 @@ public class SaveIO{
//--MAP DATA--
//map ID
stream.writeByte(Vars.world.getMap().ordinal());
//seed
stream.writeInt(Vars.world.getSeed());
@ -286,6 +297,7 @@ public class SaveIO{
//general state
byte mode = stream.readByte();
byte mapid = stream.readByte();
int wave = stream.readInt();
float wavetime = stream.readFloat();
@ -364,7 +376,6 @@ public class SaveIO{
//map
int mapid = stream.readByte();
int seed = stream.readInt();
int tiles = stream.readInt();

View File

@ -46,8 +46,9 @@ public class LoadDialog extends FloatingDialog{
button.row();
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(slot) + ", Wave " +
SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i)));
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(slot) + ", " +
SaveIO.getMap(slot) +
", Wave " + SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i)));
info.setAlignment(Align.center, Align.center);
button.add(info).padBottom(2).padTop(6);

Binary file not shown.

Binary file not shown.