Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8228 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jun 8, 2006, 11:19:08 AM (18 years ago)
Author:
patrick
Message:

trunk: merged the network branche back to trunk with command: svn merge branches/network trunk -r8150:HEAD

Location:
trunk/src/world_entities
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/space_ships/space_ship.cc

    r7954 r8228  
    305305    }
    306306  }
    307 //  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
     307  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
    308308}
    309309
  • trunk/src/world_entities/spectator.cc

    r8147 r8228  
    2424
    2525
    26 /**
    27  * constructor
    28  */
    29 Spectator::Spectator( const TiXmlElement * root )
    30 {
     26using namespace std;
     27
     28
     29/**
     30 *  destructs the Spectator, deletes alocated memory
     31 */
     32Spectator::~Spectator ()
     33{
     34  this->setPlayer(NULL);
     35}
     36
     37
     38/**
     39 *  creates a new Spectator from Xml Data
     40 * @param root the xml element containing Spectator data
     41
     42   @todo add more parameters to load
     43 */
     44Spectator::Spectator(const TiXmlElement* root)
     45{
     46  this->init();
     47  if (root != NULL)
     48    this->loadParams(root);
     49
     50}
     51
     52
     53/**
     54 * initializes a Spectator
     55 */
     56void Spectator::init()
     57{
     58//  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    3159  this->setClassID(CL_SPECTATOR, "Spectator");
    32  
    33   bool                  bLeft;
    34   bool                  bRight;
    35   bool                  bForward;
    36   bool                  bBackward;
    37    
    38   float                 xMouse;             //!< mouse moved in x-Direction
    39   float                 yMouse;             //!< mouse moved in y-Direction
     60
     61  this->getWeaponManager().changeWeaponConfig(1);
    4062
    4163  this->bLeft = false;
     
    4567  this->xMouse = 0.0f;
    4668  this->yMouse = 0.0f;
    47    
     69
     70  this->setHealthMax(100);
     71  this->setHealth(80);
     72
     73  this->mouseDir = this->getAbsDir();
     74
     75  //add events to the eventlist
    4876  registerEvent(KeyMapper::PEV_FORWARD);
    4977  registerEvent(KeyMapper::PEV_BACKWARD);
     
    5280  registerEvent(KeyMapper::PEV_FIRE1);
    5381  registerEvent(EV_MOUSE_MOTION);
    54  
     82
     83  this->getWeaponManager().setSlotCount(0);
     84
     85  this->getWeaponManager().getFixedTarget()->setParent(this);
     86  this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
     87
     88  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
     89
     90 
    5591  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
    5692  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
     
    6096}
    6197
    62 /**
    63  * destructor
    64  */
    65 Spectator::~Spectator( )
    66 {
    67   this->setPlayer(NULL);
    68 }
    69 
    70 void Spectator::setPlayDirection( const Quaternion & rot, float speed )
    71 {
    72   this->mouseDir =  rot;
    73   this->angleY = rot.getHeading();
    74   this->angleX = rot.getAttitude();
    75 }
    76 
    77 void Spectator::enter( )
    78 {
     98
     99/**
     100 * loads the Settings of a Spectator from an XML-element.
     101 * @param root the XML-element to load the Spaceship's properties from
     102 */
     103void Spectator::loadParams(const TiXmlElement* root)
     104{
     105  Playable::loadParams(root);
     106}
     107
     108void Spectator::setPlayDirection(const Quaternion& quat, float speed)
     109{
     110  this->mouseDir = quat;
     111  this->angleY = quat.getHeading();
     112  this->angleX = quat.getAttitude();
     113}
     114
     115
     116void Spectator::reset()
     117{
     118  this->bLeft = false;
     119  this->bRight = false;
     120  this->bForward = false;
     121  this->bBackward = false;
     122  this->xMouse = 0.0f;
     123  this->yMouse = 0.0f;
     124
     125  this->setHealth(80);
     126}
     127
     128
     129void Spectator::enter()
     130{
     131  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false );
    79132  this->attachCamera();
    80133}
    81134
    82 void Spectator::leave( )
    83 {
     135void Spectator::leave()
     136{
     137  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
    84138  this->detachCamera();
    85139}
    86140
    87 /**
    88  * collision handling
    89  * @param entity other entity
    90  * @param location
    91  * @todo dont allow spectator to go through walls
    92  */
    93 void Spectator::collidesWith( WorldEntity * entity, const Vector & location )
    94 {
    95 }
    96 
    97 void Spectator::tick( float time )
     141
     142/**
     143 *  this function is called, when two entities collide
     144 * @param entity: the world entity with whom it collides
     145 *
     146 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
     147 * @todo dont let Spectator fly through walls
     148 */
     149void Spectator::collidesWith(WorldEntity* entity, const Vector& location)
     150{
     151}
     152
     153
     154
     155/**
     156 *  the function called for each passing timeSnap
     157 * @param time The timespan passed since last update
     158 */
     159void Spectator::tick (float time)
    98160{
    99161  Playable::tick( time );
     
    147209}
    148210
    149 void Spectator::process( const Event & event )
     211/**
     212 * @todo switch statement ??
     213 */
     214void Spectator::process(const Event &event)
    150215{
    151216  Playable::process(event);
     
    165230  }
    166231}
     232
     233
     234
     235
  • trunk/src/world_entities/spectator.h

    r8147 r8228  
    1111class Spectator : public Playable
    1212{
     13
    1314  public:
    14     Spectator( const TiXmlElement* root = NULL );
     15    Spectator(const TiXmlElement* root = NULL);
    1516    virtual ~Spectator();
    16    
     17
     18    virtual void loadParams(const TiXmlElement* root);
     19
    1720    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
    1821
    1922    virtual void enter();
    2023    virtual void leave();
    21    
     24
     25    virtual void reset();
     26
    2227    virtual void collidesWith(WorldEntity* entity, const Vector& location);
    2328    virtual void tick(float time);
    2429
    2530    virtual void process(const Event &event);
    26    
     31
    2732  private:
     33    void init();
     34
    2835    bool                  bLeft;
    2936    bool                  bRight;
     
    3542    Quaternion            mouseDir;           //!< the direction where the player wants to fly
    3643
    37     //Quaternion            rotY;
    38     //Quaternion            rotAxis;
    3944    float                 angleX;
    4045    float                 angleY;
     46
    4147};
    4248
Note: See TracChangeset for help on using the changeset viewer.