Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6793 was 6512, checked in by bensch, 19 years ago

orxonox/trunk: loadParams is now virtual.
ALL THE CLASSES HAVE TO CALL

SuperClass::loadParams(root);

isntead of:
static_cast<SuperClass*>(this)→loadParams(root);

which was quite stupid anyways

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