Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
dean11 2013-12-16 10:02:41 +01:00
commit b351a7bac4
20 changed files with 364 additions and 63 deletions

Binary file not shown.

Binary file not shown.

View File

@ -196,6 +196,7 @@ Global
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32

View File

@ -192,26 +192,26 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="GameClientState\Obj\C_UIobject.cpp" />
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
<ClCompile Include="GameClientState\C_obj\C_UIobject.cpp" />
<ClCompile Include="DanBiasGame_Impl.cpp" />
<ClCompile Include="DLLMain.cpp" />
<ClCompile Include="GameClientState\Obj\C_DynamicObj.cpp" />
<ClCompile Include="GameClientState\GameClientState.cpp" />
<ClCompile Include="GameClientState\GameState.cpp" />
<ClCompile Include="GameClientState\LobbyState.cpp" />
<ClCompile Include="GameClientState\Obj\C_Player.cpp" />
<ClCompile Include="GameClientState\Obj\C_StaticObj.cpp" />
<ClCompile Include="GameClientState\C_Object.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="GameClientState\Obj\C_UIobject.h" />
<ClInclude Include="GameClientState\Obj\C_DynamicObj.h" />
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
<ClInclude Include="GameClientState\C_obj\C_UIobject.h" />
<ClInclude Include="GameClientState\GameClientState.h" />
<ClInclude Include="GameClientState\GameState.h" />
<ClInclude Include="Include\DanBiasGame.h" />
<ClInclude Include="GameClientState\LobbyState.h" />
<ClInclude Include="GameClientState\Obj\C_Player.h" />
<ClInclude Include="GameClientState\Obj\C_StaticObj.h" />
<ClInclude Include="GameClientState\C_Object.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -30,41 +30,39 @@ namespace DanBias
void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& p) override
{
int pType = p[0].value.netInt;
Client::GameClientState::ProtocolStruct* protocol;
switch (pType)
{
case protocol_PlayerNavigation:
int pType = p[0].value.netInt;
Client::GameClientState::ProtocolStruct* protocolData;
switch (pType)
{
case protocol_PlayerNavigation:
break;
case protocol_PlayerPosition:
protocol = new Client::GameClientState::PlayerPos;
for(int i = 0; i< 3; i++)
{
((Client::GameClientState::PlayerPos*)protocol)->playerPos[i] = p[i].value.netFloat;
}
gameClientState->Protocol(protocol);
delete protocol;
protocol = NULL;
break;
break;
case protocol_PlayerPosition:
protocolData = new Client::GameClientState::PlayerPos;
for(int i = 0; i< 3; i++)
{
((Client::GameClientState::PlayerPos*)protocolData)->playerPos[i] = p[i].value.netFloat;
}
gameClientState->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
break;
case protocol_ObjectPosition:
protocol = new Client::GameClientState::ObjPos;
for(int i = 0; i< 16; i++)
{
((Client::GameClientState::ObjPos*)protocol)->worldPos[i] = p[i].value.netFloat;
}
gameClientState->Protocol(protocol);
delete protocol;
protocol = NULL;
break;
default:
break;
}
case protocol_ObjectPosition:
protocolData = new Client::GameClientState::ObjPos;
for(int i = 0; i< 16; i++)
{
((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i].value.netFloat;
}
gameClientState->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
break;
default:
break;
}
}
};
class DanBiasGamePrivateData
@ -112,12 +110,18 @@ namespace DanBias
prevTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
// Start in lobby state
m_data->gameClientState = new Client::LobbyState();
m_data->gameClientState->Init();
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())
{
// failed to connect
return DanBiasClientReturn_Error;
}
// Start in lobby state
m_data->gameClientState = new Client::LobbyState();
m_data->gameClientState->Init(m_data->r->nwClient);
return DanBiasClientReturn_Sucess;
}
@ -253,7 +257,7 @@ namespace DanBias
return E_FAIL;
break;
}
m_data->gameClientState->Init(); // send game client
m_data->gameClientState->Init(m_data->r->nwClient); // send game client
}
return S_OK;

