src/weapon/lowgrav.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Low gravity weapon
00020  *****************************************************************************/
00021 
00022 #include "lowgrav.h"
00023 #include "explosion.h"
00024 #include "../game/game.h"
00025 #include "../game/game_loop.h"
00026 #include "../object/physical_obj.h"
00027 #include "../sound/jukebox.h"
00028 #include "../interface/game_msg.h"
00029 #include "../team/teams_list.h"
00030 #include "../tool/i18n.h"
00031 #include "../include/action_handler.h"
00032 
00033 const double LOW_GRAVITY_FACTOR = 0.4;
00034 
00035 LowGrav::LowGrav() : Weapon(WEAPON_LOWGRAV, "lowgrav",
00036                             new WeaponConfig(), NEVER_VISIBLE)
00037 {
00038   m_name = _("LowGrav");
00039 
00040   override_keys = true ;
00041   use_unit_on_first_shoot = false;
00042 }
00043 
00044 void LowGrav::Refresh()
00045 {
00046   ActiveCharacter().UpdatePosition();
00047 }
00048 
00049 void LowGrav::p_Deselect()
00050 {
00051   ActiveCharacter().ResetConstants();
00052   ActiveCharacter().SetClothe("normal");
00053   m_is_active = false;
00054 }
00055 
00056 bool LowGrav::p_Shoot()
00057 {
00058   ActiveCharacter().SetGravityFactor(LOW_GRAVITY_FACTOR);
00059   ActiveCharacter().SetClothe("helmet");
00060   return true;
00061 }
00062 
00063 void LowGrav::Draw()
00064 {
00065 }
00066 
00067 void LowGrav::HandleKeyEvent(Action::Action_t action, Keyboard::Key_Event_t event_type)
00068 {
00069   switch (action)
00070     {
00071       case Action::ACTION_SHOOT:
00072         if (event_type == Keyboard::KEY_PRESSED)
00073           ActionHandler::GetInstance()->NewAction(new Action(Action::ACTION_WEAPON_STOP_USE));
00074         break ;
00075 
00076       default:
00077         ActiveCharacter().HandleKeyEvent(action, event_type);
00078         break ;
00079     }
00080 }
00081 
00082 void LowGrav::SignalTurnEnd()
00083 {
00084   p_Deselect();
00085 }
00086 
00087 void LowGrav::ActionStopUse()
00088 {
00089   UseAmmoUnit();
00090 }

Generated on Mon Jan 1 13:11:00 2007 for Wormux by  doxygen 1.4.7