diff --git a/Code/Game/GameClient/GameClient.vcxproj b/Code/Game/GameClient/GameClient.vcxproj
index b4bf1a75..1693576a 100644
--- a/Code/Game/GameClient/GameClient.vcxproj
+++ b/Code/Game/GameClient/GameClient.vcxproj
@@ -224,6 +224,7 @@
+
@@ -251,6 +252,7 @@
+
diff --git a/Code/Game/GameClient/GameClientState/Buttons/Text_UI.h b/Code/Game/GameClient/GameClientState/Buttons/Text_UI.h
index 380c73e1..d37b347e 100644
--- a/Code/Game/GameClient/GameClientState/Buttons/Text_UI.h
+++ b/Code/Game/GameClient/GameClientState/Buttons/Text_UI.h
@@ -21,6 +21,10 @@ namespace DanBias
: pos(pos), size(size), text(text), textColor(textColor)
{
}
+ void setText(std::wstring text)
+ {
+ this->text = text;
+ }
void RenderText() const
{
if(text.size() > 0)
diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp
index 27ad8ba9..71a984c9 100644
--- a/Code/Game/GameClient/GameClientState/GameState.cpp
+++ b/Code/Game/GameClient/GameClientState/GameState.cpp
@@ -11,6 +11,7 @@
#include "Utilities.h"
#include "GamingUI.h"
#include "RespawnUI.h"
+#include "StatsUI.h"
using namespace ::DanBias::Client;
using namespace ::Oyster;
@@ -98,9 +99,11 @@ bool GameState::Init( SharedStateContent &shared )
// create UI states
this->gameUI = new GamingUI(this->privData->mouseInput, this->privData->keyboardInput, this->privData->nwClient, &this->privData->camera);
this->respawnUI = new RespawnUI(this->privData->nwClient, 20);
+ this->statsUI = new StatsUI();
this->currGameUI = gameUI;
((GamingUI*)gameUI)->Init();
- // TODO init respawn
+ ((RespawnUI*)respawnUI)->Init();
+ ((StatsUI*)statsUI)->Init();
return true;
}
@@ -248,12 +251,24 @@ bool GameState::Render()
//!RB DEBUG
#endif
- // render current UI state
+ 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;
}
@@ -301,6 +316,12 @@ bool GameState::Release()
delete gameUI;
gameUI = NULL;
}
+ if(statsUI)
+ {
+ statsUI->Release();
+ delete statsUI;
+ statsUI = NULL;
+ }
currGameUI = NULL;
return true;
@@ -336,12 +357,34 @@ void GameState::ReadKeyInput()
{
this->renderWhireframe = !this->renderWhireframe;
this->key_Wireframe_Toggle = true;
+ // DEBUG set you as dead when render wireframe
+ this->currGameUI = respawnUI;
+ // !DEBUG
}
}
else
+ {
this->key_Wireframe_Toggle = false;
-
+ // DEBUG set you as dead when render wireframe
+ this->currGameUI = gameUI;
+ // !DEBUG
+ }
#endif // !DEGUG KEYS
+
+ // 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 )
@@ -363,8 +406,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);
@@ -500,12 +557,34 @@ 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:
- this->currGameUI = this->gameUI;
+ 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:
- this->currGameUI = this->respawnUI;
- // set countdown
+ {
+ 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:
{
//Removes
diff --git a/Code/Game/GameClient/GameClientState/GameState.h b/Code/Game/GameClient/GameClientState/GameState.h
index 5a9519ad..8342d558 100644
--- a/Code/Game/GameClient/GameClientState/GameState.h
+++ b/Code/Game/GameClient/GameClientState/GameState.h
@@ -32,13 +32,16 @@ namespace DanBias { namespace Client
private:
struct MyData;
::Utility::DynamicMemory::UniquePointer privData;
- GameStateUI *currGameUI, *gameUI, *respawnUI;
+ 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/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp
index e29b2f93..222f81c0 100644
--- a/Code/Game/GameClient/GameClientState/GamingUI.cpp
+++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp
@@ -33,6 +33,7 @@ GamingUI::GamingUI( Mouse *mouseInput, Keyboard *keyboardInput, NetworkClient *c
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));
@@ -57,13 +58,11 @@ bool GamingUI::HaveTextRender() const
void GamingUI::RenderGUI() const
{
- Oyster::Graphics::API::StartGuiRender();
this->plane->RenderTexture();
}
void GamingUI::RenderText() const
{
- Oyster::Graphics::API::StartTextRender();
this->text->RenderText();
}
@@ -76,7 +75,10 @@ bool GamingUI::Release()
delete this->text;
return true;
}
-
+void GamingUI::SetHPtext( std::wstring hp )
+{
+ this->text->setText(hp);
+}
void GamingUI::ReadKeyInput()
{
if( this->keyboardInput->IsKeyDown(::Input::Enum::SAKI_W) )
diff --git a/Code/Game/GameClient/GameClientState/GamingUI.h b/Code/Game/GameClient/GameClientState/GamingUI.h
index a1e68f2a..c5346004 100644
--- a/Code/Game/GameClient/GameClientState/GamingUI.h
+++ b/Code/Game/GameClient/GameClientState/GamingUI.h
@@ -22,12 +22,15 @@ namespace DanBias { namespace Client
void RenderGUI() const;
void RenderText() const;
bool Release();
+ void SetHPtext( std::wstring hp );
private:
::Input::Mouse *mouseInput;
::Input::Keyboard *keyboardInput;
::Oyster::Network::NetworkClient *netClient;
Camera_FPSV2 *camera;
+
+ // TODO add multiple UI elements
Text_UI* text;
Plane_UI* plane;
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/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp
index 30eabed2..2b8a7d5c 100644
--- a/Code/Game/GameServer/Implementation/GameSession_General.cpp
+++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp
@@ -234,7 +234,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());
}
}