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

This commit is contained in:
Pontus Fransson 2014-01-30 23:24:16 +01:00
commit cec022b381
5 changed files with 13 additions and 9 deletions

View File

@ -9,6 +9,7 @@
#include "GameClientState\LanMenuState.h" #include "GameClientState\LanMenuState.h"
#include <Protocols.h> #include <Protocols.h>
#include "NetworkClient.h" #include "NetworkClient.h"
#include <GameServerAPI.h>
#include "../WindowManager/WindowShell.h" #include "../WindowManager/WindowShell.h"
#include "L_inputClass.h" #include "L_inputClass.h"
@ -39,6 +40,7 @@ namespace DanBias
InputClass* inputObj; InputClass* inputObj;
Utility::WinTimer* timer; Utility::WinTimer* timer;
GameRecieverObject* recieverObj; GameRecieverObject* recieverObj;
bool serverOwner;
} data; } data;
#pragma endregion #pragma endregion
@ -63,13 +65,8 @@ namespace DanBias
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
m_data->recieverObj = new GameRecieverObject; m_data->recieverObj = new GameRecieverObject;
/*m_data->recieverObj->Connect(desc.port, desc.IP); m_data->serverOwner = false;
if (!m_data->recieverObj->IsConnected())
{
// failed to connect
return DanBiasClientReturn_Error;
}*/
// Start in lobby state // Start in lobby state
m_data->recieverObj->gameClientState = new Client::LoginState(); m_data->recieverObj->gameClientState = new Client::LoginState();
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj)) if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
@ -134,8 +131,13 @@ namespace DanBias
HRESULT DanBiasGame::Update(float deltaTime) HRESULT DanBiasGame::Update(float deltaTime)
{ {
m_data->recieverObj->Update();
m_data->inputObj->Update(); m_data->inputObj->Update();
if(m_data->serverOwner)
{
DanBias::GameServerAPI::ServerUpdate();
}
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same; DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
state = m_data->recieverObj->gameClientState->Update(deltaTime, m_data->inputObj); state = m_data->recieverObj->gameClientState->Update(deltaTime, m_data->inputObj);
@ -148,6 +150,8 @@ namespace DanBias
switch (state) switch (state)
{ {
case Client::GameClientState::ClientState_LobbyCreated:
m_data->serverOwner = true;
case Client::GameClientState::ClientState_Lobby: case Client::GameClientState::ClientState_Lobby:
m_data->recieverObj->gameClientState = new Client::LobbyState(); m_data->recieverObj->gameClientState = new Client::LobbyState();
break; break;

View File

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

View File

@ -144,7 +144,6 @@ bool GameState::InitCamera(Oyster::Math::Float3 startPos)
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput) GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
{ {
DanBias::GameServerAPI::ServerUpdate();
switch (privData->state) switch (privData->state)
{ {
case gameStateState_loading: case gameStateState_loading:

View File

@ -87,7 +87,7 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key
// update animation // update animation
// send data to server // send data to server
// check data from server // check data from server
DanBias::GameServerAPI::ServerUpdate();
if( KeyInput->IsKeyPressed(DIK_G)) if( KeyInput->IsKeyPressed(DIK_G))
{ {

View File

@ -103,7 +103,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key
// failed to connect // failed to connect
return ClientState_Same; return ClientState_Same;
} }
return ClientState_Lobby; return ClientState_LobbyCreated;
} }
// join game // join game
if( KeyInput->IsKeyPressed(DIK_J)) if( KeyInput->IsKeyPressed(DIK_J))