Add a go-back button to kit selection

This commit is contained in:
Sam 2017-06-28 23:38:50 +01:00
parent 82182c5d50
commit 85007820d2
6 changed files with 95 additions and 46 deletions

View File

@ -79,12 +79,6 @@ public class ClientArmorStand implements ArmorStand
_observers = players;
}
public void sendSpawnPacket(Player player)
{
Packet<?> packet = new PacketPlayOutSpawnEntityLiving(_armorStand);
UtilPlayer.sendPacket(player, packet);
}
public EntityArmorStand getHandle()
{
return _armorStand;
@ -182,7 +176,7 @@ public class ClientArmorStand implements ArmorStand
@Override
public Location getLocation()
{
return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ);
return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ, _armorStand.yaw, _armorStand.pitch);
}
@Override
@ -246,6 +240,20 @@ public class ClientArmorStand implements ArmorStand
return false;
}
public boolean teleport(Location location, Player player)
{
double pX = _armorStand.locX;
double pY = _armorStand.locY;
double pZ = _armorStand.locZ;
float pYaw = _armorStand.yaw;
float pPitch = _armorStand.pitch;
_armorStand.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
UtilPlayer.sendPacket(player, new PacketPlayOutEntityTeleport(_armorStand));
_armorStand.setPositionRotation(pX, pY, pZ, pYaw, pPitch);
return false;
}
@Override
public boolean teleport(Location loc)
{

View File

@ -40,7 +40,7 @@ public class WitherBoss extends MobaBoss
private static final String NAME = "Wither Boss";
private static final float SPEED_TARGET = 4F;
private static final float SPEED_HOME = 6F;
private static final int INITIAL_HEALTH = 125;
private static final int INITIAL_HEALTH = 275;
private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod();
private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30);
@ -66,9 +66,8 @@ public class WitherBoss extends MobaBoss
{
ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class);
// Reducing the wither's health to 10% gives a shield like effect.
stand.setMaxHealth(INITIAL_HEALTH);
stand.setHealth(INITIAL_HEALTH * 0.1);
stand.setHealth(INITIAL_HEALTH);
stand.setGravity(false);
MobaUtil.setTeamEntity(stand, _team);
@ -148,20 +147,6 @@ public class WitherBoss extends MobaBoss
return;
}
// If not damageable
if (!_damageable)
{
Player damager = event.GetDamagerPlayer(true);
if (damager != null)
{
damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!"));
damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F);
}
return;
}
LivingEntity damagee = event.GetDamageeEntity();
Player damager = event.GetDamagerPlayer(true);
@ -175,6 +160,18 @@ public class WitherBoss extends MobaBoss
}
}
// If not damageable
if (!_damageable)
{
if (damager != null)
{
damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!"));
damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F);
}
return;
}
// Inform the team
if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME))
{
@ -214,11 +211,14 @@ public class WitherBoss extends MobaBoss
return;
}
// Here we can remove the shield effect, as the wither is no longer invincible
if (!tower.isFirstTower())
if (tower.isFirstTower())
{
_entity.setHealth(_entity.getHealth() - 50);
}
else
{
_entity.setHealth(_entity.getHealth() - 100);
_damageable = true;
_entity.setHealth(INITIAL_HEALTH);
updateDisplay();
}
}
@ -241,7 +241,7 @@ public class WitherBoss extends MobaBoss
public double getHealthPercentage()
{
return _damageable ? (_entity.getHealth() / _entity.getMaxHealth()) : 1;
return _entity.getHealth() / _entity.getMaxHealth();
}
private void updateDisplay()

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.moba.boss.wither;
import mineplex.core.common.geom.Polygon2D;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
@ -45,4 +46,10 @@ public class WitherBossOvertimeAI extends MobaAI
_aiMethod.updateMovement(_entity, _target, 2);
}
@Override
public Polygon2D getBoundaries()
{
return null;
}
}

View File

@ -328,17 +328,17 @@ public class HeroSkill extends Perk
@Override
public void run()
{
long timeLeft = System.currentTimeMillis() + time - now;
long timeLeft = now + time - System.currentTimeMillis();
double percentage = (double) timeLeft / (double) time;
if (percentage >= 1)
if (percentage <= 0)
{
UtilTextBottom.display(C.cRedB + GetName(), player);
cancel();
return;
}
UtilTextBottom.displayProgress(GetName(), percentage, player);
UtilTextBottom.displayProgress(C.cWhiteB + GetName(), percentage, UtilTime.MakeStr(timeLeft), player);
}
}, 0, 1);
@ -356,6 +356,7 @@ public class HeroSkill extends Perk
complete.run();
}
useSkill(player);
Kit.GiveItems(player);
cancel();
return;
}

View File

@ -22,7 +22,6 @@ import nautilus.game.arcade.game.games.moba.MobaRole;
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
@ -91,6 +90,8 @@ public class PrepareSelection implements Listener, IPacketHandler
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average)));
try
{
MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]);
ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players);
@ -104,6 +105,10 @@ public class PrepareSelection implements Listener, IPacketHandler
_roleStands.put(stand, role);
}
catch (IllegalArgumentException e)
{
}
}
// Only spawn the NPCs once all players have been loaded into the world.
}, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10);
}
@ -124,7 +129,7 @@ public class PrepareSelection implements Listener, IPacketHandler
goBackStand.setCustomNameVisible(true);
goBackStand.setCustomName(C.cGreenB + "Go Back");
goBackStand.setArms(true);
goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM, (byte) 2));
goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM));
goBackStand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.MAROON).build());
goBackStand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.MAROON).build());
goBackStand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.MAROON).build());
@ -190,11 +195,21 @@ public class PrepareSelection implements Listener, IPacketHandler
ClientArmorStand goBackStand = _goBackStands.get(player);
if (goBackStand != null)
if (goBackStand != null && goBackStand.getEntityId() == entityId)
{
packetInfo.setCancelled(true);
_host.getMobaData(player).setRole(null);
_goBackStands.remove(player).remove();
for (ClientArmorStand stand2 : _kitStands.keySet())
{
stand2.remove(player);
}
for (ClientArmorStand stand2 : _roleStands.keySet())
{
stand2.teleport(stand2.getLocation(), player);
}
return;
}
@ -218,7 +233,7 @@ public class PrepareSelection implements Listener, IPacketHandler
for (ClientArmorStand stand2 : _roleStands.keySet())
{
stand2.remove(player);
stand2.teleport(stand2.getLocation().add(0, 100, 0), player);
}
GameTeam team = _host.GetTeam(player);
@ -243,6 +258,11 @@ public class PrepareSelection implements Listener, IPacketHandler
HeroKit kit = _kitStands.get(stand);
if (goBackStand != null)
{
_goBackStands.remove(player).remove();
}
for (ClientArmorStand stand2 : _kitStands.keySet())
{
stand2.remove(player);
@ -287,6 +307,14 @@ public class PrepareSelection implements Listener, IPacketHandler
stand.remove();
}
for (ClientArmorStand stand : _goBackStands.values())
{
stand.remove();
}
_roleStands.clear();
_kitStands.clear();
_goBackStands.clear();
removePodiums();
_host.getArcadeManager().getPacketHandler().removePacketHandler(this);
}

View File

@ -72,6 +72,11 @@ public class MobaUtil
public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, Polygon2D boundaries, LivingEntity target)
{
if (boundaries == null)
{
return true;
}
return getEntitiesInBoundary(owner, source, center, boundaries).contains(target);
}