Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/powerups/src/world_entities/power_ups/weapon_power_up.cc @ 6107

Last change on this file since 6107 was 6107, checked in by manuel, 18 years ago

implemented param_power_up.
started some powerup respawn possibilities
powerups don't display yet!

File size: 1.7 KB
RevLine 
[4597]1/*
[2077]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:
[5434]12   main-programmer: Benjamin Grauer
[2077]13   co-programmer: ...
14*/
15
[5439]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
[2077]17
[5965]18#include "weapon_power_up.h"
[5434]19#include "factory.h"
[5435]20#include "state.h"
21#include "list.h"
[2077]22
[5437]23#include "primitive_model.h"
24
[5973]25#include "factory.h"
26#include "load_param.h"
27
[2077]28using namespace std;
29
[5965]30CREATE_FACTORY(WeaponPowerUp, CL_WEAPON_POWER_UP);
[2077]31
[6040]32WeaponPowerUp::WeaponPowerUp () : PowerUp(0.0, 1.0, 0.0)
[4597]33{
[5434]34  this->init();
[4597]35}
[2077]36
[6040]37WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) : PowerUp(0.0, 1.0, 0.0)
[5434]38{
39  this->init();
40  this->loadParams(root);
41}
[2077]42
43
[5965]44WeaponPowerUp::~WeaponPowerUp ()
[5437]45{
[5435]46}
[5434]47
[5435]48
[5965]49void WeaponPowerUp::init()
[5434]50{
[5988]51  weaponXML = NULL;
52  weapon = NULL;
[5434]53}
54
55
[5965]56void WeaponPowerUp::loadParams(const TiXmlElement* root)
[5434]57{
58  static_cast<PowerUp*>(this)->loadParams(root);
[5973]59  const TiXmlElement* elem = root->FirstChildElement("weapon");
[5988]60  if(elem != NULL && (elem = elem->FirstChildElement()) != NULL)
[5973]61  {
62    this->weaponXML = elem;
[6107]63    respawn();
[5973]64  }
65  else
66  {
[5986]67    LoadParam(root, "weaponID", this, WeaponPowerUp, setWeaponClass);
[5973]68  }
[5434]69}
[5435]70
[5965]71Weapon* WeaponPowerUp::getWeapon()
[5435]72{
[5973]73  return this->weapon;
[5435]74}
75
[6107]76void WeaponPowerUp::respawn()
[5435]77{
[5973]78  this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL)
[5988]79      ? Factory::fabricate(static_cast<ClassID>(this->weapon->getClassID()))
80      : Factory::fabricate(weaponXML));
[5435]81}
82
[5973]83void WeaponPowerUp::setWeaponClass(const char* name)
[5965]84{
[5988]85  this->weapon = dynamic_cast<Weapon*>(Factory::fabricate(name));
[5435]86}
Note: See TracBrowser for help on using the repository browser.