[Clans] More work on world events

This commit is contained in:
Shaun Bennett 2015-05-28 15:20:43 -05:00
parent 20fadcd187
commit 6b10d9f3c9
5 changed files with 176 additions and 6 deletions

View File

@ -92,7 +92,7 @@ public class Clans extends JavaPlugin
new BuildingShop(clans, _clientManager, _donationManager); new BuildingShop(clans, _clientManager, _donationManager);
new PvpShop(clans, _clientManager, _donationManager); new PvpShop(clans, _clientManager, _donationManager);
new WorldEventManager(this); new WorldEventManager(this, clans);
//Updates //Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);

View File

@ -77,6 +77,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
private ClassCombatShop _classShop; private ClassCombatShop _classShop;
private ClassManager _classManager; private ClassManager _classManager;
private WarManager _warManager; private WarManager _warManager;
private ProjectileManager _projectileManager;
private int _inviteExpire = 2; private int _inviteExpire = 2;
private int _nameMin = 3; private int _nameMin = 3;
@ -124,15 +125,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
new Weapon(plugin, energy); new Weapon(plugin, energy);
new Gameplay(plugin, this, blockRestore, damageManager); new Gameplay(plugin, this, blockRestore, damageManager);
ProjectileManager throwManager = new ProjectileManager(plugin); _projectileManager = new ProjectileManager(plugin);
Fire fire = new Fire(plugin, _condition, damageManager); Fire fire = new Fire(plugin, _condition, damageManager);
HashSet<String> itemIgnore = new HashSet<String>(); HashSet<String> itemIgnore = new HashSet<String>();
itemIgnore.add("Proximity Explosive"); itemIgnore.add("Proximity Explosive");
itemIgnore.add("Proximity Zapper"); itemIgnore.add("Proximity Zapper");
ItemFactory itemFactory = new ItemFactory(plugin, blockRestore, _condition, damageManager, energy, fire, throwManager, webServerAddress, itemIgnore); ItemFactory itemFactory = new ItemFactory(plugin, blockRestore, _condition, damageManager, energy, fire, _projectileManager, webServerAddress, itemIgnore);
SkillFactory skillManager = new SkillFactory(plugin, damageManager, this, _combatManager, _condition, throwManager, disguiseManager, blockRestore, fire, new Movement(plugin), teleport, energy, webServerAddress); SkillFactory skillManager = new SkillFactory(plugin, damageManager, this, _combatManager, _condition, _projectileManager, disguiseManager, blockRestore, fire, new Movement(plugin), teleport, energy, webServerAddress);
skillManager.RemoveSkill("Dwarf Toss", "Block Toss"); skillManager.RemoveSkill("Dwarf Toss", "Block Toss");
_classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress); _classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress);
@ -498,6 +499,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
return _warManager; return _warManager;
} }
public ProjectileManager getProjectile()
{
return _projectileManager;
}
public int convertGoldToEnergy(int gold) public int convertGoldToEnergy(int gold)
{ {
return gold * 4; return gold * 4;

View File

@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; import mineplex.game.clans.clans.worldevent.command.WorldEventCommand;
import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent; import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent;
@ -20,10 +21,13 @@ public class WorldEventManager extends MiniPlugin implements WorldEventListener
private final WorldEventFactory _factory; private final WorldEventFactory _factory;
private final Set<AbstractWorldEvent> _events; private final Set<AbstractWorldEvent> _events;
public WorldEventManager(JavaPlugin plugin) private ClansManager _clansManager;
public WorldEventManager(JavaPlugin plugin, ClansManager clansManager)
{ {
super("World Event", plugin); super("World Event", plugin);
_clansManager = clansManager;
_factory = new ConcreteWorldEventFactory(this); _factory = new ConcreteWorldEventFactory(this);
_events = new HashSet<AbstractWorldEvent>(); _events = new HashSet<AbstractWorldEvent>();
} }
@ -45,6 +49,11 @@ public class WorldEventManager extends MiniPlugin implements WorldEventListener
return event; return event;
} }
public ClansManager getClans()
{
return _clansManager;
}
@Override @Override
public void onComplete(AbstractWorldEvent event) public void onComplete(AbstractWorldEvent event)
{ {

View File

@ -16,6 +16,7 @@ import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.game.clans.clans.worldevent.event.boss.AbstractBoss; import mineplex.game.clans.clans.worldevent.event.boss.AbstractBoss;
import mineplex.game.clans.clans.worldevent.event.state.RocketState;
public class SlamState extends BossState public class SlamState extends BossState
{ {
@ -102,7 +103,7 @@ public class SlamState extends BossState
fallLoc.getWorld().playSound(fallLoc, Sound.ANVIL_LAND, 10, 0.5F); fallLoc.getWorld().playSound(fallLoc, Sound.ANVIL_LAND, 10, 0.5F);
event.setCancelled(true); event.setCancelled(true);
getBoss().setState(null); getBoss().setState(new RocketState(getBoss(), _entity));
} }
} }

