Last change
on this file since e6c26b8 was e6c26b8, checked in by Dmitry Portnoy <dportnoy@…>, 11 years ago |
The client dynamically allocates memory for players and passes around a map with player pointers and some includes are now in individual files instead of in Common.h
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | #ifndef _PLAYER_H
|
---|
2 | #define _PLAYER_H
|
---|
3 |
|
---|
4 | #include <string>
|
---|
5 | #include <map>
|
---|
6 |
|
---|
7 | #include "Compiler.h"
|
---|
8 |
|
---|
9 | #if defined WINDOWS
|
---|
10 | #include <winsock2.h>
|
---|
11 | #elif defined LINUX
|
---|
12 | #include <netinet/in.h>
|
---|
13 | #endif
|
---|
14 |
|
---|
15 | #include "WorldMap.h"
|
---|
16 |
|
---|
17 | using namespace std;
|
---|
18 |
|
---|
19 | //forward declaration
|
---|
20 | class Game;
|
---|
21 |
|
---|
22 | class Player {
|
---|
23 | public:
|
---|
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 |
|
---|
37 | Player();
|
---|
38 | Player(const Player& p);
|
---|
39 | Player(string name, string password);
|
---|
40 |
|
---|
41 | ~Player();
|
---|
42 |
|
---|
43 | void setId(int id);
|
---|
44 | void setAddr(sockaddr_in addr);
|
---|
45 | void setClass(PlayerClass c);
|
---|
46 |
|
---|
47 | void serialize(char* buffer);
|
---|
48 | void deserialize(char* buffer);
|
---|
49 |
|
---|
50 | bool updateTarget(map<unsigned int, Player*>& mapPlayers);
|
---|
51 | bool move(WorldMap *map);
|
---|
52 |
|
---|
53 | void takeFlag(int flag, WorldMap* map);
|
---|
54 | void dropFlag(int flag, WorldMap* map);
|
---|
55 |
|
---|
56 | int id;
|
---|
57 | string name;
|
---|
58 | string password;
|
---|
59 | sockaddr_in addr;
|
---|
60 | FLOAT_POSITION pos;
|
---|
61 | POSITION target;
|
---|
62 | unsigned long long timeLastUpdated;
|
---|
63 | unsigned long long timeAttackStarted;
|
---|
64 | unsigned long long timeDied;
|
---|
65 | bool isChasing;
|
---|
66 | bool isAttacking;
|
---|
67 | int targetPlayer;
|
---|
68 | bool isDead;
|
---|
69 |
|
---|
70 | int playerClass;
|
---|
71 | int maxHealth;
|
---|
72 | int health;
|
---|
73 | int attackType;
|
---|
74 | int damage;
|
---|
75 | int range;
|
---|
76 | unsigned long long attackCooldown;
|
---|
77 | int team; // 0 is blue, 1 is red
|
---|
78 | bool hasBlueFlag;
|
---|
79 | bool hasRedFlag;
|
---|
80 |
|
---|
81 | Game* currentGame;
|
---|
82 | };
|
---|
83 |
|
---|
84 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.