Robot Devastation
GameState.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_GAME_STATE_HPP__
6 #define __RD_GAME_STATE_HPP__
7 
8 #include "State.hpp"
9 #include "ManagerHub.hpp"
10 #include "InputEventListener.hpp"
11 #include "ImageEventListener.hpp"
12 #include "NetworkManager.hpp"
13 #include "ImageManager.hpp"
14 #include "InputManager.hpp"
15 #include "MentalMap.hpp"
16 #include "IRobotManager.hpp"
17 #include "AudioManager.hpp"
18 #include "ScreenManager.hpp"
19 #include "Key.hpp"
20 #include "WindowEvent.hpp"
21 #include "ProcessorImageEventListener.hpp"
22 #include "GameScreen.hpp"
23 
24 namespace rd{
25 
36 class GameState : public State, public ManagerHub,
38 {
39  public:
40  GameState(NetworkManager * networkManager, ImageManager * imageManager,
41  InputManager * inputManager, MentalMap * mentalMap,
42  asrob::IRobotManager * robotManager, AudioManager * audioManager,
43  ScreenManager * screenManager);
44  virtual ~GameState();
45  virtual bool setup();
46  virtual bool loop();
47  virtual bool cleanup();
48  virtual int evaluateConditions();
49 
50  static const int KILLED;
51  static const int EXIT_REQUESTED;
52 
53  //-- InputEventListener interface:
54  virtual bool onKeyDown(const Key & k);
55  virtual bool onKeyUp(const Key & k);
56  virtual bool onWindowEvent(const WindowEvent & event);
57 
58  //-- ImageEventListener interface
59  virtual bool onImageArrived(ImageManager * manager);
60 
61  //-- Define keys that trigger actions
62  static const Key KEY_EXIT;
63  static const Key KEY_SHOOT;
64  static const Key KEY_RELOAD;
65  static const Key KEY_MOVE_FWD;
66  static const Key KEY_MOVE_BACK;
67  static const Key KEY_TURN_LEFT;
68  static const Key KEY_TURN_RIGHT;
69  static const Key KEY_PAN_LEFT;
70  static const Key KEY_PAN_RIGHT;
71  static const Key KEY_TILT_UP;
72  static const Key KEY_TILT_DOWN;
73 
74  protected:
75  GameScreen screen;
76  bool received_exit;
77  ProcessorImageEventListener processorImageEventListener;
78  Image last_camera_frame;
79 
80 
81 };
82 
83 
84 }
85 #endif // __RD_GAME_STATE_HPP__
rd::GameState::setup
virtual bool setup()
Function executed just before the loop function, when the state is enabled.
Definition: GameState.cpp:42
rd::MentalMap
Mental map is a repository for information about the players, targets and weapons.
Definition: MentalMap.hpp:38
rd::AudioManager
Music and sound effects manager.
Definition: AudioManager.hpp:28
rd::GameState
Game State.
Definition: GameState.hpp:36
rd::ImageEventListener
Interface for objects that can be notified of events related to images.
Definition: ImageEventListener.hpp:21
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::GameState::onKeyUp
virtual bool onKeyUp(const Key &k)
This function will be called whenever a key is released on the keyboard.
Definition: GameState.cpp:237
rd::GameState::onKeyDown
virtual bool onKeyDown(const Key &k)
This function will be called whenever a key is pressed on the keyboard.
Definition: GameState.cpp:161
rd::GameState::onWindowEvent
virtual bool onWindowEvent(const WindowEvent &event)
This function will be called whenever a window event is raised.
Definition: GameState.cpp:293
rd::InputEventListener
Interface for objects that can be notified of input events by the InputManager.
Definition: InputEventListener.hpp:20
rd::ProcessorImageEventListener
ProcessorImageEventListener used for processing.
Definition: ProcessorImageEventListener.hpp:28
rd::GameState::loop
virtual bool loop()
Function executed periodically when the state is active.
Definition: GameState.cpp:109
rd::Key
Class that represents a keyboard key.
Definition: Key.hpp:23
rd::State
Base class for each of the states of a FiniteStateMachine.
Definition: State.hpp:18
rd::GameScreen
A User Interface.
Definition: GameScreen.hpp:28
rd::InputManager
User input manager (keyboard, mouse, joysticks, etc)
Definition: InputManager.hpp:35
rd::GameState::cleanup
virtual bool cleanup()
Function excuted when this state is going to be stopped (due to an error or a transition)
Definition: GameState.cpp:129
rd::ManagerHub
A classs to interface all the robotDevastation managers. As some classes, such as the game states,...
Definition: ManagerHub.hpp:28
rd::GameState::evaluateConditions
virtual int evaluateConditions()
This function is called after each call to loop() in order to know the transition to make.
Definition: GameState.cpp:150
rd::ScreenManager
Manage game screens.
Definition: ScreenManager.hpp:35
rd::WindowEvent
Class that represents a window event.
Definition: WindowEvent.hpp:19
rd::GameState::onImageArrived
virtual bool onImageArrived(ImageManager *manager)
This function will be called whenever a image arrives to the ImageManager.
Definition: GameState.cpp:304
rd::NetworkManager
Manages the communications between the user and the RobotDevastation network.
Definition: NetworkManager.hpp:37
rd::ImageManager
Generic image input manager.
Definition: ImageManager.hpp:39