diff --git a/Code/Game/GameClient/GameClient.vcxproj b/Code/Game/GameClient/GameClient.vcxproj index 349a88ec..082a9344 100644 --- a/Code/Game/GameClient/GameClient.vcxproj +++ b/Code/Game/GameClient/GameClient.vcxproj @@ -211,6 +211,8 @@ + + @@ -221,6 +223,7 @@ + @@ -237,6 +240,8 @@ + + @@ -246,6 +251,7 @@ + diff --git a/Code/Game/GameClient/GameClient.vcxproj.user b/Code/Game/GameClient/GameClient.vcxproj.user index 2e28d6f7..4b847ee6 100644 --- a/Code/Game/GameClient/GameClient.vcxproj.user +++ b/Code/Game/GameClient/GameClient.vcxproj.user @@ -1,7 +1,7 @@  - true + false $(OutDir) diff --git a/Code/Game/GameClient/GameClientState/GameClientState.h b/Code/Game/GameClient/GameClientState/GameClientState.h index 9891a16c..d336e196 100644 --- a/Code/Game/GameClient/GameClientState/GameClientState.h +++ b/Code/Game/GameClient/GameClientState/GameClientState.h @@ -35,7 +35,7 @@ namespace DanBias { namespace Client /****************************************************************** * @param message of the event - * @return message or GameClientState::event_processed. + * @return message or a reference to GameClientState::event_processed. ******************************************************************/ virtual const NetEvent & DataRecieved( const NetEvent &message ); }; diff --git a/Code/Game/GameClient/GameClientState/GameStateUI.cpp b/Code/Game/GameClient/GameClientState/GameStateUI.cpp new file mode 100644 index 00000000..6b8b7ed5 --- /dev/null +++ b/Code/Game/GameClient/GameClientState/GameStateUI.cpp @@ -0,0 +1,17 @@ +#include "GameStateUI.h" + +using namespace ::DanBias::Client; +using namespace ::Oyster::Network; + +GameStateUI::GameStateUI() +{ + this->nextState = GameStateUI::UIState_same; +} + +GameStateUI::~GameStateUI() { /* Do nothing */ } + +const GameStateUI::NetEvent & GameStateUI::DataRecieved( const GameStateUI::NetEvent &message ) +{ + /* Do nothing */ + return message; +} \ No newline at end of file diff --git a/Code/Game/GameClient/GameClientState/GameStateUI.h b/Code/Game/GameClient/GameClientState/GameStateUI.h new file mode 100644 index 00000000..40350211 --- /dev/null +++ b/Code/Game/GameClient/GameClientState/GameStateUI.h @@ -0,0 +1,58 @@ +#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H +#define DANBIAS_CLIENT_GAMECLIENTSTATE_H + +#include "Utilities.h" +#include "NetworkClient.h" + +namespace DanBias { namespace Client +{ + class GameStateUI + { + public: + enum UIState + { + UIState_same, + UIState_gaming, + + + UIState_main_menu, + UIState_shut_down + }; + + typedef ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> NetEvent; + static const NetEvent event_processed; + + GameStateUI(); + virtual ~GameStateUI(); + virtual UIState Update( float deltaTime ) = 0; + virtual bool HaveGUIRender() const = 0; + virtual bool HaveTextRender() const = 0; + virtual void RenderGUI() const = 0; + virtual void RenderText() const = 0; + virtual bool Release() = 0; + + /****************************************************************** + * @param message of the event + * @return message or a reference to GameStateUI::event_processed. + ******************************************************************/ + virtual const NetEvent & DataRecieved( const NetEvent &message ); + + protected: + UIState nextState; + }; +} } + +namespace Utility { namespace DynamicMemory +{ // template specializationto allowuse of dynamicmemory tools + template<> + inline void SafeDeleteInstance( ::DanBias::Client::GameStateUI *dynamicInstance ) + { + if( dynamicInstance ) + { + dynamicInstance->Release(); + delete dynamicInstance; + } + } +} } + +#endif \ No newline at end of file diff --git a/Code/Game/GameClient/GameClientState/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp new file mode 100644 index 00000000..a2edc28f --- /dev/null +++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp @@ -0,0 +1,153 @@ +#include "GamingUI.h" +#include + +using namespace ::DanBias::Client; +using namespace ::Oyster::Network; +using namespace ::GameLogic; + +GamingUI::GamingUI() : + GameStateUI() +{ + /* Should never be called! */ + this->input = nullptr; + this->netClient = nullptr; + this->camera = nullptr; +} + +GamingUI::GamingUI( InputClass *input, NetworkClient *connection, Camera_FPSV2 *camera ) : + GameStateUI() +{ + this->input = input; + this->netClient = connection; + this->camera = camera; +} + +GamingUI::~GamingUI() { /* Do nothing */ } + +GameStateUI::UIState GamingUI::Update( float deltaTime ) +{ + return this->nextState; +} + +bool GamingUI::HaveGUIRender() const +{ + return false; // TODO: change to true when we want UI elements like a crosshair +} + +bool GamingUI::HaveTextRender() const +{ + return false; // TODO: change to true when we want UI elements like a chat window +} + +void GamingUI::RenderGUI() const +{ + // TODO: Render crosshairs and such here. Don't forget to adjust GamingUI::HaveGUIRender +} + +void GamingUI::RenderText() const +{ + // TODO: Render chattext and such here. Don't forget to adjust GamingUI::HaveGUIRender +} + +bool GamingUI::Release() +{ + // TODO: Release UI components here. + return true; +} + +void GamingUI::ReadKeyInput() +{ + if( this->input->IsKeyPressed(DIK_W) ) + { + this->netClient->Send( Protocol_PlayerMovementForward() ); + } + + if( this->input->IsKeyPressed(DIK_S) ) + { + this->netClient->Send( Protocol_PlayerMovementBackward() ); + } + + if( this->input->IsKeyPressed(DIK_A) ) + { + this->netClient->Send( Protocol_PlayerMovementLeft() ); + } + + if( this->input->IsKeyPressed(DIK_D) ) + { + this->netClient->Send( Protocol_PlayerMovementRight() ); + } + +// if( this->input->IsKeyPressed(DIK_R) ) +// { +// if( !this->key_Reload_Shaders ) +// { +//#ifdef _DEBUG +// Graphics::API::ReloadShaders(); +//#endif +// this->key_Reload_Shaders = true; +// } +// } +// else +// this->key_Reload_Shaders = false; + + //send delta mouse movement + { + this->camera->YawRight( this->input->GetYaw() * 0.017f ); + this->camera->PitchDown( this->input->GetPitch() * 0.017f ); + this->camera->UpdateOrientation(); + + this->netClient->Send( Protocol_PlayerLook(this->camera->GetLook(), this->camera->GetRight()) ); + } + + // shoot + //if( this->input->IsKeyPressed(DIK_Z) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = true; + // playerShot.secondaryPressed = false; + // playerShot.utilityPressed = false; + // this->netClient->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; + + //if( this->input->IsKeyPressed(DIK_X) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = false; + // playerShot.secondaryPressed = true; + // playerShot.utilityPressed = false; + // this->netClient->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; + + //if( this->input->IsKeyPressed(DIK_C) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = false; + // playerShot.secondaryPressed = false; + // playerShot.utilityPressed = true; + // this->netClient->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; + + // jump + if( this->input->IsKeyPressed(DIK_SPACE) ) + { + this->netClient->Send( Protocol_PlayerJump() ); + } +} \ No newline at end of file diff --git a/Code/Game/GameClient/GameClientState/GamingUI.h b/Code/Game/GameClient/GameClientState/GamingUI.h new file mode 100644 index 00000000..9f93674b --- /dev/null +++ b/Code/Game/GameClient/GameClientState/GamingUI.h @@ -0,0 +1,33 @@ +#ifndef DANBIAS_CLIENT_GAMING_UI_H +#define DANBIAS_CLIENT_GAMING_UI_H + +#include "GameStateUI.h" +#include "L_inputClass.h" +#include "Camera_FPSV2.h" + +namespace DanBias { namespace Client +{ + class GamingUI : public GameStateUI + { + public: + GamingUI( InputClass *input, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera ); + virtual ~GamingUI(); + + UIState Update( float deltaTime ); + bool HaveGUIRender() const; + bool HaveTextRender() const; + void RenderGUI() const; + void RenderText() const; + bool Release(); + + private: + InputClass *input; + ::Oyster::Network::NetworkClient *netClient; + Camera_FPSV2 *camera; + + GamingUI(); + void ReadKeyInput(); + }; +} } + +#endif \ No newline at end of file diff --git a/Code/Game/GameClient/GameClientState/RespawnUI.cpp b/Code/Game/GameClient/GameClientState/RespawnUI.cpp new file mode 100644 index 00000000..4588d367 --- /dev/null +++ b/Code/Game/GameClient/GameClientState/RespawnUI.cpp @@ -0,0 +1,58 @@ +#include "RespawnUI.h" + +using namespace ::DanBias::Client; +using namespace ::Oyster::Network; +using namespace ::Utility::Value; + +RespawnUI::RespawnUI() : + GameStateUI() +{ + /* Should never be called! */ + this->netClient = nullptr; + this->countDown = 0.0f; +} + +RespawnUI::RespawnUI( NetworkClient *connection, float delay ) : + GameStateUI() +{ + this->netClient = connection; + this->countDown = delay; +} + +RespawnUI::~RespawnUI() { /* Do nothing */ } + +GameStateUI::UIState RespawnUI::Update( float deltaTime ) +{ + this->countDown = Max( this->countDown - deltaTime, 0.0f ); + return this->nextState; +} + +bool RespawnUI::HaveGUIRender() const +{ + return false; // TODO: change to true when we want UI elements like a crosshair +} + +bool RespawnUI::HaveTextRender() const +{ + return false; // TODO: change to true when we want UI elements like a chat window +} + +void RespawnUI::RenderGUI() const +{ + // TODO: We need? +} + +void RespawnUI::RenderText() const +{ + // TODO: Text countdown somewhere on screen would be nice +} + +bool RespawnUI::Release() +{ + // TODO: Release UI components here. + return true; +} + + + + diff --git a/Code/Game/GameClient/GameClientState/RespawnUI.h b/Code/Game/GameClient/GameClientState/RespawnUI.h new file mode 100644 index 00000000..c45616b7 --- /dev/null +++ b/Code/Game/GameClient/GameClientState/RespawnUI.h @@ -0,0 +1,29 @@ +#ifndef DANBIAS_CLIENT_RESPAWN_UI_H +#define DANBIAS_CLIENT_RESPAWN_UI_H + +#include "GameStateUI.h" + +namespace DanBias { namespace Client +{ + class RespawnUI : public GameStateUI + { + public: + RespawnUI( ::Oyster::Network::NetworkClient *connection, float delay ); + virtual ~RespawnUI(); + + UIState Update( float deltaTime ); + bool HaveGUIRender() const; + bool HaveTextRender() const; + void RenderGUI() const; + void RenderText() const; + bool Release(); + + private: + ::Oyster::Network::NetworkClient *netClient; + float countDown; + + RespawnUI(); + }; +} } + +#endif \ No newline at end of file diff --git a/Code/Misc/Input/L_inputClass.h b/Code/Misc/Input/L_inputClass.h index 8ed8e528..5511102a 100644 --- a/Code/Misc/Input/L_inputClass.h +++ b/Code/Misc/Input/L_inputClass.h @@ -7,6 +7,7 @@ #ifndef _INPUTCLASS_H_ #define _INPUTCLASS_H_ +#define NOMINMAX #define DIRECTINPUT_VERSION 0x0800 #pragma comment(lib, "dinput8.lib")