From 83c86b388305231fd751dcbefee922786554b36a Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 8 Aug 2019 21:26:50 -0400 Subject: [PATCH] more tutorial --- core/assets/bundles/bundle.properties | 4 +- .../io/anuke/mindustry/game/EventType.java | 10 ++++ .../src/io/anuke/mindustry/game/Tutorial.java | 12 ++++- .../anuke/mindustry/input/InputHandler.java | 52 +++++++++---------- .../ui/fragments/BlockInventoryFragment.java | 6 ++- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 8e2a9c3daf..9686aed179 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -874,6 +874,8 @@ tutorial.pause = During battle, you are able to[accent] pause the game.[]\nYou m 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 and unpause. tutorial.breaking = Blocks frequently need to be destroyed.\n[accent]Hold down right-click[] to destroy all blocks in a selection.[]\n\n[yellow]Destroy all the scrap blocks to the right of your core. 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[yellow]Destroy all the scrap blocks to the right of your core. +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. Multiple items can be withdrawn by [accent]tapping and holding[].\n\n[yellow]Withdraw some copper from the core.[] +tutorial.deposit = Deposit items into blocks by dragging from your ship to the destination block.\n\n[yellow]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 resources can then be used to research new technology.\n\n[accent]Press the launch button. @@ -965,7 +967,7 @@ block.junction.description = Acts as a bridge for two crossing conveyor belts. U block.bridge-conveyor.description = Advanced item transport block. Allows transporting items over up to 3 tiles of any terrain or building. block.phase-conveyor.description = Advanced item transport block. Uses power to teleport items to a connected phase conveyor over several tiles. block.sorter.description = Sorts items. If an item matches the selection, it is allowed to pass. Otherwise, the item is outputted to the left and right. -block.router.description = Accepts items, then outputs them to up to 3 other directions equally. Useful for splitting the materials from one source to multiple targets. +block.router.description = Accepts items, then outputs them to up to 3 other directions equally. Useful for splitting the materials from one source to multiple targets.\n[scarlet]Never[] use next to production inputs, as they will get clogged by output. block.distributor.description = An advanced router. Splits items to up to 7 other directions equally. block.overflow-gate.description = A combination splitter and router. Only outputs to the left and right if the front path is blocked. block.mass-driver.description = The ultimate item transport block. Collects several items and then shoots them to another mass driver over a long range. Requires power to operate. diff --git a/core/src/io/anuke/mindustry/game/EventType.java b/core/src/io/anuke/mindustry/game/EventType.java index d697532afe..c9da8c9c57 100644 --- a/core/src/io/anuke/mindustry/game/EventType.java +++ b/core/src/io/anuke/mindustry/game/EventType.java @@ -68,6 +68,16 @@ public class EventType{ } + /** Called when a player withdraws items from a block. Tutorial only.*/ + public static class WithdrawEvent{ + + } + + /** Called when a player deposits items to a block.*/ + public static class DepositEvent{ + + } + public static class GameOverEvent{ public final Team winner; diff --git a/core/src/io/anuke/mindustry/game/Tutorial.java b/core/src/io/anuke/mindustry/game/Tutorial.java index 82c5d44f2f..4e64f30b85 100644 --- a/core/src/io/anuke/mindustry/game/Tutorial.java +++ b/core/src/io/anuke/mindustry/game/Tutorial.java @@ -37,6 +37,8 @@ public class Tutorial{ Events.on(TurretAmmoDeliverEvent.class, event -> events.add("ammo")); Events.on(CoreItemDeliverEvent.class, event -> events.add("coreitem")); Events.on(BlockInfoEvent.class, event -> events.add("blockinfo")); + Events.on(DepositEvent.class, event -> events.add("deposit")); + Events.on(WithdrawEvent.class, event -> events.add("withdraw")); } /** update tutorial state, transition if needed */ @@ -55,7 +57,7 @@ public class Tutorial{ /** Resets tutorial state. */ public void reset(){ - stage = TutorialStage.values()[0]; + stage = TutorialStage.values()[6]; stage.begin(); blocksPlaced.clear(); events.clear(); @@ -120,7 +122,13 @@ public class Tutorial{ } } }, - waves(() -> state.wave > 2 && state.enemies() <= 0){ + withdraw(() -> event("withdraw")){ + void begin(){ + state.teams.get(defaultTeam).cores.first().entity.items.add(Items.copper, 10); + } + }, + deposit(() -> event("deposit")), + waves(() -> state.wave > 2 && state.enemies() <= 0 && !world.spawner.isSpawning()){ void begin(){ state.rules.waveTimer = true; logic.runWave(); diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index fae86625e8..03048e75b5 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -1,34 +1,28 @@ package io.anuke.mindustry.input; -import io.anuke.annotations.Annotations.Loc; -import io.anuke.annotations.Annotations.Remote; -import io.anuke.arc.Core; -import io.anuke.arc.collection.Array; -import io.anuke.arc.function.Consumer; -import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.TextureRegion; -import io.anuke.arc.input.InputProcessor; -import io.anuke.arc.math.Angles; -import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Point2; -import io.anuke.arc.math.geom.Vector2; -import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; -import io.anuke.mindustry.content.Blocks; -import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.effect.ItemTransfer; -import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.gen.Call; -import io.anuke.mindustry.graphics.Pal; +import io.anuke.annotations.Annotations.*; +import io.anuke.arc.*; +import io.anuke.arc.collection.*; +import io.anuke.arc.function.*; +import io.anuke.arc.graphics.*; +import io.anuke.arc.graphics.g2d.*; +import io.anuke.arc.input.*; +import io.anuke.arc.math.*; +import io.anuke.arc.math.geom.*; +import io.anuke.arc.scene.ui.layout.*; +import io.anuke.arc.util.*; +import io.anuke.mindustry.content.*; +import io.anuke.mindustry.entities.*; +import io.anuke.mindustry.entities.effect.*; +import io.anuke.mindustry.entities.traits.BuilderTrait.*; +import io.anuke.mindustry.entities.type.*; +import io.anuke.mindustry.game.EventType.*; +import io.anuke.mindustry.gen.*; +import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.net.Net; -import io.anuke.mindustry.net.ValidateException; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.ui.fragments.OverlayFragment; +import io.anuke.mindustry.net.*; +import io.anuke.mindustry.type.*; +import io.anuke.mindustry.ui.fragments.*; import io.anuke.mindustry.world.*; import static io.anuke.mindustry.Vars.*; @@ -83,6 +77,8 @@ public abstract class InputHandler implements InputProcessor{ int[] remaining = {accepted, accepted}; Block block = tile.block(); + Events.fire(new DepositEvent()); + for(int i = 0; i < sent; i++){ boolean end = i == sent - 1; Time.run(i * 3, () -> { diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java index b7da02cdf2..4a8b96707e 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.ui.fragments; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; -import io.anuke.arc.Core; +import io.anuke.arc.*; import io.anuke.arc.collection.IntSet; import io.anuke.arc.function.BooleanProvider; import io.anuke.arc.function.Supplier; @@ -21,6 +21,7 @@ import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.util.*; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.type.Player; +import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Item.Icon; @@ -100,6 +101,8 @@ public class BlockInventoryFragment extends Fragment{ Call.requestItem(player, tile, lastItem, amount); holding = false; holdTime = 0f; + + Events.fire(new WithdrawEvent()); } } @@ -152,6 +155,7 @@ public class BlockInventoryFragment extends Fragment{ lastItem = item; holding = true; holdTime = 0f; + Events.fire(new WithdrawEvent()); } return true; }