diff --git a/Code/Game/GameClient/DanBiasGame_Impl.cpp b/Code/Game/GameClient/DanBiasGame_Impl.cpp
index 7c809af6..acc97efb 100644
--- a/Code/Game/GameClient/DanBiasGame_Impl.cpp
+++ b/Code/Game/GameClient/DanBiasGame_Impl.cpp
@@ -78,8 +78,8 @@ namespace DanBias
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
WindowShell::WINDOW_INIT_DESC winDesc;
- winDesc.windowSize.x = 1920;
- winDesc.windowSize.y = 1080;
+ winDesc.windowSize.x = 1080;
+ winDesc.windowSize.y = 720;
winDesc.windowProcCallback = WindowCallBack;
if(! data.window->CreateWin(winDesc) )
@@ -153,7 +153,7 @@ namespace DanBias
Oyster::Graphics::API::Option p;
p.modelPath = L"..\\Content\\Models\\";
p.texturePath = L"..\\Content\\Textures\\";
- p.Resolution = Oyster::Math::Float2( 1920.0f, 1080.0f );
+ p.Resolution = Oyster::Math::Float2( 1080.0f, 720.0f );
//! @todo fix proper amb value
p.AmbientValue = 1.3f;
diff --git a/Code/Game/GameClient/GameClient.vcxproj b/Code/Game/GameClient/GameClient.vcxproj
index 1693576a..42438434 100644
--- a/Code/Game/GameClient/GameClient.vcxproj
+++ b/Code/Game/GameClient/GameClient.vcxproj
@@ -237,6 +237,7 @@
+
diff --git a/Code/Game/GameClient/GameClientState/ColorDefines.h b/Code/Game/GameClient/GameClientState/ColorDefines.h
new file mode 100644
index 00000000..4e08ed99
--- /dev/null
+++ b/Code/Game/GameClient/GameClientState/ColorDefines.h
@@ -0,0 +1,65 @@
+#ifndef COLORDEFINES_H
+#define COLORDEFINES_H
+namespace DanBias
+{
+ namespace Client
+ {
+ class ColorDefines
+ {
+ public:
+ ColorDefines();
+ ~ColorDefines();
+ Oyster::Math::Float3 getGlowColor(int index);
+ Oyster::Math::Float3 getTintColor(int index);
+
+ private:
+ Oyster::Math::Float3 tintColor[10];
+ Oyster::Math::Float3 glowTintColor[10];
+ };
+
+ ColorDefines::ColorDefines()
+ {
+ // TODO make nice colors
+ tintColor[0] = Oyster::Math::Float3( 0.3f, 0.0f, 0.0f );
+ tintColor[1] = Oyster::Math::Float3( 0.3f, 0.0f, 0.0f );
+ tintColor[2] = Oyster::Math::Float3( 0.3f, 0.0f, 0.0f );
+ tintColor[3] = Oyster::Math::Float3( 0.0f, 0.3f, 0.0f );
+ tintColor[4] = Oyster::Math::Float3( 0.0f, 0.3f, 0.0f );
+ tintColor[5] = Oyster::Math::Float3( 0.0f, 0.3f, 0.0f );
+ tintColor[6] = Oyster::Math::Float3( 0.0f, 0.0f, 0.3f );
+ tintColor[7] = Oyster::Math::Float3( 0.0f, 0.0f, 0.3f );
+ tintColor[8] = Oyster::Math::Float3( 0.0f, 0.0f, 0.3f );
+ tintColor[9] = Oyster::Math::Float3( 0.0f, 0.0f, 0.5f );
+
+ glowTintColor[0] = Oyster::Math::Float3( 0.8f, 0.0f, 0.0f );
+ glowTintColor[1] = Oyster::Math::Float3( 0.0f, 0.8f, 0.0f );
+ glowTintColor[2] = Oyster::Math::Float3( 0.0f, 0.0f, 0.8f );
+ glowTintColor[3] = Oyster::Math::Float3( 0.6f, 0.0f, 0.3f );
+ glowTintColor[4] = Oyster::Math::Float3( 0.0f, 0.6f, 0.0f );
+ glowTintColor[5] = Oyster::Math::Float3( 0.3f, 0.0f, 0.6f );
+ glowTintColor[6] = Oyster::Math::Float3( 0.3f, 0.0f, 0.6f );
+ glowTintColor[7] = Oyster::Math::Float3( 0.0f, 0.3f, 0.6f );
+ glowTintColor[8] = Oyster::Math::Float3( 0.0f, 0.6f, 0.3f );
+ glowTintColor[9] = Oyster::Math::Float3( 0.0f, 0.9f, 0.0f );
+
+
+
+
+ }
+
+ ColorDefines::~ColorDefines()
+ {
+ }
+ Oyster::Math::Float3 ColorDefines::getGlowColor(int index)
+ {
+ return glowTintColor[index];
+ }
+ Oyster::Math::Float3 ColorDefines::getTintColor(int index)
+ {
+ return tintColor[index];
+ }
+
+ }
+}
+
+#endif // COLORDEFINES_H
diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp
index 28880eef..aeaba3cf 100644
--- a/Code/Game/GameClient/GameClientState/GameState.cpp
+++ b/Code/Game/GameClient/GameClientState/GameState.cpp
@@ -13,6 +13,7 @@
#include "RespawnUI.h"
#include "StatsUI.h"
#include
+#include "ColorDefines.h"
using namespace ::DanBias::Client;
using namespace ::Oyster;
@@ -113,7 +114,7 @@ bool GameState::Init( SharedStateContent &shared )
return true;
}
-void GameState::InitiatePlayer( int id, const std::string &modelName, const float position[3], const float rotation[4], const float scale[3], bool isMyPlayer )
+void GameState::InitiatePlayer( int id, const std::string &modelName, const float position[3], const float rotation[4], const float scale[3], bool isMyPlayer)
{
ModelInitData modelData;
modelData.visible = true;
@@ -139,6 +140,11 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
// start with runing animation
p->playAnimation( L"idle", true );
+ // set color tint
+ ColorDefines colors;
+ p->SetTint(colors.getTintColor(id));
+ p->SetGlowTint(colors.getGlowColor(id));
+
(this->privData->players)[id] = p;
if( isMyPlayer )
@@ -735,13 +741,27 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
Protocol_ObjectDie decoded(data);
// if is this player. Remember to change camera
int killerID = decoded.killerID;
- int victimID = decoded.objectID;
- if( this->privData->myId == decoded.objectID )
+ int victimID = decoded.victimID;
+ if( this->privData->myId == decoded.victimID )
{
this->currGameUI = this->respawnUI;
// set countdown
((RespawnUI*)currGameUI)->SetCountdown( decoded.seconds );
}
+ // update score board
+ int killerKills = decoded.killerKillCount;
+ int victimDeath = decoded.victimDeathCount;
+ }
+ return GameClientState::event_processed;
+ case protocol_Gameplay_PlayerScore:
+ {
+ Protocol_PlayerScore decoded(data);
+ int ID = decoded.playerID;
+ int kills = decoded.killCount;
+ int death = decoded.deathCount;
+
+ // update scoreboard
+
}
return GameClientState::event_processed;
case protocol_Gameplay_ObjectDisconnectPlayer:
diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h
index 28ad9772..ff2ce998 100644
--- a/Code/Game/GameLogic/Game.h
+++ b/Code/Game/GameLogic/Game.h
@@ -40,6 +40,8 @@ namespace GameLogic
Oyster::Math::Float3 GetScale() override;
Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override;
+ int GetKills() const override;
+ int GetDeaths() const override;
void SetLookDir(const Oyster::Math3D::Float3& lookDir) override;
void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) override;
ObjectSpecialType GetObjectType() const override;
diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h
index 80b255bd..d4c7fe36 100644
--- a/Code/Game/GameLogic/GameAPI.h
+++ b/Code/Game/GameLogic/GameAPI.h
@@ -30,7 +30,7 @@ namespace GameLogic
typedef void(*ObjectEnabledFunction)(IObjectData* object); // Callback method that recieves and object
typedef void(*ObjectHpFunction)(IObjectData* object, float hp); // Callback method that sends obj HP
typedef void(*ObjectRespawnedFunction)(IObjectData* object, Oyster::Math::Float3 spawnPos ); // Callback method that sends spawnPos
- typedef void(*ObjectDeadFunction)(IObjectData* victim, IObjectData* killer, float seconds); // Callback method that sends killer and death timer
+ typedef void(*ObjectDeadFunction)(IObjectData* victim, int deatchCount, IObjectData* killer, int killCount, float seconds); // Callback method that sends killer and death timer
typedef void(*PickupEventFunction)(IObjectData* player, int pickupEffectID ); // Callback method that sends killer and death timer
typedef void(*AnimationEventFunction)(IObjectData* player, int actionID ); // Callback method that sends killer and death timer
typedef void(*CollisionEventFunction)(IObjectData*object, int collisionID);
@@ -114,6 +114,8 @@ namespace GameLogic
********************************************************/
virtual PLAYER_STATE GetState() const = 0;
+ virtual int GetKills() const = 0;
+ virtual int GetDeaths() const = 0;
virtual void Inactivate() = 0;
virtual void Release() = 0;
};
diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj
index 08a932d2..26c98891 100644
--- a/Code/Game/GameLogic/GameLogic.vcxproj
+++ b/Code/Game/GameLogic/GameLogic.vcxproj
@@ -178,6 +178,7 @@
+
@@ -202,6 +203,7 @@
+
diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp
index 88b4bbbe..477551b5 100644
--- a/Code/Game/GameLogic/Game_PlayerData.cpp
+++ b/Code/Game/GameLogic/Game_PlayerData.cpp
@@ -77,6 +77,14 @@ int Game::PlayerData::GetID() const
{
return this->player->GetID();
}
+int Game::PlayerData::GetKills() const
+{
+ return this->player->GetKills();
+}
+int Game::PlayerData::GetDeaths() const
+{
+ return this->player->GetDeath();
+}
int Game::PlayerData::GetTeamID() const
{
return this->player->GetTeamID();
diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp
index 385571af..324d49da 100644
--- a/Code/Game/GameLogic/Level.cpp
+++ b/Code/Game/GameLogic/Level.cpp
@@ -352,7 +352,7 @@ bool Level::InitiateLevel(std::wstring levelPath)
pos.x = ((SpawnPointAttributes*)obj)->position[0];
pos.y = ((SpawnPointAttributes*)obj)->position[1];
pos.z = ((SpawnPointAttributes*)obj)->position[2];
- spawnPoints.Push(pos);
+ spawnPoints.addSpawnPos(pos);
}
default:
break;
@@ -368,9 +368,7 @@ void Level::AddPlayerToTeam(Player *player, int teamID)
}
void Level::AddPlayerToGame(Player *player)
{
- int i = rand() % spawnPoints.Size();
- Float3 spawnPoint = spawnPoints[i];
- player->ResetPlayer(spawnPoint);
+ player->ResetPlayer(spawnPoints.getSpawnPos());
for(int i = 0; i < (int)this->playerObjects.Size(); i++)
{
if (!this->playerObjects[i])
@@ -400,10 +398,7 @@ void Level::CreateTeam(int teamSize)
void Level::RespawnPlayer(Player *player)
{
//this->teamManager.RespawnPlayerRandom(player);
-
- int i = rand() % spawnPoints.Size();
- Float3 spawnPoint = spawnPoints[i];
- player->Respawn(spawnPoint);
+ player->Respawn(spawnPoints.getSpawnPos());
}
void Level::Update(float deltaTime)
{
@@ -414,6 +409,11 @@ void Level::Update(float deltaTime)
{
if(this->playerObjects[i])
{
+ // TODO check against gameMode win condition
+ if(this->playerObjects[i]->GetKills() > 30 )
+ {
+ // winner
+ }
if(this->playerObjects[i]->getAffectingPlayer() != NULL)
{
@@ -428,14 +428,20 @@ void Level::Update(float deltaTime)
else if (this->playerObjects[i]->GetState() == PLAYER_STATE::PLAYER_STATE_DIED)
{
this->playerObjects[i]->setDeathTimer(DEATH_TIMER);
- // HACK to avoid crasch. affected by tag is NULL
- //((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], this->playerObjects[i], DEATH_TIMER); // add killer ID
Player* killer = this->playerObjects[i]->getAffectingPlayer();
- if(!killer) //if there is no killer then you commited suicide
+ if(!killer) //if there is no killer then you committed suicide
{
killer = this->playerObjects[i];
+ // suicide penalty
}
- ((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], killer, DEATH_TIMER); // add killer ID
+ else
+ killer->AddKill();
+
+ this->playerObjects[i]->AddDeath();
+
+
+ ((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], this->playerObjects[i]->GetDeath(), killer, killer->GetKills(), DEATH_TIMER); // add killer ID
+
}
}
}
@@ -446,7 +452,7 @@ void Level::Update(float deltaTime)
{
Oyster::Math::Float vel = dynamicObjects[i]->GetRigidBody()->GetLinearVelocity().GetMagnitude();
- if(vel <= 0.1f) // is bearly moving
+ if(vel <= 0.1f) // is barely moving
{
//set the tag AffectedBy to NULL
dynamicObjects[i]->RemoveAffectedBy();
@@ -460,7 +466,7 @@ void Level::Update(float deltaTime)
{
Oyster::Math::Float vel = playerObjects[i]->GetRigidBody()->GetLinearVelocity().GetMagnitude();
- if(vel <= 0.1f) // is bearly moving
+ if(vel <= 0.1f) // is barely moving
{
//set the tag AffectedBy to NULL
playerObjects[i]->RemoveAffectedBy();
diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h
index 1811c9af..a6c88bd7 100644
--- a/Code/Game/GameLogic/Level.h
+++ b/Code/Game/GameLogic/Level.h
@@ -9,6 +9,7 @@
#include "StaticObject.h"
#include "DynamicObject.h"
#include "GameModeType.h"
+#include "SpawnPoint.h"
#include "Player.h"
#include "PhysicsAPI.h"
@@ -88,10 +89,8 @@ namespace GameLogic
Utility::DynamicMemory::DynamicArray> staticObjects;
Utility::DynamicMemory::DynamicArray> dynamicObjects;
GameModeType gameMode;
- //Utility::DynamicMemory::SmartPointer rigidBodyLevel;
-// //StaticObject *levelObj;
int objIDCounter;
- Utility::DynamicMemory::DynamicArray spawnPoints;
+ SpawnPoint spawnPoints;
PickupSystem pickupSystem;
};
diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp
index bea0f896..209287a8 100644
--- a/Code/Game/GameLogic/Player.cpp
+++ b/Code/Game/GameLogic/Player.cpp
@@ -339,7 +339,22 @@ PLAYER_STATE Player::GetState() const
{
return this->playerState;
}
-
+void Player::AddKill()
+{
+ this->playerScore.killScore++;
+}
+void Player::AddDeath()
+{
+ this->playerScore.deathScore++;
+}
+int Player::GetKills() const
+{
+ return this->playerScore.killScore;
+}
+int Player::GetDeath() const
+{
+ return this->playerScore.deathScore;
+}
void Player::DamageLife(int damage)
{
if(damage != 0)
diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h
index 965abfd9..63c17f90 100644
--- a/Code/Game/GameLogic/Player.h
+++ b/Code/Game/GameLogic/Player.h
@@ -91,6 +91,10 @@ namespace GameLogic
PLAYER_STATE GetState() const;
Oyster::Math::Float GetRecentlyAffected();
+ void AddKill();
+ void AddDeath();
+ int GetKills() const;
+ int GetDeath() const;
void DamageLife(int damage);
void setDeathTimer(float deathTimer);
bool deathTimerTick(float dt);
diff --git a/Code/Game/GameLogic/SpawnPoint.cpp b/Code/Game/GameLogic/SpawnPoint.cpp
new file mode 100644
index 00000000..f11df5ba
--- /dev/null
+++ b/Code/Game/GameLogic/SpawnPoint.cpp
@@ -0,0 +1,22 @@
+#include "SpawnPoint.h"
+
+using namespace GameLogic;
+
+SpawnPoint::SpawnPoint()
+{
+}
+
+
+SpawnPoint::~SpawnPoint(void)
+{
+}
+void SpawnPoint::addSpawnPos(Oyster::Math::Float3 pos)
+{
+ spawnPoints.Push(pos);
+}
+Oyster::Math::Float3 SpawnPoint::getSpawnPos()
+{
+ int i = rand() % spawnPoints.Size();
+ Oyster::Math::Float3 spawnPoint = spawnPoints[i];
+ return spawnPoint;
+}
\ No newline at end of file
diff --git a/Code/Game/GameLogic/SpawnPoint.h b/Code/Game/GameLogic/SpawnPoint.h
new file mode 100644
index 00000000..8d494b99
--- /dev/null
+++ b/Code/Game/GameLogic/SpawnPoint.h
@@ -0,0 +1,20 @@
+#ifndef GAMELOGIC_SPAWNPOINT_H
+#define GAMELOGIC_SPAWNPOINT_H
+#include
+#include "OysterMath.h"
+
+namespace GameLogic
+{
+class SpawnPoint
+{
+private:
+ Utility::DynamicMemory::DynamicArray spawnPoints;
+
+public:
+ SpawnPoint();
+ ~SpawnPoint(void);
+ void addSpawnPos(Oyster::Math::Float3 pos);
+ Oyster::Math::Float3 getSpawnPos();
+};
+}
+#endif // GAMELOGIC_SPAWNPOINT_H
diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h
index 9b469bbc..628fb396 100644
--- a/Code/Game/GameProtocols/ObjectProtocols.h
+++ b/Code/Game/GameProtocols/ObjectProtocols.h
@@ -571,6 +571,7 @@ namespace GameLogic
private:
Oyster::Network::CustomNetProtocol protocol;
};
+
//#define protocol_Gameplay_ObjectCreatePlayer 361
struct Protocol_ObjectCreatePlayer :public Oyster::Network::CustomProtocolObject
{
@@ -580,8 +581,8 @@ namespace GameLogic
/*4*/ std::string name;
/*5*/ std::string meshName;
/*6 - 8*/ float position[3];
- /*9 - 11*/ float rotationQ[4];
- /*12 - 14*/ float scale[3];
+ /*9 - 12*/ float rotationQ[4];
+ /*13 - 15*/ float scale[3];
Protocol_ObjectCreatePlayer()
{
@@ -606,10 +607,11 @@ namespace GameLogic
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
- //SCALE
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
+ //SCALE
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
+ this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
}
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
{
@@ -892,8 +894,10 @@ namespace GameLogic
//#define protocol_Gameplay_ObjectDie 367
struct Protocol_ObjectDie :public Oyster::Network::CustomProtocolObject
{
- int objectID;
+ int victimID;
+ int victimDeathCount;
int killerID;
+ int killerKillCount;
float seconds;
Protocol_ObjectDie()
@@ -902,33 +906,45 @@ namespace GameLogic
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
- this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
- this->objectID = -1;
+ this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
+ this->protocol[4].type = Oyster::Network::NetAttributeType_Int;
+ this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
+ this->victimID = -1;
+ this->victimDeathCount = -1;
this->killerID = -1;
+ this->killerKillCount = -1;
this->seconds = 0.0f;
}
- Protocol_ObjectDie(int objectID, int killerID, float seconds)
+ Protocol_ObjectDie(int victimID, int deathCount, int killerID, int killCount, float seconds)
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
- this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
- this->objectID = objectID;
+ this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
+ this->protocol[4].type = Oyster::Network::NetAttributeType_Int;
+ this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
+ this->victimID = victimID;
+ this->victimDeathCount = deathCount;
this->killerID = killerID;
+ this->killerKillCount = killCount;
this->seconds = seconds;
}
Protocol_ObjectDie(Oyster::Network::CustomNetProtocol& p)
{
- this->objectID = p[1].value.netInt;
- this->killerID = p[2].value.netInt;
- this->seconds = p[3].value.netFloat;
+ this->victimID = p[1].value.netInt;
+ this->victimDeathCount = p[2].value.netInt;
+ this->killerID = p[3].value.netInt;
+ this->killerKillCount = p[4].value.netInt;
+ this->seconds = p[5].value.netFloat;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
- this->protocol[1].value = this->objectID;
- this->protocol[2].value = this->killerID;
- this->protocol[3].value = this->seconds;
+ this->protocol[1].value = this->victimID;
+ this->protocol[2].value = this->victimDeathCount;
+ this->protocol[3].value = this->killerID;
+ this->protocol[4].value = this->killerKillCount;
+ this->protocol[5].value = this->seconds;
return protocol;
}
diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h
index eb34c07c..66d1b38f 100644
--- a/Code/Game/GameProtocols/PlayerProtocols.h
+++ b/Code/Game/GameProtocols/PlayerProtocols.h
@@ -194,7 +194,56 @@ namespace GameLogic
private:
Oyster::Network::CustomNetProtocol protocol;
};
+ //#define protocol_Gameplay_ObjectPickup 350
+ struct Protocol_PlayerScore :public Oyster::Network::CustomProtocolObject
+ {
+ int playerID;
+ int killCount;
+ int deathCount;
+ Protocol_PlayerScore()
+ {
+ this->protocol[0].value = protocol_Gameplay_PlayerScore;
+ this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
+
+ this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
+ this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
+ this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
+
+ playerID = -1;
+ killCount = -1;
+ deathCount = -1;
+ }
+ Protocol_PlayerScore(Oyster::Network::CustomNetProtocol& p)
+ {
+ playerID = p[1].value.netShort;
+ killCount = p[2].value.netInt;
+ deathCount = p[3].value.netInt;
+ }
+ Protocol_PlayerScore(int objectID, int kills, int deaths)
+ {
+ this->protocol[0].value = protocol_Gameplay_PlayerScore;
+ this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
+
+ this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
+ this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
+ this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
+
+ playerID = objectID;
+ killCount = kills;
+ deathCount = deaths;
+ }
+ Oyster::Network::CustomNetProtocol GetProtocol() override
+ {
+ this->protocol[1].value = playerID;
+ this->protocol[2].value = killCount;
+ this->protocol[3].value = deathCount;
+ return protocol;
+ }
+
+ private:
+ Oyster::Network::CustomNetProtocol protocol;
+ };
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h
index eea1e945..bfc5a85e 100644
--- a/Code/Game/GameProtocols/ProtocolIdentificationID.h
+++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h
@@ -52,6 +52,7 @@
#define protocol_Gameplay_PlayerChangeWeapon 305
#define protocol_Gameplay_PlayerShot 306
#define protocol_Gameplay_PlayerJump 307
+#define protocol_Gameplay_PlayerScore 308
#define protocol_Gameplay_ObjectPickup 350
#define protocol_Gameplay_ObjectDamage 351
diff --git a/Code/Game/GameServer/GameSession.h b/Code/Game/GameServer/GameSession.h
index d449ff2d..25e6dc2f 100644
--- a/Code/Game/GameServer/GameSession.h
+++ b/Code/Game/GameServer/GameSession.h
@@ -102,7 +102,7 @@ namespace DanBias
static void ObjectEnabled ( GameLogic::IObjectData* movedObject );
static void ObjectDamaged ( GameLogic::IObjectData* movedObject, float hp );
static void ObjectRespawned ( GameLogic::IObjectData* movedObject, Oyster::Math::Float3 spawnPos );
- static void ObjectDead ( GameLogic::IObjectData* victim, GameLogic::IObjectData* killer, float seconds );
+ static void ObjectDead ( GameLogic::IObjectData* victim, int deatchCount, GameLogic::IObjectData* killer, int killCount, float seconds );
static void PickupEvent ( GameLogic::IObjectData* movedObject, int pickupEffectID );
static void ActionEvent ( GameLogic::IObjectData* movedObject , int actionID );
static void CollisionEvent ( GameLogic::IObjectData* Object , int collisionID );
diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
index ceb22431..4583978c 100644
--- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
+++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp
@@ -162,9 +162,9 @@ using namespace DanBias;
{
GameSession::gameSession->Send(Protocol_ObjectRespawn(movedObject->GetID(), spawnPos).GetProtocol());
}
- void GameSession::ObjectDead( GameLogic::IObjectData* victim, GameLogic::IObjectData* killer, float seconds )
+ void GameSession::ObjectDead( IObjectData* victim, int deatchCount, IObjectData* killer, int killCount, float seconds )
{
- GameSession::gameSession->Send(Protocol_ObjectDie(victim->GetID(), killer->GetID(), seconds).GetProtocol());
+ GameSession::gameSession->Send(Protocol_ObjectDie(victim->GetID(), deatchCount, killer->GetID(), killCount, seconds).GetProtocol());
}
void GameSession::PickupEvent( GameLogic::IObjectData* movedObject, int pickupEffectID )
{
diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp
index d19fcecf..8c746bf2 100644
--- a/Code/Game/GameServer/Implementation/GameSession_General.cpp
+++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp
@@ -223,6 +223,7 @@ bool GameSession::Join(gClient gameClient)
{
if(this->gClients[i] && !this->gClients[i]->IsInvalid())
{
+ // other Player
IPlayerData* temp = this->gClients[i]->GetPlayer();
Protocol_ObjectCreatePlayer p1( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
temp->GetID(), false, temp->GetTeamID(),
@@ -230,12 +231,19 @@ bool GameSession::Join(gClient gameClient)
Utility::String::WStringToString(this->gClients[i]->GetCharacter(), std::string()));
nwClient->Send(p1);
+ Protocol_PlayerScore oldPlayerScore(temp->GetID(), temp->GetKills(), temp->GetDeaths());
+ nwClient->Send(oldPlayerScore);
+
+ // new player
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);
+
+ Protocol_PlayerScore newPlayerScore(temp->GetID(), temp->GetKills(), temp->GetDeaths());
+ this->gClients[i]->GetClient()->Send(newPlayerScore);
}
}
}