From e4266d22f5972e9b19ba1659c53b526b22957efb Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 21 Nov 2020 17:17:03 -0500 Subject: [PATCH] Added more hints --- core/assets/bundles/bundle.properties | 42 ++++++++---------- core/assets/scripts/base.js | 2 +- core/assets/scripts/global.js | 2 +- core/src/mindustry/content/Blocks.java | 1 + .../entities/comp/CommanderComp.java | 7 +++ .../mindustry/entities/comp/MinerComp.java | 2 +- core/src/mindustry/input/Binding.java | 1 + core/src/mindustry/input/DesktopInput.java | 5 ++- .../mindustry/ui/dialogs/PlanetDialog.java | 17 ++++--- .../mindustry/ui/fragments/HintsFragment.java | 44 ++++++++++--------- core/src/mindustry/world/meta/BlockFlag.java | 4 +- 11 files changed, 68 insertions(+), 59 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index e0ee08fca0..ba2ea894e8 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -548,6 +548,10 @@ sectors.launch = Launch sectors.select = Select sectors.nonelaunch = [lightgray]none (sun) sectors.rename = Rename Sector +sectors.enemybase = [scarlet]Enemy Base +sectors.vulnerable = [scarlet]Vulnerable +sectors.underattack = [scarlet]Under attack! [accent]{0}% damaged +sectors.survives = [accent]Survives {0} waves sector.curcapture = Sector Captured sector.curlost = Sector Lost @@ -890,6 +894,7 @@ keybind.menu.name = Menu keybind.pause.name = Pause keybind.pause_building.name = Pause/Resume Building keybind.minimap.name = Minimap +keybind.planet_map.name = Planet Map keybind.chat.name = Chat keybind.player_list.name = Player List keybind.console.name = Console @@ -1257,30 +1262,19 @@ hint.research = Use the \ue875 [accent]Research[] button to research new technol hint.research.mobile = Use the \ue875 [accent]Research[] button in the \ue88c [accent]Menu[] to research new technology. hint.unitControl = Hold [accent][[L-ctrl][] and [accent]click[] to control friendly units or turrets. hint.unitControl.mobile = [accent][Double-tap[] to control friendly units or turrets. -hint.launch = Once you collect enough resources, you can [accent]Launch[] by selecting nearby sectors from the \ue827 [accent]Map[] in the bottom right. -hint.launch.mobile = Once you collect enough resources, you can [accent]Launch[] by selecting nearby sectors from the \ue827 [accent]Map[] in the \ue88c [accent]Menu[]. - -tutorial.next = [lightgray] -tutorial.intro = You have entered the[scarlet] Mindustry Tutorial.[]\nUse[accent] [[WASD][] to move.\n[accent]Scroll[] to zoom in and out.\nBegin by[accent] mining copper[]. Move close to it, then tap a copper ore vein near your core to do this.\n\n[accent]{0}/{1} copper -tutorial.intro.mobile = You have entered the[scarlet] Mindustry Tutorial.[]\nSwipe the screen to move.\n[accent]Pinch with 2 fingers[] to zoom in and out.\nBegin by[accent] mining copper[]. Move close to it, then tap a copper ore vein near your core to do this.\n\n[accent]{0}/{1} copper -tutorial.drill = Mining manually is inefficient.\n[accent]Drills[] can mine automatically.\nClick the drill tab in the bottom right.\nSelect the[accent] mechanical drill[]. Place it on a copper vein by clicking.\nYou can also select the drill by tapping [accent][[2][] then [accent][[1][] quickly, regardless of which tab is open.\n[accent]Right-click[] to stop building. -tutorial.drill.mobile = Mining manually is inefficient.\n[accent]Drills[] can mine automatically.\nTap the drill tab in the bottom right.\nSelect the[accent] mechanical drill[].\nPlace it on a copper vein by tapping, then press the[accent] checkmark[] below to confirm your selection.\nPress the[accent] X button[] to cancel placement. -tutorial.blockinfo = Each block has different stats. Each drill can only mine certain ores.\nTo check a block's info and stats,[accent] tap the "?" button while selecting it in the build menu.[]\n\n[accent]Access the Mechanical Drill's stats now.[] -tutorial.conveyor = [accent]Conveyors[] are used to transport items to the core.\nMake a line of conveyors from the drill to the core.\n[accent]Hold down the mouse to place in a line.[]\nHold[accent] CTRL[] while selecting a line to place diagonally.\nUse the scrollwheel to rotate blocks before placing them.\n[accent]Place 2 conveyors with the line tool, then deliver an item into the core. -tutorial.conveyor.mobile = [accent]Conveyors[] are used to transport items to the core.\nMake a line of conveyors from the drill to the core.\n[accent] Place in a line by holding down your finger for a few seconds[] and dragging in a direction.\n\n[accent]Place 2 conveyors with the line tool, then deliver an item into the core. -tutorial.turret = Once an item enters your core, it can be used for building.\nKeep in mind that not all items can be used for building.\nItems that are not used for building, such as[accent] coal[] or[accent] scrap[], cannot be put into the core.\nDefensive structures must be built to repel the[lightgray] enemy[].\nBuild a[accent] duo turret[] near your base. -tutorial.drillturret = Duo turrets require[accent] copper ammo[] to shoot.\nPlace a drill near the turret.\nLead conveyors into the turret to supply it with copper.\n\n[accent]Ammo delivered: 0/1 -tutorial.pause = During battle, you are able to[accent] pause the game.[]\nYou may queue buildings while paused.\n\n[accent]Press space to pause. -tutorial.pause.mobile = During battle, you are able to[accent] pause the game.[]\nYou may queue buildings while paused.\n\n[accent]Press this button in the top left to pause. -tutorial.unpause = Now press space again to unpause. -tutorial.unpause.mobile = Now press it again to unpause. -tutorial.breaking = Blocks frequently need to be destroyed.\n[accent]Hold down right-click[] to destroy all blocks in a selection.[]\n\n[accent]Destroy all the scrap blocks to the left of your core using area selection. -tutorial.breaking.mobile = Blocks frequently need to be destroyed.\n[accent]Select deconstruction mode[], then tap a block to begin breaking it.\nDestroy an area by holding down your finger for a few seconds[] and dragging in a direction.\nPress the checkmark button to confirm breaking.\n\n[accent]Destroy all the scrap blocks to the left of your core using area selection. -tutorial.withdraw = In some situations, taking items directly from blocks is necessary.\nTo do this, [accent]tap a block[] with items in it, then [accent]tap the item[] in the inventory.\nMultiple items can be withdrawn by [accent]tapping and holding[].\n\n[accent]Withdraw some copper from the core.[] -tutorial.deposit = Deposit items into blocks by dragging from your ship to the destination block.\n\n[accent]Deposit your copper back into the core.[] -tutorial.waves = The[lightgray] enemy[] approaches.\n\nDefend the core for 2 waves.[accent] Click[] to shoot.\nBuild more turrets and drills. Mine more copper. -tutorial.waves.mobile = The[lightgray] enemy[] approaches.\n\nDefend the core for 2 waves. Your ship will automatically fire at enemies.\nBuild more turrets and drills. Mine more copper. -tutorial.launch = Once you reach a specific wave, you are able to[accent] launch the core[], leaving your defenses behind and[accent] obtaining all the resources in your core.[]\nThese obtained resources can then be used to research new technology.\n\n[accent]Press the launch button. +hint.launch = Once enough resources are collected, you can [accent]Launch[] by selecting nearby sectors from the \ue827 [accent]Map[] in the bottom right. +hint.launch.mobile = Once enough resources are collected, you can [accent]Launch[] by selecting nearby sectors from the \ue827 [accent]Map[] in the \ue88c [accent]Menu[]. +hint.schematicSelect = Hold [accent][[F][] and drag to select blocks to copy and paste.\n\n[accent][[Middle Click][] to copy a single block type. +hint.conveyorPathfind = Hold [accent][[L-Ctrl][] while dragging conveyors to automatically generate a path. +hint.conveyorPathfind.mobile = Enable \ue844 [accent]diagonal mode[] and drag conveyors to automatically generate a path. +hint.boost = Hold [accent][[L-Shift][] to fly over obstacles with your current unit.\n\nOnly a few ground units have boosters. +hint.command = Press [accent][[G][] to command nearby units into formation. +hint.command.mobile = [accent][[Double-tap][] your unit to command nearby units into formation. +hint.payloadPickup = Press [accent][[[] to pick up small blocks or units. +hint.payloadPickup.mobile = [accent]Tap and hold[] a small block or unit to pick it up. +hint.payloadDrop = Press [accent]][] to drop a payload. +hint.payloadDrop.mobile = [accent]Tap and hold[] an empty location to drop a payload there. +hint.waveFire = [accent]Wave[] turrets with water as ammunition will automatically put out nearby fires. item.copper.description = Used in all types of construction and ammunition. item.copper.details = Copper. Abnormally abundant metal on Serpulo. Structurally weak unless reinforced. diff --git a/core/assets/scripts/base.js b/core/assets/scripts/base.js index a4ec37b18d..d0fab50b81 100755 --- a/core/assets/scripts/base.js +++ b/core/assets/scripts/base.js @@ -51,4 +51,4 @@ const prov = method => new Prov(){get: method} const func = method => new Func(){get: method} const newEffect = (lifetime, renderer) => new Effects.Effect(lifetime, new Effects.EffectRenderer({render: renderer})) -const Call = Packages.mindustry.gen.Call +Call = Packages.mindustry.gen.Call diff --git a/core/assets/scripts/global.js b/core/assets/scripts/global.js index c20c6f84fb..214da61a7b 100755 --- a/core/assets/scripts/global.js +++ b/core/assets/scripts/global.js @@ -53,7 +53,7 @@ const prov = method => new Prov(){get: method} const func = method => new Func(){get: method} const newEffect = (lifetime, renderer) => new Effects.Effect(lifetime, new Effects.EffectRenderer({render: renderer})) -const Call = Packages.mindustry.gen.Call +Call = Packages.mindustry.gen.Call importPackage(Packages.arc) importPackage(Packages.arc.func) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 793cd765f0..f9681348fe 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -1508,6 +1508,7 @@ public class Blocks implements ContentList{ shootEffect = Fx.shootLiquid; range = 110f; health = 250 * size * size; + flags = EnumSet.of(BlockFlag.turret, BlockFlag.extinguisher); }}; lancer = new ChargeTurret("lancer"){{ diff --git a/core/src/mindustry/entities/comp/CommanderComp.java b/core/src/mindustry/entities/comp/CommanderComp.java index 2fe2bf83a0..0ce8d60d10 100644 --- a/core/src/mindustry/entities/comp/CommanderComp.java +++ b/core/src/mindustry/entities/comp/CommanderComp.java @@ -29,9 +29,14 @@ abstract class CommanderComp implements Entityc, Posc{ transient float minFormationSpeed; public void update(){ + if(controlling.isEmpty()){ + formation = null; + } + if(formation != null){ formation.anchor.set(x, y, 0); formation.updateSlots(); + controlling.removeAll(u -> u.dead || !(u.controller() instanceof FormationAI ai && ai.leader == self())); } } @@ -64,6 +69,8 @@ abstract class CommanderComp implements Entityc, Posc{ } }); + if(units.isEmpty()) return; + //sort by hitbox size, then by distance units.sort(Structs.comps(Structs.comparingFloat(u -> -u.hitSize), Structs.comparingFloat(u -> u.dst2(this)))); units.truncate(type.commandLimit); diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index eb5802711e..9368918d8c 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -45,7 +45,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ } public boolean canMine(){ - return type.mineSpeed > 0; + return type.mineSpeed > 0 && type.mineTier >= 0; } @Override diff --git a/core/src/mindustry/input/Binding.java b/core/src/mindustry/input/Binding.java index 75655412cb..c65424ed6e 100644 --- a/core/src/mindustry/input/Binding.java +++ b/core/src/mindustry/input/Binding.java @@ -58,6 +58,7 @@ public enum Binding implements KeyBind{ fullscreen(KeyCode.f11), pause(KeyCode.space), minimap(KeyCode.m), + planet_map(KeyCode.n), toggle_menus(KeyCode.c), screenshot(KeyCode.p), toggle_power_lines(KeyCode.f5), diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index d7a25a2b92..7771b30fed 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -237,8 +237,9 @@ public class DesktopInput extends InputHandler{ player.shooting = false; } - if(state.isGame() && Core.input.keyTap(Binding.minimap) && !scene.hasDialog() && !(scene.getKeyboardFocus() instanceof TextField)){ - ui.minimapfrag.toggle(); + if(state.isGame() && !scene.hasDialog() && !(scene.getKeyboardFocus() instanceof TextField)){ + if(Core.input.keyTap(Binding.minimap)) ui.minimapfrag.toggle(); + if(Core.input.keyTap(Binding.planet_map) && state.isCampaign()) ui.planet.toggle(); } if(state.isMenu() || Core.scene.hasDialog()) return; diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 14901c83e8..e0eb64904c 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -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(); } diff --git a/core/src/mindustry/ui/fragments/HintsFragment.java b/core/src/mindustry/ui/fragments/HintsFragment.java index d580fa754b..eb7d8ca854 100644 --- a/core/src/mindustry/ui/fragments/HintsFragment.java +++ b/core/src/mindustry/ui/fragments/HintsFragment.java @@ -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 incomplete = Seq.with(DefaultHint.values()); - @Nullable - public Hint current; + public Seq hints = Seq.with(DefaultHint.values()); + @Nullable Hint current; Group group = new WidgetGroup(); ObjectSet events = new ObjectSet<>(); ObjectSet 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 diff --git a/core/src/mindustry/world/meta/BlockFlag.java b/core/src/mindustry/world/meta/BlockFlag.java index ca4ded3db3..f1778accff 100644 --- a/core/src/mindustry/world/meta/BlockFlag.java +++ b/core/src/mindustry/world/meta/BlockFlag.java @@ -23,7 +23,9 @@ public enum BlockFlag{ /** Any reactor block. */ reactor, /** Any block that boosts unit capacity. */ - unitModifier; + unitModifier, + /** Blocks that extinguishes fires. */ + extinguisher; public final static BlockFlag[] all = values(); }