diff --git a/Code/Game/GameClient/GameClient.vcxproj b/Code/Game/GameClient/GameClient.vcxproj
index 6d09de24..c084532d 100644
--- a/Code/Game/GameClient/GameClient.vcxproj
+++ b/Code/Game/GameClient/GameClient.vcxproj
@@ -215,12 +215,15 @@
+
+
+
@@ -238,10 +241,13 @@
+
+
+
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/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp
index 41518db6..7ab0aeac 100644
--- a/Code/Game/GameClient/GameClientState/GameState.cpp
+++ b/Code/Game/GameClient/GameClientState/GameState.cpp
@@ -122,7 +122,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
RBInitData RBData;
RBData.position = position;
RBData.rotation = ArrayToQuaternion( rotation );
- RBData.scale = Float3( 1 );
+ RBData.scale = scale;
// !RB DEBUG
if( isMyPlayer )
{
@@ -216,13 +216,16 @@ bool GameState::Render()
dynamicObject = this->privData->dynamicObjects->begin();
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
{
- if( dynamicObject->second->getBRtype() == RB_Type_Cube)
+ if( dynamicObject->second )
{
- Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld());
- }
- if( dynamicObject->second->getBRtype() == RB_Type_Sphere)
- {
- Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
+ if( dynamicObject->second->getBRtype() == RB_Type_Cube)
+ {
+ Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld());
+ }
+ if( dynamicObject->second->getBRtype() == RB_Type_Sphere)
+ {
+ Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
+ }
}
}
}
@@ -479,8 +482,8 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
// if is this player. Remember to change camera
if( this->privData->myId == decoded.object_ID )
{
- //this->privData->camera.SetPosition( position );
- //this->privData->camera.SetRotation( rotation );
+ this->privData->camera.SetPosition( position );
+ this->privData->camera.SetRotation( rotation );
this->privData->player.setPos( position );
//this->privData->player.setRot( rotation );
}
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/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h
index b7d79d6c..57137fb4 100644
--- a/Code/Game/GameProtocols/PlayerProtocols.h
+++ b/Code/Game/GameProtocols/PlayerProtocols.h
@@ -74,69 +74,40 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
+ //protocol_Gameplay_PlayerLeftTurn
+ struct Protocol_PlayerLeftTurn : public ::Oyster::Network::CustomProtocolObject
{
- // can be swapped to a quaternion later
- float lookDir[3];
- float right[3];
-
- Protocol_PlayerLook()
+ public:
+ float deltaRadian;
+
+ Protocol_PlayerLeftTurn()
{
- this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
- this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
- // LookDir
- this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
- this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
- this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
- // Right
- this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
- this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
- this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
-
- memset(&this->lookDir[0], 0, sizeof(float) * 3);
- memset(&this->right[0], 0, sizeof(float) * 3);
+ this->protocol[0].value = protocol_Gameplay_PlayerLeftTurn;
+ this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short;
+ // deltaRadian
+ this->protocol[1].type = ::Oyster::Network::NetAttributeType_Float;
}
- Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p)
- {
- this->lookDir[0] = p[1].value.netFloat;
- this->lookDir[1] = p[2].value.netFloat;
- this->lookDir[2] = p[3].value.netFloat;
- this->right[0] = p[4].value.netFloat;
- this->right[1] = p[5].value.netFloat;
- this->right[2] = p[6].value.netFloat;
+ Protocol_PlayerLeftTurn( const ::Oyster::Network::CustomNetProtocol &p )
+ {
+ this->deltaRadian = p[1].value.netFloat;
}
- Protocol_PlayerLook(float l[3], float r[3])
+
+ Protocol_PlayerLeftTurn( float deltaRadian )
{
- this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
- this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
-
- this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
- this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
- this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
-
- this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
- this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
- this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
-
- memcpy(&this->lookDir[0], &l[0], sizeof(float) * 3);
- memcpy(&this->right[0], &r[0], sizeof(float) * 3);
+ this->protocol[0].value = protocol_Gameplay_PlayerLeftTurn;
+ this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short;
+ this->deltaRadian = deltaRadian;
}
- Oyster::Network::CustomNetProtocol GetProtocol() override
+ ::Oyster::Network::CustomNetProtocol GetProtocol() override
{
- this->protocol[1].value = this->lookDir[0];
- this->protocol[2].value = this->lookDir[1];
- this->protocol[3].value = this->lookDir[2];
- this->protocol[4].value = this->right[0];
- this->protocol[5].value = this->right[1];
- this->protocol[6].value = this->right[2];
-
+ this->protocol[1].value = this->deltaRadian;
return protocol;
}
- private:
- Oyster::Network::CustomNetProtocol protocol;
+ private:
+ ::Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerChangeWeapon :public Oyster::Network::CustomProtocolObject
diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h
index 25df7b78..4394a1a1 100644
--- a/Code/Game/GameProtocols/ProtocolIdentificationID.h
+++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h
@@ -47,7 +47,7 @@
#define protocol_Gameplay_PlayerMovementLeft 301
#define protocol_Gameplay_PlayerMovementForward 302
#define protocol_Gameplay_PlayerMovementBackward 303
-#define protocol_Gameplay_PlayerLookDir 304
+#define protocol_Gameplay_PlayerLeftTurn 304
#define protocol_Gameplay_PlayerChangeWeapon 305
#define protocol_Gameplay_PlayerShot 306
#define protocol_Gameplay_PlayerJump 307
diff --git a/Code/Game/GameServer/GameSession.h b/Code/Game/GameServer/GameSession.h
index 28e8bde3..ad9440e9 100644
--- a/Code/Game/GameServer/GameSession.h
+++ b/Code/Game/GameServer/GameSession.h
@@ -84,7 +84,7 @@ namespace DanBias
void Gameplay_PlayerMovementBack ( DanBias::GameClient* c );
void Gameplay_PlayerMovementForth ( DanBias::GameClient* c );
void Gameplay_PlayerJump ( DanBias::GameClient* c );
- void Gameplay_PlayerLookDir ( GameLogic::Protocol_PlayerLook& p, DanBias::GameClient* c );
+ void Gameplay_PlayerLeftTurn ( GameLogic::Protocol_PlayerLeftTurn& p, DanBias::GameClient* c );
void Gameplay_PlayerChangeWeapon ( GameLogic::Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c );
void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c );
void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c );
diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
index 4044cfdb..8cbb542d 100644
--- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
+++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
@@ -156,7 +156,7 @@ using namespace DanBias;
break;
case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( c );
break;
- case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c );
+ case protocol_Gameplay_PlayerLeftTurn: this->Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn (p), c );
break;
case protocol_Gameplay_PlayerChangeWeapon: this->Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon (p), c );
break;
@@ -203,12 +203,9 @@ using namespace DanBias;
{
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP);
}
- void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c )
+ void GameSession::Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn& p, DanBias::GameClient* c )
{
- Oyster::Math3D::Float3 lookDir = p.lookDir;
- Oyster::Math3D::Float3 right = p.right;
-
- c->GetPlayer()->Rotate(lookDir, right);
+ c->GetPlayer()->TurnLeft( p.deltaRadian );
}
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
{
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")