diff --git a/Code/Game/GameClient/GameClient.vcxproj b/Code/Game/GameClient/GameClient.vcxproj
index c084532d..031f967f 100644
--- a/Code/Game/GameClient/GameClient.vcxproj
+++ b/Code/Game/GameClient/GameClient.vcxproj
@@ -224,8 +224,11 @@
+
+
+
@@ -249,6 +252,7 @@
+
diff --git a/Code/Game/GameClient/GameClient.vcxproj.user b/Code/Game/GameClient/GameClient.vcxproj.user
index 4b847ee6..2e28d6f7 100644
--- a/Code/Game/GameClient/GameClient.vcxproj.user
+++ b/Code/Game/GameClient/GameClient.vcxproj.user
@@ -1,7 +1,7 @@
- false
+ true
$(OutDir)
diff --git a/Code/Game/GameClient/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/GameClient/GameClientState/Buttons/EventButtonGUI.h
index c14d24f2..e598a790 100644
--- a/Code/Game/GameClient/GameClientState/Buttons/EventButtonGUI.h
+++ b/Code/Game/GameClient/GameClientState/Buttons/EventButtonGUI.h
@@ -113,7 +113,7 @@ namespace DanBias
{
if(buttonText.size() > 0)
{
- Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, -0.001f), size, size.y * 0.5f, textColor);
+ Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, +0.001f), size, size.y * 0.5f, textColor);
}
}
diff --git a/Code/Game/GameClient/GameClientState/Buttons/Plane_UI.h b/Code/Game/GameClient/GameClientState/Buttons/Plane_UI.h
new file mode 100644
index 00000000..8293eeb1
--- /dev/null
+++ b/Code/Game/GameClient/GameClientState/Buttons/Plane_UI.h
@@ -0,0 +1,51 @@
+#ifndef DANBIAS_CLIENT_PLANE_UI_H
+#define DANBIAS_CLIENT_PLANE_UI_H
+
+#include "DllInterfaces/GFXAPI.h"
+
+namespace DanBias
+{
+ namespace Client
+ {
+ class Plane_UI
+ {
+ public:
+ Plane_UI( )
+ {
+ pos = Oyster::Math::Float3::null;
+ size = Oyster::Math::Float2::null;
+ tintColor = Oyster::Math::Float4(1);
+ texture = NULL;
+ }
+ Plane_UI( std::wstring textureName, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, Oyster::Math::Float4 tintColor = Oyster::Math::Float4(1))
+ : pos(pos), size(size), tintColor(tintColor)
+ {
+ CreateTexture(textureName);
+ }
+ virtual ~Plane_UI()
+ {
+ Oyster::Graphics::API::DeleteTexture(texture);
+ texture = NULL;
+ }
+ void CreateTexture(std::wstring textureName)
+ {
+ //Create texture
+ texture = Oyster::Graphics::API::CreateTexture(textureName);
+ }
+
+ virtual void RenderTexture() const
+ {
+ if(texture)
+ Oyster::Graphics::API::RenderGuiElement(texture, pos, size, tintColor);
+ }
+ private:
+ Oyster::Math::Float3 pos;
+ Oyster::Math::Float2 size;
+
+ Oyster::Graphics::API::Texture texture;
+ Oyster::Math::Float4 tintColor;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/Code/Game/GameClient/GameClientState/Buttons/Text_UI.h b/Code/Game/GameClient/GameClientState/Buttons/Text_UI.h
new file mode 100644
index 00000000..d37b347e
--- /dev/null
+++ b/Code/Game/GameClient/GameClientState/Buttons/Text_UI.h
@@ -0,0 +1,45 @@
+#ifndef DANBIAS_CLIENT_TEXT_UI_H
+#define DANBIAS_CLIENT_TEXT_UI_H
+
+#include "DllInterfaces/GFXAPI.h"
+
+namespace DanBias
+{
+ namespace Client
+ {
+ class Text_UI
+ {
+ public:
+ Text_UI( )
+ {
+ pos = Oyster::Math::Float3::null;
+ size = Oyster::Math::Float2::null;
+ text = L"";
+ textColor = Oyster::Math::Float4(1);
+ }
+ Text_UI(std::wstring text, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, Oyster::Math::Float4 textColor = Oyster::Math::Float4(1))
+ : pos(pos), size(size), text(text), textColor(textColor)
+ {
+ }
+ void setText(std::wstring text)
+ {
+ this->text = text;
+ }
+ void RenderText() const
+ {
+ if(text.size() > 0)
+ {
+ Oyster::Graphics::API::RenderText(text, pos, size, size.y * 0.5f, textColor);
+ }
+ }
+ private:
+ Oyster::Math::Float3 pos;
+ Oyster::Math::Float2 size;
+
+ std::wstring text;
+ Oyster::Math::Float4 textColor;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp
index 624eca17..c4fe9db6 100644
--- a/Code/Game/GameClient/GameClientState/GameState.cpp
+++ b/Code/Game/GameClient/GameClientState/GameState.cpp
@@ -9,6 +9,9 @@
#include "C_obj/C_DynamicObj.h"
#include "C_obj/C_StaticObj.h"
#include "Utilities.h"
+#include "GamingUI.h"
+#include "RespawnUI.h"
+#include "StatsUI.h"
using namespace ::DanBias::Client;
using namespace ::Oyster;
@@ -30,19 +33,6 @@ struct GameState::MyData
::std::map> *dynamicObjects;
::std::map> *lights;
- bool key_forward;
- bool key_backward;
- bool key_strafeRight;
- bool key_strafeLeft;
- bool key_Shoot;
- bool key_Jump;
-
- // DEGUG KEYS
- bool key_Reload_Shaders;
- bool key_Wireframe_Toggle;
- bool renderWhireframe;
- // !DEGUG KEYS
-
C_Player player;
Camera_FPSV2 camera;
@@ -73,11 +63,6 @@ bool GameState::Init( SharedStateContent &shared )
this->privData = new MyData();
- this->privData->key_forward = false;
- this->privData->key_backward = false;
- this->privData->key_strafeRight = false;
- this->privData->key_strafeLeft = false;
-
this->privData->nextState = GameClientState::ClientState_Same;
this->privData->nwClient = shared.network;
this->privData->input = shared.input;
@@ -98,9 +83,9 @@ bool GameState::Init( SharedStateContent &shared )
this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
// DEGUG KEYS
- this->privData->key_Reload_Shaders = false;
- this->privData->key_Wireframe_Toggle = false;
- this->privData->renderWhireframe = false;
+ this->key_Reload_Shaders = false;
+ this->key_Wireframe_Toggle = false;
+ this->renderWhireframe = false;
// !DEGUG KEYS
auto light = this->privData->lights->begin();
@@ -109,6 +94,14 @@ bool GameState::Init( SharedStateContent &shared )
light->second->Render();
}
+ // create UI states
+ this->gameUI = new GamingUI(this->privData->input, this->privData->nwClient, &this->privData->camera);
+ this->respawnUI = new RespawnUI(this->privData->nwClient, 20);
+ this->statsUI = new StatsUI();
+ this->currGameUI = gameUI;
+ ((GamingUI*)gameUI)->Init();
+ ((RespawnUI*)respawnUI)->Init();
+ ((StatsUI*)statsUI)->Init();
return true;
}
@@ -165,7 +158,25 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
GameClientState::ClientState GameState::Update( float deltaTime )
{
- this->ReadKeyInput();
+ GameStateUI::UIState UIstate = this->currGameUI->Update( deltaTime );
+ switch (UIstate)
+ {
+ case DanBias::Client::GameStateUI::UIState_same:
+ break;
+ case DanBias::Client::GameStateUI::UIState_gaming:
+ break;
+ case DanBias::Client::GameStateUI::UIState_main_menu:
+ //this->privData->nextState =
+ break;
+ case DanBias::Client::GameStateUI::UIState_shut_down:
+ this->privData->nextState = ClientState_Quit;
+ break;
+ default:
+ break;
+ }
+ // DEBUG keybindings
+ ReadKeyInput();
+
return this->privData->nextState;
}
@@ -190,19 +201,13 @@ bool GameState::Render()
if( dynamicObject->second )
{
dynamicObject->second->Render();
+
}
}
-
- /*auto light = this->privData->lights->begin();
- for( ; light != this->privData->lights->end(); ++light )
- {
- light->second->Render();
- }*/
-
#ifdef _DEBUG
//RB DEBUG render wire frame
- if(this->privData->renderWhireframe)
+ if(this->renderWhireframe)
{
Oyster::Graphics::API::StartRenderWireFrame();
@@ -244,6 +249,24 @@ bool GameState::Render()
//!RB DEBUG
#endif
+ Oyster::Graphics::API::StartGuiRender();
+ // render gui elemnts
+ if(currGameUI->HaveGUIRender())
+ currGameUI->RenderGUI();
+ if(renderStats)
+ {
+ if(statsUI->HaveGUIRender())
+ statsUI->RenderGUI();
+ }
+ Oyster::Graphics::API::StartTextRender();
+ if(currGameUI->HaveTextRender())
+ currGameUI->RenderText();
+ if(renderStats)
+ {
+ if(statsUI->HaveTextRender())
+ statsUI->RenderText();
+ }
+
Oyster::Graphics::API::EndFrame();
return true;
}
@@ -277,6 +300,27 @@ bool GameState::Release()
privData = NULL;
}
+
+ if(respawnUI)
+ {
+ respawnUI->Release();
+ delete respawnUI;
+ respawnUI = NULL;
+ }
+ if(gameUI)
+ {
+ gameUI->Release();
+ delete gameUI;
+ gameUI = NULL;
+ }
+ if(statsUI)
+ {
+ statsUI->Release();
+ delete statsUI;
+ statsUI = NULL;
+ }
+ currGameUI = NULL;
+
return true;
}
@@ -284,152 +328,59 @@ void GameState::ChangeState( ClientState next )
{
this->privData->nextState = next;
}
-
void GameState::ReadKeyInput()
{
- if( this->privData->input->IsKeyPressed(DIK_W) )
- {
- //if(!this->privData->key_forward)
- {
- this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
- this->privData->key_forward = true;
- }
- }
- else
- this->privData->key_forward = false;
-
- if( this->privData->input->IsKeyPressed(DIK_S) )
- {
- //if( !this->privData->key_backward )
- {
- this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
- this->privData->key_backward = true;
- }
- }
- else
- this->privData->key_backward = false;
-
- if( this->privData->input->IsKeyPressed(DIK_A) )
- {
- //if( !this->privData->key_strafeLeft )
- {
- this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
- this->privData->key_strafeLeft = true;
- }
- }
- else
- this->privData->key_strafeLeft = false;
-
- if( this->privData->input->IsKeyPressed(DIK_D) )
- {
- //if( !this->privData->key_strafeRight )
- {
- this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
- this->privData->key_strafeRight = true;
- }
- }
- else
- this->privData->key_strafeRight = false;
-
- //send delta mouse movement
- {
- static const float mouseSensitivity = Radian( 1.0f );
- this->privData->camera.PitchDown( this->privData->input->GetPitch() * mouseSensitivity );
- float yaw = this->privData->input->GetYaw();
- //if( yaw != 0.0f ) //This made the camera reset to a specific rotation.
- {
- this->privData->nwClient->Send( Protocol_PlayerLeftTurn(yaw * mouseSensitivity) );
- }
- }
-
- // shoot
- if( this->privData->input->IsKeyPressed(DIK_Z) )
- {
- if( !this->privData->key_Shoot )
- {
- Protocol_PlayerShot playerShot;
- playerShot.primaryPressed = true;
- playerShot.secondaryPressed = false;
- playerShot.utilityPressed = false;
- this->privData->nwClient->Send( playerShot );
- this->privData->key_Shoot = true;
- }
- }
- else
- this->privData->key_Shoot = false;
- if( this->privData->input->IsKeyPressed(DIK_X) )
- {
- if( !this->privData->key_Shoot )
- {
- Protocol_PlayerShot playerShot;
- playerShot.primaryPressed = false;
- playerShot.secondaryPressed = true;
- playerShot.utilityPressed = false;
- this->privData->nwClient->Send( playerShot );
- this->privData->key_Shoot = true;
- }
- }
- else
- this->privData->key_Shoot = false;
- if( this->privData->input->IsKeyPressed(DIK_C) )
- {
- if( !this->privData->key_Shoot )
- {
- Protocol_PlayerShot playerShot;
- playerShot.primaryPressed = false;
- playerShot.secondaryPressed = false;
- playerShot.utilityPressed = true;
- this->privData->nwClient->Send( playerShot );
- this->privData->key_Shoot = true;
- }
- }
- else
- this->privData->key_Shoot = false;
-
- // jump
- if( this->privData->input->IsKeyPressed(DIK_SPACE) )
- {
- if(!this->privData->key_Jump)
- {
- this->privData->nwClient->Send( Protocol_PlayerJump() );
- this->privData->key_Jump = true;
- }
- }
- else
- this->privData->key_Jump = false;
-
-
// DEGUG KEYS
// Reload shaders
if( this->privData->input->IsKeyPressed(DIK_R) )
{
- if( !this->privData->key_Reload_Shaders )
+ if( !this->key_Reload_Shaders )
{
#ifdef _DEBUG
- Graphics::API::ReloadShaders();
+ Oyster::Graphics::API::ReloadShaders();
#endif
- this->privData->key_Reload_Shaders = true;
+ this->key_Reload_Shaders = true;
}
}
else
- this->privData->key_Reload_Shaders = false;
+ this->key_Reload_Shaders = false;
// toggle wire frame render
if( this->privData->input->IsKeyPressed(DIK_T) )
{
- if( !this->privData->key_Wireframe_Toggle )
+ if( !this->key_Wireframe_Toggle )
{
- this->privData->renderWhireframe = !this->privData->renderWhireframe;
- this->privData->key_Wireframe_Toggle = true;
+ this->renderWhireframe = !this->renderWhireframe;
+ this->key_Wireframe_Toggle = true;
+ // DEBUG set you as dead when render wireframe
+ this->currGameUI = respawnUI;
+ // !DEBUG
}
}
else
- this->privData->key_Wireframe_Toggle = false;
- // !DEGUG KEYS
- // TODO: implement sub-menu
-}
+ {
+ this->key_Wireframe_Toggle = false;
+ // DEBUG set you as dead when render wireframe
+ this->currGameUI = gameUI;
+ // !DEBUG
+ }
+ // toggle wire frame render
+ if( this->privData->input->IsKeyPressed(DIK_TAB) )
+ {
+ if( !this->key_showStats )
+ {
+ this->renderStats = true;
+ this->key_showStats = true;
+ }
+ }
+ else
+ {
+ this->renderStats = false;
+ this->key_showStats = false;
+ }
+}
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )
{
if( message.args.type == NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend )
@@ -449,8 +400,22 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
switch(ID)
{
case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
- case protocol_Gameplay_ObjectDamage: break; /** @todo TODO: implement */
- case protocol_Gameplay_ObjectHealthStatus: break; /** @todo TODO: implement */
+ case protocol_Gameplay_ObjectDamage:
+ {
+ Protocol_ObjectDamage decoded(data);
+ if( this->privData->myId == decoded.object_ID )
+ {
+ if(currGameUI == gameUI)
+ {
+ ((GamingUI*)currGameUI)->SetHPtext(std::to_wstring(decoded.healthLost));
+ }
+ }
+ }
+ return GameClientState::event_processed;
+ case protocol_Gameplay_ObjectHealthStatus:
+ {
+ }
+ return GameClientState::event_processed;
case protocol_Gameplay_ObjectPosition:
{
Protocol_ObjectPosition decoded(data);
@@ -515,19 +480,21 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
this->privData->player.updateRBWorld();
// !RB DEBUG
}
-
- C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
-
- if( object )
+ else
{
- object->setPos( position );
- object->setRot( rotation );
- object->updateWorld();
- // RB DEBUG
- object->setRBPos ( position );
- object->setRBRot ( rotation );
- object->updateRBWorld();
- // !RB DEBUG
+ C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
+
+ if( object )
+ {
+ object->setPos( position );
+ object->setRot( rotation );
+ object->updateWorld();
+ // RB DEBUG
+ object->setRBPos ( position );
+ object->setRBRot ( rotation );
+ object->updateRBWorld();
+ // !RB DEBUG
+ }
}
}
return GameClientState::event_processed;
@@ -584,8 +551,46 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectWeaponEnergy: break; /** @todo TODO: implement */
- case protocol_Gameplay_ObjectRespawn: break; /** @todo TODO: implement */
- case protocol_Gameplay_ObjectDie: break; /** @todo TODO: implement */
+ case protocol_Gameplay_ObjectRespawn:
+ {
+ // set player pos
+ Protocol_ObjectRespawn decoded(data);
+ // move player. Remember to change camera
+ this->privData->camera.SetPosition( decoded.position );
+ this->privData->player.setPos( decoded.position );
+ this->privData->player.updateWorld();
+ // RB DEBUG
+ this->privData->player.setRBPos ( decoded.position );
+ this->privData->player.updateRBWorld();
+ // !RB DEBUG
+
+ this->currGameUI = this->gameUI;
+ }
+ return GameClientState::event_processed;
+ case protocol_Gameplay_ObjectDie:
+ {
+ Protocol_ObjectDie decoded(data);
+ // if is this player. Remember to change camera
+ if( this->privData->myId == decoded.objectID )
+ {
+ this->currGameUI = this->respawnUI;
+ // set countdown
+ ((RespawnUI*)currGameUI)->SetCountdown( decoded.seconds );
+ }
+ }
+ return GameClientState::event_processed;
+ case protocol_Gameplay_ObjectDisconnectPlayer:
+ {
+ //Remove the disconnected player
+ Protocol_ObjectDisconnectPlayer decoded(data);
+ auto object = this->privData->dynamicObjects->find( decoded.objectID );
+ if( object != this->privData->dynamicObjects->end() )
+ {
+ object->second = nullptr;
+ this->privData->dynamicObjects->erase( object );
+ }
+ }
+ return GameClientState::event_processed;
default: break;
}
}
diff --git a/Code/Game/GameClient/GameClientState/GameState.h b/Code/Game/GameClient/GameClientState/GameState.h
index 8c5ca64e..8342d558 100644
--- a/Code/Game/GameClient/GameClientState/GameState.h
+++ b/Code/Game/GameClient/GameClientState/GameState.h
@@ -3,6 +3,7 @@
#include "GameClientState.h"
#include "OysterMath.h"
#include
+#include "GameStateUI.h"
namespace DanBias { namespace Client
{
@@ -31,6 +32,16 @@ namespace DanBias { namespace Client
private:
struct MyData;
::Utility::DynamicMemory::UniquePointer privData;
+ GameStateUI *currGameUI, *gameUI, *respawnUI, *statsUI;
+
+ // DEGUG KEYS
+ bool key_Reload_Shaders;
+ bool key_Wireframe_Toggle;
+ bool renderWhireframe;
+ bool key_showStats;
+ bool renderStats;
+ // !DEGUG KEYS
+
};
} }
#endif
\ No newline at end of file
diff --git a/Code/Game/GameClient/GameClientState/GameStateUI.h b/Code/Game/GameClient/GameClientState/GameStateUI.h
index 40350211..152a7f04 100644
--- a/Code/Game/GameClient/GameClientState/GameStateUI.h
+++ b/Code/Game/GameClient/GameClientState/GameStateUI.h
@@ -1,5 +1,5 @@
-#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H
-#define DANBIAS_CLIENT_GAMECLIENTSTATE_H
+#ifndef DANBIAS_CLIENT_GAMESTATEUI_H
+#define DANBIAS_CLIENT_GAMESTATEUI_H
#include "Utilities.h"
#include "NetworkClient.h"
diff --git a/Code/Game/GameClient/GameClientState/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp
index 8ff43d88..03840881 100644
--- a/Code/Game/GameClient/GameClientState/GamingUI.cpp
+++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp
@@ -6,6 +6,7 @@ using namespace ::DanBias::Client;
using namespace ::Oyster::Network;
using namespace ::GameLogic;
using namespace ::Utility::Value;
+using namespace ::Oyster::Math;
GamingUI::GamingUI() :
GameStateUI()
@@ -14,6 +15,8 @@ GamingUI::GamingUI() :
this->input = nullptr;
this->netClient = nullptr;
this->camera = nullptr;
+ this->plane = nullptr;
+ this->text = nullptr;
}
GamingUI::GamingUI( InputClass *input, NetworkClient *connection, Camera_FPSV2 *camera ) :
@@ -25,38 +28,54 @@ GamingUI::GamingUI( InputClass *input, NetworkClient *connection, Camera_FPSV2 *
}
GamingUI::~GamingUI() { /* Do nothing */ }
+bool GamingUI::Init()
+{
+ // z value should be between 0.5 - 0.9 so that it will be behind other states
+ // add textures and text
+ this->plane = new Plane_UI(L"box_tex.png", Float3(0.5f, 0.0f, 0.5f), Float2(0.3f, 0.1f));
+ this->text = new Text_UI(L"hej", Float3(0.5f,0.0f,0.1f), Float2(0.1f,0.1f));
+ return true;
+}
GameStateUI::UIState GamingUI::Update( float deltaTime )
{
+ ReadKeyInput();
return this->nextState;
}
bool GamingUI::HaveGUIRender() const
{
- return false; // TODO: change to true when we want UI elements like a crosshair
+ return true;
}
bool GamingUI::HaveTextRender() const
{
- return false; // TODO: change to true when we want UI elements like a chat window
+ return true;
}
void GamingUI::RenderGUI() const
{
- // TODO: Render crosshairs and such here. Don't forget to adjust GamingUI::HaveGUIRender
+ this->plane->RenderTexture();
}
void GamingUI::RenderText() const
{
- // TODO: Render chattext and such here. Don't forget to adjust GamingUI::HaveGUIRender
+ this->text->RenderText();
}
bool GamingUI::Release()
{
// TODO: Release UI components here.
+ if(this->plane)
+ delete this->plane;
+ if(this->text)
+ delete this->text;
return true;
}
-
+void GamingUI::SetHPtext( std::wstring hp )
+{
+ this->text->setText(hp);
+}
void GamingUI::ReadKeyInput()
{
if( this->input->IsKeyPressed(DIK_W) )
@@ -79,75 +98,78 @@ void GamingUI::ReadKeyInput()
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
+//send delta mouse movement
{
static const float mouseSensitivity = Radian( 1.0f );
this->camera->PitchDown( this->input->GetPitch() * mouseSensitivity );
- this->netClient->Send( Protocol_PlayerLeftTurn(this->input->GetYaw() * mouseSensitivity) );
+ float yaw = this->input->GetYaw();
+ //if( yaw != 0.0f ) //This made the camera reset to a specific rotation.
+ {
+ this->netClient->Send( Protocol_PlayerLeftTurn(yaw * mouseSensitivity) );
+ }
}
// 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;
+ 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() );
+ if(!this->key_Jump)
+ {
+ this->netClient->Send( Protocol_PlayerJump() );
+ this->key_Jump = true;
+ }
}
-}
\ No newline at end of file
+ else
+ this->key_Jump = false;
+
+ if( this->input->IsKeyPressed(DIK_ESCAPE) )
+ {
+ this->nextState = GameStateUI::UIState_shut_down;
+ }
+ // !DEGUG KEYS
+ // TODO: implement sub-menu
+}
+
diff --git a/Code/Game/GameClient/GameClientState/GamingUI.h b/Code/Game/GameClient/GameClientState/GamingUI.h
index 9f93674b..36e94262 100644
--- a/Code/Game/GameClient/GameClientState/GamingUI.h
+++ b/Code/Game/GameClient/GameClientState/GamingUI.h
@@ -4,6 +4,8 @@
#include "GameStateUI.h"
#include "L_inputClass.h"
#include "Camera_FPSV2.h"
+#include "Buttons\Text_UI.h"
+#include "Buttons\Plane_UI.h"
namespace DanBias { namespace Client
{
@@ -12,6 +14,7 @@ namespace DanBias { namespace Client
public:
GamingUI( InputClass *input, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera );
virtual ~GamingUI();
+ bool Init();
UIState Update( float deltaTime );
bool HaveGUIRender() const;
@@ -19,12 +22,24 @@ namespace DanBias { namespace Client
void RenderGUI() const;
void RenderText() const;
bool Release();
+ void SetHPtext( std::wstring hp );
private:
InputClass *input;
::Oyster::Network::NetworkClient *netClient;
Camera_FPSV2 *camera;
+ // TODO add multiple UI elements
+ Text_UI* text;
+ Plane_UI* plane;
+
+ bool key_forward;
+ bool key_backward;
+ bool key_strafeRight;
+ bool key_strafeLeft;
+ bool key_Shoot;
+ bool key_Jump;
+
GamingUI();
void ReadKeyInput();
};
diff --git a/Code/Game/GameClient/GameClientState/RespawnUI.cpp b/Code/Game/GameClient/GameClientState/RespawnUI.cpp
index 4588d367..21732df6 100644
--- a/Code/Game/GameClient/GameClientState/RespawnUI.cpp
+++ b/Code/Game/GameClient/GameClientState/RespawnUI.cpp
@@ -3,6 +3,7 @@
using namespace ::DanBias::Client;
using namespace ::Oyster::Network;
using namespace ::Utility::Value;
+using namespace ::Oyster::Math;
RespawnUI::RespawnUI() :
GameStateUI()
@@ -17,13 +18,23 @@ RespawnUI::RespawnUI( NetworkClient *connection, float delay ) :
{
this->netClient = connection;
this->countDown = delay;
+ this->text = nullptr;
}
RespawnUI::~RespawnUI() { /* Do nothing */ }
+bool RespawnUI::Init()
+{
+ // z value should be between 0.5 - 0.9 so that it will be behind other states
+ // add textures and text
+ this->text = new Text_UI(L"DEAD", Float3(0.5f,0.0f,0.5f), Float2(0.2f,0.2f));
+ return true;
+}
GameStateUI::UIState RespawnUI::Update( float deltaTime )
{
this->countDown = Max( this->countDown - deltaTime, 0.0f );
+ // countDown == 0
+ // return UIState_gaming state;
return this->nextState;
}
@@ -34,25 +45,32 @@ bool RespawnUI::HaveGUIRender() const
bool RespawnUI::HaveTextRender() const
{
- return false; // TODO: change to true when we want UI elements like a chat window
+ return true; // TODO: change to true when we want UI elements like a chat window
}
void RespawnUI::RenderGUI() const
{
- // TODO: We need?
+ // TODO:BLOODY SCREEN
}
void RespawnUI::RenderText() const
{
+ this->text->RenderText();
// TODO: Text countdown somewhere on screen would be nice
}
bool RespawnUI::Release()
{
// TODO: Release UI components here.
+ if(this->text)
+ delete this->text;
return true;
}
+void RespawnUI::SetCountdown( float cd )
+{
+ this->countDown = cd;
+ // this text should be rendered
+}
-
diff --git a/Code/Game/GameClient/GameClientState/RespawnUI.h b/Code/Game/GameClient/GameClientState/RespawnUI.h
index c45616b7..6e5df64e 100644
--- a/Code/Game/GameClient/GameClientState/RespawnUI.h
+++ b/Code/Game/GameClient/GameClientState/RespawnUI.h
@@ -2,6 +2,8 @@
#define DANBIAS_CLIENT_RESPAWN_UI_H
#include "GameStateUI.h"
+#include "Buttons\Text_UI.h"
+#include "Buttons\Plane_UI.h"
namespace DanBias { namespace Client
{
@@ -10,18 +12,23 @@ namespace DanBias { namespace Client
public:
RespawnUI( ::Oyster::Network::NetworkClient *connection, float delay );
virtual ~RespawnUI();
+ bool Init();
+ // TODO countdown
UIState Update( float deltaTime );
bool HaveGUIRender() const;
bool HaveTextRender() const;
void RenderGUI() const;
void RenderText() const;
bool Release();
+ void SetCountdown( float cd );
private:
::Oyster::Network::NetworkClient *netClient;
float countDown;
+ // TODO add multiple UI elements
+ Text_UI* text;
RespawnUI();
};
} }
diff --git a/Code/Game/GameClient/GameClientState/StatsUI.cpp b/Code/Game/GameClient/GameClientState/StatsUI.cpp
new file mode 100644
index 00000000..ab07b89d
--- /dev/null
+++ b/Code/Game/GameClient/GameClientState/StatsUI.cpp
@@ -0,0 +1,65 @@
+#include "StatsUI.h"
+#include
+#include "Utilities.h"
+
+using namespace ::DanBias::Client;
+using namespace ::GameLogic;
+using namespace ::Utility::Value;
+using namespace ::Oyster::Math;
+
+StatsUI::StatsUI() :
+ GameStateUI()
+{
+ /* Should never be called! */
+ this->plane = nullptr;
+ this->text = nullptr;
+}
+
+StatsUI::~StatsUI() { /* Do nothing */ }
+bool StatsUI::Init()
+{
+ // z value should be between 0.1 - 0.5 so that it will be in front of other states
+ // add textures and text for player stats
+ this->plane = new Plane_UI(L"box_tex.png", Float3(0.0f, 0.0f, 0.5f), Float2(0.3f, 0.1f));
+ this->text = new Text_UI(L"Stats", Float3(0.0f,0.0f,0.1f), Float2(0.1f,0.1f));
+
+ return true;
+}
+GameStateUI::UIState StatsUI::Update( float deltaTime )
+{
+ return this->nextState;
+}
+
+bool StatsUI::HaveGUIRender() const
+{
+ // Set true if UIstate have any plane to render
+ return true;
+}
+
+bool StatsUI::HaveTextRender() const
+{
+ // Set true if UIstate have any text to render
+ return true;
+}
+
+void StatsUI::RenderGUI() const
+{
+ // render all the planes
+ this->plane->RenderTexture();
+}
+
+void StatsUI::RenderText() const
+{
+ // render all the text
+ this->text->RenderText();
+}
+
+bool StatsUI::Release()
+{
+ // TODO: Release UI components here.
+ if(this->plane)
+ delete this->plane;
+ if(this->text)
+ delete this->text;
+ return true;
+}
diff --git a/Code/Game/GameClient/GameClientState/StatsUI.h b/Code/Game/GameClient/GameClientState/StatsUI.h
new file mode 100644
index 00000000..589f956b
--- /dev/null
+++ b/Code/Game/GameClient/GameClientState/StatsUI.h
@@ -0,0 +1,34 @@
+#ifndef DANBIAS_CLIENT_STATS_UI_H
+#define DANBIAS_CLIENT_STATS_UI_H
+
+#include "GameStateUI.h"
+#include "Buttons\Text_UI.h"
+#include "Buttons\Plane_UI.h"
+
+namespace DanBias { namespace Client
+{
+ class StatsUI : public GameStateUI
+ {
+ public:
+ StatsUI();
+ virtual ~StatsUI();
+ bool Init();
+
+ UIState Update( float deltaTime );
+ bool HaveGUIRender() const;
+ bool HaveTextRender() const;
+ void RenderGUI() const;
+ void RenderText() const;
+ bool Release();
+ // TODO add function to add a new players statistics
+ // TODO add function to remove a players statistics
+
+ private:
+ // TODO add multiple UI elements
+ // one for each player ingame
+ Text_UI* text;
+ Plane_UI* plane;
+ };
+} }
+
+#endif
\ No newline at end of file
diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp
index 3102b9f2..89de1f3e 100644
--- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp
+++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp
@@ -106,6 +106,8 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
args.pushForce = pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
+
+ if(hitCone) delete hitCone;
}
/********************************************************
@@ -141,6 +143,8 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
args.pushForce = -pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
+
+ if(hitCone) delete hitCone;
}
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
@@ -150,5 +154,5 @@ void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp);
- delete hitSphere;
+ if(hitSphere) delete hitSphere;
}
diff --git a/Code/Game/GameLogic/DynamicObject.cpp b/Code/Game/GameLogic/DynamicObject.cpp
index 6df5bef0..e6d9ff49 100644
--- a/Code/Game/GameLogic/DynamicObject.cpp
+++ b/Code/Game/GameLogic/DynamicObject.cpp
@@ -2,37 +2,76 @@
#include "CollisionManager.h"
using namespace GameLogic;
+using namespace Oyster::Math;
DynamicObject::DynamicObject()
:Object()
{
-
+ this->isReleased = false;
+ this->isActive = true;
}
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
:Object(rigidBody, EventOnCollision, type, objectID)
{
-
+ this->isReleased = false;
+ this->isActive = true;
}
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
:Object(rigidBody, EventOnCollision, type, objectID)
{
-
+ this->isReleased = false;
+ this->isActive = true;
}
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
:Object(rigidBody, EventOnCollision, type, objectID)
{
this->extraDamageOnCollision = extraDamageOnCollision;
+ this->isReleased = false;
+ this->isActive = true;
}
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
:Object(rigidBody, EventOnCollision, type, objectID)
{
this->extraDamageOnCollision = extraDamageOnCollision;
+ this->isReleased = false;
+ this->isActive = true;
}
DynamicObject::~DynamicObject(void)
{
+}
+
+void DynamicObject::ReleaseDynamicObject()
+{
+ //TODO: Inactivate the physics object
+ if(this->isReleased) return;
+
+ this->isReleased = true;
+ this->isActive = false;
+ this->lookDirection = Float3::null;
+ this->forwardDirection = Float3::null;
+ this->scale = Float3::null;
+ this->extraDamageOnCollision = 0;
+
+}
+bool DynamicObject::IsReleased()
+{
+ return this->isReleased;
+}
+bool DynamicObject::IsActive()
+{
+ return this->isActive;
+}
+void DynamicObject::Inactivate()
+{
+ this->isActive = false;
+}
+void DynamicObject::Activate()
+{
+ this->isActive = true;
+ this->isReleased = false;
}
\ No newline at end of file
diff --git a/Code/Game/GameLogic/DynamicObject.h b/Code/Game/GameLogic/DynamicObject.h
index 2d5fa617..8a32e849 100644
--- a/Code/Game/GameLogic/DynamicObject.h
+++ b/Code/Game/GameLogic/DynamicObject.h
@@ -22,7 +22,15 @@ namespace GameLogic
~DynamicObject(void);
+ void ReleaseDynamicObject();
+ bool IsReleased();
+ bool IsActive();
+ void Inactivate();
+ void Activate();
+
private:
+ bool isActive;
+ bool isReleased;
};
diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp
index 8dd7ffa6..c599fecf 100644
--- a/Code/Game/GameLogic/Game.cpp
+++ b/Code/Game/GameLogic/Game.cpp
@@ -67,6 +67,17 @@ void Game::GetAllPlayerPositions() const
Game::PlayerData* Game::CreatePlayer()
{
+ //Se if there is a free player somewhere in our list
+ for (unsigned int i = 0; i < this->players.Size(); i++)
+ {
+ if(this->players[i] && this->players[i]->player->IsReleased())
+ {
+ //We give the body to someone else
+ this->players[i]->player->Activate();
+ return this->players[i];
+ }
+ }
+
// Find a free space in array or insert at end
int insert = InsertObject(this->players, (PlayerData*)0);
int freeID = 0;
diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h
index 5ab19ba2..8d34a154 100644
--- a/Code/Game/GameLogic/Game.h
+++ b/Code/Game/GameLogic/Game.h
@@ -43,8 +43,8 @@ namespace GameLogic
void Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right) override;
void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) override;
ObjectSpecialType GetObjectType() const override;
-
-
+ void Inactivate() override;
+ void Release() override;
Player *player;
};
diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h
index 66cf5ea2..a501a0d9 100644
--- a/Code/Game/GameLogic/GameAPI.h
+++ b/Code/Game/GameLogic/GameAPI.h
@@ -106,6 +106,9 @@ namespace GameLogic
* @return The current player state
********************************************************/
virtual PLAYER_STATE GetState() const = 0;
+
+ virtual void Inactivate() = 0;
+ virtual void Release() = 0;
};
class ILevelData :public IObjectData
diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp
index 045da742..1f675f6a 100644
--- a/Code/Game/GameLogic/Game_PlayerData.cpp
+++ b/Code/Game/GameLogic/Game_PlayerData.cpp
@@ -93,4 +93,12 @@ void Game::PlayerData::Rotate(const Oyster::Math3D::Float3& lookDir, const Oyste
void Game::PlayerData::TurnLeft(Oyster::Math3D::Float deltaLeftRadians )
{
this->player->TurnLeft(deltaLeftRadians);
+}
+void Game::PlayerData::Inactivate()
+{
+ this->player->Inactivate();
+}
+void Game::PlayerData::Release()
+{
+ this->player->ReleaseDynamicObject();
}
\ No newline at end of file
diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp
index 5b855785..02e8510c 100644
--- a/Code/Game/GameLogic/Player.cpp
+++ b/Code/Game/GameLogic/Player.cpp
@@ -293,6 +293,11 @@ bool Player::IsIdle()
return (this->playerState == PLAYER_STATE::PLAYER_STATE_IDLE);
}
+void Player::Inactivate()
+{
+ //this->
+}
+
Oyster::Math::Float3 Player::GetPosition() const
{
return (Oyster::Math::Float3) this->rigidBody->GetState().centerPos;
diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h
index 13c6e300..3ddd7f9a 100644
--- a/Code/Game/GameLogic/Player.h
+++ b/Code/Game/GameLogic/Player.h
@@ -63,6 +63,8 @@ namespace GameLogic
bool IsJumping();
bool IsIdle();
+ void Inactivate();
+
Oyster::Math::Float3 GetPosition() const;
Oyster::Math::Float3 GetLookDir() const;
Oyster::Math::Float4x4 GetOrientation() const;
diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h
index fc02a4bd..22f8213e 100644
--- a/Code/Game/GameProtocols/ObjectProtocols.h
+++ b/Code/Game/GameProtocols/ObjectProtocols.h
@@ -292,6 +292,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
+ //#define protocol_Gameplay_ObjectEnabled 356
struct Protocol_ObjectPositionRotation :public Oyster::Network::CustomProtocolObject
{
short object_ID;
@@ -366,7 +367,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectEnabled 356
+ //#define protocol_Gameplay_ObjectEnabled 357
struct Protocol_ObjectEnable :public Oyster::Network::CustomProtocolObject
{
int objectID;
@@ -399,7 +400,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectDisabled 357
+ //#define protocol_Gameplay_ObjectDisabled 358
struct Protocol_ObjectDisable :public Oyster::Network::CustomProtocolObject
{
int objectID;
@@ -439,7 +440,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectCreate 358
+ //#define protocol_Gameplay_ObjectCreate 359
struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject
{
//ObjectType type; //ie player, box or whatever
@@ -543,7 +544,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectCreatePlayer 359
+ //#define protocol_Gameplay_ObjectCreatePlayer 360
struct Protocol_ObjectCreatePlayer :public Oyster::Network::CustomProtocolObject
{
/*1*/ int object_ID;
@@ -673,7 +674,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectJoinTeam 360
+ //#define protocol_Gameplay_ObjectJoinTeam 361
struct Protocol_ObjectJoinTeam :public Oyster::Network::CustomProtocolObject
{
int objectID;
@@ -713,7 +714,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectLeaveTeam 361
+ //#define protocol_Gameplay_ObjectLeaveTeam 362
struct Protocol_ObjectLeaveTeam :public Oyster::Network::CustomProtocolObject
{
int objectID;
@@ -745,7 +746,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectWeaponCooldown 362
+ //#define protocol_Gameplay_ObjectWeaponCooldown 363
struct Protocol_ObjectWeaponCooldown :public Oyster::Network::CustomProtocolObject
{
float seconds;
@@ -777,7 +778,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectWeaponEnergy 363
+ //#define protocol_Gameplay_ObjectWeaponEnergy 364
struct Protocol_ObjectWeaponEnergy :public Oyster::Network::CustomProtocolObject
{
float energy;
@@ -809,7 +810,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectRespawn 364
+ //#define protocol_Gameplay_ObjectRespawn 365
struct Protocol_ObjectRespawn :public Oyster::Network::CustomProtocolObject
{
float position[3];
@@ -852,7 +853,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
- //#define protocol_Gameplay_ObjectDie 365
+ //#define protocol_Gameplay_ObjectDie 366
struct Protocol_ObjectDie :public Oyster::Network::CustomProtocolObject
{
int objectID;
@@ -892,6 +893,38 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
+ //#define protocol_Gameplay_ObjectDisconnectPlayer 367
+ struct Protocol_ObjectDisconnectPlayer :public Oyster::Network::CustomProtocolObject
+ {
+ int objectID;
+
+ Protocol_ObjectDisconnectPlayer()
+ {
+ this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
+ this->protocol[0].value.netShort = protocol_Gameplay_ObjectDisconnectPlayer;
+ this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
+ this->objectID = 0;
+ }
+ Protocol_ObjectDisconnectPlayer(int objectID)
+ {
+ this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
+ this->protocol[0].value.netShort = protocol_Gameplay_ObjectDisconnectPlayer;
+ this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
+ this->objectID = objectID;
+ }
+ Protocol_ObjectDisconnectPlayer(Oyster::Network::CustomNetProtocol& p)
+ {
+ this->objectID = p[1].value.netInt;
+ }
+ Oyster::Network::CustomNetProtocol GetProtocol() override
+ {
+ this->protocol[1].value = this->objectID;
+ return protocol;
+ }
+
+ private:
+ Oyster::Network::CustomNetProtocol protocol;
+ };
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
\ No newline at end of file
diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h
index 4394a1a1..79235e2f 100644
--- a/Code/Game/GameProtocols/ProtocolIdentificationID.h
+++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h
@@ -69,6 +69,7 @@
#define protocol_Gameplay_ObjectWeaponEnergy 364
#define protocol_Gameplay_ObjectRespawn 365
#define protocol_Gameplay_ObjectDie 366
+#define protocol_Gameplay_ObjectDisconnectPlayer 367
#define protocol_GameplayMAX 399
diff --git a/Code/Game/GameServer/GameClient.h b/Code/Game/GameServer/GameClient.h
index 497e6c2e..aace26c7 100644
--- a/Code/Game/GameServer/GameClient.h
+++ b/Code/Game/GameServer/GameClient.h
@@ -55,6 +55,7 @@ namespace DanBias
GameLogic::IPlayerData* ReleasePlayer();
Oyster::Network::NetClient ReleaseClient();
+ bool IsInvalid();
void Invalidate();
int IncrementFailedProtocol();
void ResetFailedProtocolCount();
diff --git a/Code/Game/GameServer/Implementation/GameClient.cpp b/Code/Game/GameServer/Implementation/GameClient.cpp
index 3293a383..e8e78ab0 100644
--- a/Code/Game/GameServer/Implementation/GameClient.cpp
+++ b/Code/Game/GameServer/Implementation/GameClient.cpp
@@ -25,12 +25,15 @@ GameClient::GameClient(Utility::DynamicMemory::SmartPointerclient = 0;
- this->player = 0;
+ if(this->player)
+ this->player->Inactivate();
+
this->isReady = false;
this->character = L"crate_colonists.dan";
this->alias = L"Unknown";
this->secondsSinceLastResponse = 0.0f;
+ this->client = 0;
+ this->player = 0;
}
void GameClient::SetPlayer(GameLogic::IPlayerData* player)
@@ -58,8 +61,14 @@ void GameClient::SetState(ClientState state)
this->state = state;
}
+bool GameClient::IsInvalid()
+{
+ return this->isInvalid;
+}
void GameClient::Invalidate()
{
+ this->player->Release();
+ this->player = 0;
this->isInvalid = true;
this->isReady = false;
this->state = ClientState_Invalid;
diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
index e2a2961d..c919c159 100644
--- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
+++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
@@ -61,14 +61,32 @@ using namespace DanBias;
switch (e.args.type)
{
case NetworkClient::ClientEventArgs::EventType_Disconnect:
+ {
printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
+ Protocol_ObjectDisconnectPlayer prot(this->gClients[temp]->GetPlayer()->GetID());
+ for (unsigned int i = 0; i < this->gClients.Size(); i++)
+ {
+ if(i != temp && this->gClients[i]) this->gClients[i]->GetClient()->Send(prot);
+ }
+
this->gClients[temp]->Invalidate();
+ }
break;
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve:
break;
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
+ {
if(this->gClients[temp]->IncrementFailedProtocol() >= 5/*client->threshold*/)
+ {
+ printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
+ Protocol_ObjectDisconnectPlayer prot(this->gClients[temp]->GetPlayer()->GetID());
+ for (unsigned int i = 0; i < this->gClients.Size(); i++)
+ {
+ if(i != temp && this->gClients[i]) this->gClients[i]->GetClient()->Send(prot);
+ }
this->gClients[temp]->Invalidate();
+ }
+ }
break;
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
this->ParseProtocol(e.args.data.protocol, cl);
@@ -256,10 +274,17 @@ using namespace DanBias;
switch (p.status)
{
case GameLogic::Protocol_General_Status::States_disconected:
+ {
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
- //TODO: Tell other clients
- //Protocol_
+
+ Protocol_ObjectDisconnectPlayer prot(c->GetPlayer()->GetID());
+ for (unsigned int i = 0; i < this->gClients.Size(); i++)
+ {
+ if( this->gClients[i] && c->GetClient()->GetID() != this->gClients[i]->GetClient()->GetID() ) this->gClients[i]->GetClient()->Send(prot);
+ }
+ c->Invalidate();
this->Detach(c->GetClient()->GetID());
+ }
break;
case GameLogic::Protocol_General_Status::States_idle:
diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp
index 30eabed2..fb4c9246 100644
--- a/Code/Game/GameServer/Implementation/GameSession_General.cpp
+++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp
@@ -214,14 +214,21 @@ bool GameSession::Join(gClient gameClient)
{
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
- if(this->gClients[i])
+ if(this->gClients[i] && !this->gClients[i]->IsInvalid())
{
IPlayerData* temp = this->gClients[i]->GetPlayer();
- Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
+ Protocol_ObjectCreatePlayer p1( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
temp->GetID(), false, temp->GetTeamID(),
Utility::String::WStringToString(this->gClients[i]->GetAlias(), std::string()),
Utility::String::WStringToString(this->gClients[i]->GetCharacter(), std::string()));
- nwClient->Send(oc);
+ nwClient->Send(p1);
+
+ temp = playerData;
+ Protocol_ObjectCreatePlayer p2( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
+ temp->GetID(), false, temp->GetTeamID(),
+ Utility::String::WStringToString(gameClient->GetAlias(), std::string()),
+ Utility::String::WStringToString(gameClient->GetCharacter(), std::string()));
+ this->gClients[i]->GetClient()->Send(p2);
}
}
}
@@ -234,7 +241,7 @@ bool GameSession::Join(gClient gameClient)
{
//Protocol_ObjectPosition p(movedObject->GetPosition(), id);
Protocol_ObjectPositionRotation p(objects[i]->GetPosition(), objects[i]->GetRotation(), objects[i]->GetID());
- GameSession::gameSession->Send(p.GetProtocol());
+ nwClient->Send(p.GetProtocol());
}
}
diff --git a/Code/Network/NetworkAPI/NetworkServer.h b/Code/Network/NetworkAPI/NetworkServer.h
index 593c3847..82693310 100644
--- a/Code/Network/NetworkAPI/NetworkServer.h
+++ b/Code/Network/NetworkAPI/NetworkServer.h
@@ -22,16 +22,16 @@ namespace Oyster
{
struct BroadcastOptions
{
- //bool broadcast;
- //float broadcastInterval;
- //std::wstring subnetToBroadcast;
- //CustomNetProtocol broadcastMessage;
- //BroadcastOptions()
- //{
- // broadcast = true;
- // broadcastInterval = 1.0f;
- // subnetToBroadcast = L"192.168.0.1";
- //}
+ bool broadcast;
+ float broadcastInterval;
+ std::wstring subnetToBroadcast;
+ CustomNetProtocol broadcastMessage;
+ BroadcastOptions()
+ {
+ broadcast = true;
+ broadcastInterval = 1.0f;
+ subnetToBroadcast = L"192.168.0.1";
+ }
} broadcastOptions;
struct MainOptions
@@ -117,6 +117,23 @@ namespace Oyster
*/
int NetworkServer::GetPort();
+
+
+ /***************************************
+ Broadcast functions
+ ***************************************/
+ //Set broadcast settings.
+ void SetBroadcast(CustomNetProtocol& broadcastMessage, float interval = 1.0f, bool enable = true);
+
+ //Set broadcast settings.
+ void SetBroadcastMessage(CustomNetProtocol& broadcastMessage);
+
+ //Enable/disable broadcast.
+ void SetBroadcast(bool enable);
+
+ //Set interval between each broadcast message in seconds.
+ void SetBroadcastInterval(float interval);
+
private:
struct PrivateData;
PrivateData* privateData;
diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.user b/Code/OysterGraphics/OysterGraphics.vcxproj.user
index 9a0b0ae0..3f030911 100644
--- a/Code/OysterGraphics/OysterGraphics.vcxproj.user
+++ b/Code/OysterGraphics/OysterGraphics.vcxproj.user
@@ -1,6 +1,6 @@
- true
+ false
\ No newline at end of file
diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp
index b71be6d7..98642604 100644
--- a/Code/OysterGraphics/Render/GuiRenderer.cpp
+++ b/Code/OysterGraphics/Render/GuiRenderer.cpp
@@ -56,8 +56,8 @@ namespace Oyster
//size.x = size.x / (text.length() * TEXT_SPACING /2);
- pos *= 2;
- pos -= 1;
+ pos.xy *= 2;
+ pos.xy -= 1;
pos.y *= -1;
diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl
index f7721d38..c3f7e69e 100644
--- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl
+++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl
@@ -43,4 +43,5 @@ void main( uint3 DTid : SV_DispatchThreadID )
//Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(Output.Length*0.5f)].xyz,1);
//Output[DTid.xy] = SSAO * float4(1,1,1,1);
+ //Output[DTid.xy] = Ambient[DTid.xy];
}
\ No newline at end of file
diff --git a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp
index 018c3be0..e2d87ce7 100644
--- a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp
+++ b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp
@@ -412,4 +412,14 @@ void SimpleRigidBody::PreStep (const btCollisionWorld* collisionWorld)
float SimpleRigidBody::GetLambda() const
{
return this->rayLambda[0];
+}
+
+void SimpleRigidBody::MoveToLimbo()
+{
+ this->rigidBody->setCollisionFlags(this->rigidBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
+}
+
+void SimpleRigidBody::ReleaseFromLimbo()
+{
+ this->rigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
}
\ No newline at end of file
diff --git a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h
index effd123d..4290b540 100644
--- a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h
+++ b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h
@@ -69,6 +69,9 @@ namespace Oyster
float GetLambda() const;
+ void MoveToLimbo();
+ void ReleaseFromLimbo();
+
private:
btCollisionShape* collisionShape;
diff --git a/Code/Physics/GamePhysics/PhysicsAPI.h b/Code/Physics/GamePhysics/PhysicsAPI.h
index 72d4a8c6..33dc24a8 100644
--- a/Code/Physics/GamePhysics/PhysicsAPI.h
+++ b/Code/Physics/GamePhysics/PhysicsAPI.h
@@ -169,6 +169,9 @@ namespace Oyster
virtual void CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Math::Float kineticEnergyLoss) = 0;
virtual void CallSubscription_Move() = 0;
+ virtual void MoveToLimbo() = 0;
+ virtual void ReleaseFromLimbo() = 0;
+
/********************************************************
* @return the void pointer set by SetCustomTag.
* nullptr if none is set.