more valentines :)

This commit is contained in:
Cheese 2016-02-07 13:27:53 +11:00
parent 690c2acce8
commit a35a9ea31f
5 changed files with 252 additions and 43 deletions

View File

@ -6,49 +6,59 @@ public enum ValItem
{ {
FLOWER1("Red Rose", FLOWER1("Red Rose",
"She will love this bouquet of roses!", "She will love this bouquet of roses!",
Material.RED_ROSE), Material.RED_ROSE, 0),
FLOWER2("Dandelion", FLOWER2("Dandelion",
"Oh my, these flowers smell great!", "I hope she's not allergic to these!",
Material.YELLOW_FLOWER), Material.YELLOW_FLOWER, 0),
FLOWER3("Other Flower", FLOWER3("Blue Orchid",
"MOO", "Thank you! These are her favourites!",
Material.REDSTONE), Material.RED_ROSE, 1),
WINE("Red Wine", WINE("Blue Wine",
"This will go great with our dinner!", "This will go great with our steak dinner!",
Material.POTION), Material.POTION, 0),
GRASS("Organic Grass", GRASS("Organic Free Range Grass",
"Only the best for my date!", "Yum! This is much tastier than caged grass!",
Material.LONG_GRASS), Material.LONG_GRASS, 1),
DIAMONDS("Diamond Earings", DIAMONDS("Diamond Earings",
"An expensive, but worthwhile gift!", "I saved up for months for this gift!",
Material.DIAMOND), Material.DIAMOND, 0),
EMERALDS("Emerald Necklace", EMERALDS("Cold Hard Cash",
"Such necklace, many wow!", "They say love don't cost a thing. That's a lie!",
Material.EMERALD), Material.EMERALD, 0),
BOOK("Book of Poetry", BOOK("Love Poems",
"I will use impress her with poetry!", "I will use impress her with poetry!",
Material.BOOK), Material.BOOK, 0),
WATCH("Fancy Pocket Watch", WATCH("Fancy Pocket Watch",
"This sure looks good on me!", "This Moolex Watch sure looks good on me!",
Material.WATCH); 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 _title;
private String _endText; private String _endText;
private Material _item; private Material _item;
private byte _itemByte;
ValItem(String title, String endText, Material item) ValItem(String title, String endText, Material item, int data)
{ {
_title = title; _title = title;
_item = item; _item = item;
_endText = endText; _endText = endText;
_itemByte = (byte)data;
} }
public String getTitle() public String getTitle()

View File

@ -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.gladiators.tutorial.TutorialGladiators;
import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove; import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove;
import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines; import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines;
import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
public class Valentines extends SoloGame public class Valentines extends SoloGame
@ -119,7 +120,7 @@ public class Valentines extends SoloGame
this.HungerSet = 20; this.HungerSet = 20;
this.HealthSet = 20; this.HealthSet = 20;
EnableTutorials = false; EnableTutorials = true;
try try
@ -178,14 +179,7 @@ public class Valentines extends SoloGame
{ {
GetTeamList().get(0).setTutorial(new TutorialValentines(this, Manager)); 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 @EventHandler
public void knockback(CustomDamageEvent event) public void knockback(CustomDamageEvent event)
{ {
@ -675,10 +669,10 @@ public class Valentines extends SoloGame
//Announce //Announce
if (_pigs.size() > 1) 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 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)) for (Player player : GetPlayers(true))
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1, "Pig Saddle")); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1, "Pig Saddle"));

View File

@ -14,10 +14,15 @@ public class TutorialPhaseValentines extends TutorialPhase
super(new TutorialText[] super(new TutorialText[]
{ {
new TutorialText(C.cRed + "Moolanie", "Calvin! Did you forget Valentines Day again?!", 1, Sound.COW_IDLE), 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.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.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", "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),
}); });
} }

View File

@ -1,13 +1,26 @@
package nautilus.game.arcade.game.games.valentines.tutorial; 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.Cow;
import org.bukkit.entity.Item;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.Pig; 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.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.game.games.valentines.Valentines;
import nautilus.game.arcade.gametutorial.GameTutorial; import nautilus.game.arcade.gametutorial.GameTutorial;
import nautilus.game.arcade.gametutorial.TutorialPhase; import nautilus.game.arcade.gametutorial.TutorialPhase;
@ -15,20 +28,196 @@ import nautilus.game.arcade.gametutorial.TutorialPhase;
public class TutorialValentines extends GameTutorial public class TutorialValentines extends GameTutorial
{ {
private Valentines Host; private Valentines Host;
private Cow _cowBoy; private Cow _cowBoy;
private Cow _cowGirl; private Cow _cowGirl;
private ArrayList<Pig> _pigs = new ArrayList<Pig>(); private HashMap<Pig, Integer> _pigs = new HashMap<Pig, Integer>();
private Location _pigSpawn;
private Location _pigWaypointA;
private Location _pigWaypointB;
public TutorialValentines(Valentines valentines, ArcadeManager manager) public TutorialValentines(Valentines valentines, ArcadeManager manager)
{ {
super(manager, new TutorialPhase[]{new TutorialPhaseValentines()}); super(manager, new TutorialPhase[]{new TutorialPhaseValentines()});
Host = valentines; 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<Pig,Integer> 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());
} }
} }

View File

@ -62,7 +62,7 @@ public abstract class TutorialPhase
/** /**
* preparing Pitch/Yaw of the location * 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()); Vector vector = new Vector(_target.getBlockX() - _location.getBlockX(), _target.getBlockY() - _location.getBlockY(), _target.getBlockZ() - _location.getBlockZ());
float pitch = UtilAlg.GetPitch(vector); float pitch = UtilAlg.GetPitch(vector);
@ -158,7 +158,7 @@ public abstract class TutorialPhase
i++; i++;
} }
displayMessage(text); displayMessage(text);
UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); UtilTextMiddle.display(text.getTitle(), text.getText(), 0, text.getStayTime(), 0, players);
try try
{ {
Thread.sleep(text.getStayTime() * 50); Thread.sleep(text.getStayTime() * 50);
@ -222,6 +222,11 @@ public abstract class TutorialPhase
return _text; return _text;
} }
public TutorialText getCurrentText()
{
return _currentText;
}
public void setText(TutorialText[] text) public void setText(TutorialText[] text)
{ {
_text = text; _text = text;
@ -240,11 +245,17 @@ public abstract class TutorialPhase
public void setLocation(Location location) public void setLocation(Location location)
{ {
_location = location; _location = location;
if (_location != null && _target != null)
prepareLocations();
} }
public void setTarget(Location target) public void setTarget(Location target)
{ {
_target = target; _target = target;
if (_location != null && _target != null)
prepareLocations();
} }
public GameTutorial getTutorial() public GameTutorial getTutorial()