00001
00002
00003
00004
00005 #if !defined ( _SHIPS_H_ )
00006 #define _SHIPS_H_
00007
00008 #include <string>
00009 #include <vector>
00010 #include <boost/shared_ptr.hpp>
00011 #include "ISaveObject.h"
00012
00013 using boost::shared_ptr;
00014
00015 class Cargo;
00016 class ShipResource;
00017
00018 enum SailState { NOSAILS, HALFSAILS, FULLSAILS };
00019 enum RudderState { LEFT, CENTER, RIGHT };
00020 enum ShipState { NORMAL, SINKING, SUNK };
00021
00022
00023
00024 class Ship: public ISaveObject {
00025 public:
00026 Ship(std::string name, std::string shipTitle);
00027
00028
00029 Ship(std::string shipTitle);
00030
00031
00032
00033 Ship(Ship *copy);
00034
00035 ~Ship();
00036
00037 void Draw(bool doTranslate, float dX, float dZ);
00038
00039 int GetMaxDamage();
00040
00041 shared_ptr<Cargo> GetCargo();
00042
00043 void Update(const unsigned int ticks);
00044
00045 void RaiseSails();
00046 void LowerSails();
00047 void SetSails(SailState newSails);
00048 SailState GetSails();
00049 const std::string& GetSailsStr();
00050
00051 void SetRudder(RudderState newRudder);
00052
00053 void SinkShip();
00054 ShipState GetShipState();
00055 bool IsShipNormal();
00056 bool IsShipSinking();
00057 bool IsShipSunk();
00058
00059 void GetDirectionVector(double output[3]);
00060
00061
00062 void Dump();
00063
00064
00065 void Reset();
00066
00067
00068 void Save(TiXmlElement *parent);
00069 void Load(TiXmlElement *parent);
00070
00071 static const std::string& GetSailStateStr(SailState sails);
00072
00073 float m_x, m_z;
00074 float m_rot;
00075 float m_speed;
00076 int m_damage;
00077 std::string m_title;
00078
00079 private:
00080 void AcquireResource(std::string name);
00081 void ReleaseResource();
00082
00083 ShipResource *m_resource;
00084
00085 shared_ptr<Cargo> m_cargo;
00086
00087 SailState m_sails;
00088 RudderState m_rudder;
00089
00090 ShipState m_state;
00091
00092 float m_rotSpeed;
00093
00094 float m_shipSine;
00095 float m_shipCos;
00096 float m_rotX;
00097 float m_rotXAngle;
00098 };
00099
00100 #endif