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