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