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