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"
|
2013-12-10 11:26:18 +01:00
|
|
|
|
2013-12-06 10:38:43 +01:00
|
|
|
using namespace DanBias::Client;
|
|
|
|
|
2013-12-09 09:23:39 +01:00
|
|
|
struct LobbyState::myData
|
2013-12-06 10:38:43 +01:00
|
|
|
{
|
2013-12-09 09:23:39 +01:00
|
|
|
myData(){}
|
2013-12-06 10:38:43 +01:00
|
|
|
Oyster::Math3D::Float4x4 view;
|
|
|
|
Oyster::Math3D::Float4x4 proj;
|
2013-12-10 11:26:18 +01:00
|
|
|
C_Object* object[2];
|
|
|
|
int modelCount;
|
|
|
|
// UI object
|
|
|
|
// game client*
|
2013-12-09 09:23:39 +01:00
|
|
|
}privData;
|
2013-12-06 10:38:43 +01:00
|
|
|
|
|
|
|
LobbyState::LobbyState(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
LobbyState::~LobbyState(void)
|
|
|
|
{
|
2013-12-09 11:05:47 +01:00
|
|
|
|
2013-12-06 10:38:43 +01:00
|
|
|
}
|
2013-12-10 11:26:18 +01:00
|
|
|
|
2013-12-16 09:45:12 +01:00
|
|
|
bool LobbyState::Init(Oyster::Network::NetworkClient* nwClient)
|
2013-12-06 10:38:43 +01:00
|
|
|
{
|
2013-12-10 11:26:18 +01:00
|
|
|
privData = new myData();
|
|
|
|
|
|
|
|
// load models
|
|
|
|
LoadModels(L"UImodels.txt");
|
|
|
|
InitCamera(Oyster::Math::Float3(0,0,5.4f));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool LobbyState::LoadModels(std::wstring file)
|
|
|
|
{
|
|
|
|
// open file
|
|
|
|
// read file
|
|
|
|
// init models
|
|
|
|
privData->modelCount = 2;
|
|
|
|
|
2013-12-09 12:01:36 +01:00
|
|
|
ModelInitData modelData;
|
|
|
|
|
|
|
|
modelData.world = Oyster::Math3D::Float4x4::identity;
|
|
|
|
modelData.visible = true;
|
2013-12-19 13:35:56 +01:00
|
|
|
modelData.modelPath = L"..\\Content\\crate";
|
2013-12-09 09:23:39 +01:00
|
|
|
// load models
|
2013-12-10 11:26:18 +01:00
|
|
|
privData->object[0] = new C_StaticObj();
|
|
|
|
privData->object[0]->Init(modelData);
|
2013-12-09 12:01:36 +01:00
|
|
|
|
2013-12-10 11:26:18 +01:00
|
|
|
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
|
|
|
|
modelData.world = modelData.world * translate;
|
2013-12-09 09:23:39 +01:00
|
|
|
|
2013-12-10 11:26:18 +01:00
|
|
|
privData->object[1] = new C_DynamicObj();
|
|
|
|
privData->object[1]->Init(modelData);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LobbyState::InitCamera(Oyster::Math::Float3 startPos)
|
|
|
|
{
|
2013-12-09 09:23:39 +01:00
|
|
|
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
|
|
|
|
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
|
|
|
|
Oyster::Graphics::API::SetProjection(privData->proj);
|
|
|
|
|
2013-12-10 11:26:18 +01:00
|
|
|
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
|
2013-12-09 09:23:39 +01:00
|
|
|
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
2013-12-06 10:38:43 +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
|
|
|
{
|
2013-12-10 11:26:18 +01:00
|
|
|
// picking
|
|
|
|
// mouse events
|
|
|
|
// different menus
|
|
|
|
// play sounds
|
|
|
|
// update animation
|
|
|
|
// send data to server
|
|
|
|
// check data from server
|
2013-12-06 10:38:43 +01:00
|
|
|
|
2013-12-09 11:05:47 +01:00
|
|
|
if( KeyInput->IsKeyPressed(DIK_G))
|
2013-12-09 09:23:39 +01:00
|
|
|
return ClientState_Game;
|
2013-12-06 10:38:43 +01:00
|
|
|
return ClientState_Same;
|
|
|
|
}
|
|
|
|
bool LobbyState::Render()
|
|
|
|
{
|
2013-12-09 09:23:39 +01:00
|
|
|
|
|
|
|
Oyster::Graphics::API::SetView(privData->view);
|
|
|
|
Oyster::Graphics::API::SetProjection( privData->proj);
|
2013-12-10 11:26:18 +01:00
|
|
|
|
|
|
|
|
2013-12-09 09:23:39 +01:00
|
|
|
Oyster::Graphics::API::NewFrame();
|
2013-12-09 11:05:47 +01:00
|
|
|
// render objects
|
2013-12-10 11:26:18 +01:00
|
|
|
for (int i = 0; i < privData->modelCount; i++)
|
|
|
|
{
|
|
|
|
privData->object[i]->Render();
|
|
|
|
}
|
|
|
|
|
|
|
|
// render effects
|
|
|
|
|
|
|
|
// render lights
|
|
|
|
|
2013-12-06 10:38:43 +01:00
|
|
|
Oyster::Graphics::API::EndFrame();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool LobbyState::Release()
|
|
|
|
{
|
2013-12-10 11:26:18 +01:00
|
|
|
for (int i = 0; i < privData->modelCount; i++)
|
|
|
|
{
|
|
|
|
privData->object[i]->Release();
|
|
|
|
delete privData->object[i];
|
|
|
|
privData->object[i] = NULL;
|
|
|
|
}
|
|
|
|
|
2013-12-09 11:05:47 +01:00
|
|
|
delete privData;
|
|
|
|
privData = NULL;
|
2013-12-06 10:38:43 +01:00
|
|
|
return true;
|
2013-12-13 12:02:49 +01:00
|
|
|
}
|
|
|
|
void LobbyState::Protocol(ProtocolStruct* protocol)
|
|
|
|
{
|
|
|
|
if((PlayerName*)protocol)
|
|
|
|
PlayerJoinProtocol((PlayerName*)protocol);
|
|
|
|
|
|
|
|
}
|
|
|
|
void LobbyState::PlayerJoinProtocol(PlayerName* name)
|
|
|
|
{
|
|
|
|
|
2013-12-06 10:38:43 +01:00
|
|
|
}
|