From a35a9ea31f871720381acd80273322c942a96866 Mon Sep 17 00:00:00 2001 From: Cheese Date: Sun, 7 Feb 2016 13:27:53 +1100 Subject: [PATCH] more valentines :) --- .../arcade/game/games/valentines/ValItem.java | 54 +++-- .../game/games/valentines/Valentines.java | 16 +- .../tutorial/TutorialPhaseValentines.java | 7 +- .../tutorial/TutorialValentines.java | 203 +++++++++++++++++- .../arcade/gametutorial/TutorialPhase.java | 15 +- 5 files changed, 252 insertions(+), 43 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/ValItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/ValItem.java index e23726cba..bb38e5317 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/ValItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/ValItem.java @@ -6,49 +6,59 @@ public enum ValItem { FLOWER1("Red Rose", "She will love this bouquet of roses!", - Material.RED_ROSE), + Material.RED_ROSE, 0), FLOWER2("Dandelion", - "Oh my, these flowers smell great!", - Material.YELLOW_FLOWER), + "I hope she's not allergic to these!", + Material.YELLOW_FLOWER, 0), - FLOWER3("Other Flower", - "MOO", - Material.REDSTONE), + FLOWER3("Blue Orchid", + "Thank you! These are her favourites!", + Material.RED_ROSE, 1), - WINE("Red Wine", - "This will go great with our dinner!", - Material.POTION), + WINE("Blue Wine", + "This will go great with our steak dinner!", + Material.POTION, 0), - GRASS("Organic Grass", - "Only the best for my date!", - Material.LONG_GRASS), + GRASS("Organic Free Range Grass", + "Yum! This is much tastier than caged grass!", + Material.LONG_GRASS, 1), DIAMONDS("Diamond Earings", - "An expensive, but worthwhile gift!", - Material.DIAMOND), + "I saved up for months for this gift!", + Material.DIAMOND, 0), - EMERALDS("Emerald Necklace", - "Such necklace, many wow!", - Material.EMERALD), + EMERALDS("Cold Hard Cash", + "They say love don't cost a thing. That's a lie!", + Material.EMERALD, 0), - BOOK("Book of Poetry", + BOOK("Love Poems", "I will use impress her with poetry!", - Material.BOOK), + Material.BOOK, 0), WATCH("Fancy Pocket Watch", - "This sure looks good on me!", - Material.WATCH); + "This Moolex Watch sure looks good on me!", + Material.WATCH, 0), + + LEASH("Checkered Neck Tie", + "Phew, you found my tie! This restaurant is fancy!", + Material.LEASH, 0), + + SADDLE("Saddle", + "Oh, uh... that's for later.", + Material.LEASH, 0); private String _title; private String _endText; private Material _item; + private byte _itemByte; - ValItem(String title, String endText, Material item) + ValItem(String title, String endText, Material item, int data) { _title = title; _item = item; _endText = endText; + _itemByte = (byte)data; } public String getTitle() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java index 1b1631744..b2ac18fcf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java @@ -58,6 +58,7 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.gladiators.tutorial.TutorialGladiators; import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove; import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines; +import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; public class Valentines extends SoloGame @@ -119,7 +120,7 @@ public class Valentines extends SoloGame this.HungerSet = 20; this.HealthSet = 20; - EnableTutorials = false; + EnableTutorials = true; try @@ -178,14 +179,7 @@ public class Valentines extends SoloGame { GetTeamList().get(0).setTutorial(new TutorialValentines(this, Manager)); } - - @EventHandler - public void tutorialUpdate(UpdateEvent event) - { - TutorialValentines tutorial = (TutorialValentines) GetTeamList().get(0).getTutorial(); - tutorial.update(event); - } - + @EventHandler public void knockback(CustomDamageEvent event) { @@ -675,10 +669,10 @@ public class Valentines extends SoloGame //Announce if (_pigs.size() > 1) - UtilTextMiddle.display("Round " + _round, _item.getTitle(), 0, 80, 20); + UtilTextMiddle.display(C.cYellow + "Round " + _round, _item.getTitle(), 0, 80, 20); else { - UtilTextMiddle.display("Final Round", "Capture the Pig!", 0, 80, 20); + UtilTextMiddle.display(C.cYellow + "Final Round", "Capture the Pig!", 0, 80, 20); for (Player player : GetPlayers(true)) player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1, "Pig Saddle")); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialPhaseValentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialPhaseValentines.java index e273444d2..2548c9284 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialPhaseValentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialPhaseValentines.java @@ -14,10 +14,15 @@ public class TutorialPhaseValentines extends TutorialPhase super(new TutorialText[] { new TutorialText(C.cRed + "Moolanie", "Calvin! Did you forget Valentines Day again?!", 1, Sound.COW_IDLE), - new TutorialText(C.cGreen + "Calvin", "...of course not!", 2, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "Of course not!!!", 2, Sound.COW_IDLE), new TutorialText(C.cGreen + "Calvin", "I promise this year will be amazing!", 3, Sound.COW_IDLE), new TutorialText(C.cRed + "Moolanie", "It better be, or we're finished...", 4, Sound.COW_IDLE), new TutorialText(C.cGreen + "Calvin", "Good thing I prepared for this!", 5, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "WHAT?!", 6, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "NO!!", 7, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "SOMEBODY HELP ME!", 8, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "I'M BEING ROBBED!", 9, Sound.COW_IDLE), + }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java index 1f2c66df6..cb0831bcf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java @@ -1,13 +1,26 @@ package nautilus.game.arcade.game.games.valentines.tutorial; -import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map.Entry; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Cow; +import org.bukkit.entity.Item; +import org.bukkit.entity.MushroomCow; import org.bukkit.entity.Pig; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; -import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.typewars.tutorial.TutorialPhaseTypeWars; +import nautilus.game.arcade.game.games.valentines.ValItem; import nautilus.game.arcade.game.games.valentines.Valentines; import nautilus.game.arcade.gametutorial.GameTutorial; import nautilus.game.arcade.gametutorial.TutorialPhase; @@ -15,20 +28,196 @@ import nautilus.game.arcade.gametutorial.TutorialPhase; public class TutorialValentines extends GameTutorial { private Valentines Host; - + private Cow _cowBoy; private Cow _cowGirl; - private ArrayList _pigs = new ArrayList(); - + private HashMap _pigs = new HashMap(); + + private Location _pigSpawn; + private Location _pigWaypointA; + private Location _pigWaypointB; + public TutorialValentines(Valentines valentines, ArcadeManager manager) { super(manager, new TutorialPhase[]{new TutorialPhaseValentines()}); Host = valentines; + + PlayTutorialSounds = true; + } + + @Override + public void onTick(int tick) + { + if (!hasStarted()) + return; + + if (getCurrentPhase() == null || getCurrentPhase().getCurrentText() == null) + return; + + cowGirlUpdate(tick); + cowBoyUpdate(tick); + pigUpdate(tick); + + lookUpdate(); + + } + + private void lookUpdate() + { + if (getCurrentPhase().getCurrentText().ID() == 2) + getPhase(1).setTarget(_cowBoy.getLocation().add(0, 2, 0)); + + if (getCurrentPhase().getCurrentText().ID() == 3) + getPhase(1).setTarget(_cowBoy.getLocation().add(0, 2, 0)); + + if (getCurrentPhase().getCurrentText().ID() == 4) + getPhase(1).setTarget(Host.WorldData.GetDataLocs("RED").get(0).clone().add(0, 2, 0)); + + if (getCurrentPhase().getCurrentText().ID() == 5) + getPhase(1).setTarget(_pigWaypointA.clone().add(0, 2, 0)); + } + + private void cowGirlUpdate(int tick) + { + if (getCurrentPhase().getCurrentText().ID() >= 4) + { + Location loc = _cowGirl.getLocation().add(UtilAlg.getTrajectory(_pigWaypointA, _cowGirl.getLocation()).multiply(5)); + + UtilEnt.CreatureMoveFast(_cowGirl, loc, 1.4f); + } } - public void update(UpdateEvent event) + private void cowBoyUpdate(int tick) { + if (getCurrentPhase().getCurrentText().ID() == 5) + { + Location loc = _cowBoy.getLocation().add(UtilAlg.getTrajectory(_cowBoy.getLocation(), _pigSpawn).multiply(5)); + + UtilEnt.CreatureMoveFast(_cowBoy, loc, 1f); + } + } + + private void pigUpdate(int tick) + { + //Pigs + if (getCurrentPhase().getCurrentText().ID() > 5) + { + //Spawn + if (_pigs.size() < 5 && tick % 20 == 0) + { + Host.CreatureAllowOverride = true; + + //Spawn + Pig pig = _pigSpawn.getWorld().spawn(_pigSpawn, Pig.class); + UtilEnt.Vegetate(pig); + + + //Item + Item item = pig.getWorld().dropItem(pig.getLocation(), new ItemStack(Material.CHEST)); + pig.setPassenger(item); + + _pigs.put(pig, 0);; + + Host.CreatureAllowOverride = false; + } + + //Move + for (Entry data : _pigs.entrySet()) + { + //Move + if (data.getValue().intValue() == 0) + { + if (UtilMath.offset(data.getKey().getLocation(), _pigWaypointA) > 1) + { + UtilEnt.CreatureMoveFast(data.getKey(), _pigWaypointA, 1.4f); + } + else + { + data.setValue(1); + } + } + if (data.getValue().intValue() == 1) + { + if (UtilMath.offset(data.getKey().getLocation(), _pigWaypointB) > 1) + { + UtilEnt.CreatureMoveFast(data.getKey(), _pigWaypointB, 1.2f); + } + else + { + data.setValue(2); + } + } + + //Oink + if (Math.random() > 0.98) + { + data.getKey().getWorld().playSound(data.getKey().getLocation(), Sound.PIG_IDLE, 1.5f, 1f); + } + } + } + } + + @Override + public void onStart() + { + //Pig Spawn + _pigSpawn = Host.WorldData.GetDataLocs("PINK").get(0); + + //Pig Waypoints + if (UtilMath.offset(_pigSpawn, Host.WorldData.GetDataLocs("ORANGE").get(0)) < + UtilMath.offset(_pigSpawn, Host.WorldData.GetDataLocs("ORANGE").get(1))) + { + _pigWaypointA = Host.WorldData.GetDataLocs("ORANGE").get(0); + _pigWaypointB = Host.WorldData.GetDataLocs("ORANGE").get(1); + } + else + { + _pigWaypointA = Host.WorldData.GetDataLocs("ORANGE").get(1); + _pigWaypointB = Host.WorldData.GetDataLocs("ORANGE").get(0); + } + + //Spawn Cows + Host.CreatureAllowOverride = true; + + _cowBoy = _pigSpawn.getWorld().spawn(Host.WorldData.GetDataLocs("BROWN").get(0), Cow.class); + _cowBoy.setCustomName(C.cGreenB + "Calvin"); + _cowBoy.setCustomNameVisible(true); + UtilEnt.Vegetate(_cowBoy); + + _cowGirl = _pigSpawn.getWorld().spawn(Host.WorldData.GetDataLocs("RED").get(0), MushroomCow.class); + _cowGirl.setCustomName(C.cRedB + "Moolanie"); + _cowGirl.setCustomNameVisible(true); + UtilEnt.Vegetate(_cowGirl); + + Host.CreatureAllowOverride = false; + + //Player Data + getPhase(1).setLocation(Host.WorldData.GetDataLocs("WHITE").get(0)); + getPhase(1).setTarget(_cowGirl.getLocation().add(0, 2, 0)); + } + + @Override + public void onEnd() + { + _cowBoy.remove(); + _cowGirl.remove(); + + for (Pig pig : _pigs.keySet()) + { + if (pig.getPassenger() != null) + pig.getPassenger().remove(); + + pig.remove(); + } + _pigs.clear(); + + for (Player player : getPlayers().keySet()) + { + Host.Manager.GetCondition().Factory().Blind("Tutorial End", player, player, 2, 0, false, false, false); + } + + UtilTextMiddle.display(C.cGreenB + "Calvin", "Get my things back from the pigs!", 0, 80, 20, UtilServer.getPlayers()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 57c4baad5..e94afdbe3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -62,7 +62,7 @@ public abstract class TutorialPhase /** * preparing Pitch/Yaw of the location */ - private void prepareLocations() + public void prepareLocations() { Vector vector = new Vector(_target.getBlockX() - _location.getBlockX(), _target.getBlockY() - _location.getBlockY(), _target.getBlockZ() - _location.getBlockZ()); float pitch = UtilAlg.GetPitch(vector); @@ -158,7 +158,7 @@ public abstract class TutorialPhase i++; } displayMessage(text); - UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); + UtilTextMiddle.display(text.getTitle(), text.getText(), 0, text.getStayTime(), 0, players); try { Thread.sleep(text.getStayTime() * 50); @@ -222,6 +222,11 @@ public abstract class TutorialPhase return _text; } + public TutorialText getCurrentText() + { + return _currentText; + } + public void setText(TutorialText[] text) { _text = text; @@ -240,11 +245,17 @@ public abstract class TutorialPhase public void setLocation(Location location) { _location = location; + + if (_location != null && _target != null) + prepareLocations(); } public void setTarget(Location target) { _target = target; + + if (_location != null && _target != null) + prepareLocations(); } public GameTutorial getTutorial()