View File

@ -0,0 +1,42 @@
#include "C_DynamicObj.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_DynamicObj::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
// light
// sound
// effect
}privData;
C_DynamicObj::C_DynamicObj(void)
{
}
C_DynamicObj::~C_DynamicObj(void)
{
}
void C_DynamicObj::Init(ModelInitData modelInit)
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
}
void C_DynamicObj::setPos()
{
}
void C_DynamicObj::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_DynamicObj::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,22 @@
#ifndef DANBIAS_CLIENT_CDYNAMICOBJECT_H
#define DANBIAS_CLIENT_CDYNAMICOBJECT_H
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_DynamicObj : public C_Object
{
private:
struct myData;
myData* privData;
public:
C_DynamicObj(void);
virtual ~C_DynamicObj(void);
void Init(ModelInitData modelInit);
void setPos();
void Render();
void Release();
};};};
#endif

View File

@ -0,0 +1,46 @@
#include "C_Player.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_Player::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
}privData;
C_Player::C_Player(void)
{
}
C_Player::~C_Player(void)
{
}
void C_Player::Init(ModelInitData modelInit)
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
}
void C_Player::setPos()
{
}
void C_Player::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_Player::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,25 @@
#ifndef DANBIAS_CLIENT_CPLAYER_H
#define DANBIAS_CLIENT_CPLAYER_H
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_Player : public C_Object
{
private:
struct myData;
myData* privData;
//Oyster::Graphics:: LIght
public:
C_Player(void);
~C_Player(void);
void Init(ModelInitData modelInit);
void setPos();
void Render();
void Release();
};};};
#endif

View File

@ -0,0 +1,45 @@
#include "C_StaticObj.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_StaticObj::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
// light
// sound
// effect
}privData;
C_StaticObj::C_StaticObj(void)
{
}
C_StaticObj::~C_StaticObj(void)
{
}
void C_StaticObj::Init(ModelInitData modelInit)
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
}
void C_StaticObj::setPos()
{
}
void C_StaticObj::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_StaticObj::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,22 @@
#ifndef DANBIAS_CLIENT_CSTATICOBJECT_H
#define DANBIAS_CLIENT_CSTATICOBJECT_H
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_StaticObj : public C_Object
{
private:
struct myData;
myData* privData;
public:
C_StaticObj(void);
virtual ~C_StaticObj(void);
void Init(ModelInitData modelInit);
void setPos();
void Render();
void Release();
};};};
#endif

View File

@ -0,0 +1,43 @@
#include "C_UIobject.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_UIobject::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
}privData;
C_UIobject::C_UIobject(void)
{
}
C_UIobject::~C_UIobject(void)
{
}
void C_UIobject::Init(ModelInitData modelInit)
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
}
void C_UIobject::setPos()
{
}
void C_UIobject::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_UIobject::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,22 @@
#ifndef DANBIAS_CLIENT_CUIOBJECT_H
#define DANBIAS_CLIENT_CUIOBJECT_H
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_UIobject : public C_Object
{
private:
struct myData;
myData* privData;
public:
C_UIobject(void);
virtual ~C_UIobject(void);
void Init(ModelInitData modelInit);
void setPos();
void Render();
void Release();
};};};
#endif

View File

