Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6402 was 6402, checked in by patrick, 18 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.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
15
16#include "campaign_data.h"
17
18#include "factory.h"
19#include "load_param.h"
20
21#include "story_entity.h"
22
23
24using namespace std;
25
26
27/**
28 * constructor for CampaignData
29 */
30CampaignData::CampaignData(const TiXmlElement* root)
31{
32  this->setClassID(CL_CAMPAIGN_DATA, "CampaignData");
33
34  this->currentEntity = NULL;
35  this->loadParams(root);
36}
37
38
39/**
40 * destructor for CampaignData
41 */
42CampaignData::~CampaignData()
43{
44  PRINTF(3)("Deleting CampaignData\n");
45  while( !this->storyEntities.empty())
46  {
47    StoryEntity* bo = this->storyEntities.back();
48    this->storyEntities.pop_back();
49    PRINTF(3)("CampaignData is been deleted: nr %i\n", bo->getStoryID());
50    delete bo;
51  }
52}
53
54
55
56/**
57 *  loads the Parameters of a Campaign
58 * @param root: The XML-element to load from
59 */
60void CampaignData::loadParams(const TiXmlElement* root)
61{
62  LoadParamXML(root, "WorldList", this, CampaignData, loadParamsWorldList)
63      .describe("A List of Worlds to be loaded in this Campaign");
64
65}
66
67
68/**
69 *  loads a WorldList
70 * @param root: the XML-element to load from
71 */
72void CampaignData::loadParamsWorldList(const TiXmlElement* root)
73{
74  if( root == NULL)
75    return;
76
77  LOAD_PARAM_START_CYCLE(root, element);
78  {
79    StoryEntity* created = (StoryEntity*) Factory::fabricate(element);
80    if( created != NULL)
81      this->addStoryEntity(created);
82  }
83  LOAD_PARAM_END_CYCLE(element);
84}
85
86
87/**
88 *  add the StoryEntity to the campaign data tank
89 * @param se the StoryEntity to add
90 */
91void CampaignData::addStoryEntity(StoryEntity* se)
92{
93  this->storyEntities.push_back(se);
94}
95
96
97/**
98 *  switch to the next level in the list and return it
99 */
100StoryEntity* CampaignData::getFirstLevel()
101{
102  int                            nextStoryID;
103  int                            storyID;
104  list<StoryEntity*>::iterator   it;
105
106  nextStoryID = 0;
107  this->currentEntity = NULL;
108  for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++)
109  {
110    storyID = (*it)->getStoryID();
111    if( storyID == nextStoryID)
112      this->currentEntity = (*it);
113  }
114  return this->currentEntity;
115}
116
117
118/**
119 *  switch to the next level in the list and return it
120 */
121StoryEntity* CampaignData::getNextLevel()
122{
123  int                            nextStoryID;
124  int                            storyID;
125  list<StoryEntity*>::iterator   it;
126
127  nextStoryID = this->currentEntity->getNextStoryID();
128  this->currentEntity = NULL;
129  for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++)
130  {
131    storyID = (*it)->getStoryID();
132    if( storyID == nextStoryID)
133      this->currentEntity = (*it);
134  }
135  return this->currentEntity;
136}
137
138
139
140
141
Note: See TracBrowser for help on using the repository browser.