Added more hints

This commit is contained in:
Anuken
2020-11-21 17:17:03 -05:00
parent b09dc47aad
commit e4266d22f5
11 changed files with 68 additions and 59 deletions

View File

@@ -677,23 +677,22 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
stable.add(Core.bundle.get("sectors.threat") + " [accent]" + sector.displayThreat()).row();
}
if(sector.isAttacked()){ //TODO localize
//these mechanics are likely to change and as such are not added to the bundle
stable.add("[scarlet]Under attack! [accent]" + (int)(sector.info.damage * 100) + "% damaged");
if(sector.isAttacked()){
stable.add(Core.bundle.format("sectors.underattack", (int)(sector.info.damage * 100)));
stable.row();
if(sector.info.wavesSurvived >= 0 && sector.info.wavesSurvived - sector.info.wavesPassed >= 0 && !sector.isBeingPlayed()){
int toCapture = sector.info.attack || sector.info.winWave <= 1 ? -1 : sector.info.winWave - (sector.info.wave + sector.info.wavesPassed);
boolean plus = (sector.info.wavesSurvived - sector.info.wavesPassed) >= SectorDamage.maxRetWave - 1;
stable.add("[accent]Survives " + Math.min(sector.info.wavesSurvived - sector.info.wavesPassed, toCapture <= 0 ? 200 : 0) +
(plus ? "+" : "") + (toCapture < 0 ? "" : "/" + toCapture) + " waves");
stable.add(Core.bundle.format("sectors.survives", Math.min(sector.info.wavesSurvived - sector.info.wavesPassed, toCapture <= 0 ? 200 : 0) +
(plus ? "+" : "") + (toCapture < 0 ? "" : "/" + toCapture)));
stable.row();
}
}else if(sector.hasBase() && sector.near().contains(Sector::hasEnemyBase)){ //TODO localize
stable.add("[scarlet]Vulnerable");
}else if(sector.hasBase() && sector.near().contains(Sector::hasEnemyBase)){
stable.add("@sectors.vulnerable");
stable.row();
}else if(!sector.hasBase() && sector.hasEnemyBase()){ //TODO localize
stable.add("[scarlet]Enemy Base");
}else if(!sector.hasBase() && sector.hasEnemyBase()){
stable.add("@sectors.enemybase");
stable.row();
}

View File

@@ -13,9 +13,11 @@ import arc.util.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.game.EventType.*;
import mindustry.gen.*;
import mindustry.input.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
@@ -24,10 +26,9 @@ public class HintsFragment extends Fragment{
private static final float foutTime = 0.6f;
/** All hints to be displayed in the game. */
public Seq<Hint> incomplete = Seq.with(DefaultHint.values());
@Nullable
public Hint current;
public Seq<Hint> hints = Seq.with(DefaultHint.values());
@Nullable Hint current;
Group group = new WidgetGroup();
ObjectSet<String> events = new ObjectSet<>();
ObjectSet<Block> placedBlocks = new ObjectSet<>();
@@ -47,10 +48,10 @@ public class HintsFragment extends Fragment{
}else if(!current.show()){ //current became hidden
hide();
}
}else if(incomplete.size > 0){
}else if(hints.size > 0){
//check one hint each frame to see if it should be shown.
checkIdx = (checkIdx + 1) % incomplete.size;
Hint hint = incomplete.get(checkIdx);
checkIdx = (checkIdx + 1) % hints.size;
Hint hint = hints.get(checkIdx);
if(hint.show() && !hint.finished() & !hint.complete()){
display(hint);
}
@@ -61,7 +62,7 @@ public class HintsFragment extends Fragment{
checkNext();
Events.on(BlockBuildEndEvent.class, event -> {
if(!event.breaking && event.tile.team() == Vars.state.rules.defaultTeam){
if(!event.breaking && event.unit == player.unit()){
placedBlocks.add(event.tile.block());
}
@@ -70,26 +71,22 @@ public class HintsFragment extends Fragment{
}
});
Events.on(UnitControlEvent.class, e -> {
if(e.player == player){
events.add("unitcontrol");
}
Events.on(ResetEvent.class, e -> {
placedBlocks.clear();
events.clear();
});
Events.on(WorldLoadEvent.class, e -> Core.app.post(() -> {
checkNext();
}));
}
void checkNext(){
if(current != null) return;
incomplete.removeAll(h -> h == current || !h.valid() || h.finished() || (h.show() && h.complete()));
incomplete.sort(Hint::order);
hints.removeAll(h -> h == current || !h.valid() || h.finished() || (h.show() && h.complete()));
hints.sort(Hint::order);
Hint first = incomplete.find(Hint::show);
Hint first = hints.find(Hint::show);
if(first != null){
incomplete.remove(first);
hints.remove(first);
display(first);
}
}
@@ -120,7 +117,7 @@ public class HintsFragment extends Fragment{
if(current == null) return;
current.finish();
incomplete.remove(current);
hints.remove(current);
hide();
}
@@ -144,7 +141,7 @@ public class HintsFragment extends Fragment{
public enum DefaultHint implements Hint{
desktopMove(visibleDesktop, () -> Core.input.axis(Binding.move_x) != 0 || Core.input.axis(Binding.move_y) != 0),
zoom(visibleDesktop, () -> Core.input.axis(KeyCode.scroll) != 0),
mine(isTutorial, () -> player.unit().mining()),
mine(() -> player.unit().canMine() && isTutorial.get(), () -> player.unit().mining()),
placeDrill(isTutorial, () -> ui.hints.placedBlocks.contains(Blocks.mechanicalDrill)),
placeConveyor(isTutorial, () -> ui.hints.placedBlocks.contains(Blocks.conveyor)),
placeTurret(isTutorial, () -> ui.hints.placedBlocks.contains(Blocks.duo)),
@@ -156,6 +153,13 @@ public class HintsFragment extends Fragment{
unitControl(() -> state.rules.defaultTeam.data().units.size > 1 && !net.active(), () -> !player.dead() && !player.unit().spawnedByCore),
respawn(visibleMobile, () -> !player.dead() && !player.unit().spawnedByCore, () -> !player.dead() && player.unit().spawnedByCore),
launch(() -> isTutorial.get() && state.rules.sector.isCaptured(), () -> ui.planet.isShown()),
schematicSelect(visibleDesktop, () -> ui.hints.placedBlocks.contains(Blocks.router), () -> Core.input.keyRelease(Binding.schematic_select) || Core.input.keyTap(Binding.pick)),
conveyorPathfind(() -> control.input.block == Blocks.titaniumConveyor, () -> Core.input.keyTap(Binding.diagonal_placement) || (mobile && Core.settings.getBool("swapdiagonal"))),
boost(visibleDesktop, () -> !player.dead() && player.unit().type.canBoost, () -> Core.input.keyDown(Binding.boost)),
command(() -> state.rules.defaultTeam.data().units.size > 3 && !net.active(), () -> player.unit().isCommanding()),
payloadPickup(() -> !player.unit().dead && player.unit() instanceof Payloadc p && p.payloads().isEmpty(), () -> player.unit() instanceof Payloadc p && p.payloads().any()),
payloadDrop(() -> !player.unit().dead && player.unit() instanceof Payloadc p && p.payloads().any(), () -> player.unit() instanceof Payloadc p && p.payloads().isEmpty()),
waveFire(() -> Groups.fire.size() > 0 && Blocks.wave.unlockedNow(), () -> indexer.getAllied(state.rules.defaultTeam, BlockFlag.extinguisher).size() > 0),
;
@Nullable