2013-12-06 10:38:43 +01:00
|
|
|
#include "LobbyState.h"
|
|
|
|
#include "DllInterfaces/GFXAPI.h"
|
|
|
|
#include "OysterMath.h"
|
2013-12-16 09:45:12 +01:00
|
|
|
#include "C_obj/C_Player.h"
|
|
|
|
#include "C_obj/C_StaticObj.h"
|
|
|
|
#include "C_obj/C_DynamicObj.h"
|
2014-01-30 14:17:50 +01:00
|
|
|
#include <GameServerAPI.h>
|
2014-02-04 16:07:10 +01:00
|
|
|
#include <Protocols.h>
|
2013-12-10 11:26:18 +01:00
|
|
|
|
2014-02-12 16:31:15 +01:00
|
|
|
using namespace ::Oyster;
|
|
|
|
using namespace ::Oyster::Network;
|
|
|
|
using namespace ::DanBias::Client;
|
2013-12-06 10:38:43 +01:00
|
|
|
|
2014-02-12 16:31:15 +01:00
|
|
|
struct LobbyState::MyData
|
2013-12-06 10:38:43 +01:00
|
|
|
{
|
2014-02-12 16:31:15 +01:00
|
|
|
MyData(){}
|
|
|
|
|
|
|
|
GameClientState::ClientState nextState;
|
|
|
|
NetworkClient *nwClient;
|
2014-02-12 09:15:41 +01:00
|
|
|
} privData;
|
2013-12-06 10:38:43 +01:00
|
|
|
|
2014-02-12 09:15:41 +01:00
|
|
|
LobbyState::LobbyState(void) {}
|
2013-12-06 10:38:43 +01:00
|
|
|
|
2014-02-12 16:31:15 +01:00
|
|
|
LobbyState::~LobbyState(void)
|
2013-12-06 10:38:43 +01:00
|
|
|
{
|
2014-02-12 16:31:15 +01:00
|
|
|
if( this->privData )
|
|
|
|
this->Release();
|
2013-12-10 11:26:18 +01:00
|
|
|
}
|
2014-02-12 09:15:41 +01:00
|
|
|
|
2014-02-12 16:31:15 +01:00
|
|
|
bool LobbyState::Init(NetworkClient* nwClient)
|
2013-12-10 11:26:18 +01:00
|
|
|
{
|
2014-02-12 16:31:15 +01:00
|
|
|
privData = new MyData();
|
2013-12-09 12:01:36 +01:00
|
|
|
|
2014-02-12 16:31:15 +01:00
|
|
|
this->privData->nextState = GameClientState::ClientState_Same;
|
|
|
|
this->privData->nwClient = nwClient;
|
2013-12-09 12:01:36 +01:00
|
|
|
|
2013-12-10 11:26:18 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-09 09:23:39 +01:00
|
|
|
GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* KeyInput)
|
2013-12-06 10:38:43 +01:00
|
|
|
{
|
2014-02-12 16:31:15 +01:00
|
|
|
//// picking
|
|
|
|
//// mouse events
|
|
|
|
//// different menus
|
|
|
|
//// play sounds
|
|
|
|
//// update animation
|
|
|
|
//// send data to server
|
|
|
|
//// check data from server
|
|
|
|
|
|
|
|
//if(GameServerAPI::ServerIsRunning() && GameServerAPI::ServerIsRunning()) //May be a problem if server is not shut down properly after lan session.
|
|
|
|
//{
|
|
|
|
// if( KeyInput->IsKeyPressed(DIK_G))
|
|
|
|
// {
|
|
|
|
// if(!DanBias::GameServerAPI::GameStart())
|
|
|
|
// {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
2014-01-30 14:17:50 +01:00
|
|
|
|
2014-02-12 16:31:15 +01:00
|
|
|
//return ClientState_Same;
|
|
|
|
|
|
|
|
return this->privData->nextState;
|
2013-12-06 10:38:43 +01:00
|
|
|
}
|
2014-02-12 14:33:56 +01:00
|
|
|
bool LobbyState::Render( )
|
2013-12-06 10:38:43 +01:00
|
|
|
{
|
2014-02-12 16:31:15 +01:00
|
|
|
Graphics::API::NewFrame();
|
|
|
|
Graphics::API::StartGuiRender();
|
2013-12-10 11:26:18 +01:00
|
|
|
|
2014-02-12 16:31:15 +01:00
|
|
|
Graphics::API::EndFrame();
|
2013-12-06 10:38:43 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool LobbyState::Release()
|
|
|
|
{
|
2013-12-09 11:05:47 +01:00
|
|
|
privData = NULL;
|
2013-12-06 10:38:43 +01:00
|
|
|
return true;
|
2013-12-13 12:02:49 +01:00
|
|
|
}
|
2014-02-12 09:15:41 +01:00
|
|
|
|
2014-02-12 16:31:15 +01:00
|
|
|
void LobbyState::ChangeState( ClientState next )
|
|
|
|
{
|
|
|
|
this->privData->nextState = next;
|
|
|
|
}
|
|
|
|
|
2014-02-12 09:15:41 +01:00
|
|
|
using namespace ::Oyster::Network;
|
|
|
|
|
2014-02-12 10:43:06 +01:00
|
|
|
void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
2013-12-13 12:02:49 +01:00
|
|
|
{
|
2014-02-12 09:15:41 +01:00
|
|
|
CustomNetProtocol data = e.args.data.protocol;
|
|
|
|
short ID = data[0].value.netShort; // fetching the id data.
|
2013-12-13 12:02:49 +01:00
|
|
|
|
2014-02-12 09:15:41 +01:00
|
|
|
// Block irrelevant messages.
|
2014-02-12 09:54:33 +01:00
|
|
|
if( ProtocolIsLobby(ID) )
|
2014-02-12 09:15:41 +01:00
|
|
|
{
|
2014-02-12 09:54:33 +01:00
|
|
|
switch(ID)
|
|
|
|
{
|
|
|
|
case protocol_Lobby_Create: break; /** @todo TODO: implement */
|
|
|
|
case protocol_Lobby_Start: break; /** @todo TODO: implement */
|
|
|
|
case protocol_Lobby_Join: break; /** @todo TODO: implement */
|
|
|
|
case protocol_Lobby_Login: break; /** @todo TODO: implement */
|
|
|
|
case protocol_Lobby_Refresh: break; /** @todo TODO: implement */
|
|
|
|
case protocol_Lobby_ClientData: break; /** @todo TODO: implement */
|
|
|
|
case protocol_Lobby_GameData: break; /** @todo TODO: implement */
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( ProtocolIsGeneral(ID) )
|
|
|
|
{
|
|
|
|
switch( ID )
|
|
|
|
{
|
|
|
|
case protocol_General_Status: break; /** @todo TODO: implement */
|
|
|
|
case protocol_General_Text: break; /** @todo TODO: implement */
|
|
|
|
default: break;
|
|
|
|
}
|
2014-02-12 09:15:41 +01:00
|
|
|
}
|
2013-12-06 10:38:43 +01:00
|
|
|
}
|