Last change
on this file since f15d6a9 was 34bd549, checked in by Dmitry Portnoy <dmp1488@…>, 11 years ago |
Make client compile on a Mac
|
-
Property mode
set to
100644
|
File size:
1.7 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 | #elif defined MAC
|
---|
14 | #include <netinet/in.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include "WorldMap.h"
|
---|
18 |
|
---|
19 | using namespace std;
|
---|
20 |
|
---|
21 | //forward declaration
|
---|
22 | class Game;
|
---|
23 |
|
---|
24 | class Player {
|
---|
25 | private:
|
---|
26 | unsigned int id;
|
---|
27 | unsigned int targetPlayer;
|
---|
28 |
|
---|
29 | public:
|
---|
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 |
|
---|
43 | Player();
|
---|
44 | Player(const Player& p);
|
---|
45 | Player(string name, string password);
|
---|
46 |
|
---|
47 | ~Player();
|
---|
48 |
|
---|
49 | unsigned int getId();
|
---|
50 | unsigned int getTargetPlayer();
|
---|
51 |
|
---|
52 | void setId(unsigned int id);
|
---|
53 | void setTargetPlayer(unsigned int id);
|
---|
54 | void setAddr(sockaddr_in addr);
|
---|
55 | void setClass(PlayerClass c);
|
---|
56 |
|
---|
57 | void serialize(char* buffer);
|
---|
58 | void deserialize(char* buffer);
|
---|
59 |
|
---|
60 | bool updateTarget(map<unsigned int, Player*>& players);
|
---|
61 | bool move(WorldMap *map);
|
---|
62 | void takeDamage(int damage);
|
---|
63 |
|
---|
64 | void takeFlag(unsigned int flag, WorldMap* map);
|
---|
65 | void dropFlag(unsigned int flag, WorldMap* map);
|
---|
66 |
|
---|
67 | string name;
|
---|
68 | string password;
|
---|
69 | sockaddr_in addr;
|
---|
70 | FLOAT_POSITION pos;
|
---|
71 | POSITION target;
|
---|
72 | unsigned long long timeLastUpdated;
|
---|
73 | unsigned long long timeAttackStarted;
|
---|
74 | unsigned long long timeDied;
|
---|
75 | bool isChasing;
|
---|
76 | bool isAttacking;
|
---|
77 | bool isDead;
|
---|
78 |
|
---|
79 | PlayerClass playerClass;
|
---|
80 | int maxHealth;
|
---|
81 | int health;
|
---|
82 | int attackType;
|
---|
83 | int damage;
|
---|
84 | int range;
|
---|
85 | unsigned long long attackCooldown;
|
---|
86 | int team; // 0 is blue, 1 is red
|
---|
87 | bool hasBlueFlag;
|
---|
88 | bool hasRedFlag;
|
---|
89 |
|
---|
90 | Game* currentGame;
|
---|
91 | };
|
---|
92 |
|
---|
93 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.