Capture point fix
This commit is contained in:
parent
8f01015df9
commit
3210843395
@ -1,11 +1,18 @@
|
|||||||
package nautilus.game.arcade.game.games.moba;
|
package nautilus.game.arcade.game.games.moba;
|
||||||
|
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
import nautilus.game.arcade.game.TeamGame;
|
import nautilus.game.arcade.game.TeamGame;
|
||||||
import nautilus.game.arcade.game.games.moba.kit.KitPlayer;
|
import nautilus.game.arcade.game.games.moba.kit.KitPlayer;
|
||||||
|
import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint;
|
||||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||||
import nautilus.game.arcade.kit.Kit;
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class Moba extends TeamGame
|
public class Moba extends TeamGame
|
||||||
{
|
{
|
||||||
@ -14,12 +21,16 @@ public class Moba extends TeamGame
|
|||||||
"MORE CAPTURE POINTS"
|
"MORE CAPTURE POINTS"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final List<CapturePoint> _capturePoints = new ArrayList<>(3);
|
||||||
|
|
||||||
public Moba(ArcadeManager manager)
|
public Moba(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION);
|
super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION);
|
||||||
|
|
||||||
|
DeathOut = false;
|
||||||
DeathSpectateSecs = 8;
|
DeathSpectateSecs = 8;
|
||||||
HungerSet = 20;
|
HungerSet = 20;
|
||||||
|
DontAllowOverfill = false;
|
||||||
|
|
||||||
new CompassModule()
|
new CompassModule()
|
||||||
.setGiveCompass(true)
|
.setGiveCompass(true)
|
||||||
@ -30,7 +41,83 @@ public class Moba extends TeamGame
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ParseData()
|
public void ParseData()
|
||||||
|
{
|
||||||
|
Collection<Location> capturePoints = getLocationStartsWith("POINT").values();
|
||||||
|
|
||||||
|
for (Location location : capturePoints)
|
||||||
|
{
|
||||||
|
_capturePoints.add(new CapturePoint(this, location));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@EventHandler
|
||||||
|
public void ScoreboardUpdate(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameState state = GetState();
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case Prepare:
|
||||||
|
writePrepare();
|
||||||
|
break;
|
||||||
|
case Live:
|
||||||
|
writeLive();
|
||||||
|
break;
|
||||||
|
case End:
|
||||||
|
writeEnd();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Scoreboard.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writePrepare()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writeLive()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeEnd()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void update(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SEC)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (CapturePoint point : _capturePoints)
|
||||||
|
{
|
||||||
|
point.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Location> getLocationStartsWith(String s)
|
||||||
|
{
|
||||||
|
Map<String, Location> map = new HashMap<>();
|
||||||
|
|
||||||
|
for (String key : WorldData.GetAllCustomLocs().keySet())
|
||||||
|
{
|
||||||
|
if (key.startsWith(s))
|
||||||
|
{
|
||||||
|
map.put(key, WorldData.GetCustomLocs(key).get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package nautilus.game.arcade.game.games.moba.kit;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
import nautilus.game.arcade.game.games.moba.Moba;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class KitSelection implements Listener
|
||||||
|
{
|
||||||
|
|
||||||
|
private final
|
||||||
|
|
||||||
|
public KitSelection(Moba moba)
|
||||||
|
{
|
||||||
|
UtilServer.RegisterEvents(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void live(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Live)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilServer.Unregister(this);
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,10 @@
|
|||||||
package nautilus.game.arcade.game.games.moba.structure.point;
|
package nautilus.game.arcade.game.games.moba.structure.point;
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.*;
|
||||||
import mineplex.core.common.util.UtilMath;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import nautilus.game.arcade.game.GameTeam;
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
import nautilus.game.arcade.game.games.moba.Moba;
|
import nautilus.game.arcade.game.games.moba.Moba;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.FireworkEffect.Type;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -66,7 +61,7 @@ public class CapturePoint
|
|||||||
_captureDist = highestDist * (double) MAX_RADIUS;
|
_captureDist = highestDist * (double) MAX_RADIUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean update()
|
public void update()
|
||||||
{
|
{
|
||||||
// Store the number of players in a team in this map
|
// Store the number of players in a team in this map
|
||||||
Map<GameTeam, Integer> playersOnPoint = new HashMap<>();
|
Map<GameTeam, Integer> playersOnPoint = new HashMap<>();
|
||||||
@ -112,7 +107,7 @@ public class CapturePoint
|
|||||||
// This means there are 2 teams on the point
|
// This means there are 2 teams on the point
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,17 +115,16 @@ public class CapturePoint
|
|||||||
// No one at all is on the point
|
// No one at all is on the point
|
||||||
if (highest == null)
|
if (highest == null)
|
||||||
{
|
{
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it has just reached the maximum progress, set the owner.
|
// If it has just reached the maximum progress, set the owner.
|
||||||
if (_owner != null && _owner.equals(highest) && _progress == MAX_PROGRESS)
|
if (_owner != null && _owner.equals(highest) && _progress >= MAX_PROGRESS)
|
||||||
{
|
{
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
capture(highest);
|
capture(highest);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void capture(GameTeam team)
|
private void capture(GameTeam team)
|
||||||
@ -144,15 +138,15 @@ public class CapturePoint
|
|||||||
// If it is the same team
|
// If it is the same team
|
||||||
if (_side.equals(team))
|
if (_side.equals(team))
|
||||||
{
|
{
|
||||||
// Captured
|
|
||||||
if (_progress == MAX_PROGRESS)
|
|
||||||
{
|
|
||||||
setOwner(team);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase progress
|
// Increase progress
|
||||||
_progress++;
|
_progress++;
|
||||||
display(team, true);
|
display(team, true);
|
||||||
|
|
||||||
|
// Captured
|
||||||
|
if (_progress >= MAX_PROGRESS)
|
||||||
|
{
|
||||||
|
setOwner(team);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Other team
|
// Other team
|
||||||
else
|
else
|
||||||
@ -160,6 +154,7 @@ public class CapturePoint
|
|||||||
// Point back to a neutral state
|
// Point back to a neutral state
|
||||||
if (_progress == 0)
|
if (_progress == 0)
|
||||||
{
|
{
|
||||||
|
setBeaconColour(null);
|
||||||
_side = team;
|
_side = team;
|
||||||
// Recursively call this method now that the first (same team) condition will be true
|
// Recursively call this method now that the first (same team) condition will be true
|
||||||
capture(team);
|
capture(team);
|
||||||
@ -175,6 +170,9 @@ public class CapturePoint
|
|||||||
{
|
{
|
||||||
_owner = team;
|
_owner = team;
|
||||||
|
|
||||||
|
setBeaconColour(team);
|
||||||
|
UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false);
|
||||||
|
|
||||||
UtilServer.CallEvent(new CapturePointCaptureEvent(this));
|
UtilServer.CallEvent(new CapturePointCaptureEvent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +180,7 @@ public class CapturePoint
|
|||||||
{
|
{
|
||||||
Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward);
|
Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward);
|
||||||
|
|
||||||
double toChange = Math.ceil(_wool.size() / MAX_PROGRESS);
|
double toChange = Math.ceil(_wool.size() / MAX_PROGRESS) + 1;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
for (Block block : _wool)
|
for (Block block : _wool)
|
||||||
{
|
{
|
||||||
@ -203,6 +201,7 @@ public class CapturePoint
|
|||||||
block.setData(team.GetColorData());
|
block.setData(team.GetColorData());
|
||||||
glass.setData(team.GetColorData());
|
glass.setData(team.GetColorData());
|
||||||
changed++;
|
changed++;
|
||||||
|
_changed.add(block);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -214,8 +213,18 @@ public class CapturePoint
|
|||||||
block.setData((byte) 0);
|
block.setData((byte) 0);
|
||||||
glass.setData((byte) 0);
|
glass.setData((byte) 0);
|
||||||
changed++;
|
changed++;
|
||||||
|
_changed.remove(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
glass.getWorld().playEffect(glass.getLocation().add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), team.GetColorData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setBeaconColour(GameTeam team)
|
||||||
|
{
|
||||||
|
byte colour = team == null ? 0 : team.GetColorData();
|
||||||
|
|
||||||
|
_center.getBlock().getRelative(BlockFace.DOWN).setData(colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameTeam getOwner()
|
public GameTeam getOwner()
|
||||||
|
Loading…
Reference in New Issue
Block a user