Emergency 20 Dokumentation  4.2.0
CampaignGameMode.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
15 
16 
17 //[-------------------------------------------------------]
18 //[ Forward declarations ]
19 //[-------------------------------------------------------]
20 namespace em5
21 {
22  class CampaignProgress;
23 }
24 
25 
26 //[-------------------------------------------------------]
27 //[ Namespace ]
28 //[-------------------------------------------------------]
29 namespace em5
30 {
31 
32 
33  //[-------------------------------------------------------]
34  //[ Classes ]
35  //[-------------------------------------------------------]
41  {
42 
43 
44  //[-------------------------------------------------------]
45  //[ Friends ]
46  //[-------------------------------------------------------]
47  friend class FreeplaySystem; // Sets "em5::CampaignGameMode::mCampaignIndex"
48 
49 
50  //[-------------------------------------------------------]
51  //[ Public methods ]
52  //[-------------------------------------------------------]
53  public:
59 
64  virtual ~CampaignGameMode();
65 
70  void initNextMap(bool triggerStartGame);
71 
76  bool isMainEvent() const;
77 
82  bool isMiniEvent() const;
83 
88  bool getReceivedRepeatSignal() const;
89 
90 
91  //[-------------------------------------------------------]
92  //[ Public virtual em5::GameMode methods ]
93  //[-------------------------------------------------------]
94  public:
95  virtual std::string getGameModeAsString() const override;
96  virtual void startup() override;
97  virtual void shutdown() override;
98  virtual void onGameLoaded() override;
99  virtual void updateGameMode(qsf::Time timePassed) override;
100  virtual void onSendGameModeSignal(const std::string& gameModeSignal) override;
101 
102 
103  //[-------------------------------------------------------]
104  //[ Protected virtual em5::FreeplayGameMode methods ]
105  //[-------------------------------------------------------]
106  protected:
107  virtual void onEventSucceeded(const qsf::MessageParameters& parameters) override;
108  virtual void onEventFailed(const qsf::MessageParameters& parameters) override;
109  virtual void onReceiveObjectivePoints(const qsf::MessageParameters& parameters) override;
110  // Gets called when through a successful event some points should be added to players point "pool"
111  virtual void onSetPointGain(const FreeplayEvent::EventResult& eventResult, int32 pointGain) override;
112  virtual std::string getIntroVideo(uint32 index) override;
113 
114 
115  //[-------------------------------------------------------]
116  //[ Private definitions ]
117  //[-------------------------------------------------------]
118  private:
119  enum PhaseState
120  {
121  STATE_PENDING,
122  STATE_RUNNING,
123  STATE_ENDED,
124  STATE_FADEOUT,
125  STATE_FAILED,
126  STATE_UNDEFINED
127  };
128 
129  enum HQExtendedState
130  {
131  HQSTATE_NONE,
132  HQSTATE_EXTENDED,
133  HQSTATE_NOT_EXTENDED
134  };
135 
136 
137  //[-------------------------------------------------------]
138  //[ Private methods ]
139  //[-------------------------------------------------------]
140  private:
141  void startPhase();
142  void updatePhase(qsf::Time timePassed);
143  void phaseEnded();
144  void phaseFadeout();
145  void phaseFailed();
146 
147  void gotoNextPhase();
148 
149  void setUnitPoolByName(const std::string& unitPoolName);
150  void applyBuyOptions(const std::vector<Player::BuyOption>& buyOptions);
151  bool checkBuyOptions(const std::vector<Player::BuyOption>& buyOptions) const;
152  uint32 getRemainingBuyOptionsCost(const std::vector<Player::BuyOption>& buyOptions) const;
153  void clearBoughtUnits();
154 
155  void onSetPointGain(int32 pointGain);
156  void showPromotionWindow();
157 
158  void onOutroFadeOutFinished(const qsf::MessageParameters&);
159  void onOutroCutsceneFinished(const qsf::MessageParameters&);
160  void onEventFinishFadeOutFinished(const qsf::MessageParameters&);
161  void onEventFinishFadeInFinished(const qsf::MessageParameters&);
162 
163  std::string getBackgroundMusicByMapIdentifier(const std::string& mapIdentifier, uint32 campaginIndex);
164 
165 
166  //[-------------------------------------------------------]
167  //[ Private data ]
168  //[-------------------------------------------------------]
169  private:
170  uint32 mCampaignIndex;
171  const CampaignDefinition* mCurrentCampaign;
172  const CampaignDefinition::CampaignPhaseArray* mCurrentMapPhases;
173  const CampaignDefinition::CampaignPhase* mCurrentPhase;
174  std::shared_ptr<CampaignProgress> mCampaignProgress;
175 
176  uint32 mCurrentMapIndex;
177  uint32 mCurrentPhaseIndex;
178  PhaseState mPhaseState;
179  bool mFirstPhaseStart;
180  HQExtendedState mHQExtendedState;
181  uint32 mSuccessfulEvents;
182  uint32 mFailedEvents;
183  bool mAddedBuyOptions;
184  bool mWorldEventsAdded;
185  bool mReceivedContinueSignal;
186  bool mReceivedRepeatSignal;
187  bool mHaveToShowPromotionWindow;
188  qsf::Time mTimeUntilNextBuyHint;
189  qsf::Time mDelayToNextPhaseDelayTime;
190  bool mMadeChangesDueToDifficulty;
191  float mOriginalFireDamageConvert;
192 
193 
194  //[-------------------------------------------------------]
195  //[ CAMP reflection system ]
196  //[-------------------------------------------------------]
197  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
198 
199 
200  };
201 
202 
203 //[-------------------------------------------------------]
204 //[ Namespace ]
205 //[-------------------------------------------------------]
206 } // em5
207 
208 
209 //[-------------------------------------------------------]
210 //[ CAMP reflection system ]
211 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Definition: FreeplayEvent.h:110
Message parameters class.
Definition: MessageParameters.h:34
unsigned int uint32
Definition: PlatformTypes.h:181
virtual std::string getIntroVideo(uint32 index) override
bool getReceivedRepeatSignal() const
Received repeat signal?
std::vector< CampaignPhase > CampaignPhaseArray
Definition: CampaignDefinition.h:69
bool isMiniEvent() const
Are we in a mini-event phase right now?
virtual void onSendGameModeSignal(const std::string &gameModeSignal) override
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
void initNextMap(bool triggerStartGame)
Go to next map in campaign progress.
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
signed int int32
Definition: PlatformTypes.h:180
virtual void onEventFailed(const qsf::MessageParameters &parameters) override
virtual void updateGameMode(qsf::Time timePassed) override
CampaignGameMode()
Default constructor.
virtual void onReceiveObjectivePoints(const qsf::MessageParameters &parameters) override
virtual void onSetPointGain(const FreeplayEvent::EventResult &eventResult, int32 pointGain) override
virtual void startup() override
virtual std::string getGameModeAsString() const override
Return the game mode type as string (lowercase)
virtual void shutdown() override
bool isMainEvent() const
Are we in a main-event phase right now?
virtual void onGameLoaded() override
EMERGENCY 5 freeplay game mode.
Definition: FreeplayGameMode.h:48
virtual void onEventSucceeded(const qsf::MessageParameters &parameters) override
EMERGENCY 5 campaign game mode.
Definition: CampaignGameMode.h:40
virtual ~CampaignGameMode()
Destructor.
EMERGENCY 5 freeplay system.
Definition: FreeplaySystem.h:55
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32