Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9047 in orxonox.OLD for branches/single_player_map/src


Ignore:
Timestamp:
Jul 3, 2006, 4:19:47 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: Each Playable has an EnterRange

Location:
branches/single_player_map/src/world_entities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/world_entities/playable.cc

    r9008 r9047  
    6363  this->score = 0;
    6464  this->collider = NULL;
     65  this->enterRadius = 10.0f;
    6566
    6667  this->bDead = false;
  • branches/single_player_map/src/world_entities/playable.h

    r9031 r9047  
    7575  inline int  getScore() { return this->score; }
    7676
     77  void setEnterRadius(float radius) { this->enterRadius = radius; };
     78  /** @returns the EnterRadius (how far away a Player must be to enter this entity) */
     79  inline float getEnterRadius() const { return this->enterRadius; };
    7780
    7881  // WorldEntity Extensions
     
    117120  Playable::Playmode    playmode;           //!< The current playmode.
    118121
     122  float                 enterRadius;        //!< How far one can be away from the Playable to enter it.
     123
    119124  WorldEntity* collider;
    120125};
  • branches/single_player_map/src/world_entities/player.cc

    r8362 r9047  
    3232Player::Player()
    3333{
    34 //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
     34  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    3535  this->setClassID(CL_PLAYER, "Player");
    3636
     
    7474  {
    7575    PRINTF(4)("Enter new Playable\n");
    76       this->playable = playable;
    77       this->hud.setEnergyWidget(this->playable->getHealthWidget());
    78       this->hud.setWeaponManager(&this->playable->getWeaponManager());
     76    this->playable = playable;
     77    this->hud.setEnergyWidget(this->playable->getHealthWidget());
     78    this->hud.setWeaponManager(&this->playable->getWeaponManager());
    7979
    80       this->playable->setPlayer(this);
    81       return true;
     80    this->playable->setPlayer(this);
     81    return true;
    8282  }
    8383
     
    8989
    9090bool Player::eject()
    91  {
    92    return this->setPlayable(NULL);
    93  }
     91{
     92  return this->setPlayable(NULL);
     93}
    9494
    9595
    96  void Player::weaponConfigChanged()
    97  {
    98    this->hud.updateWeaponManager();
    99  }
     96void Player::weaponConfigChanged()
     97{
     98  this->hud.updateWeaponManager();
     99}
    100100
    101  void Player::process(const Event &event)
    102  {
    103    if (event.type == KeyMapper::PEV_CHANGE_SHIP && event.bPressed)
    104    {
    105      /// FIXME this should be in the ObjectManager
    106      const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE);
    107      if (objectList != NULL)
    108      {
    109        std::list<BaseObject*>::const_iterator node;
    110        for (node = objectList->begin(); node != objectList->end(); node++)
    111          if (this->playable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < 10.0)
    112        {
     101void Player::enterNewPlayable()
     102{
     103  /// FIXME this should be in the ObjectManager
     104  const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE);
     105  if (objectList != NULL)
     106  {
     107    std::list<BaseObject*>::const_iterator node;
     108    for (node = objectList->begin(); node != objectList->end(); node++)
     109      if (this->playable != (*node) &&
     110          (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < (dynamic_cast<Playable*>(*node)->getEnterRadius()))
     111      {
    113112
    114          this->setPlayable(dynamic_cast<Playable*>(*node));
     113        this->setPlayable(dynamic_cast<Playable*>(*node));
    115114
    116          break;
    117        }
    118      }
    119    }
     115        break;
     116      }
     117  }
     118}
    120119
    121    if (likely(this->playable != NULL))
    122      this->playable->process(event);
    123  }
    124120
     121void Player::process(const Event &event)
     122{
     123  if (event.type == KeyMapper::PEV_CHANGE_SHIP && event.bPressed)
     124  {
     125    this->enterNewPlayable();
     126  }
     127
     128  if (likely(this->playable != NULL))
     129    this->playable->process(event);
     130}
     131
  • branches/single_player_map/src/world_entities/player.h

    r9002 r9047  
    3737
    3838    void              weaponConfigChanged();
     39    void              enterNewPlayable();
    3940
    4041    // eventListener extension.
  • branches/single_player_map/src/world_entities/space_ships/spacecraft_2d.cc

    r9046 r9047  
    8989  this->getWeaponManager().changeWeaponConfig(1);
    9090  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
    91 
    92   this->loadModel("models/ships/hoverglider_mainbody.obj");
    9391}
    9492
Note: See TracChangeset for help on using the changeset viewer.