mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-23 13:09:27 +07:00
Game stats cleanup
This commit is contained in:
parent
512b65a592
commit
ba48373bbc
@ -78,13 +78,12 @@ schematic.tagexists = That tag already exists.
|
||||
|
||||
stats = Stats
|
||||
stat.wave = Waves Defeated:[accent] {0}
|
||||
stat.unitsCreated = Units Created:[accent] {0}
|
||||
stat.enemiesDestroyed = Enemies Destroyed:[accent] {0}
|
||||
stat.built = Buildings Built:[accent] {0}
|
||||
stat.destroyed = Buildings Destroyed:[accent] {0}
|
||||
stat.deconstructed = Buildings Deconstructed:[accent] {0}
|
||||
stat.delivered = Resources Launched:
|
||||
stat.playtime = Time Played:[accent] {0}
|
||||
stat.rank = Final Rank: [accent]{0}
|
||||
|
||||
globalitems = [accent]Total Items
|
||||
map.delete = Are you sure you want to delete the map "[accent]{0}[]"?
|
||||
|
BIN
core/assets/sounds/wind3.ogg
Normal file
BIN
core/assets/sounds/wind3.ogg
Normal file
Binary file not shown.
@ -172,13 +172,19 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
Events.on(BlockDestroyEvent.class, e -> {
|
||||
if(e.tile.team() == player.team()){
|
||||
state.stats.buildingsDestroyed++;
|
||||
state.stats.buildingsDestroyed ++;
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(UnitDestroyEvent.class, e -> {
|
||||
if(e.unit.team() != player.team()){
|
||||
state.stats.enemyUnitsDestroyed++;
|
||||
state.stats.enemyUnitsDestroyed ++;
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(UnitCreateEvent.class, e -> {
|
||||
if(e.unit.team == state.rules.defaultTeam){
|
||||
state.stats.unitsCreated++;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -7,6 +7,7 @@ import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
@ -40,6 +41,7 @@ public class UnitSpawnAbility extends Ability{
|
||||
Unit u = this.unit.create(unit.team);
|
||||
u.set(x, y);
|
||||
u.rotation = unit.rotation;
|
||||
Events.fire(new UnitCreateEvent(u, null, unit));
|
||||
if(!Vars.net.client()){
|
||||
u.add();
|
||||
}
|
||||
|
@ -411,14 +411,20 @@ public class EventType{
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when a unit is created in a reconstructor or factory. */
|
||||
/** Called when a unit is created in a reconstructor, factory or other unit. */
|
||||
public static class UnitCreateEvent{
|
||||
public final Unit unit;
|
||||
public final Building spawner;
|
||||
public final @Nullable Building spawner;
|
||||
public final @Nullable Unit spawnerUnit;
|
||||
|
||||
public UnitCreateEvent(Unit unit, Building spawner){
|
||||
public UnitCreateEvent(Unit unit, Building spawner, Unit spawnerUnit){
|
||||
this.unit = unit;
|
||||
this.spawner = spawner;
|
||||
this.spawnerUnit = spawnerUnit;
|
||||
}
|
||||
|
||||
public UnitCreateEvent(Unit unit, Building spawner){
|
||||
this(unit, spawner, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,52 +1,16 @@
|
||||
package mindustry.game;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
//TODO more stats:
|
||||
//- units constructed
|
||||
public class GameStats{
|
||||
/** Total items delivered to global resoure counter. Campaign only. */
|
||||
public ObjectIntMap<Item> itemsDelivered = new ObjectIntMap<>();
|
||||
/** Enemy (red team) units destroyed. */
|
||||
public int enemyUnitsDestroyed;
|
||||
/** Total waves lasted. */
|
||||
public int wavesLasted;
|
||||
/** Total (ms) time lasted in this save/zone. */
|
||||
public long timeLasted;
|
||||
/** Friendly buildings fully built. */
|
||||
public int buildingsBuilt;
|
||||
/** Friendly buildings fully deconstructed. */
|
||||
public int buildingsDeconstructed;
|
||||
/** Friendly buildings destroyed. */
|
||||
public int buildingsDestroyed;
|
||||
|
||||
//unused
|
||||
public RankResult calculateRank(Sector sector){
|
||||
float score = 0;
|
||||
|
||||
int rankIndex = Mathf.clamp((int)score, 0, Rank.all.length - 1);
|
||||
Rank rank = Rank.all[rankIndex];
|
||||
String sign = Math.abs((rankIndex + 0.5f) - score) < 0.2f || rank.name().contains("S") ? "" : (rankIndex + 0.5f) < score ? "-" : "+";
|
||||
|
||||
return new RankResult(rank, sign);
|
||||
}
|
||||
|
||||
public static class RankResult{
|
||||
public final Rank rank;
|
||||
/** + or - */
|
||||
public final String modifier;
|
||||
|
||||
public RankResult(Rank rank, String modifier){
|
||||
this.rank = rank;
|
||||
this.modifier = modifier;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Rank{
|
||||
F, D, C, B, A, S, SS;
|
||||
|
||||
public static final Rank[] all = values();
|
||||
}
|
||||
/** Total units created by any means. */
|
||||
public int unitsCreated;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import arc.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@ -52,6 +51,7 @@ public class GameOverDialog extends BaseDialog{
|
||||
t.margin(13f);
|
||||
t.left().defaults().left();
|
||||
t.add(Core.bundle.format("stat.wave", state.stats.wavesLasted)).row();
|
||||
t.add(Core.bundle.format("stat.unitsCreated", state.stats.unitsCreated)).row();
|
||||
t.add(Core.bundle.format("stat.enemiesDestroyed", state.stats.enemyUnitsDestroyed)).row();
|
||||
t.add(Core.bundle.format("stat.built", state.stats.buildingsBuilt)).row();
|
||||
t.add(Core.bundle.format("stat.destroyed", state.stats.buildingsDestroyed)).row();
|
||||
@ -59,17 +59,6 @@ public class GameOverDialog extends BaseDialog{
|
||||
if(control.saves.getCurrent() != null){
|
||||
t.add(Core.bundle.format("stat.playtime", control.saves.getCurrent().getPlayTime())).row();
|
||||
}
|
||||
if(state.isCampaign() && !state.stats.itemsDelivered.isEmpty()){
|
||||
t.add("@stat.delivered").row();
|
||||
for(Item item : content.items()){
|
||||
if(state.stats.itemsDelivered.get(item, 0) > 0){
|
||||
t.table(items -> {
|
||||
items.add(" [lightgray]" + state.stats.itemsDelivered.get(item, 0));
|
||||
items.image(item.uiIcon).size(8 * 3).pad(4);
|
||||
}).left().row();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(state.isCampaign() && net.client()){
|
||||
t.add("@gameover.waiting").padTop(20f).row();
|
||||
|
@ -108,13 +108,15 @@ public class PowerNode extends PowerBlock{
|
||||
Core.bundle.format("bar.powerbalance",
|
||||
((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + UI.formatAmount((long)(entity.power.graph.getPowerBalance() * 60)))),
|
||||
() -> Pal.powerBar,
|
||||
() -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded())));
|
||||
() -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded())
|
||||
));
|
||||
|
||||
bars.add("batteries", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.powerstored",
|
||||
(UI.formatAmount((long)entity.power.graph.getLastPowerStored())), UI.formatAmount((long)entity.power.graph.getLastCapacity())),
|
||||
() -> Pal.powerBar,
|
||||
() -> Mathf.clamp(entity.power.graph.getLastPowerStored() / entity.power.graph.getLastCapacity())));
|
||||
() -> Mathf.clamp(entity.power.graph.getLastPowerStored() / entity.power.graph.getLastCapacity())
|
||||
));
|
||||
|
||||
bars.add("connections", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.powerlines", entity.power.links.size, maxNodes),
|
||||
|
@ -11,4 +11,4 @@ android.useAndroidX=true
|
||||
#used for slow jitpack builds; TODO see if this actually works
|
||||
http.socketTimeout=80000
|
||||
http.connectionTimeout=80000
|
||||
archash=d9eb4aa5b85f51c87f2e5e78cea4043e65bd29f0
|
||||
archash=96dbecb52d98b54550bda3d6bb33c69d24884c08
|
||||
|
Loading…
Reference in New Issue
Block a user