GL - Lan State

This commit is contained in:
Pontus Fransson 2014-01-31 10:49:52 +01:00
parent cec022b381
commit e718048f7f
6 changed files with 68 additions and 9 deletions

View File

@ -38,7 +38,7 @@ namespace DanBias
public:
WindowShell* window;
InputClass* inputObj;
Utility::WinTimer* timer;
Utility::WinTimer timer;
GameRecieverObject* recieverObj;
bool serverOwner;
@ -68,12 +68,11 @@ namespace DanBias
m_data->serverOwner = false;
// Start in lobby state
m_data->recieverObj->gameClientState = new Client::LoginState();
m_data->recieverObj->gameClientState = new Client::LanMenuState();
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
return DanBiasClientReturn_Error;
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
m_data->timer->reset();
m_data->timer.reset();
return DanBiasClientReturn_Sucess;
}
@ -82,8 +81,8 @@ namespace DanBias
// Main message loop
while(m_data->window->Frame())
{
float dt = (float)m_data->timer->getElapsedSeconds();
m_data->timer->reset();
float dt = (float)m_data->timer.getElapsedSeconds();
m_data->timer.reset();
capFrame += dt;
if(capFrame > 0.03)
@ -130,8 +129,8 @@ namespace DanBias
HRESULT DanBiasGame::Update(float deltaTime)
{
m_data->recieverObj->Update();
if(m_data->recieverObj->IsConnected())
m_data->recieverObj->Update();
m_data->inputObj->Update();
if(m_data->serverOwner)
@ -191,7 +190,6 @@ namespace DanBias
delete m_data->recieverObj->gameClientState;
m_data->recieverObj->Disconnect();
delete m_data->recieverObj;
delete m_data->timer;
delete m_data->inputObj;
delete m_data;

View File

@ -2,6 +2,8 @@
#define DANBIAS_CLIENTRECIEVEROBJECT_H
//WTF!? No headers included???
#include "../DanBiasGame/Include/DanBiasGame.h"
#include "../GameProtocols/GeneralProtocols.h"
namespace DanBias
{

View File

@ -53,6 +53,7 @@ public:
{
ClientState_Login,
ClientState_Lobby,
ClientState_Lan,
ClientState_LobbyCreated,
ClientState_Game,
ClientState_Same,

View File

@ -5,6 +5,10 @@
#include "C_obj/C_DynamicObj.h"
#include "DllInterfaces/GFXAPI.h"
#include "LobbyState.h"
#include "GameState.h"
#include "../GameClientRecieverFunc.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
@ -16,6 +20,10 @@ struct LanMenuState::myData
Oyster::Math3D::Float4x4 proj;
C_Object* object[2];
int modelCount;
GameRecieverObject* recieverObj;
bool serverOwner;
// UI object
// game client*
}privData;
@ -83,6 +91,49 @@ bool LanMenuState::InitCamera(Oyster::Math::Float3 startPos)
}
GameClientState::ClientState LanMenuState::Update(float deltaTime, InputClass* KeyInput)
{
/*ChangeState(KeyInput);
if(privData->recieverObj->IsConnected())
privData->recieverObj->Update();
KeyInput->Update();
if(privData->serverOwner)
{
DanBias::GameServerAPI::ServerUpdate();
}
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
state = privData->recieverObj->gameClientState->Update(deltaTime, KeyInput);
if(state != Client::GameClientState::ClientState_Same)
{
privData->recieverObj->gameClientState->Release();
delete privData->recieverObj->gameClientState;
privData->recieverObj->gameClientState = NULL;
switch (state)
{
case Client::GameClientState::ClientState_LobbyCreated:
privData->serverOwner = true;
case Client::GameClientState::ClientState_Lobby:
privData->recieverObj->gameClientState = new Client::LobbyState();
break;
case Client::GameClientState::ClientState_Game:
privData->recieverObj->gameClientState = new Client::GameState();
break;
default:
//return E_FAIL;
break;
}
privData->recieverObj->gameClientState->Init(privData->recieverObj); // send game client
}*/
return ChangeState(KeyInput);
}
GameClientState::ClientState LanMenuState::ChangeState(InputClass* KeyInput)
{
// create game
if( KeyInput->IsKeyPressed(DIK_C))

View File

@ -17,6 +17,8 @@ namespace DanBias
virtual bool Init(Oyster::Network::NetworkClient* nwClient);
virtual ClientState Update(float deltaTime, InputClass* KeyInput);
ClientState ChangeState(InputClass* KeyInput);
bool LoadModels(std::wstring file);
bool InitCamera(Oyster::Math::Float3 startPos);

View File

@ -88,6 +88,8 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key
// send data to server
// check data from server
// create game
if( KeyInput->IsKeyPressed(DIK_C))
{
@ -118,6 +120,9 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key
}
return ClientState_Lobby;
}
return ClientState_Same;
}
bool LoginState::Render()