Merged with Linda after merge conflicts
This commit is contained in:
commit
8667e14afb
Binary file not shown.
|
@ -43,7 +43,8 @@ namespace DanBias
|
|||
{
|
||||
((Client::GameClientState::PlayerPos*)protocolData)->playerPos[i] = p[i].value.netFloat;
|
||||
}
|
||||
gameClientState->Protocol(protocolData);
|
||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
||||
((Client::GameState*)gameClientState)->Protocol(protocolData);
|
||||
delete protocolData;
|
||||
protocolData = NULL;
|
||||
break;
|
||||
|
@ -51,11 +52,15 @@ namespace DanBias
|
|||
|
||||
case protocol_Gamplay_ObjectPosition:
|
||||
protocolData = new Client::GameClientState::ObjPos;
|
||||
((Client::GameClientState::ObjPos*)protocolData)->object_ID = p[1].value.netInt;
|
||||
for(int i = 0; i< 16; i++)
|
||||
{
|
||||
((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i].value.netFloat;
|
||||
((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i+2].value.netFloat;
|
||||
}
|
||||
gameClientState->Protocol(protocolData);
|
||||
|
||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
||||
((Client::GameState*)gameClientState)->Protocol(protocolData);
|
||||
|
||||
delete protocolData;
|
||||
protocolData = NULL;
|
||||
break;
|
||||
|
@ -79,9 +84,9 @@ namespace DanBias
|
|||
}
|
||||
|
||||
public:
|
||||
Client::GameClientState* gameClientState;
|
||||
//Client::GameClientState* gameClientState;
|
||||
InputClass* inputObj;
|
||||
MyRecieverObject* r;
|
||||
MyRecieverObject* recieverObj;
|
||||
|
||||
} data;
|
||||
#pragma endregion
|
||||
|
@ -110,17 +115,17 @@ namespace DanBias
|
|||
prevTimeStamp = 0;
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
|
||||
|
||||
m_data->r = new MyRecieverObject;
|
||||
m_data->r->nwClient = new Oyster::Network::NetworkClient();
|
||||
m_data->r->nwClient->Connect(desc.port, desc.IP);
|
||||
if (!m_data->r->nwClient->IsConnected())
|
||||
m_data->recieverObj = new MyRecieverObject;
|
||||
m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient();
|
||||
m_data->recieverObj->nwClient->Connect(desc.port, desc.IP);
|
||||
if (!m_data->recieverObj->nwClient->IsConnected())
|
||||
{
|
||||
// failed to connect
|
||||
return DanBiasClientReturn_Error;
|
||||
}
|
||||
// Start in lobby state
|
||||
m_data->gameClientState = new Client::LobbyState();
|
||||
m_data->gameClientState->Init(m_data->r->nwClient);
|
||||
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
||||
m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient);
|
||||
|
||||
|
||||
return DanBiasClientReturn_Sucess;
|
||||
|
@ -237,27 +242,27 @@ namespace DanBias
|
|||
m_data->inputObj->Update();
|
||||
|
||||
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
|
||||
state = m_data->gameClientState->Update(deltaTime, m_data->inputObj);
|
||||
state = m_data->recieverObj->gameClientState->Update(deltaTime, m_data->inputObj);
|
||||
|
||||
if(state != Client::GameClientState::ClientState_Same)
|
||||
{
|
||||
m_data->gameClientState->Release();
|
||||
delete m_data->gameClientState;
|
||||
m_data->gameClientState = NULL;
|
||||
m_data->recieverObj->gameClientState->Release();
|
||||
delete m_data->recieverObj->gameClientState;
|
||||
m_data->recieverObj->gameClientState = NULL;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case Client::GameClientState::ClientState_Lobby:
|
||||
m_data->gameClientState = new Client::LobbyState();
|
||||
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
||||
break;
|
||||
case Client::GameClientState::ClientState_Game:
|
||||
m_data->gameClientState = new Client::GameState();
|
||||
m_data->recieverObj->gameClientState = new Client::GameState();
|
||||
break;
|
||||
default:
|
||||
return E_FAIL;
|
||||
break;
|
||||
}
|
||||
m_data->gameClientState->Init(m_data->r->nwClient); // send game client
|
||||
m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient); // send game client
|
||||
|
||||
}
|
||||
return S_OK;
|
||||
|
@ -275,15 +280,18 @@ namespace DanBias
|
|||
swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed));
|
||||
SetWindowText(g_hWnd, title);
|
||||
|
||||
m_data->gameClientState->Render();
|
||||
m_data->recieverObj->gameClientState->Render();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DanBiasGame::CleanUp()
|
||||
{
|
||||
m_data->gameClientState->Release();
|
||||
delete m_data->gameClientState;
|
||||
m_data->recieverObj->gameClientState->Release();
|
||||
delete m_data->recieverObj->gameClientState;
|
||||
m_data->recieverObj->nwClient->Disconnect();
|
||||
delete m_data->recieverObj->nwClient;
|
||||
delete m_data->recieverObj;
|
||||
delete m_data->inputObj;
|
||||
delete m_data;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ private:
|
|||
public:
|
||||
|
||||
virtual void Init(ModelInitData modelInit) = 0;
|
||||
virtual void setPos() = 0;
|
||||
virtual void setPos(Oyster::Math::Float4x4 world) = 0;
|
||||
|
||||
virtual void Render() = 0;
|
||||
virtual void Release() = 0;
|
||||
|
|
|
@ -26,9 +26,9 @@ void C_DynamicObj::Init(ModelInitData modelInit)
|
|||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
}
|
||||
void C_DynamicObj::setPos()
|
||||
void C_DynamicObj::setPos(Oyster::Math::Float4x4 world)
|
||||
{
|
||||
|
||||
privData->model->WorldMatrix = world;
|
||||
}
|
||||
|
||||
void C_DynamicObj::Render()
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
C_DynamicObj(void);
|
||||
virtual ~C_DynamicObj(void);
|
||||
void Init(ModelInitData modelInit);
|
||||
void setPos();
|
||||
void setPos(Oyster::Math::Float4x4 world);
|
||||
|
||||
void Render();
|
||||
void Release();
|
||||
|
|
|
@ -30,9 +30,9 @@ void C_Player::Init(ModelInitData modelInit)
|
|||
|
||||
|
||||
}
|
||||
void C_Player::setPos()
|
||||
void C_Player::setPos(Oyster::Math::Float4x4 world)
|
||||
{
|
||||
|
||||
privData->model->WorldMatrix = world;
|
||||
}
|
||||
|
||||
void C_Player::Render()
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
C_Player(void);
|
||||
~C_Player(void);
|
||||
void Init(ModelInitData modelInit);
|
||||
void setPos();
|
||||
void setPos(Oyster::Math::Float4x4 world);
|
||||
|
||||
void Render();
|
||||
void Release();
|
||||
|
|
|
@ -29,9 +29,9 @@ void C_StaticObj::Init(ModelInitData modelInit)
|
|||
privData->model->Visible = modelInit.visible;
|
||||
|
||||
}
|
||||
void C_StaticObj::setPos()
|
||||
void C_StaticObj::setPos(Oyster::Math::Float4x4 world)
|
||||
{
|
||||
|
||||
privData->model->WorldMatrix = world;
|
||||
}
|
||||
|
||||
void C_StaticObj::Render()
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
C_StaticObj(void);
|
||||
virtual ~C_StaticObj(void);
|
||||
void Init(ModelInitData modelInit);
|
||||
void setPos();
|
||||
void setPos(Oyster::Math::Float4x4 world);
|
||||
|
||||
void Render();
|
||||
void Release();
|
||||
|
|
|
@ -27,9 +27,9 @@ void C_UIobject::Init(ModelInitData modelInit)
|
|||
privData->model->Visible = modelInit.visible;
|
||||
|
||||
}
|
||||
void C_UIobject::setPos()
|
||||
void C_UIobject::setPos(Oyster::Math::Float4x4 world)
|
||||
{
|
||||
|
||||
privData->model->WorldMatrix = world;
|
||||
}
|
||||
|
||||
void C_UIobject::Render()
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace DanBias
|
|||
C_UIobject(void);
|
||||
virtual ~C_UIobject(void);
|
||||
void Init(ModelInitData modelInit);
|
||||
void setPos();
|
||||
void setPos(Oyster::Math::Float4x4 world);
|
||||
|
||||
void Render();
|
||||
void Release();
|
||||
|
|
|
@ -19,6 +19,7 @@ public:
|
|||
};
|
||||
struct ObjPos :public ProtocolStruct
|
||||
{
|
||||
int object_ID;
|
||||
float worldPos[16];
|
||||
};
|
||||
struct PlayerPos :public ProtocolStruct
|
||||
|
|
|
@ -91,7 +91,6 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
|||
case gameStateState_playing:
|
||||
// read server data
|
||||
// update objects
|
||||
// Client.send(obj);
|
||||
{
|
||||
GameLogic::Protocol_PlayerMovement movePlayer;
|
||||
movePlayer.bForward = false;
|
||||
|
@ -119,9 +118,13 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
|||
movePlayer.bStrafeRight = true;
|
||||
}
|
||||
|
||||
|
||||
if (privData->nwClient->IsConnected())
|
||||
{
|
||||
privData->nwClient->Send(movePlayer);
|
||||
}
|
||||
|
||||
// send event data
|
||||
//
|
||||
if(KeyInput->IsKeyPressed(DIK_L))
|
||||
privData->state = GameState::gameStateState_end;
|
||||
}
|
||||
|
@ -169,12 +172,45 @@ void GameState::Protocol(ProtocolStruct* pos)
|
|||
else if((PlayerPos*)pos)
|
||||
PlayerPosProtocol((PlayerPos*)pos);
|
||||
}
|
||||
|
||||
void DanBias::Client::GameState::Protocol( PlayerPos* pos )
|
||||
{
|
||||
Oyster::Math::Float4x4 world, translate;
|
||||
|
||||
world = Oyster::Math::Float4x4::identity;
|
||||
translate = Oyster::Math::Float4x4::identity;
|
||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2]));
|
||||
world = world * translate;
|
||||
privData->object[0]->setPos( world );
|
||||
}
|
||||
|
||||
void DanBias::Client::GameState::Protocol( ObjPos* pos )
|
||||
{
|
||||
Oyster::Math::Float4x4 world;
|
||||
for(int i = 0; i<16; i++)
|
||||
{
|
||||
world[i] = pos->worldPos[i];
|
||||
}
|
||||
privData->object[pos->object_ID]->setPos(world);
|
||||
}
|
||||
|
||||
void GameState::PlayerPosProtocol(PlayerPos* pos)
|
||||
{
|
||||
Oyster::Math::Float4x4 world, translate;
|
||||
|
||||
world = Oyster::Math::Float4x4::identity;
|
||||
translate = Oyster::Math::Float4x4::identity;
|
||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2] ));
|
||||
world = translate;
|
||||
privData->object[0]->setPos( world );
|
||||
}
|
||||
void GameState::ObjectPosProtocol(ObjPos* pos)
|
||||
{
|
||||
|
||||
Oyster::Math::Float4x4 world;
|
||||
for(int i = 0; i<16; i++)
|
||||
{
|
||||
world[i] = pos->worldPos[i];
|
||||
}
|
||||
privData->object[1]->setPos(world);
|
||||
}
|
||||
//void GameState::Protocol(LightPos pos);
|
|
@ -32,6 +32,8 @@ public:
|
|||
bool Release()override;
|
||||
|
||||
void Protocol(ProtocolStruct* pos)override;
|
||||
void Protocol(PlayerPos* pos);
|
||||
void Protocol(ObjPos* pos);
|
||||
void PlayerPosProtocol(PlayerPos* pos);
|
||||
void ObjectPosProtocol(ObjPos* pos);
|
||||
//void Protocol(LightPos pos);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <Windows.h>
|
||||
#include <vld.h>
|
||||
|
||||
|
||||
#include "DanBiasServerAPI.h"
|
||||
//#include "DanBiasGame.h"
|
||||
|
||||
|
@ -29,8 +28,8 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
|||
}
|
||||
// Game client starter code goes here
|
||||
DanBias::DanBiasGameDesc gameDesc;
|
||||
gameDesc.port = 1;
|
||||
gameDesc.IP = "10.1010.303";
|
||||
gameDesc.port = 15151;
|
||||
gameDesc.IP = "193.11.186.101";
|
||||
gameDesc.hinst = hinst;
|
||||
gameDesc.nCmdShow = cmdShow;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace GameLogic
|
|||
{
|
||||
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
int object_ID;
|
||||
float worldMatrix[16];
|
||||
// look at dir
|
||||
|
||||
|
@ -18,7 +19,8 @@ namespace GameLogic
|
|||
this->protocol[0].value = protocol_Gamplay_ObjectPosition;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
@ -34,12 +36,13 @@ namespace GameLogic
|
|||
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[16].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[17].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
|
||||
this->protocol[1].value = worldMatrix[0];
|
||||
this->protocol[1].value = object_ID;
|
||||
this->protocol[2].value = worldMatrix[1];
|
||||
this->protocol[3].value = worldMatrix[2];
|
||||
this->protocol[4].value = worldMatrix[3];
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace GameLogic
|
|||
{
|
||||
struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
|
||||
bool bForward;
|
||||
bool bBackward;
|
||||
bool bTurnLeft;
|
||||
|
@ -25,8 +26,8 @@ namespace GameLogic
|
|||
Protocol_PlayerMovement()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_PlayerNavigation;
|
||||
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
||||
|
@ -52,13 +53,14 @@ namespace GameLogic
|
|||
|
||||
struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
|
||||
float position[3];
|
||||
// look at dir
|
||||
|
||||
Protocol_PlayerPosition()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_PlayerPosition;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
|
Loading…
Reference in New Issue