Balancing

This commit is contained in:
Anuken
2019-01-17 13:03:06 -05:00
parent 47605583d1
commit ccc20a9716
23 changed files with 333 additions and 553 deletions

View File

@@ -7,11 +7,14 @@ import io.anuke.arc.collection.ObjectMap;
import io.anuke.arc.collection.ObjectSet;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.EventType.UnlockEvent;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
import static io.anuke.mindustry.Vars.*;
/**Stores player unlocks. Clientside only.*/
public class GlobalData{
private ObjectMap<ContentType, ObjectSet<String>> unlocked = new ObjectMap<>();
@@ -49,8 +52,7 @@ public class GlobalData{
/** Returns whether or not this piece of content is unlocked yet.*/
public boolean isUnlocked(UnlockableContent content){
//return true;
return content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.getContentName());
return (!state.is(State.menu) && !world.isZone()) || content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.getContentName());
}
/**

View File

@@ -1,6 +1,7 @@
package io.anuke.mindustry.game;
import io.anuke.annotations.Annotations.Serialize;
import io.anuke.arc.collection.Array;
/**Defines current rules on how the game should function.
* Does not store game state, just configuration.*/
@@ -26,4 +27,6 @@ public class Rules{
public float waveSpacing = 60 * 60;
/**Zone ID, -1 for invalid zone.*/
public byte zone = -1;
/**Spawn layout. Since only zones modify this, it should be assigned on save load.*/
public transient Array<SpawnGroup> spawns = Waves.getDefaultSpawns();
}

View File

