finishing spells, kits and animations.

This commit is contained in:
Sarah 2015-09-26 14:31:17 +02:00
parent 0a42ab7aee
commit c99851da37
11 changed files with 379 additions and 27 deletions

View File

@ -19,8 +19,10 @@ import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
@ -161,7 +163,6 @@ public class Minion implements Listener
private GameTeam _team;
private Player _player;
private Player _killer;
private DisguiseBase _disguise;
private Location _lastNameChanged;
private int _money;
private float _walkSpeed;
@ -326,14 +327,9 @@ public class Minion implements Listener
public void changeName(String name)
{
_name = name;
try
{
Class<? extends DisguiseBase> clazz = _type.getDisguiseClass();
clazz.getMethod("setName", String.class).invoke(_disguise, _team.GetColor() + _name);
_manager.GetDisguise().disguise((DisguiseBase) _disguise);
}
catch (Exception e) {}
_lastNameChanged = _entity.getLocation();
Location loc = _entity.getLocation();
_lastNameChanged = loc;
disguiseCreeper();
}
public void changeRandomName(int min, int max, boolean spawned)
@ -346,10 +342,14 @@ public class Minion implements Listener
for(String str : tempList)
{
if(str.length() >= min && str.length() <= max)
{
if(!spawned)
changeName(str);
else
_name = str;
return;
}
}
}
@ -376,6 +376,8 @@ public class Minion implements Listener
{
float oldSpeed = _walkSpeed;
_walkSpeed = oldSpeed + speed;
if(_walkSpeed <= 0.5)
_walkSpeed = 0.6F;
}
public Location getTarget()

View File

@ -64,9 +64,14 @@ public abstract class Spell
Location loc = player.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 80).get(0).getLocation().add(0.5, 0.5, 0.5);
if(trail() != null)
{
int i = 0;
for (Location location : UtilShapes.getLinesDistancedPoints(player.getEyeLocation().subtract(0, 0.1, 0), loc, 0.1))
{
UtilParticle.PlayParticle(trail(), location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
trailAnimation(location, i);
i++;
if(i > 30)
i = 0;
}
}
if(hit() != null)
@ -97,6 +102,8 @@ public abstract class Spell
return ParticleType.EXPLODE;
}
public void trailAnimation(Location location, int frame) {}
public abstract boolean execute(Player player, Location location);
public ArcadeManager getManager()

View File

