Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/campaign.cc @ 6855

Last change on this file since 6855 was 6834, checked in by bensch, 19 years ago

trunk: less debug

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#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_STORY_ENTITY
18
19#include "campaign.h"
20
21#include "factory.h"
22#include "load_param.h"
23
24#include "campaign_data.h"
25
26using namespace std;
27
28
29/**
30 *  the constructor
31 * @param root the XML root element
32 *
33 * this constructor is always called in a XML context (loading procedure)
34 */
35Campaign::Campaign ( TiXmlElement* root)
36{
37  this->setClassID(CL_CAMPAIGN, "Campaign");
38
39  PRINTF(4)("Loading Campaign...\n");
40  assert( root != NULL);
41
42  this->campaignData = new CampaignData(root);
43  this->loadParams(root);
44
45}
46
47
48/**
49 * the campaign destructor
50 */
51Campaign::~Campaign ()
52{
53  if( this->campaignData)
54    delete this->campaignData;
55}
56
57
58/**
59 *  loads the Parameters of a Campaign
60 * @param root: The XML-element to load from
61 */
62void Campaign::loadParams(const TiXmlElement* root)
63{
64  StoryEntity::loadParams(root);
65
66  PRINTF(4)("Loaded Campaign specific stuff\n");
67}
68
69
70/**
71 *  starts the campaing with a specific ID
72 * @param storyID the id of the StoryEntity
73 */
74bool Campaign::start()
75{
76  PRINTF(2)("Starting Campaign nr. %i\n", this->getStoryID());
77
78  this->isRunning = true;
79  this->run();
80}
81
82
83/**
84 *  pauses the campaign
85 */
86bool Campaign::pause()
87{
88  this->isPaused = true;
89}
90
91
92/**
93 *  resumes the campaign after a pause
94 */
95bool Campaign::resume()
96{
97  PRINTF(4)("Resuming the current Campaign\n");
98  this->isPaused = false;
99}
100
101
102/**
103 *  stops the campaign
104 */
105bool Campaign::stop()
106{
107  PRINTF(4)("Stopping the current Campaign\n");
108  this->isRunning = false;
109  if( this->currentEntity != NULL)
110  {
111    this->currentEntity->stop();
112  }
113}
114
115
116/**
117 *  runs the campaign
118 */
119void Campaign::run()
120{
121  ErrorMessage       errorCode;
122  int                storyID = WORLD_ID_0;
123
124  for( this->currentEntity = this->campaignData->getFirstLevel(), this->isRunning = true;
125       this->currentEntity != NULL && this->isRunning;
126       this->currentEntity = this->campaignData->getNextLevel())
127  {
128    PRINTF(0)("Campaign is starting StoryEntity nr:%i\n", this->currentEntity->getStoryID());
129
130    this->currentEntity->init();
131
132    this->currentEntity->loadData();
133    this->currentEntity->start();
134    this->currentEntity->unloadData();
135  }
136  PRINTF(2)("There is no StoryEnity left to play, quitting\n");
137}
138
139
140/**
141 *  this changes to the next level
142 */
143void Campaign::switchToNextLevel()
144{
145  PRINTF(4)("Switching to the next StoryEntity\n");
146  this->currentEntity->stop();
147}
148
149
Note: See TracBrowser for help on using the repository browser.