@@ -11,6 +11,7 @@ import io.anuke.arc.util.Time;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.EventType.StateChangeEvent;
import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.io.SaveIO.SaveException;
import io.anuke.mindustry.io.SaveMeta;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.type.ContentType;
@@ -170,11 +171,15 @@ public class Saves{
this.index = index;
}
public void load(){
SaveIO.loadFromSlot(index);
meta = SaveIO.getData(index);
current = this;
totalPlaytime = meta.timePlayed;
public void load() throws SaveException{
try{
SaveIO.loadFromSlot(index);
meta = SaveIO.getData(index);
current = this;
totalPlaytime = meta.timePlayed;
}catch(Exception e){
throw new SaveException(e);
}
}
public void save(){

View File

@@ -13,53 +13,25 @@ import io.anuke.mindustry.type.Weapon;
* Each spawn group can have multiple sub-groups spawned in different areas of the map.
*/
public class SpawnGroup{
/**
* The unit type spawned
*/
/**The unit type spawned*/
public final UnitType type;
/**
* When this spawn should end
*/
/**When this spawn should end*/
protected int end = Integer.MAX_VALUE;
/**
* When this spawn should start
*/
/**When this spawn should start*/
protected int begin;
/**
* The spacing, in waves, of spawns. For example, 2 = spawns every other wave
*/
/**The spacing, in waves, of spawns. For example, 2 = spawns every other wave*/
protected int spacing = 1;
/**
* Maximum amount of units that spawn
*/
/**Maximum amount of units that spawn*/
protected int max = 60;
/**
* How many waves need to pass before the amount of units spawned increases by 1
*/
/**How many waves need to pass before the amount of units spawned increases by 1*/
protected float unitScaling = 9999f;
/**
* How many waves need to pass before the amount of instances of this group increases by 1
*/
protected float groupScaling = 9999f;
/**
* Amount of enemies spawned initially, with no scaling
*/
/**Amount of enemies spawned initially, with no scaling*/
protected int unitAmount = 1;
/**
* Amount of enemies spawned initially, with no scaling
*/
protected int groupAmount = 1;
/**
* Weapon used by the spawned unit. Null to disable. Only applicable to ground units.
*/
/**Weapon used by the spawned unit. Null to disable. Only applicable to ground units.*/
protected Weapon weapon;
/**
* Status effect applied to the spawned unit. Null to disable.
*/
/**Status effect applied to the spawned unit. Null to disable.*/
protected StatusEffect effect;
/**
* Items this unit spawns with. Null to disable.
*/
/**Items this unit spawns with. Null to disable.*/
protected ItemStack items;
public SpawnGroup(UnitType type){
@@ -78,17 +50,6 @@ public class SpawnGroup{
return Math.min(unitAmount - 1 + Math.max((int) ((wave / spacing) / scaling), 1), max);
}
/**
* Returns the amount of different unit groups at a specific wave.
*/
public int getGroupsSpawned(int wave){
if(wave < begin || wave > end || (wave - begin) % spacing != 0){
return 0;
}
return Math.min(groupAmount - 1 + Math.max((int) ((wave / spacing) / groupScaling), 1), max);
}
/**
* Creates a unit, and assigns correct values based on this group's data.
* This method does not add() the unit.
@@ -110,4 +71,20 @@ public class SpawnGroup{
return unit;
}
@Override
public String toString(){
return "SpawnGroup{" +
"type=" + type +
", end=" + end +
", begin=" + begin +
", spacing=" + spacing +
", max=" + max +
", unitScaling=" + unitScaling +
", unitAmount=" + unitAmount +
", weapon=" + weapon +
", effect=" + effect +
", items=" + items +
'}';
}
}

View File

@@ -8,176 +8,171 @@ import io.anuke.mindustry.content.Weapons;
import io.anuke.mindustry.type.ItemStack;
public class Waves{
private static Array<SpawnGroup> spawns = Array.with(
new SpawnGroup(UnitTypes.dagger){{
end = 8;
unitScaling = 3;
}},
public static Array<SpawnGroup> getSpawns(){
return Array.with(
new SpawnGroup(UnitTypes.dagger){{
end = 8;
unitScaling = 3;
}},
new SpawnGroup(UnitTypes.wraith){{
begin = 12;
end = 14;
}},
new SpawnGroup(UnitTypes.wraith){{
begin = 12;
end = 14;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 11;
unitScaling = 2;
spacing = 2;
max = 4;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 11;
unitScaling = 2;
spacing = 2;
max = 4;
}},
new SpawnGroup(UnitTypes.titan){{
begin = 9;
spacing = 3;
unitScaling = 2;
new SpawnGroup(UnitTypes.titan){{
begin = 9;
spacing = 3;
unitScaling = 2;
end = 30;
}},
end = 30;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 10;
unitScaling = 2;
unitAmount = 1;
spacing = 2;
end = 30;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 10;
unitScaling = 2;
unitAmount = 1;
spacing = 2;
end = 30;
}},
new SpawnGroup(UnitTypes.titan){{
begin = 28;
spacing = 3;
unitScaling = 2;
weapon = Weapons.flamethrower;
end = 40;
}},
new SpawnGroup(UnitTypes.titan){{
begin = 28;
spacing = 3;
unitScaling = 2;
weapon = Weapons.flamethrower;
end = 40;
}},
new SpawnGroup(UnitTypes.titan){{
begin = 45;
spacing = 3;
unitScaling = 2;
weapon = Weapons.flamethrower;
effect = StatusEffects.overdrive;
}},
new SpawnGroup(UnitTypes.titan){{
begin = 45;
spacing = 3;
unitScaling = 2;
weapon = Weapons.flamethrower;
effect = StatusEffects.overdrive;
}},
new SpawnGroup(UnitTypes.titan){{
begin = 120;
spacing = 2;
unitScaling = 3;
unitAmount = 5;
weapon = Weapons.flakgun;
effect = StatusEffects.overdrive;
}},
new SpawnGroup(UnitTypes.titan){{
begin = 120;
spacing = 2;
unitScaling = 3;
unitAmount = 5;
weapon = Weapons.flakgun;
effect = StatusEffects.overdrive;
}},
new SpawnGroup(UnitTypes.wraith){{
begin = 16;
unitScaling = 2;
spacing = 2;
new SpawnGroup(UnitTypes.wraith){{
begin = 16;
unitScaling = 2;
spacing = 2;
end = 39;
max = 7;
}},
end = 39;
max = 7;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 82;
spacing = 3;
unitAmount = 4;
unitScaling = 3;
effect = StatusEffects.overdrive;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 82;
spacing = 3;
unitAmount = 4;
groupAmount = 2;
unitScaling = 3;
effect = StatusEffects.overdrive;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 41;
spacing = 5;
unitAmount = 1;
unitScaling = 3;
effect = StatusEffects.shielded;
max = 10;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 41;
spacing = 5;
unitAmount = 1;
unitScaling = 3;
effect = StatusEffects.shielded;
max = 10;
}},
new SpawnGroup(UnitTypes.fortress){{
begin = 40;
spacing = 5;
unitAmount = 2;
unitScaling = 3;
max = 10;
}},
new SpawnGroup(UnitTypes.fortress){{
begin = 40;
spacing = 5;
unitAmount = 2;
unitScaling = 3;
max = 10;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 35;
spacing = 3;
unitAmount = 4;
effect = StatusEffects.overdrive;
items = new ItemStack(Items.blastCompound, 60);
end = 60;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 35;
spacing = 3;
unitAmount = 4;
groupAmount = 2;
effect = StatusEffects.overdrive;
items = new ItemStack(Items.blastCompound, 60);
end = 60;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 42;
spacing = 3;
unitAmount = 4;
effect = StatusEffects.overdrive;
items = new ItemStack(Items.pyratite, 100);
end = 130;
}},
new SpawnGroup(UnitTypes.dagger){{
begin = 42;
spacing = 3;
unitAmount = 4;
groupAmount = 2;
effect = StatusEffects.overdrive;
items = new ItemStack(Items.pyratite, 100);
end = 130;
}},
new SpawnGroup(UnitTypes.ghoul){{
begin = 40;
unitAmount = 2;
spacing = 2;
unitScaling = 3;
max = 8;
}},
new SpawnGroup(UnitTypes.ghoul){{
begin = 40;
unitAmount = 2;
spacing = 2;
unitScaling = 3;
max = 8;
}},
new SpawnGroup(UnitTypes.wraith){{
begin = 50;
unitAmount = 4;
unitScaling = 3;
spacing = 5;
effect = StatusEffects.overdrive;
max = 8;
}},
new SpawnGroup(UnitTypes.wraith){{
begin = 50;
unitAmount = 4;
unitScaling = 3;
spacing = 5;
groupAmount = 2;
effect = StatusEffects.overdrive;
max = 8;
}},
new SpawnGroup(UnitTypes.revenant){{
begin = 50;
unitAmount = 4;
unitScaling = 3;
spacing = 5;
max = 8;
}},
new SpawnGroup(UnitTypes.revenant){{
begin = 50;
unitAmount = 4;
unitScaling = 3;
spacing = 5;
groupAmount = 2;
max = 8;
}},
new SpawnGroup(UnitTypes.ghoul){{
begin = 53;
unitAmount = 2;
unitScaling = 3;
spacing = 4;
max = 8;
end = 74;
}},
new SpawnGroup(UnitTypes.ghoul){{
begin = 53;
unitAmount = 2;
unitScaling = 3;
spacing = 4;
max = 8;
end = 74;
}},
new SpawnGroup(UnitTypes.ghoul){{
begin = 53;
unitAmount = 2;
unitScaling = 3;
spacing = 4;
max = 8;
end = 74;
}}
);
new SpawnGroup(UnitTypes.ghoul){{
begin = 53;
unitAmount = 2;
unitScaling = 3;
spacing = 4;
max = 8;
end = 74;
}}
);
public static Array<SpawnGroup> getDefaultSpawns(){
return spawns;
}
public static void testWaves(int from, int to){
Array<SpawnGroup> spawns = getSpawns();
for(int i = from; i <= to; i++){
System.out.print(i + ": ");
int total = 0;
for(SpawnGroup spawn : spawns){
int a = spawn.getUnitsSpawned(i) * spawn.getGroupsSpawned(i);
int a = spawn.getUnitsSpawned(i);
total += a;
if(a > 0){