Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/story_entities/campaign.cc @ 6402

Last change on this file since 6402 was 6402, checked in by patrick, 19 years ago

network: more modularity for the GameWorld: data and process are now totaly separated from each other, as it should be. Now I will do some magic on the MultiPlayerWorld, see if it works :D

File size: 2.7 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15*/
16
17
18#include "campaign.h"
19
20#include "factory.h"
21#include "load_param.h"
22
23#include "campaign_data.h"
24
25using namespace std;
26
27
28/**
29 *  the constructor
30 * @param root the XML root element
31 *
32 * this constructor is always called in a XML context (loading procedure)
33 */
34Campaign::Campaign ( TiXmlElement* root)
35{
36  this->setClassID(CL_CAMPAIGN, "Campaign");
37
38  PRINTF(4)("Loading Campaign...\n");
39  assert( root != NULL);
40
41  this->campaignData = new CampaignData(root);
42  this->loadParams(root);
43
44}
45
46
47/**
48 * the campaign destructor
49 */
50Campaign::~Campaign ()
51{
52  if( this->campaignData)
53    delete this->campaignData;
54}
55
56
57/**
58 *  loads the Parameters of a Campaign
59 * @param root: The XML-element to load from
60 */
61void Campaign::loadParams(const TiXmlElement* root)
62{
63  static_cast<StoryEntity*>(this)->loadParams(root);
64
65  PRINTF(4)("Loaded Campaign specific stuff\n");
66}
67
68
69/**
70 *  starts the campaing with a specific ID
71 * @param storyID the id of the StoryEntity
72 */
73bool Campaign::start()
74{
75  PRINTF(2)("Starting Campaign nr. %i\n", this->getStoryID());
76
77  this->isRunning = true;
78  this->run();
79
80  PRINTF(2)("There is no StoryEnity left to play, quitting\n");
81}
82
83
84/**
85 *  pauses the campaign
86 */
87bool Campaign::pause()
88{
89  this->isPaused = true;
90}
91
92
93/**
94 *  resumes the campaign after a pause
95 */
96bool Campaign::resume()
97{
98  PRINTF(4)("Resuming the current Campaign\n");
99  this->isPaused = false;
100}
101
102
103/**
104 *  stops the campaign
105 */
106bool Campaign::stop()
107{
108  PRINTF(4)("Stopping the current Campaign\n");
109  this->isRunning = false;
110  if( this->currentEntity != NULL)
111  {
112    this->currentEntity->stop();
113  }
114}
115
116
117/**
118 *  runs the campaign
119 */
120void Campaign::run()
121{
122  ErrorMessage       errorCode;
123  int                storyID = WORLD_ID_0;
124
125  for( this->currentEntity = this->campaignData->getFirstLevel(), this->isRunning = true;
126       this->currentEntity != NULL && this->isRunning;
127       this->currentEntity = this->campaignData->getNextLevel())
128  {
129    PRINTF(0)("Campaign is starting StoryEntity nr:%i\n", this->currentEntity->getStoryID());
130
131    this->currentEntity->init();
132    this->currentEntity->loadData();
133    this->currentEntity->start();
134    this->currentEntity->unloadData();
135  }
136}
137
138
139/**
140 *  this changes to the next level
141 */
142void Campaign::switchToNextLevel()
143{
144  PRINTF(4)("Switching to the next StoryEntity\n");
145  this->currentEntity->stop();
146}
147
148
Note: See TracBrowser for help on using the repository browser.