@ -10,10 +10,15 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -22,6 +27,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.typewars.kits.KitTactician;
import nautilus.game.arcade.game.games.typewars.kits.KitTypeWarsBase;
import nautilus.game.arcade.game.games.typewars.kits.KitTyper;
import nautilus.game.arcade.game.games.typewars.kits.KitWarrior;
@ -60,7 +66,8 @@ public class TypeWars extends TeamGame
new Kit[]
{
new KitTyper(manager),
new KitWarrior(manager)
new KitWarrior(manager),
new KitTactician(manager)
},
new String[]
{
@ -83,6 +90,7 @@ public class TypeWars extends TeamGame
this.DamagePvE = false;
this.DamagePvP = false;
this.TeamArmorHotbar = true;
this.Damage = false;
_activeMinions = new ArrayList<>();
_deadMinions = new ArrayList<>();
@ -92,6 +100,8 @@ public class TypeWars extends TeamGame
_timeToSpawn = 5000;
_lineGrowth = new HashMap<>();
_lineShorten = new HashMap<>();
_animationTicks = 0;
}
private void initSpawns()
@ -113,7 +123,7 @@ public class TypeWars extends TeamGame
for (Player player : GetPlayers(true))
{
UtilAction.velocity(player, 0.1, 0.1, 0.1, false);
_moneyMap.put(player, 0);
_moneyMap.put(player, 100);
}
if(event.GetState() != GameState.Live)
@ -278,7 +288,7 @@ public class TypeWars extends TeamGame
event.setCancelled(true);
killMinion(minion, event.getPlayer());
UtilPlayer.message(event.getPlayer(), F.main("Game", "You killed the "+ "Minion " + C.cYellow + "\"" + minion.getName() + "\"" + C.cGray + " and got " + minion.getMoney() + "$"));
UtilTextMiddle.display("", C.cGreen + "+" + minion.getMoney() + "$");
UtilTextMiddle.display("", C.cGreen + "+" + minion.getMoney() + "$", event.getPlayer());
_moneyMap.put(event.getPlayer(), _moneyMap.get(event.getPlayer()) + minion.getMoney());
return;
}
@ -430,28 +440,58 @@ public class TypeWars extends TeamGame
}
}
private int _animationTicks;
@EventHandler
public void lines(UpdateEvent event)
{
if(event.getType() != UpdateType.FASTER)
if(event.getType() != UpdateType.TICK)
return;
for(ArrayList<Location> locs : _lineGrowth.values())
{
for(Location loc : locs)
{
loc.getBlock().setType(Material.FIRE);
double radius = _animationTicks / 20D;
int particleAmount = _animationTicks / 2;
for (int e = 0; e < particleAmount; e++)
{
double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius;
Location location = loc.clone().add(0.5, 0, 0.5).clone().add(xDiff, particleAmount/10, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.RED_DUST, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}
for(ArrayList<Location> locs : _lineShorten.values())
{
for(Location loc : locs)
{
loc.getBlock().setType(Material.FIRE);
double radius = _animationTicks / 20D;
int particleAmount = _animationTicks / 2;
for (int e = 0; e < particleAmount; e++)
{
double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius;
Location location = loc.clone().add(0.5, 0, 0.5).add(xDiff, particleAmount/10, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}
for(Minion minion : _activeMinions)
_animationTicks++;
if(_animationTicks > 15)
_animationTicks = 0;
Iterator<Minion> minionIterator = _activeMinions.iterator();
while(minionIterator.hasNext())
{
Minion minion = minionIterator.next();
for(GameTeam team : _lineGrowth.keySet())
{
for(Location loc : _lineGrowth.get(team))

View File

@ -0,0 +1,36 @@
package nautilus.game.arcade.game.games.typewars.kits;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.typewars.Spell;
import nautilus.game.arcade.game.games.typewars.spells.SpellGrowthLiner;
import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything;
import nautilus.game.arcade.game.games.typewars.spells.SpellMassSlow;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class KitTactician extends KitTypeWarsBase
{
public KitTactician(ArcadeManager manager)
{
super(manager, "Alpha. Tactician", KitAvailability.Achievement,
new String[]
{
"The ahlpabet Tactician",
"is known for using deffensive spells"
},
new Perk[]
{
new Perk("Growth Liner", new String[]{"This Spell creats a line of fire and all", "enemy mobs that pass it will get a shorter name"}){},
new Perk("Mass Slow", new String[]{"Slows down all enemy Minions"}){},
new Perk("Nuke Spell", new String[]{"Kill all enemy Minions", "This is a single use spell"}){}
},
EntityType.SKELETON, new ItemStack(Material.PAPER),
new Spell[]{new SpellGrowthLiner(manager), new SpellMassSlow(manager), new SpellKillEverything(manager)});
}
}

View File

@ -5,6 +5,8 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.typewars.MinionType;
import nautilus.game.arcade.game.games.typewars.Spell;
@ -69,6 +71,9 @@ public abstract class KitTypeWarsBase extends Kit
if(event.getPlayer().getItemInHand() == null)
return;
if(!Manager.GetGame().GetKit(event.getPlayer()).GetName().equalsIgnoreCase(GetName()))
return;
executeSpell(event.getPlayer(), event.getPlayer().getItemInHand().getType());
}

View File

@ -2,8 +2,9 @@ package nautilus.game.arcade.game.games.typewars.kits;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.typewars.Spell;
import nautilus.game.arcade.game.games.typewars.spells.SpellGrowthLiner;
import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything;
import nautilus.game.arcade.game.games.typewars.spells.SpellShrinkLiner;
import nautilus.game.arcade.game.games.typewars.spells.SpellSniper;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -24,12 +25,12 @@ public class KitWarrior extends KitTypeWarsBase
},
new Perk[]
{
new Perk("Growth Liner", new String[]{"This Spell creats a line of fire and all", "enemy mobs that pass it will get a longer name"}){},
new Perk("Speed up", new String[]{"Speeds up your mobs", "in a radius of 3"}){},
new Perk("Shrink Liner", new String[]{"This Spell creats a line of fire and all", "enemy mobs that pass it will get a shorter name"}){},
new Perk("Sniper spell", new String[]{"Shoot a minion", "and kill it instantly"}){},
new Perk("Nuke Spell", new String[]{"Kill all enemy Minions", "This is a single use spell"}){}
},
EntityType.SKELETON, new ItemStack(Material.STONE_SWORD),
new Spell[]{new SpellGrowthLiner(manager), new SpellKillEverything(manager)});
new Spell[]{new SpellShrinkLiner(manager), new SpellSniper(manager), new SpellKillEverything(manager)});
}
}

View File

@ -19,7 +19,7 @@ public class SpellFirebomb extends Spell
public SpellFirebomb(ArcadeManager manager)
{
super(manager, "Firebomb", 5, Material.BLAZE_POWDER, 2000L, false);
super(manager, "Firebomb", 4, Material.BLAZE_POWDER, 2000L, false);
}
@Override
@ -36,7 +36,7 @@ public class SpellFirebomb extends Spell
if(getTypeWars().GetTeam(player) == minion.getTeam())
continue;
if(minion.getName().length() > 100)
if(minion.getName().length() > 8)
continue;
final Location loc = minion.getEntity().getLocation();

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.typewars.spells;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.typewars.Spell;
@ -16,7 +17,7 @@ public class SpellGrowthLiner extends Spell
public SpellGrowthLiner(ArcadeManager manager)
{
super(manager, "Growth Liner", 7, Material.BLAZE_ROD, 2000L, false);
super(manager, "Growth Liner", 7, Material.STICK, 2000L, false);
}
@Override
@ -42,10 +43,9 @@ public class SpellGrowthLiner extends Spell
for(Location loc : line)
{
getTypeWars().getLineGrowth().get(getManager().GetGame().GetTeam(player)).remove(loc);
loc.getBlock().setType(Material.AIR);
}
}
}, 140);
}, 180);
return true;
}
@ -126,8 +126,7 @@ public class SpellGrowthLiner extends Spell
}
if(locs.getBlock().getType() != Material.AIR)
locIterator.remove();
//if(!UtilBlock.getInBoundingBox(getTypeWars().getMinionSpawns().get(0).get(0), getTypeWars().getMinionSpawns().get(1).get(getTypeWars().getMinionSpawns().get(1).size())).contains(locIterator))
//locIterator.remove();
}
}
return line;

