Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8957 in orxonox.OLD


Ignore:
Timestamp:
Jun 30, 2006, 2:35:42 PM (18 years ago)
Author:
patrick
Message:

animation should be initialized correctly now

Location:
branches/single_player_map/src/world_entities/npcs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/world_entities/npcs/generic_npc.cc

    r8955 r8957  
    171171
    172172
    173 void GenericNPC::nextStep()
    174 {
    175   if (!this->behaviourList.empty())
    176     this->behaviourList.pop_front();
    177   else
    178     return;
    179 
     173
     174void GenericNPC::initNPC()
     175{
    180176  if (!this->behaviourList.empty())
    181177  {
     
    200196      case Shoot:
    201197        if( this->getAnimation() != STAND)
     198          this->setAnimation(STAND, MD2_ANIM_LOOP);
     199        break;
     200
     201      default:
     202        if( this->getAnimation() != STAND)
     203          this->setAnimation(STAND, MD2_ANIM_LOOP);
     204        break;
     205
     206    }
     207  }
     208}
     209
     210
     211void GenericNPC::nextStep()
     212{
     213  if (!this->behaviourList.empty())
     214    this->behaviourList.pop_front();
     215  else
     216    return;
     217
     218  if (!this->behaviourList.empty())
     219  {
     220    switch(this->behaviourList.front().type)
     221    {
     222      case Walk:
     223        if( this->getAnimation() != RUN)
     224          this->setAnimation(RUN, MD2_ANIM_LOOP);
     225        break;
     226      case Run:
     227        if( this->getAnimation() != RUN)
     228          this->setAnimation(RUN, MD2_ANIM_LOOP);
     229        break;
     230      case Crouch:
     231        if( this->getAnimation() != CROUCH_WALK)
     232          this->setAnimation(CROUCH_WALK, MD2_ANIM_LOOP);
     233        break;
     234      case LookAt:
     235        if( this->getAnimation() != STAND)
     236          this->setAnimation(STAND, MD2_ANIM_LOOP);
     237        break;
     238      case Shoot:
     239        if( this->getAnimation() != STAND)
    202240        this->setAnimation(STAND, MD2_ANIM_LOOP);
    203241        break;
     
    215253  }
    216254}
     255
     256
    217257
    218258
     
    228268  {
    229269    this->behaviourList.push_back(anim);
     270    this->initNPC();
    230271  }
    231272  else
     
    247288  anim.type = Run;
    248289
    249   this->behaviourList.push_back(anim);
     290  if( this->behaviourList.empty())
     291  {
     292    this->behaviourList.push_back(anim);
     293    this->initNPC();
     294  }
     295  else
     296    this->behaviourList.push_back(anim);
    250297}
    251298
     
    262309  anim.type = Crouch;
    263310
    264   this->behaviourList.push_back(anim);
     311  if( this->behaviourList.empty())
     312  {
     313    this->behaviourList.push_back(anim);
     314    this->initNPC();
     315  }
     316  else
     317    this->behaviourList.push_back(anim);
    265318}
    266319void GenericNPC::crouchTo(float x, float y, float z)
     
    277330  anim.type = TurnTo;
    278331
    279   this->behaviourList.push_back(anim);
     332  if( this->behaviourList.empty())
     333  {
     334    this->behaviourList.push_back(anim);
     335    this->initNPC();
     336  }
     337  else
     338    this->behaviourList.push_back(anim);
    280339}
    281340
     
    292351  anim.type = LookAt;
    293352
    294   this->behaviourList.push_back(anim);
     353  if( this->behaviourList.empty())
     354  {
     355    this->behaviourList.push_back(anim);
     356    this->initNPC();
     357  }
     358  else
     359    this->behaviourList.push_back(anim);
    295360}
    296361
     
    340405      case Walk:
    341406        {
    342 //           if( this->getAnimation() != RUN)
    343 //             this->setAnimation(RUN, MD2_ANIM_LOOP);
    344407
    345408          Vector dest = currentAnimation.v - this->getAbsCoor();
  • branches/single_player_map/src/world_entities/npcs/generic_npc.h

    r8951 r8957  
    8383    bool isAnimationFinished();
    8484
     85    void initNPC();
     86
    8587
    8688 private:
Note: See TracChangeset for help on using the changeset viewer.