Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. package com.elvarg.game.model;
  2.  
  3. import com.elvarg.game.World;
  4. import com.elvarg.game.entity.Entity;
  5. import com.elvarg.game.entity.impl.Character;
  6. import com.elvarg.game.entity.impl.player.Player;
  7.  
  8. /**
  9. * A graphic propelled through the air by some sort of spell, weapon, or other
  10. * miscellaneous force.
  11. *
  12. * @author lare96
  13. */
  14. public final class Projectile {
  15.  
  16. /**
  17. * The starting position of the projectile.
  18. */
  19. private final Position start;
  20.  
  21. /**
  22. * The ending position of the projectile.
  23. */
  24. private final Position end;
  25.  
  26. /**
  27. * The speed of the projectile.
  28. */
  29. private final int speed;
  30.  
  31. /**
  32. * The id of the projectile.
  33. */
  34. private final int projectileId;
  35.  
  36. /**
  37. * The starting height of the projectile.
  38. */
  39. private final int startHeight;
  40.  
  41. /**
  42. * The ending height of the projectile.
  43. */
  44. private final int endHeight;
  45.  
  46. /**
  47. * The lock on value of the projectile.
  48. */
  49. private final int lockon;
  50.  
  51. /**
  52. * The delay of the projectile.
  53. */
  54. private final int delay;
  55.  
  56. /**
  57. * The curve angle of the projectile.
  58. */
  59. private final int curve;
  60.  
  61. /**
  62. * Create a new {@link Projectile}.
  63. *
  64. * @param start the starting position of the projectile.
  65. * @param end the ending position of the projectile.
  66. * @param lockon the lock on value of the projectile.
  67. * @param projectileId the id of the projectile.
  68. * @param speed the speed of the projectile.
  69. * @param delay the delay of the projectile.
  70. * @param startHeight the starting height of the projectile.
  71. * @param endHeight the ending height of the projectile.
  72. * @param curve the curve angle of the projectile.
  73. */
  74. public Projectile(Position start, Position end, int lockon, int projectileId, int delay, int speed, int startHeight,
  75. int endHeight, int curve) {
  76. this.start = start;
  77. this.end = end;
  78. this.lockon = lockon;
  79. this.projectileId = projectileId;
  80. this.delay = delay;
  81. this.speed = speed;
  82. this.startHeight = startHeight;
  83. this.endHeight = endHeight;
  84. this.curve = curve;
  85. }
  86.  
  87. /**
  88. * Create a new {@link Projectile}.
  89. *
  90. * @param source the entity that is firing this projectile.
  91. * @param victim the victim that this projectile is being fired at.
  92. * @param projectileId the id of the projectile.
  93. * @param speed the speed of the projectile.
  94. * @param delay the delay of the projectile.
  95. * @param startHeight the starting height of the projectile.
  96. * @param endHeight the ending height of the projectile.
  97. * @param curve the curve angle of the projectile.
  98. */
  99. public Projectile(Character source, Entity victim, int projectileId, int delay, int speed, int startHeight,
  100. int endHeight, int curve) {
  101. this(source.getPosition(), victim.getPosition(),
  102. (victim.isPlayer() ? -victim.getIndex() - 1 : victim.getIndex() + 1), projectileId, delay, speed,
  103. startHeight, endHeight, curve);
  104. }
  105.  
  106. /**
  107. * Sends one projectiles using the values set when the {@link Projectile} was
  108. * constructed.
  109. */
  110. public void sendProjectile() {
  111. for (Player player : World.getPlayers()) {
  112. if (player == null) {
  113. continue;
  114. }
  115. if (start.isViewableFrom(player.getPosition())) {
  116. player.getPacketSender().sendProjectile(start, end, 0, speed, projectileId, startHeight, endHeight, lockon, delay);
  117. }
  118. }
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement