00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef BODY_H
00023 #define BODY_H
00024 #include <map>
00025 #include "body_list.h"
00026 #include "clothe.h"
00027 #include "member.h"
00028 #include "movement.h"
00029 #include "../tool/resource_manager.h"
00030 #include "../tool/point.h"
00031 #include "../tool/xml_document.h"
00032 class Character;
00033 class BodyList;
00034 class Member;
00035 class Clothe;
00036
00037 class c_junction
00038 {
00039 public:
00040 Member* member;
00041 Member* parent;
00042 c_junction() { member = NULL; parent = NULL; } ;
00043 };
00044
00045 typedef class c_junction junction;
00046
00047 class Body
00048 {
00049 public:
00050 typedef enum
00051 {
00052 DIRECTION_LEFT = -1,
00053 DIRECTION_RIGHT = 1
00054 } Direction_t;
00055 private:
00056 friend class BodyList;
00057 std::map<std::string, Member*> members_lst;
00058 std::map<std::string, Clothe*> clothes_lst;
00059 std::map<std::string, Movement*> mvt_lst;
00060
00061 Clothe* current_clothe;
00062 Movement* current_mvt;
00063
00064
00065 Movement* play_once_mvt_sauv;
00066 Clothe* play_once_clothe_sauv;
00067 uint play_once_frame_sauv;
00068
00069
00070 Member* weapon_member;
00071 Point2i weapon_pos;
00072
00073 uint last_refresh;
00074 uint current_frame;
00075 int walk_events;
00076
00077 double main_rotation_rad;
00078
00079 std::vector<junction> squel_lst;
00080
00081
00082
00083 Body::Direction_t direction;
00084
00085 int animation_number;
00086 bool need_rebuild;
00087
00088 void ResetMovement();
00089 void ApplyMovement(Movement* mvt, uint frame);
00090 void ApplySqueleton();
00091
00092 void BuildSqueleton();
00093 void AddChildMembers(Member* parent);
00094 const Character* owner;
00095
00096 public:
00097
00098 Body(xmlpp::Element *xml, Profile* res);
00099 Body(Body *_body);
00100 ~Body();
00101
00102 Point2i GetSize() {return Point2i(30,45);};
00103
00104 void Draw(const Point2i& pos);
00105 void SetClothe(std::string name);
00106 void SetMovement(std::string name);
00107 void SetClotheOnce(std::string name);
00108 void SetMovementOnce(std::string name);
00109 void SetRotation(double angle);
00110 void SetFrame(uint no);
00111 void SetDirection(Body::Direction_t dir);
00112 inline void SetOwner(const Character* belonger) { owner = belonger; };
00113 void PlayAnimation();
00114 void Build();
00115
00116 const std::string& GetMovement();
00117 const std::string& GetClothe();
00118 void GetTestRect(uint &l, uint &r, uint &t, uint &b);
00119 const Direction_t &GetDirection() const;
00120 const Point2i &GetHandPosition() const;
00121 uint GetMovementDuration();
00122 uint GetFrame() { return current_frame; };
00123 uint GetFrameCount();
00124
00125 void StartWalk();
00126 void StopWalk();
00127 void ResetWalk();
00128 bool IsWalking() { return walk_events > 0 && current_mvt->type == "walk";};
00129
00130 void MakeParticles(const Point2i& pos);
00131 void MakeTeleportParticles(const Point2i& pos, const Point2i& dst);
00132 };
00133
00134 #endif //BODY_H