Added player color to client. Spawnpoint class but logic needs to be implemented. Added kills and deatch counting and message sending for it.
This commit is contained in:
parent
9c4f72882c
commit
1bf7e21fcc
|
@ -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;
|
||||
|
||||
|
|
|
@ -237,6 +237,7 @@
|
|||
<ClInclude Include="GameClientState\Camera_BasicV2.h" />
|
||||
<ClInclude Include="GameClientState\Camera_FPS.h" />
|
||||
<ClInclude Include="GameClientState\Camera_FPSV2.h" />
|
||||
<ClInclude Include="GameClientState\ColorDefines.h" />
|
||||
<ClInclude Include="GameClientState\C_Light.h" />
|
||||
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
|
||||
<ClInclude Include="GameClientState\C_obj\C_Player.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
|
|
@ -13,6 +13,7 @@
|
|||
#include "RespawnUI.h"
|
||||
#include "StatsUI.h"
|
||||
#include <ObjectDefines.h>
|
||||
#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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -178,6 +178,7 @@
|
|||
<ClInclude Include="PickupSystem\PickupSystem.h" />
|
||||
<ClInclude Include="Player.h" />
|
||||
<ClInclude Include="Portal.h" />
|
||||
<ClInclude Include="SpawnPoint.h" />
|
||||
<ClInclude Include="StaticObject.h" />
|
||||
<ClInclude Include="Team.h" />
|
||||
<ClInclude Include="TeamManager.h" />
|
||||
|
@ -202,6 +203,7 @@
|
|||
<ClCompile Include="PickupSystem\PickupSystem.cpp" />
|
||||
<ClCompile Include="Player.cpp" />
|
||||
<ClCompile Include="Portal.cpp" />
|
||||
<ClCompile Include="SpawnPoint.cpp" />
|
||||
<ClCompile Include="StaticObject.cpp" />
|
||||
<ClCompile Include="Team.cpp" />
|
||||
<ClCompile Include="TeamManager.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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
|
||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> dynamicObjects;
|
||||
GameModeType gameMode;
|
||||
//Utility::DynamicMemory::SmartPointer<Oyster::Physics::ICustomBody> rigidBodyLevel;
|
||||
// //StaticObject *levelObj;
|
||||
int objIDCounter;
|
||||
Utility::DynamicMemory::DynamicArray<Oyster::Math::Float3> spawnPoints;
|
||||
SpawnPoint spawnPoints;
|
||||
PickupSystem pickupSystem;
|
||||
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef GAMELOGIC_SPAWNPOINT_H
|
||||
#define GAMELOGIC_SPAWNPOINT_H
|
||||
#include <DynamicArray.h>
|
||||
#include "OysterMath.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
class SpawnPoint
|
||||
{
|
||||
private:
|
||||
Utility::DynamicMemory::DynamicArray<Oyster::Math::Float3> spawnPoints;
|
||||
|
||||
public:
|
||||
SpawnPoint();
|
||||
~SpawnPoint(void);
|
||||
void addSpawnPos(Oyster::Math::Float3 pos);
|
||||
Oyster::Math::Float3 getSpawnPos();
|
||||
};
|
||||
}
|
||||
#endif // GAMELOGIC_SPAWNPOINT_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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue