Parachute Class Reference

#include <parachute.h>

Inheritance diagram for Parachute:

Inheritance graph
[legend]
Collaboration diagram for Parachute:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Parachute ()
void Draw ()
void SignalTurnEnd ()
ParachuteConfigcfg ()

Protected Member Functions

void p_Select ()
void p_Deselect ()
void Refresh ()
bool p_Shoot ()

Private Attributes

bool open
bool closing
Spriteimage

Detailed Description

Definition at line 39 of file parachute.h.


Constructor & Destructor Documentation

Parachute::Parachute (  ) 

Definition at line 33 of file parachute.cpp.

00033                      : Weapon(WEAPON_PARACHUTE, "parachute", new ParachuteConfig(), NEVER_VISIBLE)
00034 {
00035   m_name = _("Parachute");
00036   m_initial_nb_ammo = 2 ;
00037   use_unit_on_first_shoot = false;
00038 
00039   image = resource_manager.LoadSprite(weapons_res_profile,"parachute_sprite");
00040 }

Here is the call graph for this function:


Member Function Documentation

ParachuteConfig & Parachute::cfg (  ) 

Definition at line 129 of file parachute.cpp.

00129                                 {
00130   return static_cast<ParachuteConfig&>(*extra_params);
00131 }

Here is the caller graph for this function:

void Parachute::Draw (  )  [virtual]

Reimplemented from Weapon.

Definition at line 62 of file parachute.cpp.

00063 {
00064   if (open)
00065     {
00066       image->Update();
00067       image->Draw(ActiveCharacter().GetHandPosition() - Point2i(image->GetWidth()/2,image->GetHeight()));
00068     }
00069 }

Here is the call graph for this function:

void Parachute::p_Deselect (  )  [protected, virtual]

Reimplemented from Weapon.

Definition at line 50 of file parachute.cpp.

00051 {
00052   ActiveCharacter().ResetConstants();
00053   m_is_active = false;
00054 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Parachute::p_Select (  )  [protected, virtual]

Reimplemented from Weapon.

Definition at line 42 of file parachute.cpp.

00043 {
00044   m_is_active = true ;
00045   open = false ;
00046   closing = false ;
00047   image->animation.SetShowOnFinish(SpriteAnimation::show_last_frame);
00048 }

Here is the call graph for this function:

bool Parachute::p_Shoot (  )  [protected, virtual]

Implements Weapon.

Definition at line 56 of file parachute.cpp.

00057 {
00058   GameMessages::GetInstance()->Add(_("Parachute is activated automatically."));
00059   return false;
00060 }

Here is the call graph for this function:

void Parachute::Refresh (  )  [protected, virtual]

Implements Weapon.

Definition at line 71 of file parachute.cpp.

00072 {
00073   double speed;
00074   double angle;
00075 
00076   ActiveCharacter().GetSpeed(speed, angle);
00077 
00078   if (ActiveCharacter().FootsInVacuum() && speed != 0.0)
00079     {
00080       if (!open && (speed > GameMode::GetInstance()->safe_fall))
00081       {
00082         if (EnoughAmmo())
00083         {
00084           UseAmmo();
00085           ActiveCharacter().SetAirResistFactor(cfg().air_resist_factor);
00086           ActiveCharacter().SetWindFactor(cfg().wind_factor);
00087           open = true ;
00088           image->animation.SetPlayBackward(false);
00089           image->Start();
00090           ActiveCharacter().SetSpeedXY(Point2d(0,0));
00091           ActiveCharacter().SetMovement("parachute");
00092         }
00093       }
00094     }
00095   else
00096     {
00097       /* We are on the ground */
00098       if (open)
00099       {
00100         /* The parachute is opened */
00101         if (!closing)
00102         {
00103           /* We have just hit the ground. Start closing animation */
00104           image->animation.SetPlayBackward(true);
00105           image->animation.SetShowOnFinish(SpriteAnimation::show_blank);
00106           image->Start();
00107           closing = true ;
00108         }
00109         else
00110         {/* The parachute is closing */
00111           if (image->IsFinished())
00112           {
00113                   /* The animation is finished...
00114             We are done with the parachute */
00115             open = false ;
00116             closing = false ;
00117             UseAmmoUnit();
00118           }
00119         }
00120       }
00121     }
00122 }

Here is the call graph for this function:

void Parachute::SignalTurnEnd (  )  [virtual]

Reimplemented from Weapon.

Definition at line 124 of file parachute.cpp.

00125 {
00126   p_Deselect();
00127 }

Here is the call graph for this function:


Member Data Documentation

bool Parachute::closing [private]

Definition at line 43 of file parachute.h.

Sprite* Parachute::image [private]

Definition at line 44 of file parachute.h.

bool Parachute::open [private]

Definition at line 42 of file parachute.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:05:04 2007 for Wormux by  doxygen 1.4.7