Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/net/aeon/epoch/ActorFactory.java b/src/net/aeon/epoch/ActorFactory.java
- index a6e039e..38b9514 100644
- --- a/src/net/aeon/epoch/ActorFactory.java
- +++ b/src/net/aeon/epoch/ActorFactory.java
- @@ -13,6 +13,7 @@ import net.aeon.epoch.actor.GroundActor;
- import net.aeon.epoch.actor.Pickup;
- import net.aeon.epoch.actor.PointsPickup;
- import net.aeon.epoch.actor.Actor.Team;
- +import net.aeon.epoch.actor.WeaponPickup;
- import net.aeon.epoch.component.AttackSprite;
- import net.aeon.epoch.component.BasicEnemyController;
- import net.aeon.epoch.component.FlowerAttack;
- @@ -20,6 +21,8 @@ import net.aeon.epoch.component.LinearAttack;
- import net.aeon.epoch.component.LinearController;
- import net.aeon.epoch.component.SineController;
- import net.aeon.epoch.component.TargetedAttack;
- +import net.aeon.epoch.weapon.Laser;
- +import net.aeon.epoch.weapon.PlasmaCannon;
- /**
- * @author Affian
- @@ -93,6 +96,10 @@ public class ActorFactory {
- return actor;
- }
- + /**
- + * @param event
- + * @return actor
- + */
- public static GroundActor createDeco(Event event) {
- GroundActor actor = new GroundActor(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN), 0);
- loadSprite(event.properties.get("sprite"), actor);
- @@ -100,13 +107,25 @@ public class ActorFactory {
- return actor;
- }
- + /**
- + * @param event
- + * @return actor
- + */
- public static Pickup createPickup(Event event) {
- - //TODO create any kind of pickup, currently only creates a points pickup
- - Pickup actor = new PointsPickup(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN), 1000);
- - loadValue(event.properties.get("value"), actor);
- -
- - actor.setTeam(Team.NEUTRAL);
- -
- + String type = event.properties.get("pickup");
- + Pickup actor = null;//new PointsPickup(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN), 1000);
- + if (type != null) {
- + if (type.equalsIgnoreCase("points")) {
- + actor = new PointsPickup(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN), 1000);
- + } else if (type.equalsIgnoreCase("weapon")) {
- + actor = new WeaponPickup(new Vector2f(event.x + PlayState.PLAY_MARGIN, PlayState.PLAY_MARGIN));
- + loadWeapon(event.properties.get("weapon"), actor);
- + }
- + }
- + if (actor != null) {
- + loadValue(event.properties.get("value"), actor);
- + actor.setTeam(Team.NEUTRAL);
- + }
- return actor;
- }
- @@ -216,7 +235,23 @@ public class ActorFactory {
- }
- /**
- - *
- + * @param param
- + * @param actor
- + */
- + private static void loadWeapon(String param, Actor actor) {
- + String[] tempTokens = null;
- +
- + if (param != null) {
- + tempTokens = param.split(DELIM);
- + if (tempTokens[0].equalsIgnoreCase("plasma")) {
- + ((WeaponPickup)actor).setWeapon(new PlasmaCannon());
- + } else if (tempTokens[0].equalsIgnoreCase("laser")) {
- + ((WeaponPickup)actor).setWeapon(new Laser());
- + }
- + }
- + }
- +
- + /**
- * @param actor
- * @return {@link org.newdawn.slick.geom.Rectangle Rectangle} defines actors hitbox
- */
- diff --git a/src/net/aeon/epoch/PlayState.java b/src/net/aeon/epoch/PlayState.java
- diff --git a/src/net/aeon/epoch/actor/Actor.java b/src/net/aeon/epoch/actor/Actor.java
- index 2a97c58..6e47098 100644
- --- a/src/net/aeon/epoch/actor/Actor.java
- +++ b/src/net/aeon/epoch/actor/Actor.java
- @@ -3,6 +3,8 @@
- */
- package net.aeon.epoch.actor;
- +import java.io.IOException;
- +
- import net.aeon.epoch.PlayState;
- import net.aeon.epoch.component.AnimatedSprite;
- import net.aeon.epoch.component.Attack;
- @@ -19,6 +21,7 @@ import org.newdawn.slick.geom.Shape;
- import org.newdawn.slick.geom.Transform;
- import org.newdawn.slick.geom.Vector2f;
- import org.newdawn.slick.particles.ConfigurableEmitter;
- +import org.newdawn.slick.particles.ParticleIO;
- /**
- * @author Affian
- @@ -73,7 +76,15 @@ public abstract class Actor {
- value = 0;
- }
- - public abstract ConfigurableEmitter getEmitter();
- + public ConfigurableEmitter getEmitter() {
- + ConfigurableEmitter ce = null;
- + try {
- + ce = ParticleIO.loadEmitter("/resources/newExplosion.xml");
- + } catch (IOException e) {
- + e.printStackTrace();
- + }
- + return ce;
- + }
- /**
- * @param container
- @@ -329,7 +340,7 @@ public abstract class Actor {
- public boolean checkCollision(PlayState game, Actor other) {
- if (this.isInvulnerable()) return false;
- if (this.hitBox == null || other.getHitBox() == null) return false;
- - return !isHit() && this.getHitBox().intersects(other.getHitBox());
- + return this.getHitBox().intersects(other.getHitBox());
- }
- diff --git a/src/net/aeon/epoch/actor/Enemy.java b/src/net/aeon/epoch/actor/Enemy.java
- index 61306fd..227a2a7 100644
- --- a/src/net/aeon/epoch/actor/Enemy.java
- +++ b/src/net/aeon/epoch/actor/Enemy.java
- @@ -3,15 +3,12 @@
- */
- package net.aeon.epoch.actor;
- -import java.io.IOException;
- -
- import net.aeon.epoch.PlayState;
- import net.aeon.epoch.component.Controller;
- import net.aeon.epoch.component.Sprite;
- import org.newdawn.slick.geom.Vector2f;
- import org.newdawn.slick.particles.ConfigurableEmitter;
- -import org.newdawn.slick.particles.ParticleIO;
- /**
- * @author Affian
- @@ -63,13 +60,7 @@ public class Enemy extends Actor {
- @Override
- public ConfigurableEmitter getEmitter() {
- - ConfigurableEmitter ce = null;
- - try {
- - ce = ParticleIO.loadEmitter("/resources/newExplosion.xml");
- - } catch (IOException e) {
- - e.printStackTrace();
- - }
- - return ce;
- + return super.getEmitter();
- }
- }
- diff --git a/src/net/aeon/epoch/actor/GroundActor.java b/src/net/aeon/epoch/actor/GroundActor.java
- index 7bfcbf4..bc48503 100644
- --- a/src/net/aeon/epoch/actor/GroundActor.java
- +++ b/src/net/aeon/epoch/actor/GroundActor.java
- @@ -51,7 +51,7 @@ public class GroundActor extends Actor {
- @Override
- public ConfigurableEmitter getEmitter() {
- // TODO Auto-generated method stub
- - return null;
- + return super.getEmitter();
- }
- }
- diff --git a/src/net/aeon/epoch/actor/WeaponPickup.java b/src/net/aeon/epoch/actor/WeaponPickup.java
- index e77dd76..ade916b 100644
- --- a/src/net/aeon/epoch/actor/WeaponPickup.java
- +++ b/src/net/aeon/epoch/actor/WeaponPickup.java
- @@ -17,6 +17,10 @@ public class WeaponPickup extends Pickup {
- private Weapon weapon;
- + public WeaponPickup(Vector2f position) {
- + this(position, null);
- + }
- +
- /**
- * @param position the position of the WeaponPickup
- * @param weapon the weapon that this pickup contains
- @@ -40,4 +44,18 @@ public class WeaponPickup extends Pickup {
- return null;
- }
- + /**
- + * @return the weapon
- + */
- + public Weapon getWeapon() {
- + return weapon;
- + }
- +
- + /**
- + * @param weapon the weapon to set
- + */
- + public void setWeapon(Weapon weapon) {
- + this.weapon = weapon;
- + }
- +
- }
- diff --git a/src/net/aeon/epoch/weapon/PlasmaCannon.java b/src/net/aeon/epoch/weapon/PlasmaCannon.java
- index e537160..38381f3 100644
- --- a/src/net/aeon/epoch/weapon/PlasmaCannon.java
- +++ b/src/net/aeon/epoch/weapon/PlasmaCannon.java
- @@ -6,7 +6,6 @@ package net.aeon.epoch.weapon;
- import java.util.ArrayList;
- import net.aeon.epoch.PlayState;
- -import net.aeon.epoch.ResourceManager;
- import net.aeon.epoch.actor.Bullet;
- import net.aeon.epoch.actor.Actor.Team;
- import net.aeon.epoch.component.LinearController;
- @@ -37,9 +36,9 @@ public class PlasmaCannon implements Weapon {
- public PlasmaCannon() {
- level = 1;
- cooldown = 0;
- - fireDelay = 100;
- + fireDelay = 120;
- - shoot = ResourceManager.getInstance().getSound("shoot");
- +// shoot = ResourceManager.getInstance().getSound("shoot");
- }
- @@ -53,22 +52,48 @@ public class PlasmaCannon implements Weapon {
- ArrayList<Bullet> bullets = new ArrayList<Bullet>();
- SpriteSheet sprites = game.getResourceManager().getSpriteSheet("bullets");
- - switch (level) {
- - case 1:
- - Bullet bullet = new Bullet();
- - Vector2f center = new Vector2f(game.getPlayer().getPosition());
- -
- - center.y -= 10;
- - bullet.setPower(5);
- +
- + Bullet bullet = new Bullet();
- + Vector2f center = new Vector2f(game.getPlayer().getPosition());
- +
- + center.y -= 10;
- + bullet.setPower(5);
- + bullet.setTeam(Team.PLAYER);
- + bullet.setSprite(sprites.getSubImage(2, 3));
- + bullet.setHitBox(new Rectangle(0,0,10,10));
- + bullet.setPosition(new Vector2f(center));
- + bullet.setController(new LinearController(bullet, 0.4f, 0));
- + bullets.add(bullet);
- +// bullets.add(createBullet(sprites, center, 5, 2, 3, 0.4f, 0));
- +
- +
- + if (level > 1) {
- + bullet = new Bullet();
- + center.y += 5;
- + center.x -= 12;
- + bullet.setPower(4);
- bullet.setTeam(Team.PLAYER);
- - bullet.setSprite(sprites.getSubImage(2, 3));
- + bullet.setSprite(sprites.getSubImage(1, 3));
- bullet.setHitBox(new Rectangle(0,0,10,10));
- bullet.setPosition(new Vector2f(center));
- bullet.setController(new LinearController(bullet, 0.4f, 0));
- bullets.add(bullet);
- +// bullets.add(createBullet(sprites, center, 4, 1, 3, 0.4f, 0));
- bullet = new Bullet();
- - center.x += 10;
- + center.x += 24;
- + bullet.setPower(4);
- + bullet.setTeam(Team.PLAYER);
- + bullet.setSprite(sprites.getSubImage(1, 3));
- + bullet.setHitBox(new Rectangle(0,0,10,10));
- + bullet.setPosition(new Vector2f(center));
- + bullet.setController(new LinearController(bullet, 0.4f, 0));
- + bullets.add(bullet);
- +// bullets.add(createBullet(sprites, center, 4, 1, 3, 0.4f, 0));
- + }
- + if (level > 2) {
- + bullet = new Bullet();
- + center.x -= 2;
- bullet.setPower(4);
- bullet.setTeam(Team.PLAYER);
- bullet.setHitBox(new Rectangle(0,0,10,10));
- @@ -77,6 +102,7 @@ public class PlasmaCannon implements Weapon {
- bullet.setSprite(sprites.getSubImage(13, 14));
- bullet.setController(new LinearController(bullet, 0.4f, 35));
- bullets.add(bullet);
- +// bullets.add(createBullet(sprites, center, 4, 13, 14, 0.4f, 35));
- bullet = new Bullet();
- center.x -= 20;
- @@ -88,13 +114,16 @@ public class PlasmaCannon implements Weapon {
- bullet.setSprite(sprites.getSubImage(12, 14));
- bullet.setController(new LinearController(bullet, 0.4f, 325));
- bullets.add(bullet);
- +// bullets.add(createBullet(sprites, center, 4, 12, 14, 0.4f, 325));
- + }
- + if (level > 3) {
- +
- + }
- + if (level > 4) {
- - break;
- - default:
- - break;
- }
- game.addActors(bullets);
- - shoot.play(1, 0.5f);
- +// shoot.play(1, 0.5f);
- cooldown = fireDelay;
- }
- @@ -130,5 +159,28 @@ public class PlasmaCannon implements Weapon {
- level = 1;
- cooldown = 0;
- }
- +
- + /**
- + * Helper function for creating a plasma bullet
- + * @param ss SpriteSheet
- + * @param pos Position of bullet
- + * @param p Power
- + * @param sx X index of sprite in SpriteSheet
- + * @param sy Y index of sprite in SpriteSheet
- + * @param s Speed
- + * @param h Heading
- + * @return bullet
- + */
- + private Bullet createBullet(SpriteSheet ss, Vector2f pos, int p, int sx, int sy, float s, float h) {
- + Bullet bullet = new Bullet();
- + bullet.setPower(p);
- + bullet.setTeam(Team.PLAYER);
- + bullet.setHitBox(new Rectangle(0,0,10,10));
- + bullet.setPosition(new Vector2f(pos));
- + bullet.setHeading(h);
- + bullet.setSprite(ss.getSubImage(sx, sy));
- + bullet.setController(new LinearController(bullet, s, h));
- + return bullet;
- + }
- }
Add Comment
Please, Sign In to add comment