GL - control protocol added
This commit is contained in:
parent
0c98e2847d
commit
a4907c8e2e
|
@ -6,6 +6,7 @@
|
|||
#include "GameClientState\GameState.h"
|
||||
#include "GameClientState\LobbyState.h"
|
||||
#include "PlayerProtocols.h"
|
||||
#include "ControlProtocols.h"
|
||||
#include "NetworkClient.h"
|
||||
|
||||
#include "../WindowManager/WindowShell.h"
|
||||
|
@ -29,9 +30,15 @@ namespace DanBias
|
|||
int pType = p[0].value.netInt;
|
||||
switch (pType)
|
||||
{
|
||||
case protocol_Gamplay_PlayerNavigation:
|
||||
case protocol_Status:
|
||||
{
|
||||
GameLogic::Protocol_Status::States state;
|
||||
state = (GameLogic::Protocol_Status::States)p[1].value.netShort;
|
||||
|
||||
}
|
||||
break;
|
||||
case protocol_Gameplay_PlayerNavigation:
|
||||
{
|
||||
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
|
||||
for(int i = 0; i< 6; i++)
|
||||
{
|
||||
|
@ -44,7 +51,7 @@ namespace DanBias
|
|||
protocolData = NULL;
|
||||
}
|
||||
break;
|
||||
case protocol_Gamplay_PlayerPosition:
|
||||
case protocol_Gameplay_PlayerPosition:
|
||||
{
|
||||
Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos;
|
||||
for(int i = 0; i< 3; i++)
|
||||
|
@ -58,7 +65,7 @@ namespace DanBias
|
|||
}
|
||||
break;
|
||||
|
||||
case protocol_Gamplay_CreateObject:
|
||||
case protocol_Gameplay_CreateObject:
|
||||
{
|
||||
|
||||
Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj;
|
||||
|
@ -76,7 +83,19 @@ namespace DanBias
|
|||
protocolData = NULL;
|
||||
}
|
||||
break;
|
||||
case protocol_Gamplay_ObjectPosition:
|
||||
case protocol_Gameplay_RemoveObject:
|
||||
{
|
||||
Client::GameClientState::RemoveObj* protocolData = new Client::GameClientState::RemoveObj;
|
||||
protocolData->object_ID = p[1].value.netInt;
|
||||
|
||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
||||
((Client::GameState*)gameClientState)->Protocol(protocolData);
|
||||
|
||||
delete protocolData;
|
||||
protocolData = NULL;
|
||||
}
|
||||
break;
|
||||
case protocol_Gameplay_ObjectPosition:
|
||||
{
|
||||
|
||||
Client::GameClientState::ObjPos* protocolData = new Client::GameClientState::ObjPos;
|
||||
|
@ -113,7 +132,6 @@ namespace DanBias
|
|||
}
|
||||
|
||||
public:
|
||||
//Client::GameClientState* gameClientState;
|
||||
WindowShell* window;
|
||||
InputClass* inputObj;
|
||||
Utility::WinTimer* timer;
|
||||
|
|
|
@ -28,6 +28,11 @@ public:
|
|||
char* path;
|
||||
float worldPos[16];
|
||||
};
|
||||
struct RemoveObj :public ProtocolStruct
|
||||
{
|
||||
int object_ID;
|
||||
//particle effect
|
||||
};
|
||||
struct KeyInput :public ProtocolStruct
|
||||
{
|
||||
bool key[6];
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "C_obj/C_DynamicObj.h"
|
||||
#include "NetworkClient.h"
|
||||
#include "PlayerProtocols.h"
|
||||
#include "ControlProtocols.h"
|
||||
|
||||
using namespace DanBias::Client;
|
||||
|
||||
|
@ -83,10 +84,15 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
|||
switch (privData->state)
|
||||
{
|
||||
case gameStateState_loading:
|
||||
{
|
||||
// load map
|
||||
// wait for all players
|
||||
LoadGame();
|
||||
GameLogic::Protocol_Status gameStatus;
|
||||
gameStatus.status = GameLogic::Protocol_Status::States_ready;
|
||||
privData->nwClient->Send(gameStatus);
|
||||
privData->state = gameStateState_playing;
|
||||
}
|
||||
break;
|
||||
case gameStateState_playing:
|
||||
// read server data
|
||||
|
@ -180,15 +186,7 @@ bool GameState::Release()
|
|||
|
||||
void GameState::Protocol(ProtocolStruct* pos)
|
||||
{
|
||||
// move message
|
||||
/*
|
||||
if ((KeyInput*)pos)
|
||||
{
|
||||
}
|
||||
if((ObjPos*)pos)
|
||||
ObjectPosProtocol((ObjPos*)pos);
|
||||
else if((PlayerPos*)pos)
|
||||
PlayerPosProtocol((PlayerPos*)pos);*/
|
||||
|
||||
}
|
||||
|
||||
void GameState::Protocol( PlayerPos* pos )
|
||||
|
@ -224,6 +222,7 @@ void GameState::Protocol( NewObj* pos )
|
|||
|
||||
modelData.world = world;
|
||||
modelData.visible = true;
|
||||
//not sure if this is good parsing rom char* to wstring
|
||||
const char* path = pos->path;
|
||||
modelData.modelPath = std::wstring(path, path + strlen(path));
|
||||
// load models
|
||||
|
@ -240,6 +239,11 @@ void GameState::Protocol( KeyInput* pos )
|
|||
}
|
||||
}
|
||||
|
||||
void DanBias::Client::GameState::Protocol( RemoveObj* obj )
|
||||
{
|
||||
privData->object[obj->object_ID]->Release( );
|
||||
}
|
||||
|
||||
void GameState::PlayerPosProtocol(PlayerPos* pos)
|
||||
{
|
||||
Oyster::Math::Float4x4 world, translate;
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
void Protocol(ObjPos* pos);
|
||||
void Protocol(KeyInput* pos);
|
||||
void Protocol( NewObj* pos );
|
||||
void Protocol(RemoveObj* obj);
|
||||
void PlayerPosProtocol(PlayerPos* pos);
|
||||
void ObjectPosProtocol(ObjPos* pos);
|
||||
//void Protocol(LightPos pos);
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef GAMELOGIC_CONTROL_PROTOCOLS_H
|
||||
#define GAMELOGIC_CONTROL_PROTOCOLS_H
|
||||
|
||||
#include <CustomNetProtocol.h>
|
||||
#include "ProtocolIdentificationID.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
struct Protocol_Status :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
enum States
|
||||
{
|
||||
States_ready,
|
||||
States_idle,
|
||||
States_bussy,
|
||||
States_disconected,
|
||||
};
|
||||
States status;
|
||||
|
||||
Protocol_Status()
|
||||
{
|
||||
this->protocol[0].value = protocol_Status;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
this->protocol[1].value = status;
|
||||
|
||||
return &protocol;
|
||||
}
|
||||
|
||||
private:
|
||||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
}
|
||||
#endif //!GAMELOGIC_CONTROL_PROTOCOLS_H
|
|
@ -154,6 +154,7 @@
|
|||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ControlProtocols.h" />
|
||||
<ClInclude Include="ObjectProtocols.h" />
|
||||
<ClInclude Include="PlayerProtocols.h" />
|
||||
<ClInclude Include="ProtocolIdentificationID.h" />
|
||||
|
|
|
@ -17,8 +17,8 @@ namespace GameLogic
|
|||
|
||||
Protocol_CreateObject()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_CreateObject;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
|
||||
this->protocol[0].value = protocol_Gameplay_CreateObject;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
|
||||
|
@ -79,7 +79,7 @@ namespace GameLogic
|
|||
|
||||
Protocol_ObjectPosition()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_ObjectPosition;
|
||||
this->protocol[0].value = protocol_Gameplay_ObjectPosition;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||
|
@ -129,6 +129,27 @@ namespace GameLogic
|
|||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
|
||||
struct Protocol_RemoveObject :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
int object_ID;
|
||||
|
||||
Protocol_RemoveObject()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gameplay_RemoveObject;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
|
||||
this->protocol[1].value = object_ID;
|
||||
return &protocol;
|
||||
}
|
||||
|
||||
private:
|
||||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
|
|
@ -25,7 +25,7 @@ namespace GameLogic
|
|||
|
||||
Protocol_PlayerMovement()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_PlayerNavigation;
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerNavigation;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||
|
@ -60,7 +60,7 @@ namespace GameLogic
|
|||
|
||||
Protocol_PlayerMouse()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_PlayerMouseMovement;
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerMouseMovement;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
@ -87,7 +87,7 @@ namespace GameLogic
|
|||
|
||||
Protocol_PlayerPosition()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_PlayerPosition;
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerPosition;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
|
||||
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
|
||||
|
||||
#define protocol_Gamplay_PlayerNavigation 0
|
||||
#define protocol_Gamplay_PlayerMouseMovement 1
|
||||
#define protocol_Gamplay_PlayerPosition 2
|
||||
#define protocol_Gamplay_CreateObject 3
|
||||
#define protocol_Gamplay_ObjectPosition 4
|
||||
#define protocol_Gameplay_PlayerNavigation 0
|
||||
#define protocol_Gameplay_PlayerMouseMovement 1
|
||||
#define protocol_Gameplay_PlayerPosition 2
|
||||
#define protocol_Gameplay_CreateObject 3
|
||||
#define protocol_Gameplay_RemoveObject 4
|
||||
#define protocol_Gameplay_ObjectPosition 5
|
||||
|
||||
#define protocol_Status 50
|
||||
|
||||
#define protocol_Lobby_Msg 100
|
||||
|
||||
|
|
Loading…
Reference in New Issue