Fix spawn facing, separate scoreboard functions

This commit is contained in:
Thanos Paravantis 2016-06-22 21:47:39 +03:00
parent cac0169827
commit 4e9ea23db8
2 changed files with 147 additions and 87 deletions

View File

@ -59,7 +59,6 @@ import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
@ -76,6 +75,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeData;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeList;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeSettings;
import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge;
@ -214,6 +214,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
DeathTeleport = false;
AutomaticRespawn = false;
DeathMessages = false;
FixSpawnFacing = false;
TeleportsDisqualify = false;
GiveClock = false;
@ -426,9 +427,14 @@ public class BawkBawkBattles extends TeamGame implements IThrown
{
ArrayList<Location> selected = _challenge.createSpawns();
for (Location spawn : selected)
{
spawn.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory2d(spawn, _challenge.getCenter())));
}
_challenge.getData().setSpawns(selected);
_playerTeam.SetSpawns(selected);
SpectatorSpawn = UtilWorld.averageLocation(selected).add(0, 7, 0);
SpectatorSpawn = _challenge.getCenter().add(0, 7, 0);
return selected;
}
@ -453,13 +459,17 @@ public class BawkBawkBattles extends TeamGame implements IThrown
}
}
/*
* Spawns
*/
private void teleportSpectatorsToSpawn()
{
for (Player player : GetPlayers(false))
{
if (!IsAlive(player))
{
player.teleport(SpectatorSpawn);
player.teleport(GetSpectatorLocation());
}
}
}
@ -606,7 +616,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (!IsLive())
return;
if (_challenge == null) // Triggered after the first challenge ends.
if (_challenge == null) // When challenge is null, a new one should start.
{
if (!UtilTime.elapsed(_delay, 1500))
{
@ -634,7 +644,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_delay = System.currentTimeMillis();
_settings.setWaiting(true);
}
else if (_settings.isWaiting()) // Triggered when a challenge should start.
else if (_settings.isWaiting()) // If challenge is waiting, show description.
{
if (!UtilTime.elapsed(_delay, 1000))
{
@ -643,7 +653,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
displayDescriptionAndStartChallenge();
}
else // Triggered when a challenge should end.
else // Otherwise, check if the challenge is ended.
{
checkChallengeEnd();
}
@ -1466,6 +1476,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
}
}
/*
* Scoreboard
*/
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
@ -1477,94 +1491,139 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (getPlayersWithRemainingLives() > 14)
{
int alive = getPlayersWithRemainingLives();
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Players");
Scoreboard.Write(alive + " ");
boolean check = _challenge != null && _settings.isChallengeStarted();
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGreen + C.Bold + "Alive");
if (check)
Scoreboard.Write("" + _challenge.getPlayersIn(false).size());
else
Scoreboard.Write("-");
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGold + C.Bold + "Completed");
if (check)
Scoreboard.Write("" + _challenge.getData().getCompletedPlayers().size());
else
Scoreboard.Write("-");
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGray + C.Bold + "Dead");
if (check)
Scoreboard.Write("" + _challenge.getData().getLostPlayers().size());
else
Scoreboard.Write("-");
displayGenericScoreboard();
}
else
{
Scoreboard.WriteBlank();
for (Player player : super.GetPlayers(true))
{
int currentLives = lives(player);
String status;
String currentlyOut = "";
if (_challenge != null)
{
if (_challenge.getData().isLost(player))
{
currentlyOut = C.cDRed + "X ";
}
else if (_challenge.getData().isCompleted(player))
{
currentlyOut = C.cGreen + "";
}
}
switch (currentLives)
{
case 5:
status = currentlyOut + C.cGreen + player.getName();
break;
case 4:
status = currentlyOut + C.cYellow + player.getName();
break;
case 3:
status = currentlyOut + C.cGold + player.getName();
break;
case 2:
status = currentlyOut + C.cRed + player.getName();
break;
case 1:
status = currentlyOut + C.cRed + player.getName();
break;
default:
status = C.cGray + C.Strike + player.getName();
break;
}
Scoreboard.WriteOrdered("Lives Left", status, currentLives, true);
}
displayDetailedScoreboard();
}
Scoreboard.Draw();
}
private void displayGenericScoreboard()
{
displayPlayerTotal();
displayAlivePlayers();
displayCompletedPlayers();
displayDeadPlayers();
}
private void displayPlayerTotal()
{
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Players");
Scoreboard.Write(getPlayersWithRemainingLives() + " ");
}
private void displayAlivePlayers()
{
int data = _challenge.getPlayersIn(false).size();
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGreen + C.Bold + "Alive");
if (_settings.isChallengeStarted())
{
Scoreboard.Write("" + data);
}
else
{
Scoreboard.Write("-");
}
}
private void displayCompletedPlayers()
{
int data = _challenge.getData().getCompletedPlayers().size();
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGold + C.Bold + "Completed");
if (_settings.isChallengeStarted())
{
Scoreboard.Write("" + data);
}
else
{
Scoreboard.Write("-");
}
}
private void displayDeadPlayers()
{
int data = _challenge.getData().getLostPlayers().size();
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGray + C.Bold + "Dead");
if (_settings.isChallengeStarted())
{
Scoreboard.Write("" + data);
}
else
{
Scoreboard.Write("-");
}
}
private void displayDetailedScoreboard()
{
Scoreboard.WriteBlank();
for (Player player : super.GetPlayers(true)) // Use super.GetPlayers(true) to show players during chicken attack.
{
displayPersonalScore(player);
}
}
private void displayPersonalScore(Player player)
{
int lives = lives(player);
String state = definePlayerState(player);
String display = definePlayerDisplay(player.getName(), lives, state);
Scoreboard.WriteOrdered("Lives Left", display, lives, true);
}
private String definePlayerDisplay(String name, int lives, String state)
{
switch (lives)
{
case 5:
return state + C.cGreen + name;
case 4:
return state + C.cYellow + name;
case 3:
return state + C.cGold + name;
case 2:
return state + C.cRed + name;
case 1:
return state + C.cRed + name;
default:
return C.cGray + C.Strike + name;
}
}
private String definePlayerState(Player player)
{
if (_settings.isChallengeStarted())
{
ChallengeData data = _challenge.getData();
if (data.isLost(player))
{
return C.cDRed + "X ";
}
else if (data.isCompleted(player))
{
return C.cGreen + "";
}
}
return "";
}
/*
* Helper methods
*/
@ -1573,7 +1632,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
public boolean isInsideMap(Player player)
{
if (_challenge != null && !_settings.isWaiting())
{
return _challenge.isInsideMap(player);
}
return true;
}

View File

@ -76,7 +76,6 @@ public abstract class TeamChallenge extends Challenge
for (Location spawn : randomSpawns)
{
spawn = Host.getPlayerTeam().fixFacing(spawn);
Block block = spawn.getBlock().getRelative(BlockFace.DOWN);
if (block.getData() == _firstTeamSpawnBlockData && firstTeamIndex < firstTeam.size())