@ -3,6 +3,7 @@
#define NOMINMAX
#include "L_inputClass.h"
#include "NetworkClient.h"
namespace DanBias
{
@ -42,7 +43,7 @@ public:
public:
GameClientState(void);
virtual ~GameClientState(void);
virtual bool Init() = 0;
virtual bool Init(Oyster::Network::NetworkClient* nwClient) = 0;
virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0;
virtual bool Render() = 0;
virtual bool Release() = 0;

View File

@ -1,7 +1,7 @@
#include "GameState.h"
#include "DllInterfaces/GFXAPI.h"
#include "Obj/C_Player.h"
#include "Obj/C_DynamicObj.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_DynamicObj.h"
#include "NetworkClient.h"
#include "PlayerProtocols.h"
@ -28,11 +28,12 @@ GameState::~GameState(void)
{
}
bool GameState::Init()
bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
{
// load models
privData = new myData();
privData->state = gameStateState_loading;
privData->nwClient = nwClient;
privData->state = LoadGame();
return true;
}
@ -92,12 +93,37 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
// update objects
// Client.send(obj);
{
GameLogic::Protocol_PlayerMovement movePlayer;
GameLogic::Protocol_PlayerMovement movePlayer;
movePlayer.bForward = false;
movePlayer.bBackward = false;
movePlayer.bStrafeLeft = false;
movePlayer.bStrafeRight = false;
movePlayer.bTurnLeft = false;
movePlayer.bTurnRight = false;
//privData->nwClient->Send(movePlayer);
if(KeyInput->IsKeyPressed(DIK_L))
privData->state = GameState::gameStateState_end;
if(KeyInput->IsKeyPressed(DIK_W))
{
movePlayer.bForward = true;
}
if(KeyInput->IsKeyPressed(DIK_S))
{
movePlayer.bBackward = true;
}
if(KeyInput->IsKeyPressed(DIK_A))
{
movePlayer.bStrafeLeft = true;
}
if(KeyInput->IsKeyPressed(DIK_D))
{
movePlayer.bStrafeRight = true;
}
privData->nwClient->Send(movePlayer);
if(KeyInput->IsKeyPressed(DIK_L))
privData->state = GameState::gameStateState_end;
}
break;
case gameStateState_end:

View File

@ -22,7 +22,7 @@ private:
public:
GameState(void);
~GameState(void);
bool Init();
bool Init(Oyster::Network::NetworkClient* nwClient);
GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput) override;
bool LoadModels(std::wstring mapFile) ;
bool InitCamera(Oyster::Math::Float3 startPos) ;

View File

@ -1,9 +1,9 @@
#include "LobbyState.h"
#include "DllInterfaces/GFXAPI.h"
#include "OysterMath.h"
#include "Obj/C_Player.h"
#include "Obj/C_StaticObj.h"
#include "Obj/C_DynamicObj.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_StaticObj.h"
#include "C_obj/C_DynamicObj.h"
using namespace DanBias::Client;
@ -28,7 +28,7 @@ LobbyState::~LobbyState(void)
}
bool LobbyState::Init()
bool LobbyState::Init(Oyster::Network::NetworkClient* nwClient)
{
privData = new myData();

View File

@ -17,7 +17,7 @@ private:
public:
LobbyState(void);
~LobbyState(void);
bool Init();
bool Init(Oyster::Network::NetworkClient* nwClient);
bool LoadModels(std::wstring file);
bool InitCamera(Oyster::Math::Float3 startPos);
ClientState Update(float deltaTime, InputClass* KeyInput);

View File

@ -1,7 +1,7 @@
#ifndef DANBIASGAME_DANBIASGAME_H
#define DANBIASGAME_DANBIASGAME_H
#define DANBIAS_CLIENT_L
#define DANBIAS_CLIENT
#if defined (DANBIAS_GAME_DLL_EXPORT)
#define DANBIAS_GAME_DLL __declspec(dllexport)
@ -29,6 +29,7 @@ namespace DanBias
{
//Stuff goes here...
int port;
const char* IP;
HINSTANCE hinst;
int nCmdShow;

View File

@ -6,8 +6,8 @@
#include <vld.h>
#include "DanBiasServerAPI.h"
//#include "DanBiasGame.h"
//#include "DanBiasServerAPI.h"
#include "DanBiasGame.h"
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
@ -22,7 +22,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
DanBias::DanBiasServerAPI::Run();
DanBias::DanBiasServerAPI::Release();
}
#elif defined(DANBIAS_CLIENT_L)
#elif defined(DANBIAS_CLIENT)
if(SetDllDirectory(L"..\\DLL") == FALSE)
{
return cmdShow;
@ -30,6 +30,7 @@ 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.hinst = hinst;
gameDesc.nCmdShow = cmdShow;