Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 11, 2005, 5:47:23 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: crosshair in WeaponManager (instead of World) and implemented easy Cyling for LoadParam

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.cc

    r4833 r4834  
    1919#include "weapon_manager.h"
    2020#include "weapon.h"
    21 
     21#include "crosshair.h"
     22
     23#include "load_param.h"
     24#include "factory.h"
    2225#include "vector.h"
    2326#include "list.h"
     
    5356      this->configs[i].slots[j] = NULL;
    5457  }
    55 }
    56 
     58
     59  // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.)
     60  //delete this->crosshair;
     61}
     62
     63/**
     64 * initializes the WeaponManager
     65 */
    5766void WeaponManager::init()
    5867{
     
    6675  }
    6776  this->currConfID = W_CONFIG0;
    68 
     77  this->crosshair = new Crosshair();
     78}
     79
     80/**
     81 *
     82 * @param root the XML-element to load from
     83 */
     84void WeaponManager::loadParams(const TiXmlElement* root)
     85{
     86  static_cast<BaseObject*>(this)->loadParams(root);
     87
     88  LoadParam<WeaponManager>(root, "slot-count", this, &WeaponManager::setSlotCount)
     89      .describe("how many slots(cannons) the WeaponManager can handle");
     90
     91  LOAD_PARAM_START_CYCLE;
     92
     93  LoadParam<WeaponManager>(root, "Weapons", this, &WeaponManager::loadWeapons)
     94      .describe("loads Weapons");
     95      // LoadParam<WeaponManager>(root, "Weapon", this, &WeaponManager::addWeapon);
     96
     97  LOAD_PARAM_END_CYCLE;
     98}
     99
     100/**
     101 * loads a Weapon onto the WeaponManager
     102 * @param root the XML-element to load the Weapons from
     103 */
     104void WeaponManager::loadWeapons(const TiXmlElement* root)
     105{
     106  LOAD_PARAM_START_CYCLE;
     107
     108  Weapon* newWeapon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(element));
     109
     110
     111
     112  LOAD_PARAM_END_CYCLE;
     113}
     114
     115
     116/**
     117 * sets the number of Slots the WeaponManager has
     118 * @param nrOfSlots the number of slots
     119 */
     120void WeaponManager::setSlotCount(int nrOfSlots)
     121{
     122  this->nrOfSlots = nrOfSlots;
    69123}
    70124
     
    100154}
    101155
    102 
     156/**
     157 * removes a Weapon from the WeaponManager
     158 */
    103159void WeaponManager::removeWeapon(Weapon* weapon, int configID)
    104160{
     
    163219    if( firingWeapon != NULL) firingWeapon->fire();
    164220  }
     221  this->crosshair->setRotationSpeed(-500);
    165222}
    166223
     
    178235    if( w != NULL) w->tick(dt);
    179236  }
     237
     238  crosshair->tick(dt);
     239  crosshair->setRotationSpeed(5);
    180240}
    181241
     
    193253      w->draw();
    194254  }
     255  crosshair->draw();
    195256}
    196257
Note: See TracChangeset for help on using the changeset viewer.