source:
network-game/common/Player.h@
3ea1839
Last change on this file since 3ea1839 was 34bd549, checked in by , 11 years ago | |
---|---|
|
|
File size: 1.7 KB |
Rev | Line | |
---|---|---|
[2488852] | 1 | #ifndef _PLAYER_H |
2 | #define _PLAYER_H | |
3 | ||
4 | #include <string> | |
[ff2133a] | 5 | #include <map> |
[2488852] | 6 | |
[e6c26b8] | 7 | #include "Compiler.h" |
[373089e] | 8 | |
[e6c26b8] | 9 | #if defined WINDOWS |
10 | #include <winsock2.h> | |
11 | #elif defined LINUX | |
[373089e] | 12 | #include <netinet/in.h> |
[34bd549] | 13 | #elif defined MAC |
14 | #include <netinet/in.h> | |
[373089e] | 15 | #endif |
16 | ||
[a1a3bd5] | 17 | #include "WorldMap.h" |
[edfd1d0] | 18 | |
[2488852] | 19 | using namespace std; |
20 | ||
[f41a7f9] | 21 | //forward declaration |
22 | class Game; | |
23 | ||
[8e540f4] | 24 | class Player { |
[5b92307] | 25 | private: |
26 | unsigned int id; | |
27 | unsigned int targetPlayer; | |
28 | ||
[2488852] | 29 | public: |
[07c73fa] | 30 | |
31 | enum PlayerClass { | |
32 | CLASS_NONE, | |
33 | CLASS_WARRIOR, | |
34 | CLASS_RANGER | |
35 | }; | |
36 | ||
37 | enum AttackType { | |
38 | ATTACK_NONE, | |
39 | ATTACK_MELEE, | |
40 | ATTACK_RANGED | |
41 | }; | |
42 | ||
[01d0d00] | 43 | Player(); |
44 | Player(const Player& p); | |
[59061f6] | 45 | Player(string name, string password); |
[01d0d00] | 46 | |
[8e540f4] | 47 | ~Player(); |
[2488852] | 48 | |
[5b92307] | 49 | unsigned int getId(); |
50 | unsigned int getTargetPlayer(); | |
51 | ||
[9ba9b96] | 52 | void setId(unsigned int id); |
[5b92307] | 53 | void setTargetPlayer(unsigned int id); |
[59061f6] | 54 | void setAddr(sockaddr_in addr); |
[46fa35a] | 55 | void setClass(PlayerClass c); |
56 | ||
57 | void serialize(char* buffer); | |
58 | void deserialize(char* buffer); | |
[59061f6] | 59 | |
[5b92307] | 60 | bool updateTarget(map<unsigned int, Player*>& players); |
[227baaa] | 61 | bool move(WorldMap *map); |
[6054f1e] | 62 | void takeDamage(int damage); |
[60017fc] | 63 | |
[9ba9b96] | 64 | void takeFlag(unsigned int flag, WorldMap* map); |
65 | void dropFlag(unsigned int flag, WorldMap* map); | |
[d436ac4] | 66 | |
[8e540f4] | 67 | string name; |
[59061f6] | 68 | string password; |
[8e540f4] | 69 | sockaddr_in addr; |
[60017fc] | 70 | FLOAT_POSITION pos; |
71 | POSITION target; | |
[8f85180] | 72 | unsigned long long timeLastUpdated; |
[8dad966] | 73 | unsigned long long timeAttackStarted; |
[c76134b] | 74 | unsigned long long timeDied; |
[11d21ee] | 75 | bool isChasing; |
[8dad966] | 76 | bool isAttacking; |
[c76134b] | 77 | bool isDead; |
[d436ac4] | 78 | |
[c991530] | 79 | PlayerClass playerClass; |
[07c73fa] | 80 | int maxHealth; |
81 | int health; | |
82 | int attackType; | |
83 | int damage; | |
[11d21ee] | 84 | int range; |
[8dad966] | 85 | unsigned long long attackCooldown; |
[d436ac4] | 86 | int team; // 0 is blue, 1 is red |
[74b8e79] | 87 | bool hasBlueFlag; |
[d436ac4] | 88 | bool hasRedFlag; |
[f41a7f9] | 89 | |
90 | Game* currentGame; | |
[2488852] | 91 | }; |
92 | ||
93 | #endif |
Note:
See TracBrowser
for help on using the repository browser.