View File

@ -0,0 +1,154 @@
package mineplex.game.clans.clans.worldevent.event.state;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.updater.UpdateType;
import mineplex.game.clans.clans.worldevent.event.boss.AbstractBoss;
import mineplex.game.clans.clans.worldevent.event.boss.state.BossState;
public class RocketState extends BossState implements IThrown
{
private LivingEntity _shooter;
private LinkedList<ShotData> _shots;
public RocketState(AbstractBoss boss, LivingEntity shooter)
{
super(boss);
_shooter = shooter;
_shots = new LinkedList<ShotData>();
}
@Override
public void onTick()
{
if (getTicks() % 20 == 0)
{
int c = getTicks() / 20;
double mod = (c / 5.0) * Math.PI;
double x = Math.sin(mod);
double z = Math.cos(mod);
double y = -0.1;
List<Entity> entities = _shooter.getNearbyEntities(20, 20, 20);
for (Entity e : entities)
{
if (e instanceof Player)
{
// Vector v = UtilAlg.getTrajectory(_shooter.getEyeLocation(), e.getLocation());
fireProjectile(((Player) e));
}
}
// fireProjectile(new Vector(x, y, z));
if (c == 5)
{
getBoss().setState(null);
}
}
Iterator<ShotData> it = _shots.iterator();
while (it.hasNext())
{
ShotData next = it.next();
if (next.getEntity().isDead())
{
it.remove();
}
else
{
Vector v = UtilAlg.getTrajectory(next.getEntity(), next.getTarget());
next.getEntity().setVelocity(v.multiply(new Vector(0.3, 0.1, 0.3)));
}
}
}
@Override
public void onStateStart()
{
}
@Override
public void onStateStop()
{
}
private void fireProjectile(LivingEntity target)
{
Location loc = _shooter.getEyeLocation();
loc.add(loc.getDirection().normalize().multiply(2));
Slime projectile = loc.getWorld().spawn(loc, Slime.class);
projectile.setSize(2);
// projectile.setVelocity(direction);
_shots.add(new ShotData(projectile, target));
ProjectileManager pm = getBoss().getEventManager().getClans().getProjectile();
pm.AddThrow(projectile, _shooter, this, -1, true, true, true, null, 0, 0, UtilParticle.ParticleType.SLIME, UpdateType.FASTEST, 1F);
Bukkit.broadcastMessage("Shot Slime");
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
Bukkit.broadcastMessage("COLLIDE " + target);
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_EXPLODE, data.GetThrown().getLocation(), 0, 0, 0, 0, 1);
}
@Override
public void Idle(ProjectileUser data)
{
Bukkit.broadcastMessage("IDLE");
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_EXPLODE, data.GetThrown().getLocation(), 0, 0, 0, 0, 1);
}
@Override
public void Expire(ProjectileUser data)
{
Bukkit.broadcastMessage("EXPIRE");
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_EXPLODE, data.GetThrown().getLocation(), 0, 0, 0, 0, 1);
}
private static class ShotData
{
private LivingEntity _entity;
private LivingEntity _target;
public ShotData(LivingEntity entity, LivingEntity target)
{
_entity = entity;
_target = target;
}
public LivingEntity getEntity()
{
return _entity;
}
public LivingEntity getTarget()
{
return _target;
}
}
}