Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.elvarg.game.model;
- import com.elvarg.game.World;
- import com.elvarg.game.entity.Entity;
- import com.elvarg.game.entity.impl.Character;
- import com.elvarg.game.entity.impl.player.Player;
- /**
- * A graphic propelled through the air by some sort of spell, weapon, or other
- * miscellaneous force.
- *
- * @author lare96
- */
- public final class Projectile {
- /**
- * The starting position of the projectile.
- */
- private final Position start;
- /**
- * The ending position of the projectile.
- */
- private final Position end;
- /**
- * The speed of the projectile.
- */
- private final int speed;
- /**
- * The id of the projectile.
- */
- private final int projectileId;
- /**
- * The starting height of the projectile.
- */
- private final int startHeight;
- /**
- * The ending height of the projectile.
- */
- private final int endHeight;
- /**
- * The lock on value of the projectile.
- */
- private final int lockon;
- /**
- * The delay of the projectile.
- */
- private final int delay;
- /**
- * The curve angle of the projectile.
- */
- private final int curve;
- /**
- * Create a new {@link Projectile}.
- *
- * @param start the starting position of the projectile.
- * @param end the ending position of the projectile.
- * @param lockon the lock on value of the projectile.
- * @param projectileId the id of the projectile.
- * @param speed the speed of the projectile.
- * @param delay the delay of the projectile.
- * @param startHeight the starting height of the projectile.
- * @param endHeight the ending height of the projectile.
- * @param curve the curve angle of the projectile.
- */
- public Projectile(Position start, Position end, int lockon, int projectileId, int delay, int speed, int startHeight,
- int endHeight, int curve) {
- this.start = start;
- this.end = end;
- this.lockon = lockon;
- this.projectileId = projectileId;
- this.delay = delay;
- this.speed = speed;
- this.startHeight = startHeight;
- this.endHeight = endHeight;
- this.curve = curve;
- }
- /**
- * Create a new {@link Projectile}.
- *
- * @param source the entity that is firing this projectile.
- * @param victim the victim that this projectile is being fired at.
- * @param projectileId the id of the projectile.
- * @param speed the speed of the projectile.
- * @param delay the delay of the projectile.
- * @param startHeight the starting height of the projectile.
- * @param endHeight the ending height of the projectile.
- * @param curve the curve angle of the projectile.
- */
- public Projectile(Character source, Entity victim, int projectileId, int delay, int speed, int startHeight,
- int endHeight, int curve) {
- this(source.getPosition(), victim.getPosition(),
- (victim.isPlayer() ? -victim.getIndex() - 1 : victim.getIndex() + 1), projectileId, delay, speed,
- startHeight, endHeight, curve);
- }
- /**
- * Sends one projectiles using the values set when the {@link Projectile} was
- * constructed.
- */
- public void sendProjectile() {
- for (Player player : World.getPlayers()) {
- if (player == null) {
- continue;
- }
- if (start.isViewableFrom(player.getPosition())) {
- player.getPacketSender().sendProjectile(start, end, 0, speed, projectileId, startHeight, endHeight, lockon, delay);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement