source: network-game/common/Player.h@ 11d21ee

Last change on this file since 11d21ee was 11d21ee, checked in by dportnoy <dmp1488@…>, 12 years ago

When a player tries to attack someone, they will now move toward the target until they are in range and then start the actual attack

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[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>
14
[edfd1d0]15#include "Common.h"
[a1a3bd5]16#include "WorldMap.h"
[edfd1d0]17
[2488852]18using namespace std;
19
[8e540f4]20class Player {
[2488852]21public:
[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
[227baaa]48 bool move(WorldMap *map);
[60017fc]49
[d436ac4]50 void takeFlag(int flag, WorldMap *map);
51 void dropFlag(int flag, WorldMap *map);
52
[01d0d00]53 int id;
[8e540f4]54 string name;
[59061f6]55 string password;
[8e540f4]56 sockaddr_in addr;
[60017fc]57 FLOAT_POSITION pos;
58 POSITION target;
[8f85180]59 unsigned long long timeLastUpdated;
[8dad966]60 unsigned long long timeAttackStarted;
[11d21ee]61 bool isChasing;
[8dad966]62 bool isAttacking;
63 int targetPlayer;
[d436ac4]64
[07c73fa]65 int playerClass;
66 int maxHealth;
67 int health;
68 int attackType;
69 int damage;
[11d21ee]70 int range;
[8dad966]71 unsigned long long attackCooldown;
[d436ac4]72 int team; // 0 is blue, 1 is red
[74b8e79]73 bool hasBlueFlag;
[d436ac4]74 bool hasRedFlag;
[2488852]75};
76
77#endif
Note: See TracBrowser for help on using the repository browser.