diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index b5241e7b7..f1db74bae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -41,8 +41,7 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; -import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; -import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; +import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; @@ -81,6 +80,7 @@ public class Moba extends TeamGame protected final MobaShop _shop; protected final GoldManager _goldManager; protected final BossManager _boss; + protected final OvertimeManager _overtimeManager; protected final BuffManager _buffs; protected final ArrowKBManager _arrowKb; protected final TowerManager _tower; @@ -116,6 +116,7 @@ public class Moba extends TeamGame _shop = registerManager(new MobaShop(this)); _goldManager = registerManager(new GoldManager(this)); _boss = registerManager(new BossManager(this)); + _overtimeManager = registerManager(new OvertimeManager(this)); _buffs = registerManager(new BuffManager()); _arrowKb = registerManager(new ArrowKBManager(this)); _minion = registerManager(new MinionManager(this)); @@ -496,6 +497,11 @@ public class Moba extends TeamGame return _goldManager; } + public OvertimeManager getOvertimeManager() + { + return _overtimeManager; + } + public BuffManager getBuffManager() { return _buffs; @@ -520,4 +526,9 @@ public class Moba extends TeamGame { return _arrowKb; } + + public MinionManager getMinionManager() + { + return _minion; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 5b89b9884..1ad97af9e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -23,11 +23,11 @@ public class MobaAI private final float _speedHome; private final Polygon2D _boundaries; - private LivingEntity _entity; + protected LivingEntity _entity; private LivingEntity _target; private Location _home; - private MobaAIMethod _aiMethod; + protected MobaAIMethod _aiMethod; public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 8d80c7f5e..d8595853a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -46,6 +46,7 @@ public class WitherBoss extends MobaBoss private final GameTeam _team; private MobaAI _ai; + private MobaAI _aiOvertime; private DisguiseWither _disguise; private boolean _damageable; private long _lastInform; @@ -70,6 +71,7 @@ public class WitherBoss extends MobaBoss stand.setHealth(INITIAL_HEALTH * 0.1); stand.setGravity(false); + MobaUtil.setTeamEntity(stand, _team); UtilEnt.setBoundingBox(stand, 3, 5); _disguise = new DisguiseWither(stand); @@ -87,10 +89,31 @@ public class WitherBoss extends MobaBoss { _ai = new MobaAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD); } + else if (_host.getOvertimeManager().isOvertime()) + { + if (_aiOvertime == null) + { + _aiOvertime = new WitherBossOvertimeAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD); + } + + return _aiOvertime; + } return _ai; } + @Override + @EventHandler + public void updateMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !_host.IsLive()) + { + return; + } + + getAi().updateTarget(); + } + @Override public String getName() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java new file mode 100644 index 000000000..9a710aaab --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.game.games.moba.boss.wither; + +import mineplex.core.common.util.UtilMath; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +import java.util.List; + +public class WitherBossOvertimeAI extends MobaAI +{ + + private List _path; + private Location _target; + private int _targetIndex; + + public WitherBossOvertimeAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) + { + super(host, owner, entity, home, speedTarget, speedHome, aiMethod); + + _path = host.getMinionManager().getPath(owner.GetColor() == ChatColor.RED); + _path = _path.subList(0, (int) (_path.size() / 2D)); + } + + @Override + public void updateTarget() + { + if (_target == null) + { + _target = _path.get(0); + _targetIndex = 0; + } + + double dist = UtilMath.offsetSquared(_target, _entity.getLocation()); + + if (dist < 16 && _targetIndex < _path.size() - 1) + { + _targetIndex++; + _target = _path.get(_targetIndex); + } + + _aiMethod.updateMovement(_entity, _target, 3); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 9e3790713..efdb7356b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -22,6 +22,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -181,4 +182,16 @@ public class MinionManager implements Listener // sign.update(); // } } + + public List getPath(boolean redTeam) + { + List path = new ArrayList<>(_path); + + if (redTeam) + { + Collections.reverse(path); + } + + return path; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java new file mode 100644 index 000000000..9e72823d5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.game.games.moba.overtime; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import java.util.concurrent.TimeUnit; + +public class OvertimeManager implements Listener +{ + + private static final long OVERTIME = TimeUnit.MINUTES.toMillis(1); + + private final Moba _host; + private boolean _enabled; + private boolean _overtime; + + public OvertimeManager(Moba host) + { + _host = host; + _enabled = true; + } + + public void disableOvertime() + { + _enabled = false; + } + + @EventHandler + public void updateOvertime(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !_host.IsLive() || !UtilTime.elapsed(_host.GetStateTime(), OVERTIME) || _overtime || !_enabled) + { + return; + } + + _overtime = true; + UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!"); + _host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1.2F); + } + } + + public boolean isOvertime() + { + return _enabled && _overtime; + } +}