Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/campaign_data.cc @ 6817

Last change on this file since 6817 was 6634, checked in by bensch, 19 years ago

orxonox/trunk: merged the network-branche back to the trunk

merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/network . -r6500:HEAD
minor conflicts in texture and one Makefile resolved to the trunk

also made a small patch to texture, so it Modulates with GL_REPEAT

File size: 3.0 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
36  this->loadParams(root);
37}
38
39
40/**
41 * destructor for CampaignData
42 */
43CampaignData::~CampaignData()
44{
45  PRINTF(4)("Deleting CampaignData\n");
46  while( !this->storyEntities.empty())
47  {
48    StoryEntity* bo = this->storyEntities.back();
49    this->storyEntities.pop_back();
50    PRINTF(4)("CampaignData is been deleted: nr %i\n", bo->getStoryID());
51    delete bo;
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, loadData)
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::loadData(const TiXmlElement* root)
72{
73  if( root == NULL)
74    return;
75
76  LOAD_PARAM_START_CYCLE(root, element);
77  {
78    StoryEntity* created = dynamic_cast<StoryEntity*>(Factory::fabricate(element));
79    if( created != NULL)
80      this->addStoryEntity(created);
81    PRINTF(4)("Created a new StoryEntity and added it to the Campaign: id=%i\n", created->getStoryID());
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.