diff options
author | pacien | 2018-02-02 11:46:03 +0100 |
---|---|---|
committer | pacien | 2018-02-02 11:46:03 +0100 |
commit | 6d05e0e8b91ccdd69a8f45227104a543febf5982 (patch) | |
tree | 0d6a113121f21dfcde240deeb16968c9d4540d71 /src | |
parent | a70916c1aba32f9ea52221e30e3882786911aaf2 (diff) | |
download | wallj-6d05e0e8b91ccdd69a8f45227104a543febf5982.tar.gz |
Implement bomb explosion and deletion event generation
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'src')
5 files changed, 13 insertions, 14 deletions
diff --git a/src/docs/class.puml b/src/docs/class.puml index 5c95e18..a889371 100644 --- a/src/docs/class.puml +++ b/src/docs/class.puml | |||
@@ -91,18 +91,16 @@ package event { | |||
91 | } | 91 | } |
92 | 92 | ||
93 | class BombSetupEvent implements GameEvent { | 93 | class BombSetupEvent implements GameEvent { |
94 | final TileVec2 | 94 | BombSetupEvent(TileVec2) |
95 | AddBombEvent(TileVec2) | 95 | TileVec2 getSource() |
96 | TileVec2 getTile() | ||
97 | } | 96 | } |
98 | 97 | ||
99 | class GameOverEvent implements GameEvent | 98 | class BombExplosionEvent implements GameEvent { |
100 | 99 | BombExplosionEvent(TileVec2) | |
101 | class ExplosionEvent implements GameEvent { | 100 | TileVec2 getSource() |
102 | Block source | ||
103 | Body source | ||
104 | } | 101 | } |
105 | 102 | ||
103 | class GameOverEvent implements GameEvent | ||
106 | class StageClearedEvent implements GameEvent | 104 | class StageClearedEvent implements GameEvent |
107 | class BlockCreateEvent implements GameEvent | 105 | class BlockCreateEvent implements GameEvent |
108 | class BlockDestroyEvent implements GameEvent | 106 | class BlockDestroyEvent implements GameEvent |
diff --git a/src/main/java/fr/umlv/java/wallj/block/BombBlock.java b/src/main/java/fr/umlv/java/wallj/block/BombBlock.java index f58f1cc..baf10b3 100644 --- a/src/main/java/fr/umlv/java/wallj/block/BombBlock.java +++ b/src/main/java/fr/umlv/java/wallj/block/BombBlock.java | |||
@@ -3,6 +3,7 @@ package fr.umlv.java.wallj.block; | |||
3 | import fr.umlv.java.wallj.board.TileVec2; | 3 | import fr.umlv.java.wallj.board.TileVec2; |
4 | import fr.umlv.java.wallj.context.Context; | 4 | import fr.umlv.java.wallj.context.Context; |
5 | import fr.umlv.java.wallj.context.GraphicsContext; | 5 | import fr.umlv.java.wallj.context.GraphicsContext; |
6 | import fr.umlv.java.wallj.event.*; | ||
6 | import fr.umlv.java.wallj.event.Event; | 7 | import fr.umlv.java.wallj.event.Event; |
7 | import org.jbox2d.common.Vec2; | 8 | import org.jbox2d.common.Vec2; |
8 | import org.jbox2d.dynamics.BodyType; | 9 | import org.jbox2d.dynamics.BodyType; |
@@ -47,14 +48,14 @@ public class BombBlock extends JBoxBlock { | |||
47 | } | 48 | } |
48 | 49 | ||
49 | private boolean containsUpdateEvent(List<Event> events) { | 50 | private boolean containsUpdateEvent(List<Event> events) { |
50 | return false; // TODO: contains PutBombEvent with same current tile location? | 51 | return Events.findFirst(events, BombSetupEvent.class).isPresent(); |
51 | } | 52 | } |
52 | 53 | ||
53 | private List<Event> consume(Duration timeDelta) { | 54 | private List<Event> consume(Duration timeDelta) { |
54 | decrementTimer(timeDelta); | 55 | decrementTimer(timeDelta); |
55 | 56 | ||
56 | if (timer.isNegative()) | 57 | if (timer.isNegative()) |
57 | return Collections.unmodifiableList(Arrays.asList()); // TODO: BombExplosionEvent and BlockRemoveEvent | 58 | return Arrays.asList(new BombExplosionEvent(TileVec2.of(getPos())), new BlockDestroyEvent(this)); |
58 | else | 59 | else |
59 | return Collections.emptyList(); | 60 | return Collections.emptyList(); |
60 | } | 61 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java b/src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java index c0baa83..577371d 100644 --- a/src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java +++ b/src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java | |||
@@ -9,7 +9,7 @@ import java.util.Objects; | |||
9 | * | 9 | * |
10 | * @author Pacien TRAN-GIRARD | 10 | * @author Pacien TRAN-GIRARD |
11 | */ | 11 | */ |
12 | public final class BombExplosionEvent { | 12 | public final class BombExplosionEvent implements GameEvent { |
13 | private final TileVec2 source; | 13 | private final TileVec2 source; |
14 | 14 | ||
15 | public BombExplosionEvent(TileVec2 source) { | 15 | public BombExplosionEvent(TileVec2 source) { |
diff --git a/src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java b/src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java index 2e5cf98..620eea2 100644 --- a/src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java +++ b/src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java | |||
@@ -5,7 +5,7 @@ import fr.umlv.java.wallj.board.TileVec2; | |||
5 | import java.util.Objects; | 5 | import java.util.Objects; |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * Bomb setup event. | 8 | * Bomb setup event signalling the creation or the update of a bomb at a given position. |
9 | * | 9 | * |
10 | * @author Pacien TRAN-GIRARD | 10 | * @author Pacien TRAN-GIRARD |
11 | */ | 11 | */ |
diff --git a/src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java b/src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java index 25f0048..9e95eb3 100644 --- a/src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java +++ b/src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java | |||
@@ -1,9 +1,9 @@ | |||
1 | package fr.umlv.java.wallj.event; | 1 | package fr.umlv.java.wallj.event; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Event to signal that a bomb will be placed at the next tick | 4 | * Asks a robot to drop a bomb. |
5 | * | 5 | * |
6 | * @author Adam NAILI | 6 | * @author Pacien TRAN-GIRARD |
7 | */ | 7 | */ |
8 | public final class BombSetupOrder implements InputEvent { | 8 | public final class BombSetupOrder implements InputEvent { |
9 | // void | 9 | // void |