Add wither overtime
This commit is contained in:
parent
3c031c70a1
commit
a79c79bc99
@ -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.larissa.HeroLarissa;
|
||||||
import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena;
|
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.minion.MinionManager;
|
||||||
import nautilus.game.arcade.game.games.moba.prepare.PrepareManager;
|
import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager;
|
||||||
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
|
|
||||||
import nautilus.game.arcade.game.games.moba.shop.MobaShop;
|
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.point.CapturePointManager;
|
||||||
import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager;
|
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 MobaShop _shop;
|
||||||
protected final GoldManager _goldManager;
|
protected final GoldManager _goldManager;
|
||||||
protected final BossManager _boss;
|
protected final BossManager _boss;
|
||||||
|
protected final OvertimeManager _overtimeManager;
|
||||||
protected final BuffManager _buffs;
|
protected final BuffManager _buffs;
|
||||||
protected final ArrowKBManager _arrowKb;
|
protected final ArrowKBManager _arrowKb;
|
||||||
protected final TowerManager _tower;
|
protected final TowerManager _tower;
|
||||||
@ -116,6 +116,7 @@ public class Moba extends TeamGame
|
|||||||
_shop = registerManager(new MobaShop(this));
|
_shop = registerManager(new MobaShop(this));
|
||||||
_goldManager = registerManager(new GoldManager(this));
|
_goldManager = registerManager(new GoldManager(this));
|
||||||
_boss = registerManager(new BossManager(this));
|
_boss = registerManager(new BossManager(this));
|
||||||
|
_overtimeManager = registerManager(new OvertimeManager(this));
|
||||||
_buffs = registerManager(new BuffManager());
|
_buffs = registerManager(new BuffManager());
|
||||||
_arrowKb = registerManager(new ArrowKBManager(this));
|
_arrowKb = registerManager(new ArrowKBManager(this));
|
||||||
_minion = registerManager(new MinionManager(this));
|
_minion = registerManager(new MinionManager(this));
|
||||||
@ -496,6 +497,11 @@ public class Moba extends TeamGame
|
|||||||
return _goldManager;
|
return _goldManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OvertimeManager getOvertimeManager()
|
||||||
|
{
|
||||||
|
return _overtimeManager;
|
||||||
|
}
|
||||||
|
|
||||||
public BuffManager getBuffManager()
|
public BuffManager getBuffManager()
|
||||||
{
|
{
|
||||||
return _buffs;
|
return _buffs;
|
||||||
@ -520,4 +526,9 @@ public class Moba extends TeamGame
|
|||||||
{
|
{
|
||||||
return _arrowKb;
|
return _arrowKb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MinionManager getMinionManager()
|
||||||
|
{
|
||||||
|
return _minion;
|
||||||
|
}
|
||||||
}
|
}
|
@ -23,11 +23,11 @@ public class MobaAI
|
|||||||
private final float _speedHome;
|
private final float _speedHome;
|
||||||
private final Polygon2D _boundaries;
|
private final Polygon2D _boundaries;
|
||||||
|
|
||||||
private LivingEntity _entity;
|
protected LivingEntity _entity;
|
||||||
private LivingEntity _target;
|
private LivingEntity _target;
|
||||||
private Location _home;
|
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)
|
public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod)
|
||||||
{
|
{
|
||||||
|
@ -46,6 +46,7 @@ public class WitherBoss extends MobaBoss
|
|||||||
|
|
||||||
private final GameTeam _team;
|
private final GameTeam _team;
|
||||||
private MobaAI _ai;
|
private MobaAI _ai;
|
||||||
|
private MobaAI _aiOvertime;
|
||||||
private DisguiseWither _disguise;
|
private DisguiseWither _disguise;
|
||||||
private boolean _damageable;
|
private boolean _damageable;
|
||||||
private long _lastInform;
|
private long _lastInform;
|
||||||
@ -70,6 +71,7 @@ public class WitherBoss extends MobaBoss
|
|||||||
stand.setHealth(INITIAL_HEALTH * 0.1);
|
stand.setHealth(INITIAL_HEALTH * 0.1);
|
||||||
stand.setGravity(false);
|
stand.setGravity(false);
|
||||||
|
|
||||||
|
MobaUtil.setTeamEntity(stand, _team);
|
||||||
UtilEnt.setBoundingBox(stand, 3, 5);
|
UtilEnt.setBoundingBox(stand, 3, 5);
|
||||||
|
|
||||||
_disguise = new DisguiseWither(stand);
|
_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);
|
_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;
|
return _ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@EventHandler
|
||||||
|
public void updateMovement(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK || !_host.IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAi().updateTarget();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
|
@ -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<Location> _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);
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -181,4 +182,16 @@ public class MinionManager implements Listener
|
|||||||
// sign.update();
|
// sign.update();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Location> getPath(boolean redTeam)
|
||||||
|
{
|
||||||
|
List<Location> path = new ArrayList<>(_path);
|
||||||
|
|
||||||
|
if (redTeam)
|
||||||
|
{
|
||||||
|
Collections.reverse(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user