Build Update

This commit is contained in:
Mini-Chiss 2015-05-03 14:50:50 -05:00
parent 11b36e6b44
commit 8224450b44
8 changed files with 222 additions and 40 deletions

View File

@ -259,8 +259,8 @@ public class UtilParticle
{ {
// Dont send to players who cannot see it! // Dont send to players who cannot see it!
if (!particleName.equals(ParticleType.FIREWORKS_SPARK.particleName) if (!particleName.equals(ParticleType.FIREWORKS_SPARK.particleName)
&& !particleName.equals(ParticleType.LARGE_EXPLODE.particleName) && !particleName.equals(ParticleType.LARGE_EXPLODE.particleName)
&& !particleName.equals(ParticleType.HUGE_EXPLOSION.particleName)) && !particleName.equals(ParticleType.HUGE_EXPLOSION.particleName))
{ {
if (UtilMath.offset(player.getLocation(), location) > 24) if (UtilMath.offset(player.getLocation(), location) > 24)
{ {

View File

@ -1,6 +1,9 @@
package nautilus.game.arcade.game.games.build; package nautilus.game.arcade.game.games.build;
import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -86,12 +89,16 @@ public class Build extends SoloGame
{ {
private NautHashMap<Player, BuildData> _data = new NautHashMap<Player, BuildData>(); private NautHashMap<Player, BuildData> _data = new NautHashMap<Player, BuildData>();
private ArrayList<Entry<Player,Double>> _scoreboardPlaces = new ArrayList<Entry<Player,Double>>();
private int _buildGameState = 0; private int _buildGameState = 0;
private long _buildStateTime = 0; private long _buildStateTime = 0;
private long _buildTime = 300000; private long _buildTime = 300000;
private long _voteTime = 12000; private long _voteTime = 12000;
private long _viewTime = 16000; private long _viewTime = 16000;
private BuildData _viewData = null; private BuildData _viewData = null;
private int _countdownTimerState = 0;
private String[] _words; private String[] _words;
@ -99,7 +106,22 @@ public class Build extends SoloGame
private OptionsShop _shop; private OptionsShop _shop;
private ItemStack _shopItem; private ItemStack _shopItem;
private String[] _hintText = new String[]
{
"Click Creatures to change their settings!",
"Set the Time/Weather in the Options Menu!",
"Vote based upon Effort, Creativity and Quality!",
"Create Particles in the Options Menu!",
"Vote fairly for other players! It's more fun!",
};
private int _hintIndex = 0;
private long _hintTimer = 0;
private ChatColor _hintColor = ChatColor.YELLOW;
private ChatColor _firstHintColor = ChatColor.YELLOW;
public Build(ArcadeManager manager) public Build(ArcadeManager manager)
{ {
super(manager, GameType.Build, super(manager, GameType.Build,
@ -113,7 +135,8 @@ public class Build extends SoloGame
new String[] new String[]
{ {
"Build the word!", "Be creative and build something",
"based on the build theme!"
}); });
this.StrictAntiHack = true; this.StrictAntiHack = true;
@ -137,7 +160,7 @@ public class Build extends SoloGame
_words = new String[] _words = new String[]
{ {
"Pirate Ship", "Mineshaft", "Archers Tower", "Dinner Table", "Pokemon" "Rollercoaster", "Archery Range", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House", "Snail", "Burger", "Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Squid", "Statue", "Cannon", "Catapult", "Sailing Boat", "Grim Reaper", "Star Wars", "Elephant", "Penguin", "Ninja", "Pot of Gold", "Shrek", "Fruit", "Breakfast", "Toaster", "Robot", "Camping", "Spaceship"
}; };
_shop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); _shop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation());
@ -179,6 +202,8 @@ public class Build extends SoloGame
_word = _words[UtilMath.r(_words.length)]; _word = _words[UtilMath.r(_words.length)];
UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + _word, 0, 80, 5); UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + _word, 0, 80, 5);
this.WorldTimeSet = -1;
} }
} }
@ -194,6 +219,62 @@ public class Build extends SoloGame
//Game //Game
if (_buildGameState == 0) if (_buildGameState == 0)
{ {
if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 60000))
{
UtilTextMiddle.display(null, C.cYellow + "4 Minutes Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 120000))
{
UtilTextMiddle.display(null, C.cYellow + "3 Minutes Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 180000))
{
UtilTextMiddle.display(null, C.cYellow + "2 Minutes Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 240000))
{
UtilTextMiddle.display(null, C.cYellow + "1 Minutes Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 270000))
{
UtilTextMiddle.display(null, C.cYellow + "30 Seconds Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 285000))
{
UtilTextMiddle.display(null, C.cYellow + "15 Seconds Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 295000))
{
UtilTextMiddle.display(null, C.cYellow + "5 Seconds Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 296000))
{
UtilTextMiddle.display(null, C.cYellow + "4 Seconds Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 297000))
{
UtilTextMiddle.display(null, C.cYellow + "3 Seconds Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 298000))
{
UtilTextMiddle.display(null, C.cYellow + "2 Seconds Remaining", 0, 60, 5);
_countdownTimerState++;
}
else if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 299000))
{
UtilTextMiddle.display(null, C.cYellow + "1 Seconds Remaining", 0, 60, 5);
_countdownTimerState++;
}
if (System.currentTimeMillis() - GetStateTime() > _buildTime) if (System.currentTimeMillis() - GetStateTime() > _buildTime)
{ {
_buildGameState++; _buildGameState++;
@ -202,10 +283,13 @@ public class Build extends SoloGame
//Flags //Flags
this.BlockBreak = false; this.BlockBreak = false;
this.BlockPlace = false; this.BlockPlace = false;
this.ItemDrop = false;
this.ItemPickup = false;
this.InventoryClick = false; this.InventoryClick = false;
UtilTextMiddle.display(null, C.cYellow + "Time Up!", 0, 60, 5); UtilTextMiddle.display(null, C.cYellow + "TIME IS UP!", 0, 60, 5);
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
player.getInventory().clear(8); player.getInventory().clear(8);
@ -224,8 +308,8 @@ public class Build extends SoloGame
else if (_buildGameState == 2) else if (_buildGameState == 2)
{ {
//End Vote Time //End Vote Time
if (_viewData != null && (UtilTime.elapsed(_buildStateTime, _voteTime) || if (_viewData != null && (UtilTime.elapsed(_buildStateTime, _voteTime)))
_viewData.Score.size() == GetPlayers(true).size() - 1)) //All votes cast //_viewData.Score.size() == GetPlayers(true).size() - 1)) //All votes cast
{ {
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
UtilInv.Clear(player); UtilInv.Clear(player);
@ -295,7 +379,7 @@ public class Build extends SoloGame
} }
//Text //Text
UtilTextMiddle.display(null, C.cYellow + "Cast Your Vote!", 0, 60, 5); UtilTextMiddle.display(null, C.cGreen + "Right-Click" + C.cYellow + " to Vote!", 0, 60, 5);
_buildStateTime = System.currentTimeMillis(); _buildStateTime = System.currentTimeMillis();
} }
@ -348,8 +432,12 @@ public class Build extends SoloGame
//Only count if they got above TERRIBLE score //Only count if they got above TERRIBLE score
if (BuildQuality.getQuality(bestScore) != BuildQuality.Failure) if (BuildQuality.getQuality(bestScore) != BuildQuality.Failure)
places.add(bestPlayer); places.add(bestPlayer);
_scoreboardPlaces.add(new AbstractMap.SimpleEntry<Player, Double>(bestPlayer, bestScore));
} }
writeScoreboard();
//Announce //Announce
AnnounceEnd(places); AnnounceEnd(places);
@ -882,6 +970,11 @@ public class Build extends SoloGame
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
return; return;
writeScoreboard();
}
public void writeScoreboard()
{
//Wipe Last //Wipe Last
Scoreboard.Reset(); Scoreboard.Reset();
@ -902,22 +995,27 @@ public class Build extends SoloGame
Scoreboard.Write(C.cYellow + C.Bold + "Vote Time"); Scoreboard.Write(C.cYellow + C.Bold + "Vote Time");
Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _voteTime - (System.currentTimeMillis() - _buildStateTime)), 1)); Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _voteTime - (System.currentTimeMillis() - _buildStateTime)), 1));
if (_viewData != null) // if (_viewData != null)
// {
// Scoreboard.WriteBlank();
// Scoreboard.Write(C.cYellow + C.Bold + "Votes " + ChatColor.RESET + _viewData.Score.size() + " / " + (GetPlayers(true).size()-1));
// Scoreboard.Write(C.cYellow + C.Bold + "Avg " + ChatColor.RESET + UtilMath.trim(2, _viewData.getScore()) + "");
// Scoreboard.Write(C.cYellow + C.Bold + "Rating " + ChatColor.RESET + BuildQuality.getQuality(_viewData.getScore()) + "");
// Scoreboard.WriteBlank();
//
// for (Player player : _viewData.Score.keySet())
// {
// Scoreboard.Write("+" + _viewData.Score.get(player) + " " + player.getName());
// }
// }
}
else if (_buildGameState == 4)
{
for (Entry<Player, Double> score : _scoreboardPlaces)
{ {
Scoreboard.WriteBlank(); int percent = (int)(score.getValue() * 20);
Scoreboard.Write(C.cYellow + C.Bold + "Debug Voted");
Scoreboard.Write(_viewData.Score.size() + " / " + (GetPlayers(true).size()-1));
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Debug Avg");
Scoreboard.Write(UtilMath.trim(2, _viewData.getScore()) + "");
Scoreboard.WriteBlank(); Scoreboard.Write(BuildQuality.getQuality(score.getValue()).getColor() + percent + "% " + ChatColor.RESET + score.getKey().getName());
Scoreboard.Write(C.cYellow + C.Bold + "Debug Rating");
Scoreboard.Write(BuildQuality.getQuality(_viewData.getScore()) + "");
} }
} }
@ -1033,13 +1131,13 @@ public class Build extends SoloGame
return; return;
if (_viewData != null) if (_viewData != null)
{ {
_viewData.playWeather(true); _viewData.playWeather(true);
} }
else else
{ {
for (BuildData data : _data.values()) for (BuildData data : _data.values())
{ {
data.playWeather(false); data.playWeather(false);
} }
} }
@ -1062,18 +1160,51 @@ public class Build extends SoloGame
} }
@EventHandler @EventHandler
public void showOpenInventory(UpdateEvent event) public void showHints(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SEC) return; if (!IsLive())
return;
if (_buildGameState != 0)
return;
if (event.getType() != UpdateType.FAST)
return;
//Hints
if (UtilTime.elapsed(_hintTimer, 8000))
{
if (_hintColor == ChatColor.AQUA)
_hintColor = ChatColor.GREEN;
else
_hintColor = ChatColor.AQUA;
_hintIndex = (_hintIndex + 1)%_hintText.length;
_hintTimer = System.currentTimeMillis();
}
boolean showHint = !UtilTime.elapsed(_hintTimer, 1100);
//Initial
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
BuildData buildData = _data.get(player); BuildData buildData = _data.get(player);
if (buildData != null && !buildData.ClickedInventory) if (buildData != null && !buildData.ClickedInventory)
{ {
UtilTextBottom.display(C.cYellow + "Open Inventory to get Blocks!", player); UtilTextBottom.display(_firstHintColor + "Open Inventory to get Blocks!", player);
}
else if (showHint)
{
UtilTextBottom.display(_hintColor + _hintText[_hintIndex], player);
} }
} }
//Initial Flash
if (_firstHintColor == ChatColor.YELLOW)
_firstHintColor = ChatColor.GREEN;
else
_firstHintColor = ChatColor.YELLOW;
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)

View File

@ -259,14 +259,14 @@ public class BuildData
} }
else else
{ {
Player.setPlayerWeather(type); playWeather(Player, type);
} }
} }
public void playWeather(Player player, org.bukkit.WeatherType type) public void playWeather(Player player, org.bukkit.WeatherType type)
{ {
player.setPlayerWeather(type); player.setPlayerWeather(type);
player.setPlayerTime(Time, false); player.setPlayerTime(Time, false);
if (Weather == WeatherType.STORMING) if (Weather == WeatherType.STORMING)
{ {

View File

@ -1,5 +1,7 @@
package nautilus.game.arcade.game.games.build; package nautilus.game.arcade.game.games.build;
import org.bukkit.ChatColor;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
public enum BuildQuality public enum BuildQuality
@ -7,7 +9,7 @@ public enum BuildQuality
NoVotes(C.cGray + "No Votes"), NoVotes(C.cGray + "No Votes"),
Mindblowing(C.cAqua + "Mindblowing"), Mindblowing(C.cAqua + "Mindblowing"),
Amazing(C.cGreen + "Amazing"), Awesome(C.cGreen + "Awesome"),
Good(C.cYellow + "Good"), Good(C.cYellow + "Good"),
Satisfactory(C.cGold + "Satisfactory"), Satisfactory(C.cGold + "Satisfactory"),
Failure(C.cRed + "FAILURE"); Failure(C.cRed + "FAILURE");
@ -30,7 +32,12 @@ public enum BuildQuality
if (avgScore <= 1) return Failure; if (avgScore <= 1) return Failure;
if (avgScore <= 2) return Satisfactory; if (avgScore <= 2) return Satisfactory;
if (avgScore <= 3) return Good; if (avgScore <= 3) return Good;
if (avgScore <= 4) return Amazing; if (avgScore <= 4) return Awesome;
return Mindblowing; return Mindblowing;
} }
public String getColor()
{
return ChatColor.getLastColors(_text);
}
} }

View File

@ -45,7 +45,7 @@ public class TimePage extends ShopPageBase<ArcadeManager, OptionsShop>
if (time == 0) time = 12; if (time == 0) time = 12;
byte data = (byte) (buildData.Time == ticks ? 5 : 14); byte data = (byte) (buildData.Time == ticks ? 5 : 14);
ShopItem item = new ShopItem(Material.STAINED_CLAY, data, time + (am ? " am" : " pm"), null, 0, false, false); ShopItem item = new ShopItem(Material.STAINED_CLAY, data, time + (am ? "am" : "pm"), null, 0, false, false);
addButton(i, item, new IButton() addButton(i, item, new IButton()
{ {
@Override @Override

View File

@ -138,6 +138,44 @@ public class Gravity extends SoloGame
Announce(C.Bold + C.cPurple + "Press " + C.Bold + C.cWhite + "DROP WEAPON" + C.Bold + C.cPurple + " to boost yourself off platforms!"); Announce(C.Bold + C.cPurple + "Press " + C.Bold + C.cWhite + "DROP WEAPON" + C.Bold + C.cPurple + " to boost yourself off platforms!");
} }
@EventHandler
public void cleanObjects(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
//Objects
Iterator<GravityObject> oIter = _objects.iterator();
while (oIter.hasNext())
{
GravityObject o = oIter.next();
if (o instanceof GravityPlayer)
continue;
if (!isInsideMap(o.Base.getLocation()))
{
o.Base.remove();
oIter.remove();
}
}
//Projectiles
Iterator<Arrow> arrowIter = _arrows.keySet().iterator();
while (arrowIter.hasNext())
{
Arrow arrow = arrowIter.next();
if (!isInsideMap(arrow.getLocation()))
{
arrow.remove();
arrowIter.remove();
}
}
}
@EventHandler @EventHandler
public void ClearObjects(GameStateChangeEvent event) public void ClearObjects(GameStateChangeEvent event)
{ {
@ -153,11 +191,14 @@ public class Gravity extends SoloGame
@EventHandler @EventHandler
public void KickOff(PlayerDropItemEvent event) public void KickOff(PlayerDropItemEvent event)
{ {
event.setCancelled(true);
if (!IsLive())
return;
for (GravityObject object : _objects) for (GravityObject object : _objects)
if (object instanceof GravityPlayer) if (object instanceof GravityPlayer)
((GravityPlayer)object).KickOff(event.getPlayer()); ((GravityPlayer)object).KickOff(event.getPlayer());
event.setCancelled(true);
} }
@EventHandler @EventHandler

View File

@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseBat;
import nautilus.game.arcade.game.games.gravity.objects.*; import nautilus.game.arcade.game.games.gravity.objects.*;
import org.bukkit.Effect;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,7 +32,7 @@ public abstract class GravityObject
public GravityObject(Gravity host, Entity ent, double mass, double size, Vector vel) public GravityObject(Gravity host, Entity ent, double mass, double size, Vector vel)
{ {
Host = host; Host = host;
Ent = ent; Ent = ent;
Mass = mass; Mass = mass;
@ -57,6 +58,7 @@ public abstract class GravityObject
UtilEnt.Vegetate(Base, true); UtilEnt.Vegetate(Base, true);
//UtilEnt.ghost(Base, true, true); //UtilEnt.ghost(Base, true, true);
Host.Manager.GetCondition().Factory().Invisible(null, Base, null, 9999, 1, false, false, false);
} }
public boolean IsPlayer() public boolean IsPlayer()
@ -86,7 +88,8 @@ public abstract class GravityObject
{ {
if (this instanceof GravityPlayer) if (this instanceof GravityPlayer)
{ {
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, Ent.getLocation().subtract(0, 0.5, 0), 0, 0, 0, 0, 1); Base.getWorld().playEffect(Ent.getLocation().subtract(0, 0.5, 0), Effect.FIREWORKS_SPARK, 0, 100);
//UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, Ent.getLocation().subtract(0, 0.5, 0), 0, 0, 0, 0, 1);
} }
else if (this instanceof GravityBomb) else if (this instanceof GravityBomb)
{ {

View File

@ -39,7 +39,7 @@ public class GravityPlayer extends GravityObject
} }
public boolean NearBlock() public boolean NearBlock()
{ {
return !NearBlockList().isEmpty(); return !NearBlockList().isEmpty();
} }
@ -76,7 +76,7 @@ public class GravityPlayer extends GravityObject
public void AutoGrab() public void AutoGrab()
{ {
UtilPlayer.message(this.Ent, "Bat: " + Base.getLocation().getY()); //UtilPlayer.message(this.Ent, "Bat: " + Base.getLocation().getY());
if (Vel.length() == 0) if (Vel.length() == 0)
return; return;
@ -88,7 +88,7 @@ public class GravityPlayer extends GravityObject
return; return;
Vel.multiply(0); Vel.multiply(0);
Base.setVelocity(new Vector(0,0,0)); Base.setVelocity(new Vector(0,0.1,0));
GrabDelay = System.currentTimeMillis(); GrabDelay = System.currentTimeMillis();