Danbias/Code/Game/GameProtocols/PlayerProtocols.h

179 lines
4.5 KiB
C
Raw Normal View History

2013-12-12 09:33:59 +01:00
//////////////////////////////////////////////////////////
// Created 2013 //
// Dennis Andersen, Linda Andersson //
//////////////////////////////////////////////////////////
2013-12-09 11:57:34 +01:00
#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H
#define GAMELOGIC_PLAYER_PROTOCOLS_H
2013-12-12 09:33:59 +01:00
#include <CustomNetProtocol.h>
2013-12-09 11:57:34 +01:00
#include "ProtocolIdentificationID.h"
namespace GameLogic
{
2013-12-12 10:36:55 +01:00
struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject
2013-12-09 11:57:34 +01:00
{
2013-12-17 10:07:46 +01:00
2013-12-09 11:57:34 +01:00
bool bForward;
bool bBackward;
bool bLeft;
bool bRight;
2013-12-09 11:57:34 +01:00
Protocol_PlayerMovement()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerMovement;
2014-01-07 10:26:09 +01:00
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
2013-12-12 09:33:59 +01:00
2013-12-12 10:36:55 +01:00
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[4].type = Oyster::Network::NetAttributeType_Bool;
2013-12-09 11:57:34 +01:00
}
2013-12-20 09:42:02 +01:00
const Protocol_PlayerMovement& operator=(Oyster::Network::CustomNetProtocol& val)
{
bForward = val[1].value.netBool;
bBackward = val[2].value.netBool;
bLeft = val[3].value.netBool;
bRight = val[4].value.netBool;
2013-12-20 09:42:02 +01:00
return *this;
}
2013-12-12 10:36:55 +01:00
Oyster::Network::CustomNetProtocol* GetProtocol() override
2013-12-09 11:57:34 +01:00
{
2013-12-12 09:33:59 +01:00
this->protocol[1].value = bForward;
this->protocol[2].value = bBackward;
this->protocol[3].value = bLeft;
this->protocol[4].value = bRight;
2013-12-09 11:57:34 +01:00
return &protocol;
}
private:
2013-12-12 10:36:55 +01:00
Oyster::Network::CustomNetProtocol protocol;
2013-12-09 11:57:34 +01:00
};
2013-12-18 12:18:01 +01:00
struct Protocol_PlayerMouse :public Oyster::Network::CustomProtocolObject
{
float dxMouse;
float dyMouse;
Protocol_PlayerMouse()
{
2014-01-07 10:26:09 +01:00
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerMouseMovement;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
2013-12-18 12:18:01 +01:00
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
}
2013-12-20 09:42:02 +01:00
const Protocol_PlayerMouse& operator=(Oyster::Network::CustomNetProtocol& val)
{
dxMouse = val[1].value.netFloat;
dyMouse = val[2].value.netFloat;
return *this;
}
2013-12-18 12:18:01 +01:00
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = dxMouse;
this->protocol[2].value = dyMouse;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerChangeWeapon :public Oyster::Network::CustomProtocolObject
{
2013-12-17 10:07:46 +01:00
int ID;
Protocol_PlayerChangeWeapon()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerChangeWeapon;
2014-01-07 10:26:09 +01:00
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
}
const Protocol_PlayerChangeWeapon& operator=(Oyster::Network::CustomNetProtocol& val)
{
return *this;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerDamage :public Oyster::Network::CustomProtocolObject
{
int hp;
// look at dir
Protocol_PlayerDamage()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerDamage;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
}
const Protocol_PlayerDamage& operator=(Oyster::Network::CustomNetProtocol& val)
{
hp = val[1].value.netInt;
return *this;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value =hp;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerPickup :public Oyster::Network::CustomProtocolObject
{
int pickupID;
Protocol_PlayerPickup()
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerPickup;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
}
const Protocol_PlayerPickup& operator=(Oyster::Network::CustomNetProtocol& val)
2013-12-20 09:42:02 +01:00
{
pickupID = val[3].value.netInt;
2013-12-20 09:42:02 +01:00
return *this;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[3].value = pickupID;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
2013-12-09 11:57:34 +01:00
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H