Revisão | 91ae155d5b47b8a82b0e4bfe1b288689944079b5 (tree) |
---|---|
Hora | 2016-09-17 05:42:55 |
Autor | sebastian_ <bugiu@head...> |
Commiter | sebastian_ |
Loading level.
@@ -0,0 +1,5 @@ | ||
1 | +#include "BoilerExplosion.h" | |
2 | + | |
3 | +void BoilerExplosionEvent::operator()() | |
4 | +{ | |
5 | +} |
@@ -0,0 +1,13 @@ | ||
1 | +#ifndef _BOILER_EXPLOSION_H_ | |
2 | +#define _BOILER_EXPLOSION_H_ | |
3 | + | |
4 | +#include "Event.h" | |
5 | + | |
6 | +class BoilerExplosionEvent : public GameEvent::Event | |
7 | +{ | |
8 | +public: | |
9 | + void operator()() override; | |
10 | +}; | |
11 | + | |
12 | +#endif | |
13 | + |
@@ -7,17 +7,22 @@ | ||
7 | 7 | class EventProperties : public artemis::Component |
8 | 8 | { |
9 | 9 | private: |
10 | - std::unique_ptr<GameEvent::Event> event; | |
10 | + std::shared_ptr<GameEvent::Event> event; | |
11 | 11 | int scoreIncrease; |
12 | 12 | bool eventDone; |
13 | 13 | |
14 | 14 | public: |
15 | - EventProperties() | |
15 | + EventProperties(std::unique_ptr<GameEvent::Event> event_) : event(std::move(event_)) | |
16 | 16 | { |
17 | 17 | |
18 | 18 | } |
19 | 19 | |
20 | 20 | |
21 | + std::shared_ptr<GameEvent::Event> getEvent() const | |
22 | + { | |
23 | + return event; | |
24 | + } | |
25 | + | |
21 | 26 | int getScoreIncrease() const |
22 | 27 | { |
23 | 28 | return scoreIncrease; |
@@ -1,1 +1,20 @@ | ||
1 | -#include "EventRelation.h" | |
\ No newline at end of file | ||
1 | +#include "EventRelation.h" | |
2 | + | |
3 | +EventRelation::EventRelation(artemis::Entity& controller_, artemis::World& world) : controller(controller_) | |
4 | +{ | |
5 | + eventPropertiesMapper.init(world); | |
6 | +} | |
7 | + | |
8 | +void EventRelation::addAffectedEntity(artemis::Entity& entity) | |
9 | +{ | |
10 | + affectedEntities.push_back(entity); | |
11 | +} | |
12 | + | |
13 | +void EventRelation::affectEntities() | |
14 | +{ | |
15 | + for (auto& entity : affectedEntities) | |
16 | + { | |
17 | + auto eventProperties = eventPropertiesMapper.get(entity); | |
18 | + (*eventProperties->getEvent())(); | |
19 | + } | |
20 | +} |
@@ -1,9 +1,26 @@ | ||
1 | 1 | #ifndef _EVENT_RELATION_H_ |
2 | 2 | #define _EVENT_RELATION_H_ |
3 | +#include <vector> | |
4 | +#include "EventProperties.h" | |
5 | +#include "artemis/src/Artemis/ComponentMapper.h" | |
6 | + | |
7 | +namespace artemis{ | |
8 | + class Entity; | |
9 | +} | |
3 | 10 | |
4 | 11 | class EventRelation |
5 | 12 | { |
6 | - | |
13 | +private: | |
14 | + artemis::Entity& controller; | |
15 | + std::vector<std::reference_wrapper<artemis::Entity>> affectedEntities; | |
16 | + artemis::ComponentMapper<EventProperties> eventPropertiesMapper; | |
17 | + | |
18 | +public: | |
19 | + EventRelation(artemis::Entity& controller_, artemis::World& world); | |
20 | + | |
21 | + void addAffectedEntity(artemis::Entity& entity); | |
22 | + | |
23 | + void affectEntities(); | |
7 | 24 | }; |
8 | 25 | |
9 | 26 | #endif |
@@ -0,0 +1,5 @@ | ||
1 | +#include "GateChange.h" | |
2 | + | |
3 | +void GateChangeEvent::operator()() | |
4 | +{ | |
5 | +} |
@@ -0,0 +1,12 @@ | ||
1 | +#ifndef _GATE_CHANGE_H_ | |
2 | +#define _GATE_CHANGE_H_ | |
3 | +#include "Event.h" | |
4 | + | |
5 | +class GateChangeEvent : public GameEvent::Event | |
6 | +{ | |
7 | +public: | |
8 | + void operator()() override; | |
9 | +}; | |
10 | + | |
11 | +#endif | |
12 | + |
@@ -1,5 +1,10 @@ | ||
1 | 1 | #include "GateControl.h" |
2 | 2 | |
3 | +GateControlEvent::GateControlEvent(std::unique_ptr<EventRelation> eventRelation_) : eventRelation(std::move(eventRelation_)) | |
4 | +{ | |
5 | +} | |
6 | + | |
3 | 7 | void GateControlEvent::operator()() |
4 | 8 | { |
9 | + eventRelation->affectEntities(); | |
5 | 10 | } |
@@ -1,11 +1,18 @@ | ||
1 | 1 | #ifndef _GATE_CONTROL_H_ |
2 | 2 | #define _GATE_CONTROL_H_ |
3 | 3 | #include "Event.h" |
4 | +#include "EventRelation.h" | |
5 | +#include <memory> | |
4 | 6 | |
5 | 7 | class GateControlEvent : public GameEvent::Event |
6 | 8 | { |
9 | +private: | |
10 | + std::unique_ptr<EventRelation> eventRelation; | |
7 | 11 | public: |
12 | + explicit GateControlEvent(std::unique_ptr<EventRelation> eventRelation); | |
13 | + | |
8 | 14 | void operator()() override; |
15 | + | |
9 | 16 | }; |
10 | 17 | |
11 | 18 | #endif |
@@ -0,0 +1,5 @@ | ||
1 | +#include "KillBoss.h" | |
2 | + | |
3 | +void KillBossEvent::operator()() | |
4 | +{ | |
5 | +} |
@@ -0,0 +1,13 @@ | ||
1 | +#ifndef _KILL_BOSS_H_ | |
2 | +#define _KILL_BOSS_H_ | |
3 | + | |
4 | +#include "Event.h" | |
5 | + | |
6 | +class KillBossEvent : public GameEvent::Event | |
7 | +{ | |
8 | +public: | |
9 | + void operator()() override; | |
10 | +}; | |
11 | + | |
12 | +#endif | |
13 | + |
@@ -160,14 +160,17 @@ | ||
160 | 160 | <ClCompile Include="..\Classes\artemis\src\TagManager.cpp" /> |
161 | 161 | <ClCompile Include="..\Classes\artemis\src\VoidEntitySystem.cpp" /> |
162 | 162 | <ClCompile Include="..\Classes\artemis\src\World.cpp" /> |
163 | + <ClCompile Include="..\Classes\BoilerExplosion.cpp" /> | |
163 | 164 | <ClCompile Include="..\Classes\CollisionDetectionSystem.cpp" /> |
164 | 165 | <ClCompile Include="..\Classes\ControlPanel.cpp" /> |
165 | 166 | <ClCompile Include="..\Classes\CreditsMenuScene.cpp" /> |
166 | 167 | <ClCompile Include="..\Classes\EventRelation.cpp" /> |
168 | + <ClCompile Include="..\Classes\GateChange.cpp" /> | |
167 | 169 | <ClCompile Include="..\Classes\GateControl.cpp" /> |
168 | 170 | <ClCompile Include="..\Classes\HighScoreScene.cpp" /> |
169 | 171 | <ClCompile Include="..\Classes\GameScene.cpp" /> |
170 | 172 | <ClCompile Include="..\Classes\InGameMenuScene.cpp" /> |
173 | + <ClCompile Include="..\Classes\KillBoss.cpp" /> | |
171 | 174 | <ClCompile Include="..\Classes\Level.cpp" /> |
172 | 175 | <ClCompile Include="..\Classes\LevelUpdateSystem.cpp" /> |
173 | 176 | <ClCompile Include="..\Classes\MainMenuScene.cpp" /> |
@@ -210,6 +213,7 @@ | ||
210 | 213 | <ClInclude Include="..\Classes\artemis\src\Artemis\TypeInfoComparator.h" /> |
211 | 214 | <ClInclude Include="..\Classes\artemis\src\Artemis\VoidEntitySystem.h" /> |
212 | 215 | <ClInclude Include="..\Classes\artemis\src\Artemis\World.h" /> |
216 | + <ClInclude Include="..\Classes\BoilerExplosion.h" /> | |
213 | 217 | <ClInclude Include="..\Classes\CollisionDetectionSystem.h" /> |
214 | 218 | <ClInclude Include="..\Classes\ControlPanel.h" /> |
215 | 219 | <ClInclude Include="..\Classes\CreditsMenuScene.h" /> |
@@ -219,9 +223,11 @@ | ||
219 | 223 | <ClInclude Include="..\Classes\EventRelation.h" /> |
220 | 224 | <ClInclude Include="..\Classes\GameResources.h" /> |
221 | 225 | <ClInclude Include="..\Classes\GameScene.h" /> |
226 | + <ClInclude Include="..\Classes\GateChange.h" /> | |
222 | 227 | <ClInclude Include="..\Classes\GateControl.h" /> |
223 | 228 | <ClInclude Include="..\Classes\HighScoreScene.h" /> |
224 | 229 | <ClInclude Include="..\Classes\InGameMenuScene.h" /> |
230 | + <ClInclude Include="..\Classes\KillBoss.h" /> | |
225 | 231 | <ClInclude Include="..\Classes\Level.h" /> |
226 | 232 | <ClInclude Include="..\Classes\LevelProperties.h" /> |
227 | 233 | <ClInclude Include="..\Classes\LevelUpdateSystem.h" /> |
@@ -159,6 +159,15 @@ | ||
159 | 159 | <ClCompile Include="..\Classes\EventRelation.cpp"> |
160 | 160 | <Filter>src</Filter> |
161 | 161 | </ClCompile> |
162 | + <ClCompile Include="..\Classes\GateChange.cpp"> | |
163 | + <Filter>src\events</Filter> | |
164 | + </ClCompile> | |
165 | + <ClCompile Include="..\Classes\BoilerExplosion.cpp"> | |
166 | + <Filter>src\events</Filter> | |
167 | + </ClCompile> | |
168 | + <ClCompile Include="..\Classes\KillBoss.cpp"> | |
169 | + <Filter>src\events</Filter> | |
170 | + </ClCompile> | |
162 | 171 | </ItemGroup> |
163 | 172 | <ItemGroup> |
164 | 173 | <ClInclude Include="main.h"> |
@@ -335,6 +344,15 @@ | ||
335 | 344 | <ClInclude Include="..\Classes\EventRelation.h"> |
336 | 345 | <Filter>src</Filter> |
337 | 346 | </ClInclude> |
347 | + <ClInclude Include="..\Classes\GateChange.h"> | |
348 | + <Filter>src\events</Filter> | |
349 | + </ClInclude> | |
350 | + <ClInclude Include="..\Classes\BoilerExplosion.h"> | |
351 | + <Filter>src\events</Filter> | |
352 | + </ClInclude> | |
353 | + <ClInclude Include="..\Classes\KillBoss.h"> | |
354 | + <Filter>src\events</Filter> | |
355 | + </ClInclude> | |
338 | 356 | </ItemGroup> |
339 | 357 | <ItemGroup> |
340 | 358 | <ResourceCompile Include="game.rc"> |