View File

@ -0,0 +1,75 @@
package nautilus.game.arcade.game.games.typewars.spells;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.typewars.Minion;
import nautilus.game.arcade.game.games.typewars.Spell;
public class SpellMassSlow extends Spell
{
public SpellMassSlow(ArcadeManager manager)
{
super(manager, "Mass Slow spell", 8, Material.ANVIL, 2000L, false);
}
@Override
public ParticleType trail()
{
return ParticleType.FLAME;
}
@Override
public boolean execute(Player player, Location location)
{
location.getWorld().playSound(location.clone().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
for(int e = 0; e <= 60; e++)
{
double radius = e/8;
int particleAmount = e / 2;
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location loc = location.clone().add(0.5, -0.4, 0.5).add(xDiff, 0, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, loc, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
for(Minion minion : getTypeWars().getActiveMinions())
{
if(getTypeWars().GetTeam(player) == minion.getTeam())
continue;
minion.increaseWalkSpeed(-0.3F);
}
return true;
}
@Override
public void trailAnimation(Location location, int frame)
{
double radius = 0.6;
int particleAmount = frame / 2;
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location loc = location.clone().add(xDiff, 0, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.ENCHANTMENT_TABLE, loc, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}

View File

@ -0,0 +1,135 @@
package nautilus.game.arcade.game.games.typewars.spells;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.typewars.Spell;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class SpellShrinkLiner extends Spell
{
public SpellShrinkLiner(ArcadeManager manager)
{
super(manager, "Shrink Liner", 7, Material.BLAZE_ROD, 2000L, false);
}
@Override
public ParticleType trail()
{
return ParticleType.FLAME;
}
@Override
public boolean execute(final Player player, Location location)
{
final ArrayList<Location> line = getLine(player, location);
for(Location loc : line)
{
getTypeWars().getLineShorten().get(getManager().GetGame().GetTeam(player)).add(loc);
}
getManager().runSyncLater(new Runnable()
{
@Override
public void run()
{
for(Location loc : line)
{
getTypeWars().getLineShorten().get(getManager().GetGame().GetTeam(player)).remove(loc);
}
}
}, 180);
return true;
}
private ArrayList<Location> getLine(Player player, Location location)
{
ArrayList<Location> line = new ArrayList<>();
ArrayList<Location> spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player));
for(Location loc : spawns)
{
if(loc.getBlockX() == location.getBlockX() || loc.getBlockX() == location.getBlockX() - 1 || loc.getBlockX() == location.getBlockX() + 1)
{
for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)))
{
Location newLoc = locs.clone();
newLoc.setZ(location.getBlockZ());
line.add(newLoc);
Location pos1 = newLoc.clone().add(1, 0, 0);
Location pos2 = newLoc.clone().add(-1, 0, 0);
boolean addLoc1 = true;
boolean addLoc2 = true;
for(Location otherLoc : line)
{
if(otherLoc.equals(pos1))
addLoc1 = false;
}
for(Location otherLoc : line)
{
if(otherLoc.equals(pos2))
addLoc2 = false;
}
if(addLoc1)
line.add(pos1);
if(addLoc2)
line.add(pos2);
}
break;
}
if(loc.getBlockZ() == location.getBlockZ() || loc.getBlockZ() == location.getBlockZ() - 1 || loc.getBlockZ() == location.getBlockZ() + 1)
{
for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)))
{
Location newLoc = locs.clone();
newLoc.setX(location.getBlockX());
line.add(newLoc);
Location pos1 = newLoc.clone().add(0, 0, 1);
Location pos2 = newLoc.clone().add(0, 0, -1);
boolean addLoc1 = true;
boolean addLoc2 = true;
for(Location otherLoc : line)
{
if(otherLoc.equals(pos1))
addLoc1 = false;
}
for(Location otherLoc : line)
{
if(otherLoc.equals(pos2))
addLoc2 = false;
}
if(addLoc1)
line.add(pos1);
if(addLoc2)
line.add(pos2);
}
break;
}
}
for(Location loc : spawns)
{
Iterator<Location> locIterator = line.iterator();
while(locIterator.hasNext())
{
Location locs = locIterator.next();
if(locs.equals(loc))
{
locIterator.remove();
}
if(locs.getBlock().getType() != Material.AIR)
locIterator.remove();
}
}
return line;
}
}

View File

@ -0,0 +1,52 @@
package nautilus.game.arcade.game.games.typewars.spells;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.typewars.Minion;
import nautilus.game.arcade.game.games.typewars.Spell;
public class SpellSniper extends Spell
{
public SpellSniper(ArcadeManager manager)
{
super(manager, "Sniper spell", 4, Material.ARROW, 2000L, false);
}
@Override
public ParticleType trail()
{
return ParticleType.EXPLODE;
}
@Override
public boolean execute(Player player, Location location)
{
Iterator<Minion> minionIterator = getTypeWars().getActiveMinions().iterator();
while(minionIterator.hasNext())
{
Minion minion = minionIterator.next();
if(UtilMath.offset2d(minion.getEntity().getLocation(), location) > 2)
continue;
if(getTypeWars().GetTeam(player) == minion.getTeam())
continue;
minion.despawn(player, true);
minionIterator.remove();
getTypeWars().getDeadMinions().add(minion);
break;
}
return true;
}
}