Advertisement
Guest User

Untitled

a guest
May 26th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class ParticleDefinition {
  4.  
  5. public static final Random RANDOM = new Random(System.currentTimeMillis());
  6.  
  7. private ParticleVector gravity;
  8.  
  9. private float startSize = 1f;
  10. private float endSize = 1f;
  11.  
  12. public int particleDepth;
  13.  
  14. private int startColor = -1;
  15. private int endColor = -1;
  16.  
  17. private ParticleVector startVelocity = ParticleVector.ZERO;
  18. private ParticleVector endVelocity = ParticleVector.ZERO;
  19.  
  20. private SpawnShape spawnShape = new PointSpawnShape(ParticleVector.ZERO);
  21.  
  22. private float startAlpha = 1f;
  23. private float endAlpha = 0.05f;
  24.  
  25. private int lifeSpan = 1;
  26. private int spawnRate = 1;
  27. private Sprite sprite;
  28. private ParticleVector velocityStep;
  29. private int colorStep;
  30. private float sizeStep;
  31. private float alphaStep;
  32.  
  33. public static ParticleDefinition[] cache = new ParticleDefinition[] {
  34. new ParticleDefinition() { {
  35. //Max Capes
  36. setStartVelocity(new ParticleVector(0, -1, 0));
  37. setEndVelocity(new ParticleVector(0, -1, 0));
  38. setGravity(new ParticleVector(0, 2 / 4, 0));
  39. setLifeSpan(19);
  40. setStartColor(0xFFFFFF);
  41. setSpawnRate(4);
  42. setStartSize(1.10f);
  43. setEndSize(0);
  44. setStartAlpha(0.095f);
  45. updateSteps();
  46. setColorStep(0x000000);}
  47. },
  48. new ParticleDefinition() { {
  49. //Infernal cape
  50. setStartVelocity(new ParticleVector(0, -1, 0));
  51. setEndVelocity(new ParticleVector(0, -1, 0));
  52. setGravity(new ParticleVector(0, 2 / 4, 0));
  53. setLifeSpan(19);
  54. setStartColor(0xEA4908);
  55. setSpawnRate(4);
  56. setStartSize(0.88f);
  57. setEndSize(0);
  58. setStartAlpha(0.095f);
  59. updateSteps();
  60. setColorStep(0x000000);}
  61. }
  62. };
  63.  
  64. public final SpawnShape getSpawnedShape() {
  65. return spawnShape;
  66. }
  67.  
  68. public final float getStartAlpha() {
  69. return startAlpha;
  70. }
  71.  
  72. public final void setStartAlpha(float startAlpha) {
  73. this.startAlpha = startAlpha;
  74. }
  75.  
  76. public final float getAlphaStep() {
  77. return alphaStep;
  78. }
  79.  
  80. public final Sprite getSprite() {
  81. return sprite;
  82. }
  83.  
  84. public final void setSprite(Sprite sprite) {
  85. this.sprite = sprite;
  86. }
  87.  
  88. public final int getSpawnRate() {
  89. return this.spawnRate;
  90. }
  91.  
  92. public final void setSpawnRate(int spawnRate) {
  93. this.spawnRate = spawnRate;
  94. }
  95.  
  96. public final void setStartSize(float startSize) {
  97. this.startSize = startSize;
  98. }
  99.  
  100. public final float getStartSize() {
  101. return startSize;
  102. }
  103.  
  104. public float getEndSize() {
  105. return endSize;
  106. }
  107.  
  108. public int getEndColor() {
  109. return endColor;
  110. }
  111.  
  112. public final void setEndSize(float endSize) {
  113. this.endSize = endSize;
  114. }
  115.  
  116. public final int getStartColor() {
  117. return startColor;
  118. }
  119.  
  120. public final void setStartColor(int startColor) {
  121. this.startColor = startColor;
  122. }
  123.  
  124. public int randomWithRange(int min, int max) {
  125. int range = (max - min) + 1;
  126. return (int) (Math.random() * range) + min;
  127. }
  128.  
  129. public final ParticleVector getStartVelocity(int id) {
  130. switch (id) {
  131. default:
  132. return new ParticleVector(this.startVelocity.getX() + randomWithRange(-1, 1), this.startVelocity.getY() + randomWithRange(0, 0), this.startVelocity.getZ() + randomWithRange(-1, 1));
  133. }
  134. }
  135.  
  136. public ParticleVector getGravity() {
  137. return gravity;
  138. }
  139.  
  140. public void setGravity(ParticleVector gravity) {
  141. this.gravity = gravity;
  142. }
  143.  
  144. public final void setStartVelocity(ParticleVector startVelocity) {
  145. this.startVelocity = startVelocity;
  146. }
  147.  
  148. public ParticleVector getEndVelocity() {
  149. return endVelocity;
  150. }
  151.  
  152. public final void setEndVelocity(ParticleVector endVelocity) {
  153. this.endVelocity = endVelocity;
  154. }
  155.  
  156. public final int getLifeSpan() {
  157. return lifeSpan;
  158. }
  159.  
  160. public final void setLifeSpan(int lifeSpan) {
  161. this.lifeSpan = lifeSpan;
  162. }
  163.  
  164. public final void setColorStep(int colorStep) {
  165. this.colorStep = colorStep;
  166. }
  167.  
  168. public final float getSizeStep() {
  169. return sizeStep;
  170. }
  171.  
  172. public final ParticleVector getVelocityStep() {
  173. return velocityStep;
  174. }
  175.  
  176. public final int getColorStep() {
  177. return colorStep;
  178. }
  179.  
  180. public final void updateSteps() {
  181. this.sizeStep = (endSize - startSize) / (lifeSpan * 1f);
  182. this.colorStep = (endColor - startColor) / lifeSpan;
  183. this.velocityStep = endVelocity.subtract(startVelocity).divide(lifeSpan);
  184. this.alphaStep = (endAlpha - startAlpha) / lifeSpan;u
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement