Implemented Fortress enemy spawning, added level save display
This commit is contained in:
@@ -111,10 +111,15 @@ public class Control extends Module{
|
|||||||
|
|
||||||
spawns = Array.with(
|
spawns = Array.with(
|
||||||
new EnemySpawn(TitanEnemy.class){{
|
new EnemySpawn(TitanEnemy.class){{
|
||||||
after = 4;
|
after = 5;
|
||||||
spacing = 2;
|
spacing = 2;
|
||||||
scaling = 5;
|
scaling = 5;
|
||||||
}},
|
}},
|
||||||
|
new EnemySpawn(FortressEnemy.class){{
|
||||||
|
after = 12;
|
||||||
|
spacing = 3;
|
||||||
|
scaling = 5;
|
||||||
|
}},
|
||||||
new EnemySpawn(HealerEnemy.class){{
|
new EnemySpawn(HealerEnemy.class){{
|
||||||
scaling = 3;
|
scaling = 3;
|
||||||
spacing = 2;
|
spacing = 2;
|
||||||
@@ -442,6 +447,7 @@ public class Control extends Module{
|
|||||||
|
|
||||||
if(Inputs.keyUp(Keys.C)){
|
if(Inputs.keyUp(Keys.C)){
|
||||||
enemyGroup.clear();
|
enemyGroup.clear();
|
||||||
|
enemies = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.keyUp(Keys.F)){
|
if(Inputs.keyUp(Keys.F)){
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class BlastEnemy extends Enemy{
|
|||||||
speed = 0.65f;
|
speed = 0.65f;
|
||||||
bullet = null;
|
bullet = null;
|
||||||
turretrotatespeed = 0f;
|
turretrotatespeed = 0f;
|
||||||
|
mass = 0.8f;
|
||||||
|
|
||||||
heal();
|
heal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class Enemy extends DestructibleEntity{
|
|||||||
protected int spawned = 0;
|
protected int spawned = 0;
|
||||||
protected float angle;
|
protected float angle;
|
||||||
protected boolean targetCore = false;
|
protected boolean targetCore = false;
|
||||||
|
protected float mass = 1f;
|
||||||
|
|
||||||
public int spawn;
|
public int spawn;
|
||||||
public int node = -1;
|
public int node = -1;
|
||||||
@@ -80,18 +81,18 @@ public class Enemy extends DestructibleEntity{
|
|||||||
float avoidSpeed = 0.1f;
|
float avoidSpeed = 0.1f;
|
||||||
|
|
||||||
Entities.getNearby(Entities.getGroup(Enemy.class), x, y, range, other -> {
|
Entities.getNearby(Entities.getGroup(Enemy.class), x, y, range, other -> {
|
||||||
|
Enemy enemy = (Enemy)other;
|
||||||
float dst = other.distanceTo(this);
|
float dst = other.distanceTo(this);
|
||||||
if(other == this)
|
if(other == this)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(dst < shiftRange){
|
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);
|
shift.add((x - other.x) * scl, (y - other.y) * scl);
|
||||||
}else if(dst < avoidRange){
|
}else if(dst < avoidRange){
|
||||||
Tmp.v2.set((x - other.x), (y - other.y)).setLength(avoidSpeed);
|
Tmp.v2.set((x - other.x), (y - other.y)).setLength(avoidSpeed);
|
||||||
shift.add(Tmp.v2);
|
shift.add(Tmp.v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
shift.limit(1f);
|
shift.limit(1f);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public class FastEnemy extends Enemy{
|
|||||||
|
|
||||||
speed = 0.7f;
|
speed = 0.7f;
|
||||||
reload = 30;
|
reload = 30;
|
||||||
|
mass = 0.2f;
|
||||||
|
|
||||||
maxhealth = 30;
|
maxhealth = 30;
|
||||||
heal();
|
heal();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class FlamerEnemy extends Enemy{
|
|||||||
reload = 6;
|
reload = 6;
|
||||||
bullet = BulletType.flameshot;
|
bullet = BulletType.flameshot;
|
||||||
shootsound = "flame";
|
shootsound = "flame";
|
||||||
|
mass = 1.5f;
|
||||||
|
|
||||||
range = 40;
|
range = 40;
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,15 @@ public class FortressEnemy extends Enemy{
|
|||||||
public FortressEnemy(int spawn) {
|
public FortressEnemy(int spawn) {
|
||||||
super(spawn);
|
super(spawn);
|
||||||
|
|
||||||
speed = 0.1f;
|
speed = 0.12f;
|
||||||
reload = 90;
|
reload = 90;
|
||||||
maxhealth = 700;
|
maxhealth = 700;
|
||||||
range = 70f;
|
range = 70f;
|
||||||
bullet = BulletType.yellowshell;
|
bullet = BulletType.yellowshell;
|
||||||
hitbox.setSize(9f);
|
hitbox.setSize(10f);
|
||||||
turretrotatespeed = rotatespeed = 0.08f;
|
turretrotatespeed = rotatespeed = 0.08f;
|
||||||
length = 7f;
|
length = 7f;
|
||||||
|
mass = 7f;
|
||||||
|
|
||||||
heal();
|
heal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public class HealerEnemy extends Enemy{
|
|||||||
range = 30f;
|
range = 30f;
|
||||||
alwaysRotate = false;
|
alwaysRotate = false;
|
||||||
targetCore = false;
|
targetCore = false;
|
||||||
|
mass = 1.1f;
|
||||||
|
|
||||||
heal();
|
heal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ public class MortarEnemy extends Enemy{
|
|||||||
reload = 100f;
|
reload = 100f;
|
||||||
bullet = BulletType.shell;
|
bullet = BulletType.shell;
|
||||||
turretrotatespeed = 0.15f;
|
turretrotatespeed = 0.15f;
|
||||||
rotatespeed = 7f;
|
rotatespeed = 0.05f;
|
||||||
range = 120f;
|
range = 120f;
|
||||||
|
mass = 1.2f;
|
||||||
|
|
||||||
heal();
|
heal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ public class RapidEnemy extends Enemy{
|
|||||||
|
|
||||||
reload = 8;
|
reload = 8;
|
||||||
bullet = BulletType.purple;
|
bullet = BulletType.purple;
|
||||||
rotatespeed = 30f;
|
rotatespeed = 0.08f;
|
||||||
maxhealth = 260;
|
maxhealth = 260;
|
||||||
speed = 0.27f;
|
speed = 0.27f;
|
||||||
heal();
|
heal();
|
||||||
hitbox.setSize(8f);
|
hitbox.setSize(8f);
|
||||||
|
mass = 3f;
|
||||||
|
|
||||||
range = 70;
|
range = 70;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ public class TankEnemy extends Enemy{
|
|||||||
maxhealth = 350;
|
maxhealth = 350;
|
||||||
speed = 0.2f;
|
speed = 0.2f;
|
||||||
reload = 90f;
|
reload = 90f;
|
||||||
|
rotatespeed = 0.06f;
|
||||||
bullet = BulletType.small;
|
bullet = BulletType.small;
|
||||||
length = 3f;
|
length = 3f;
|
||||||
|
mass = 1.4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shoot(){
|
void shoot(){
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ public class TitanEnemy extends Enemy{
|
|||||||
public TitanEnemy(int spawn) {
|
public TitanEnemy(int spawn) {
|
||||||
super(spawn);
|
super(spawn);
|
||||||
|
|
||||||
speed = 0.1f;
|
speed = 0.14f;
|
||||||
reload = 30;
|
reload = 30;
|
||||||
maxhealth = 400;
|
maxhealth = 400;
|
||||||
range = 60f;
|
range = 60f;
|
||||||
bullet = BulletType.small;
|
bullet = BulletType.small;
|
||||||
hitbox.setSize(7f);
|
hitbox.setSize(7f);
|
||||||
|
mass = 4f;
|
||||||
|
|
||||||
heal();
|
heal();
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import io.anuke.ucore.entities.Entities;
|
|||||||
* Wave countdown time (float)
|
* Wave countdown time (float)
|
||||||
*
|
*
|
||||||
* Gamemode Ordinal (byte)
|
* Gamemode Ordinal (byte)
|
||||||
|
* Map ordinal (byte)
|
||||||
*
|
*
|
||||||
* Player X (float)
|
* Player X (float)
|
||||||
* Player Y (float)
|
* Player Y (float)
|
||||||
@@ -63,7 +64,6 @@ import io.anuke.ucore.entities.Entities;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* --MAP DATA--
|
* --MAP DATA--
|
||||||
* Map ID (byte)
|
|
||||||
* Seed (int)
|
* Seed (int)
|
||||||
* Amount of tiles (int)
|
* Amount of tiles (int)
|
||||||
* (tile list)
|
* (tile list)
|
||||||
@@ -82,7 +82,7 @@ import io.anuke.ucore.entities.Entities;
|
|||||||
*/
|
*/
|
||||||
public class SaveIO{
|
public class SaveIO{
|
||||||
/**Save file version ID. Should be incremented every breaking release.*/
|
/**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?
|
//TODO automatic registration of types?
|
||||||
private static final Array<Class<? extends Enemy>> enemyIDs = Array.with(
|
private static final Array<Class<? extends Enemy>> enemyIDs = Array.with(
|
||||||
@@ -138,6 +138,7 @@ public class SaveIO{
|
|||||||
stream.readInt(); //read version
|
stream.readInt(); //read version
|
||||||
stream.readLong(); //read last saved time
|
stream.readLong(); //read last saved time
|
||||||
stream.readByte(); //read the gamemode
|
stream.readByte(); //read the gamemode
|
||||||
|
stream.readByte(); //read the map
|
||||||
return stream.readInt(); //read the wave
|
return stream.readInt(); //read the wave
|
||||||
}catch (IOException e){
|
}catch (IOException e){
|
||||||
throw new RuntimeException(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){
|
public static FileHandle fileFor(int slot){
|
||||||
return Gdx.files.local("mindustry-saves/" + slot + ".mins");
|
return Gdx.files.local("mindustry-saves/" + slot + ".mins");
|
||||||
}
|
}
|
||||||
@@ -169,6 +182,7 @@ public class SaveIO{
|
|||||||
|
|
||||||
//--GENERAL STATE--
|
//--GENERAL STATE--
|
||||||
stream.writeByte(Vars.control.getMode().ordinal()); //gamemode
|
stream.writeByte(Vars.control.getMode().ordinal()); //gamemode
|
||||||
|
stream.writeByte(Vars.world.getMap().ordinal()); //map ID
|
||||||
|
|
||||||
stream.writeInt(Vars.control.getWave()); //wave
|
stream.writeInt(Vars.control.getWave()); //wave
|
||||||
stream.writeFloat(Vars.control.getWaveCountdown()); //wave countdown
|
stream.writeFloat(Vars.control.getWaveCountdown()); //wave countdown
|
||||||
@@ -219,9 +233,6 @@ public class SaveIO{
|
|||||||
|
|
||||||
//--MAP DATA--
|
//--MAP DATA--
|
||||||
|
|
||||||
//map ID
|
|
||||||
stream.writeByte(Vars.world.getMap().ordinal());
|
|
||||||
|
|
||||||
//seed
|
//seed
|
||||||
stream.writeInt(Vars.world.getSeed());
|
stream.writeInt(Vars.world.getSeed());
|
||||||
|
|
||||||
@@ -286,6 +297,7 @@ public class SaveIO{
|
|||||||
|
|
||||||
//general state
|
//general state
|
||||||
byte mode = stream.readByte();
|
byte mode = stream.readByte();
|
||||||
|
byte mapid = stream.readByte();
|
||||||
|
|
||||||
int wave = stream.readInt();
|
int wave = stream.readInt();
|
||||||
float wavetime = stream.readFloat();
|
float wavetime = stream.readFloat();
|
||||||
@@ -364,7 +376,6 @@ public class SaveIO{
|
|||||||
|
|
||||||
//map
|
//map
|
||||||
|
|
||||||
int mapid = stream.readByte();
|
|
||||||
int seed = stream.readInt();
|
int seed = stream.readInt();
|
||||||
int tiles = stream.readInt();
|
int tiles = stream.readInt();
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,9 @@ public class LoadDialog extends FloatingDialog{
|
|||||||
|
|
||||||
button.row();
|
button.row();
|
||||||
|
|
||||||
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(slot) + ", Wave " +
|
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(slot) + ", " +
|
||||||
SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i)));
|
SaveIO.getMap(slot) +
|
||||||
|
", Wave " + SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i)));
|
||||||
info.setAlignment(Align.center, Align.center);
|
info.setAlignment(Align.center, Align.center);
|
||||||
|
|
||||||
button.add(info).padBottom(2).padTop(6);
|
button.add(info).padBottom(2).padTop(6);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user