Guest User

Untitled

a guest
Oct 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.29 KB | None | 0 0
  1. diff --git a/src/net/aeon/epoch/ActorFactory.java b/src/net/aeon/epoch/ActorFactory.java
  2. index a6e039e..38b9514 100644
  3. --- a/src/net/aeon/epoch/ActorFactory.java
  4. +++ b/src/net/aeon/epoch/ActorFactory.java
  5. @@ -13,6 +13,7 @@ import net.aeon.epoch.actor.GroundActor;
  6. import net.aeon.epoch.actor.Pickup;
  7. import net.aeon.epoch.actor.PointsPickup;
  8. import net.aeon.epoch.actor.Actor.Team;
  9. +import net.aeon.epoch.actor.WeaponPickup;
  10. import net.aeon.epoch.component.AttackSprite;
  11. import net.aeon.epoch.component.BasicEnemyController;
  12. import net.aeon.epoch.component.FlowerAttack;
  13. @@ -20,6 +21,8 @@ import net.aeon.epoch.component.LinearAttack;
  14. import net.aeon.epoch.component.LinearController;
  15. import net.aeon.epoch.component.SineController;
  16. import net.aeon.epoch.component.TargetedAttack;
  17. +import net.aeon.epoch.weapon.Laser;
  18. +import net.aeon.epoch.weapon.PlasmaCannon;
  19.  
  20. /**
  21. * @author Affian
  22. @@ -93,6 +96,10 @@ public class ActorFactory {
  23. return actor;
  24. }
  25.  
  26. + /**
  27. + * @param event
  28. + * @return actor
  29. + */
  30. public static GroundActor createDeco(Event event) {
  31. GroundActor actor = new GroundActor(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN), 0);
  32. loadSprite(event.properties.get("sprite"), actor);
  33. @@ -100,13 +107,25 @@ public class ActorFactory {
  34. return actor;
  35. }
  36.  
  37. + /**
  38. + * @param event
  39. + * @return actor
  40. + */
  41. public static Pickup createPickup(Event event) {
  42. - //TODO create any kind of pickup, currently only creates a points pickup
  43. - Pickup actor = new PointsPickup(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN), 1000);
  44. - loadValue(event.properties.get("value"), actor);
  45. -
  46. - actor.setTeam(Team.NEUTRAL);
  47. -
  48. + String type = event.properties.get("pickup");
  49. + Pickup actor = null;//new PointsPickup(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN), 1000);
  50. + if (type != null) {
  51. + if (type.equalsIgnoreCase("points")) {
  52. + actor = new PointsPickup(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN), 1000);
  53. + } else if (type.equalsIgnoreCase("weapon")) {
  54. + actor = new WeaponPickup(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN));
  55. + loadWeapon(event.properties.get("weapon"), actor);
  56. + }
  57. + }
  58. + if (actor != null) {
  59. + loadValue(event.properties.get("value"), actor);
  60. + actor.setTeam(Team.NEUTRAL);
  61. + }
  62. return actor;
  63. }
  64.  
  65. @@ -216,7 +235,23 @@ public class ActorFactory {
  66. }
  67.  
  68. /**
  69. - *
  70. + * @param param
  71. + * @param actor
  72. + */
  73. + private static void loadWeapon(String param, Actor actor) {
  74. + String[] tempTokens = null;
  75. +
  76. + if (param != null) {
  77. + tempTokens = param.split(DELIM);
  78. + if (tempTokens[0].equalsIgnoreCase("plasma")) {
  79. + ((WeaponPickup)actor).setWeapon(new PlasmaCannon());
  80. + } else if (tempTokens[0].equalsIgnoreCase("laser")) {
  81. + ((WeaponPickup)actor).setWeapon(new Laser());
  82. + }
  83. + }
  84. + }
  85. +
  86. + /**
  87. * @param actor
  88. * @return {@link org.newdawn.slick.geom.Rectangle Rectangle} defines actors hitbox
  89. */
  90. diff --git a/src/net/aeon/epoch/PlayState.java b/src/net/aeon/epoch/PlayState.java
  91. diff --git a/src/net/aeon/epoch/actor/Actor.java b/src/net/aeon/epoch/actor/Actor.java
  92. index 2a97c58..6e47098 100644
  93. --- a/src/net/aeon/epoch/actor/Actor.java
  94. +++ b/src/net/aeon/epoch/actor/Actor.java
  95. @@ -3,6 +3,8 @@
  96. */
  97. package net.aeon.epoch.actor;
  98.  
  99. +import java.io.IOException;
  100. +
  101. import net.aeon.epoch.PlayState;
  102. import net.aeon.epoch.component.AnimatedSprite;
  103. import net.aeon.epoch.component.Attack;
  104. @@ -19,6 +21,7 @@ import org.newdawn.slick.geom.Shape;
  105. import org.newdawn.slick.geom.Transform;
  106. import org.newdawn.slick.geom.Vector2f;
  107. import org.newdawn.slick.particles.ConfigurableEmitter;
  108. +import org.newdawn.slick.particles.ParticleIO;
  109.  
  110. /**
  111. * @author Affian
  112. @@ -73,7 +76,15 @@ public abstract class Actor {
  113. value = 0;
  114. }
  115.  
  116. - public abstract ConfigurableEmitter getEmitter();
  117. + public ConfigurableEmitter getEmitter() {
  118. + ConfigurableEmitter ce = null;
  119. + try {
  120. + ce = ParticleIO.loadEmitter("/resources/newExplosion.xml");
  121. + } catch (IOException e) {
  122. + e.printStackTrace();
  123. + }
  124. + return ce;
  125. + }
  126.  
  127. /**
  128. * @param container
  129. @@ -329,7 +340,7 @@ public abstract class Actor {
  130. public boolean checkCollision(PlayState game, Actor other) {
  131. if (this.isInvulnerable()) return false;
  132. if (this.hitBox == null || other.getHitBox() == null) return false;
  133. - return !isHit() && this.getHitBox().intersects(other.getHitBox());
  134. + return this.getHitBox().intersects(other.getHitBox());
  135. }
  136.  
  137.  
  138. diff --git a/src/net/aeon/epoch/actor/Enemy.java b/src/net/aeon/epoch/actor/Enemy.java
  139. index 61306fd..227a2a7 100644
  140. --- a/src/net/aeon/epoch/actor/Enemy.java
  141. +++ b/src/net/aeon/epoch/actor/Enemy.java
  142. @@ -3,15 +3,12 @@
  143. */
  144. package net.aeon.epoch.actor;
  145.  
  146. -import java.io.IOException;
  147. -
  148. import net.aeon.epoch.PlayState;
  149. import net.aeon.epoch.component.Controller;
  150. import net.aeon.epoch.component.Sprite;
  151.  
  152. import org.newdawn.slick.geom.Vector2f;
  153. import org.newdawn.slick.particles.ConfigurableEmitter;
  154. -import org.newdawn.slick.particles.ParticleIO;
  155.  
  156. /**
  157. * @author Affian
  158. @@ -63,13 +60,7 @@ public class Enemy extends Actor {
  159.  
  160. @Override
  161. public ConfigurableEmitter getEmitter() {
  162. - ConfigurableEmitter ce = null;
  163. - try {
  164. - ce = ParticleIO.loadEmitter("/resources/newExplosion.xml");
  165. - } catch (IOException e) {
  166. - e.printStackTrace();
  167. - }
  168. - return ce;
  169. + return super.getEmitter();
  170. }
  171.  
  172. }
  173. diff --git a/src/net/aeon/epoch/actor/GroundActor.java b/src/net/aeon/epoch/actor/GroundActor.java
  174. index 7bfcbf4..bc48503 100644
  175. --- a/src/net/aeon/epoch/actor/GroundActor.java
  176. +++ b/src/net/aeon/epoch/actor/GroundActor.java
  177. @@ -51,7 +51,7 @@ public class GroundActor extends Actor {
  178. @Override
  179. public ConfigurableEmitter getEmitter() {
  180. // TODO Auto-generated method stub
  181. - return null;
  182. + return super.getEmitter();
  183. }
  184.  
  185. }
  186. diff --git a/src/net/aeon/epoch/actor/WeaponPickup.java b/src/net/aeon/epoch/actor/WeaponPickup.java
  187. index e77dd76..ade916b 100644
  188. --- a/src/net/aeon/epoch/actor/WeaponPickup.java
  189. +++ b/src/net/aeon/epoch/actor/WeaponPickup.java
  190. @@ -17,6 +17,10 @@ public class WeaponPickup extends Pickup {
  191.  
  192. private Weapon weapon;
  193.  
  194. + public WeaponPickup(Vector2f position) {
  195. + this(position, null);
  196. + }
  197. +
  198. /**
  199. * @param position the position of the WeaponPickup
  200. * @param weapon the weapon that this pickup contains
  201. @@ -40,4 +44,18 @@ public class WeaponPickup extends Pickup {
  202. return null;
  203. }
  204.  
  205. + /**
  206. + * @return the weapon
  207. + */
  208. + public Weapon getWeapon() {
  209. + return weapon;
  210. + }
  211. +
  212. + /**
  213. + * @param weapon the weapon to set
  214. + */
  215. + public void setWeapon(Weapon weapon) {
  216. + this.weapon = weapon;
  217. + }
  218. +
  219. }
  220. diff --git a/src/net/aeon/epoch/weapon/PlasmaCannon.java b/src/net/aeon/epoch/weapon/PlasmaCannon.java
  221. index e537160..38381f3 100644
  222. --- a/src/net/aeon/epoch/weapon/PlasmaCannon.java
  223. +++ b/src/net/aeon/epoch/weapon/PlasmaCannon.java
  224. @@ -6,7 +6,6 @@ package net.aeon.epoch.weapon;
  225. import java.util.ArrayList;
  226.  
  227. import net.aeon.epoch.PlayState;
  228. -import net.aeon.epoch.ResourceManager;
  229. import net.aeon.epoch.actor.Bullet;
  230. import net.aeon.epoch.actor.Actor.Team;
  231. import net.aeon.epoch.component.LinearController;
  232. @@ -37,9 +36,9 @@ public class PlasmaCannon implements Weapon {
  233. public PlasmaCannon() {
  234. level = 1;
  235. cooldown = 0;
  236. - fireDelay = 100;
  237. + fireDelay = 120;
  238.  
  239. - shoot = ResourceManager.getInstance().getSound("shoot");
  240. +// shoot = ResourceManager.getInstance().getSound("shoot");
  241.  
  242.  
  243. }
  244. @@ -53,22 +52,48 @@ public class PlasmaCannon implements Weapon {
  245. ArrayList<Bullet> bullets = new ArrayList<Bullet>();
  246. SpriteSheet sprites = game.getResourceManager().getSpriteSheet("bullets");
  247.  
  248. - switch (level) {
  249. - case 1:
  250. - Bullet bullet = new Bullet();
  251. - Vector2f center = new Vector2f(game.getPlayer().getPosition());
  252. -
  253. - center.y -= 10;
  254. - bullet.setPower(5);
  255. +
  256. + Bullet bullet = new Bullet();
  257. + Vector2f center = new Vector2f(game.getPlayer().getPosition());
  258. +
  259. + center.y -= 10;
  260. + bullet.setPower(5);
  261. + bullet.setTeam(Team.PLAYER);
  262. + bullet.setSprite(sprites.getSubImage(2, 3));
  263. + bullet.setHitBox(new Rectangle(0,0,10,10));
  264. + bullet.setPosition(new Vector2f(center));
  265. + bullet.setController(new LinearController(bullet, 0.4f, 0));
  266. + bullets.add(bullet);
  267. +// bullets.add(createBullet(sprites, center, 5, 2, 3, 0.4f, 0));
  268. +
  269. +
  270. + if (level > 1) {
  271. + bullet = new Bullet();
  272. + center.y += 5;
  273. + center.x -= 12;
  274. + bullet.setPower(4);
  275. bullet.setTeam(Team.PLAYER);
  276. - bullet.setSprite(sprites.getSubImage(2, 3));
  277. + bullet.setSprite(sprites.getSubImage(1, 3));
  278. bullet.setHitBox(new Rectangle(0,0,10,10));
  279. bullet.setPosition(new Vector2f(center));
  280. bullet.setController(new LinearController(bullet, 0.4f, 0));
  281. bullets.add(bullet);
  282. +// bullets.add(createBullet(sprites, center, 4, 1, 3, 0.4f, 0));
  283.  
  284. bullet = new Bullet();
  285. - center.x += 10;
  286. + center.x += 24;
  287. + bullet.setPower(4);
  288. + bullet.setTeam(Team.PLAYER);
  289. + bullet.setSprite(sprites.getSubImage(1, 3));
  290. + bullet.setHitBox(new Rectangle(0,0,10,10));
  291. + bullet.setPosition(new Vector2f(center));
  292. + bullet.setController(new LinearController(bullet, 0.4f, 0));
  293. + bullets.add(bullet);
  294. +// bullets.add(createBullet(sprites, center, 4, 1, 3, 0.4f, 0));
  295. + }
  296. + if (level > 2) {
  297. + bullet = new Bullet();
  298. + center.x -= 2;
  299. bullet.setPower(4);
  300. bullet.setTeam(Team.PLAYER);
  301. bullet.setHitBox(new Rectangle(0,0,10,10));
  302. @@ -77,6 +102,7 @@ public class PlasmaCannon implements Weapon {
  303. bullet.setSprite(sprites.getSubImage(13, 14));
  304. bullet.setController(new LinearController(bullet, 0.4f, 35));
  305. bullets.add(bullet);
  306. +// bullets.add(createBullet(sprites, center, 4, 13, 14, 0.4f, 35));
  307.  
  308. bullet = new Bullet();
  309. center.x -= 20;
  310. @@ -88,13 +114,16 @@ public class PlasmaCannon implements Weapon {
  311. bullet.setSprite(sprites.getSubImage(12, 14));
  312. bullet.setController(new LinearController(bullet, 0.4f, 325));
  313. bullets.add(bullet);
  314. +// bullets.add(createBullet(sprites, center, 4, 12, 14, 0.4f, 325));
  315. + }
  316. + if (level > 3) {
  317. +
  318. + }
  319. + if (level > 4) {
  320.  
  321. - break;
  322. - default:
  323. - break;
  324. }
  325. game.addActors(bullets);
  326. - shoot.play(1, 0.5f);
  327. +// shoot.play(1, 0.5f);
  328. cooldown = fireDelay;
  329. }
  330.  
  331. @@ -130,5 +159,28 @@ public class PlasmaCannon implements Weapon {
  332. level = 1;
  333. cooldown = 0;
  334. }
  335. +
  336. + /**
  337. + * Helper function for creating a plasma bullet
  338. + * @param ss SpriteSheet
  339. + * @param pos Position of bullet
  340. + * @param p Power
  341. + * @param sx X index of sprite in SpriteSheet
  342. + * @param sy Y index of sprite in SpriteSheet
  343. + * @param s Speed
  344. + * @param h Heading
  345. + * @return bullet
  346. + */
  347. + private Bullet createBullet(SpriteSheet ss, Vector2f pos, int p, int sx, int sy, float s, float h) {
  348. + Bullet bullet = new Bullet();
  349. + bullet.setPower(p);
  350. + bullet.setTeam(Team.PLAYER);
  351. + bullet.setHitBox(new Rectangle(0,0,10,10));
  352. + bullet.setPosition(new Vector2f(pos));
  353. + bullet.setHeading(h);
  354. + bullet.setSprite(ss.getSubImage(sx, sy));
  355. + bullet.setController(new LinearController(bullet, s, h));
  356. + return bullet;
  357. + }
  358.  
  359. }
Add Comment
Please, Sign In to add comment