/// <summary> /// Handles the trap that is located in the lava lake. This trap can be activated by both the blue team and the red team, however, the player must be wearing the Fire Demon /// smiley. /// </summary> /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param> /// <param name="player">The player that is triggering the trap.</param> public override void Handle(CaptureTheFlagBot ctfBot, Player player) { if (!CanTriggerTrap(player)) { return; } if (!TrapActivated) { Task.Run(async() => { ctfBot.SendPrivateMessage(player, "You triggered a secret trap!"); TrapActivated = true; // Place wall for (int y = 133; y >= 129; y--) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(259, y), Blocks.Foreground.Caution); ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(306, y), Blocks.Foreground.Caution); await Task.Delay(100); } await Task.Delay(TrapCooldownMs); // Remove wall for (int y = 129; y <= 133; y++) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(259, y), Blocks.None); ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(306, y), Blocks.None); await Task.Delay(100); } await Task.Delay(TrapCooldownMs); TrapActivated = false; }); } }
/// <summary> /// Places a firework above teams flag. This method should only be called when a player captures a flag. This method will throw an exception if the /// team is set to <see cref="Team.None"/>. /// </summary> /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param> /// <param name="team">The team that captured the flag.</param> private void CelebrateCapture(CaptureTheFlagBot ctfBot, Team team) { if (team == Team.None) { throw new Exception("Unsupported team type!"); } Task.Run(async() => { MorphableBlock firework = team == Team.Blue ? Blocks.Foreground.BlueFirework : Blocks.Foreground.RedFirework; Point placeLocation = (team == Team.Blue ? Flags[Team.Blue].HomeLocation : Flags[Team.Red].HomeLocation); await Task.Delay(500); placeLocation.Offset(0, -3); ctfBot.PlaceBlock(BlockLayer.Foreground, placeLocation, firework); await Task.Delay(1000); ctfBot.PlaceBlock(BlockLayer.Foreground, placeLocation, Blocks.None); }); }
/// <summary> /// Handles a player digging in during the Capture The Flag game. /// </summary> /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param> /// <param name="player">The player to be handled.</param> private void OnPlayerMoved(CaptureTheFlagBot ctfBot, Player player) { if (ctfBot.JoinedWorld.Blocks == null || !player.IsPlayingGame || player.IsInGodMode || player.IsPressingSpacebar || !WearingDiggableSmiley(player)) { return; } if (IsDelayOver(player)) { bool handled; foreach (int blockId in m_diggableBlocks) { if (handled = CanDigLeft(ctfBot, player, blockId)) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(player.Location.X - 1, player.Location.Y), Blocks.Foreground.SlowGravityDot); } else if (handled = CanDigRight(ctfBot, player, blockId)) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(player.Location.X + 1, player.Location.Y), Blocks.Foreground.SlowGravityDot); } else if (handled = CanDigUp(ctfBot, player, blockId)) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(player.Location.X, player.Location.Y - 1), Blocks.Foreground.SlowGravityDot); } else if (handled = CanDigDown(ctfBot, player, blockId)) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(player.Location.X, player.Location.Y + 1), Blocks.Foreground.SlowGravityDot); } if (handled) // Player digged a block successfully { UpdatePlayerCurrentTick(player); break; // No need to check the other blocks } } } }
/// <summary> /// Handles the bridge trap. This trap can be activated by both the blue team and the red team. /// </summary> /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param> /// <param name="player">The player that is triggering the trap.</param> public override void Handle(CaptureTheFlagBot ctfBot, Player player) { if (!base.CanTriggerTrap(player)) { return; } if (!TrapActivated) { Task.Run(async() => { TrapActivated = true; // Remove bridge for (int x = 94; x <= 105; x++) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(x, 137), Blocks.None); await Task.Delay(100); } await Task.Delay(TrapCooldownMs); // Place bridge for (int x = 94; x <= 105; x++) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(x, 137), Blocks.Foreground.FactoryWood); await Task.Delay(100); } await Task.Delay(TrapCooldownMs); TrapActivated = false; }); } }
/// <summary> /// Handles the trap that is located in the blue teams base. This trap can only be activated by the blue team. /// </summary> /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param> /// <param name="player">The player that is triggering the trap.</param> public override void Handle(CaptureTheFlagBot ctfBot, Player player) { if (!CanTriggerTrap(player)) { return; } Task.Run(async() => { TrapActivated = true; // Close gate ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(45, 135), Blocks.Foreground.Caution); ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(45, 136), Blocks.Foreground.Caution); // Pour lava for (int i = 132; i <= 136; i++) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(47, i), Blocks.Foreground.Lava); ctfBot.PlaceBlock(BlockLayer.Background, new Point(47, i), Blocks.Background.DarkOrangeLava); await Task.Delay(100); } await Task.Delay(TrapCooldownMs); // Remove lava for (int i = 132; i <= 136; i++) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(47, i), Blocks.None); ctfBot.PlaceBlock(BlockLayer.Background, new Point(47, i), Blocks.Background.BrownBrick); await Task.Delay(100); } // Open gate ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(45, 135), Blocks.None); ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(45, 136), Blocks.None); await Task.Delay(TrapCooldownMs); TrapActivated = false; }); }
/// <summary> /// Handles the trap that is located in the red teams base. This trap can only be activated by the red team. /// </summary> /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param> /// <param name="player">The player that is triggering the trap.</param> public override void Handle(CaptureTheFlagBot ctfBot, Player player) { if (!CanTriggerTrap(player)) { return; } Task.Run(async() => { TrapActivated = true; // Close gate ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(354, 135), Blocks.Foreground.Caution); ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(354, 136), Blocks.Foreground.Caution); // Remove bridge for (int x = 347; x <= 353; x++) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(x, 137), Blocks.None); await Task.Delay(100); } await Task.Delay(TrapCooldownMs); // Show bridge for (int x = 347; x <= 353; x++) { ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(x, 137), Blocks.Foreground.FactoryWood); await Task.Delay(100); } // Remove gate ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(354, 135), Blocks.None); ctfBot.PlaceBlock(BlockLayer.Foreground, new Point(354, 136), Blocks.None); await Task.Delay(TrapCooldownMs); TrapActivated = false; }); }