TankState.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #if !defined(__INCLUDE_TankStateh_INCLUDE__)
00022 #define __INCLUDE_TankStateh_INCLUDE__
00023 
00024 #include <net/NetBuffer.h>
00025 
00026 class Tank;
00027 class ScorchedContext;
00028 class TankState
00029 {
00030 public:
00031         enum State
00032         {
00033                 sInitializing,
00034                 sLoading,
00035                 sPending,
00036                 sNormal,
00037                 sDead
00038         };
00039 
00040         enum ReadyState
00041         {
00042                 sReady,
00043                 SNotReady
00044         };
00045 
00046         TankState(ScorchedContext &context, unsigned int playerId);
00047         virtual ~TankState();
00048         
00049         void setTank(Tank *tank) { tank_ = tank; }
00050 
00051         // State Modifiers
00052         void newGame();
00053         void newMatch();
00054         void clientNewGame();
00055         
00056         // Ready State
00057         void setReady() { readyState_ = sReady; }
00058         void setNotReady() { readyState_ = SNotReady; }
00059         ReadyState getReadyState() { return readyState_; }
00060 
00061         // State
00062         void setState(State s);
00063         State getState() { return state_; }
00064         void setSpectator(bool s) { spectator_ = s; }
00065         bool getSpectator() { return spectator_; }      
00066 
00067         void setMuted(bool muted) { muted_ = muted; }
00068         bool getMuted() { return muted_; }
00069         void setSkipShots(bool skip) { skipshots_ = skip; }
00070         bool getSkipShots() { return skipshots_; }
00071         int getLives() { return lives_; }
00072         void setLives(int lives) { lives_ = lives; }
00073         int getMaxLives() { return maxLives_; }
00074         void setDestroy(bool destroy) { destroy_ = destroy; }
00075         bool getDestroy() { return destroy_; }
00076         
00077         const char *getStateString();
00078         const char *getSmallStateString();
00079         LangString &getSmallStateLangString();
00080 
00081         // Serialize the tank
00082         bool writeMessage(NetBuffer &buffer);
00083         bool readMessage(NetBufferReader &reader);
00084 
00085 protected:
00086         Tank *tank_;
00087         ScorchedContext &context_;
00088         State state_;
00089         ReadyState readyState_;
00090         int lives_, maxLives_;
00091         bool spectator_;
00092         bool muted_;
00093         bool skipshots_;
00094         bool destroy_;
00095 
00096 };
00097 
00098 #endif
00099 

Generated on Mon Feb 16 15:14:52 2009 for Scorched3D by  doxygen 1.5.3