diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 502815fb..cf0f049f 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -87,6 +87,8 @@ namespace DanBias float dt = (float)data.timer.getElapsedSeconds(); data.timer.reset(); + ::Oyster::Graphics::API::Update( dt ); + if(data.networkClient.IsConnected()) data.networkClient.Update(); @@ -95,7 +97,7 @@ namespace DanBias { if(Update(dt) != S_OK) return DanBiasClientReturn_Error; - if(Render(dt) != S_OK) + if(Render() != S_OK) return DanBiasClientReturn_Error; data.capFrame = 0; } @@ -185,7 +187,7 @@ namespace DanBias return S_OK; } - HRESULT DanBiasGame::Render(float deltaTime) + HRESULT DanBiasGame::Render( ) { data.state->Render(); diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.h b/Code/Game/DanBiasGame/GameClientState/C_Object.h index 4dec19ec..1b50b73d 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_Object.h +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.h @@ -17,12 +17,14 @@ namespace DanBias class C_Object { + protected: + Oyster::Graphics::Model::Model *model; private: Oyster::Math::Float4x4 world; Oyster::Math::Float3 position; Oyster::Math::Quaternion rotation; Oyster::Math::Float3 scale; - Oyster::Graphics::Model::Model *model; + int id; void updateWorld(); public: diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp index a75785a6..916a6d16 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp @@ -3,19 +3,14 @@ using namespace DanBias::Client; C_Player::C_Player(void) - :C_DynamicObj() -{ + :C_DynamicObj() {} -} - -C_Player::~C_Player(void) -{ - -} +C_Player::~C_Player(void) {} void C_Player::Init(ModelInitData modelInit) { C_Object::Init(modelInit); - Oyster::Graphics::API::PlayAnimation(model, L"movement"); + + Oyster::Graphics::API::PlayAnimation( this->model, L"movement" ); //Oyster::Graphics::API::Update(0.002f); } diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h index 9d7c3de0..e08d2589 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h @@ -5,13 +5,15 @@ namespace DanBias { namespace Client { -class C_Player : public C_DynamicObj -{ -private: -public: - C_Player(void); - virtual ~C_Player(void); - void Init(ModelInitData modelInit); + class C_Player : public C_DynamicObj + { + private: + public: + C_Player(void); + virtual ~C_Player(void); + void Init(ModelInitData modelInit); -};};}; + }; + } +} #endif diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp b/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp index d0d811f4..dde3e874 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp @@ -11,5 +11,5 @@ GameClientState::~GameClientState(void) { } -void DataRecieved( NetEvent e ) +void GameClientState::DataRecieved( NetEvent e ) { /* do nothing */ } \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 52cb03e0..63475ab8 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -409,10 +409,6 @@ void GameState::readKeyInput(InputClass* KeyInput) GameLogic::Protocol_PlayerLook playerLookDir; Float4 look = camera.GetLook(); - playerLookDir.lookDirX = look.x; - playerLookDir.lookDirY = look.y; - playerLookDir.lookDirZ = look.z; - playerLookDir.deltaX = -KeyInput->GetYaw(); privData->nwClient->Send( playerLookDir ); } diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index 34711b82..d83d566a 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -164,7 +164,7 @@ GameClientState::ClientState LanMenuState::ChangeState(InputClass* KeyInput) return ClientState_Same; } -bool LanMenuState::Render(float dt) +bool LanMenuState::Render( ) { Oyster::Graphics::API::SetView(privData->view); Oyster::Graphics::API::SetProjection( privData->proj); diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.h b/Code/Game/DanBiasGame/GameClientState/LanMenuState.h index 03194f1d..def6074b 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.h +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.h @@ -22,7 +22,7 @@ namespace DanBias bool LoadModels(std::wstring file); bool InitCamera(Oyster::Math::Float3 startPos); - virtual bool Render(float dt); + virtual bool Render(); virtual bool Release(); private: diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index dc2ed2be..71a21ca6 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -98,9 +98,8 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key return ClientState_Same; } -bool LobbyState::Render(float dt) +bool LobbyState::Render( ) { - Oyster::Graphics::API::SetView(privData->view); Oyster::Graphics::API::SetProjection( privData->proj); diff --git a/Code/Game/DanBiasGame/GameClientState/MainState.cpp b/Code/Game/DanBiasGame/GameClientState/MainState.cpp index 710eebbe..cc5aaa29 100644 --- a/Code/Game/DanBiasGame/GameClientState/MainState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/MainState.cpp @@ -7,10 +7,15 @@ #include #include "NetworkClient.h" +#include "EventHandler\EventHandler.h" +#include "Buttons\ButtonRectangle.h" + using namespace ::DanBias::Client; using namespace ::Oyster::Math3D; using namespace ::Oyster::Network; using namespace ::Utility::DynamicMemory; +using namespace ::Utility::StaticArray; +using namespace ::Oyster::Event; struct MainState::MyData { @@ -20,10 +25,12 @@ struct MainState::MyData Float4x4 proj; UniquePointer object[2]; - int modelCount; NetworkClient *nwClient; + EventButtonCollection button; }; +void OnButtonInteract( Oyster::Event::ButtonEvent& e ); + MainState::MainState(void) {} MainState::~MainState(void) {} @@ -32,6 +39,13 @@ bool MainState::Init( NetworkClient* nwClient ) { this->privData = new MyData(); + // create buttons + ButtonRectangle *button = new ButtonRectangle( L"box_tex.png", OnButtonInteract, this, 0.5f, 0.5f, 0.1f, 0.1f, true ); + this->privData->button.AddButton( button ); + + // bind button collection to the singleton eventhandler + EventHandler::Instance().AddCollection( &this->privData->button ); + // load models LoadModels(L"UImodels.txt"); InitCamera( Float3(0.0f, 0.0f, 5.4f) ); @@ -49,7 +63,6 @@ bool MainState::LoadModels(std::wstring file) // open file // read file // init models - privData->modelCount = 2; ModelInitData modelData; @@ -126,16 +139,19 @@ GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyI bool MainState::Render() { - Oyster::Graphics::API::SetView(privData->view); Oyster::Graphics::API::SetProjection( privData->proj); Oyster::Graphics::API::NewFrame(); // render objects - for (int i = 0; i < privData->modelCount; i++) - { - privData->object[i]->Render(); - } + //for (int i = 0; i < NumElementsOf(privData->object); i++) + //{ + // privData->object[i]->Render(); + //} + + Oyster::Graphics::API::StartGuiRender(); + this->privData->button.Render(); + // render effects @@ -147,15 +163,19 @@ bool MainState::Render() bool MainState::Release() { - for (int i = 0; i < privData->modelCount; i++) + for (int i = 0; i < NumElementsOf(privData->object); i++) { - privData->object[i]->Release(); - delete privData->object[i]; privData->object[i] = NULL; } - delete privData; privData = NULL; + // button collection will be autoreleased from EventHandler + return true; } +/// button actions +void OnButtonInteract( Oyster::Event::ButtonEvent& e ) +{ + +} diff --git a/Code/Game/DanBiasGame/GameClientState/MainState.h b/Code/Game/DanBiasGame/GameClientState/MainState.h index 0e7bf1b6..27dcd772 100644 --- a/Code/Game/DanBiasGame/GameClientState/MainState.h +++ b/Code/Game/DanBiasGame/GameClientState/MainState.h @@ -24,8 +24,6 @@ namespace DanBias bool Render(); bool Release(); - - void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e ); }; } } diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h index 33795482..e49da75b 100644 --- a/Code/Game/DanBiasGame/Include/DanBiasGame.h +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -52,7 +52,7 @@ namespace DanBias static HRESULT InitInput(); static HRESULT Update(float deltaTime); - static HRESULT Render(float deltaTime); + static HRESULT Render(); static HRESULT CleanUp(); }; diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index 1178782c..de6539df 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -38,7 +38,6 @@ struct NetworkClient::PrivateData : public IThreadObject { NetworkSession *owner; NetworkClient *parent; - ClientEventFunction OnRecieve; Connection connection; Translator translator; OysterThread thread; @@ -57,7 +56,6 @@ struct NetworkClient::PrivateData : public IThreadObject : ID(currID++) , parent(0) , owner(0) - , OnRecieve(OnRecieve_Default) { InitWinSock(); this->thread.Create(this, false); @@ -226,7 +224,8 @@ unsigned int NetworkClient::PrivateData::currID = 0; *************************************/ NetworkClient::NetworkClient() - : privateData(0) + : privateData(nullptr), + OnRecieve(OnRecieve_Default) { } NetworkClient::~NetworkClient() @@ -326,11 +325,11 @@ void NetworkClient::SetMessagePump( NetworkClient::ClientEventFunction func ) { if( func ) { - this->privateData->OnRecieve = func; + this->OnRecieve = func; } else { - this->privateData->OnRecieve = OnRecieve_Default; + this->OnRecieve = OnRecieve_Default; } } @@ -353,7 +352,7 @@ void NetworkClient::DataRecieved(NetEvent e) } else { - this->privateData->OnRecieve( e ); + this->OnRecieve( e ); } } diff --git a/Code/Network/NetworkAPI/NetworkClient.h b/Code/Network/NetworkAPI/NetworkClient.h index 46eedf9b..4533070c 100644 --- a/Code/Network/NetworkAPI/NetworkClient.h +++ b/Code/Network/NetworkAPI/NetworkClient.h @@ -140,6 +140,7 @@ namespace Oyster NetworkClient(const NetworkClient& obj); NetworkClient& operator =(const NetworkClient& obj); + ClientEventFunction OnRecieve; struct PrivateData; PrivateData* privateData; };