Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6404 was 6404, checked in by patrick, 20 years ago

network: working on the last steps, completion is in reach. sadly the world isn't loaded anymore at the moment. continue work later. work flush

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::loadData(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 *  loads a WorldList
69 * @param root: the XML-element to load from
70 */
71void CampaignData::loadParamsWorldList(const TiXmlElement* root)
72{
73  if( root == NULL)
74    return;
75
76  LOAD_PARAM_START_CYCLE(root, element);
77  {
78    StoryEntity* created = (StoryEntity*) Factory::fabricate(element);
79    if( created != NULL)
80      this->addStoryEntity(created);
81  }
82  LOAD_PARAM_END_CYCLE(element);
83}
84
85
86/**
87 *  add the StoryEntity to the campaign data tank
88 * @param se the StoryEntity to add
89 */
90void CampaignData::addStoryEntity(StoryEntity* se)
91{
92  this->storyEntities.push_back(se);
93}
94
95
96/**
97 *  switch to the next level in the list and return it
98 */
99StoryEntity* CampaignData::getFirstLevel()
100{
101  int                            nextStoryID;
102  int                            storyID;
103  list<StoryEntity*>::iterator   it;
104
105  nextStoryID = 0;
106  this->currentEntity = NULL;
107  for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++)
108  {
109    storyID = (*it)->getStoryID();
110    if( storyID == nextStoryID)
111      this->currentEntity = (*it);
112  }
113  return this->currentEntity;
114}
115
116
117/**
118 *  switch to the next level in the list and return it
119 */
120StoryEntity* CampaignData::getNextLevel()
121{
122  int                            nextStoryID;
123  int                            storyID;
124  list<StoryEntity*>::iterator   it;
125
126  nextStoryID = this->currentEntity->getNextStoryID();
127  this->currentEntity = NULL;
128  for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++)
129  {
130    storyID = (*it)->getStoryID();
131    if( storyID == nextStoryID)
132      this->currentEntity = (*it);
133  }
134  return this->currentEntity;
135}
136
137
138
139
140
Note: See TracBrowser for help on using the repository browser.