Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
2b8dbee5f6
|
@ -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:
|
||||
|
|
|
@ -105,6 +105,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
|
|||
void AttatchmentMassDriver::Update(float dt)
|
||||
{
|
||||
|
||||
|
||||
//update position of heldObject if there is an object being held
|
||||
if(hasObject)
|
||||
{
|
||||
|
@ -116,13 +117,27 @@ void AttatchmentMassDriver::Update(float dt)
|
|||
heldObject->SetPosition(pos);
|
||||
heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
|
||||
|
||||
currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object
|
||||
if(currentEnergy < maxEnergy)
|
||||
{
|
||||
currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
currentEnergy += rechargeRate;
|
||||
if(currentEnergy < maxEnergy)
|
||||
{
|
||||
currentEnergy += rechargeRate;
|
||||
|
||||
if(currentEnergy == maxEnergy)
|
||||
{
|
||||
int trap = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(currentEnergy > maxEnergy) currentEnergy = maxEnergy;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -167,9 +167,6 @@ using namespace GameLogic;
|
|||
{
|
||||
Player *hitPlayer = (Player*)realObj;
|
||||
hitPlayer->DamageLife(ExplosionSource->extraDamageOnCollision);
|
||||
//hitPlayer->GetRigidBody()->ApplyImpulse(force);
|
||||
|
||||
//hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision());
|
||||
realObj->GetRigidBody()->ApplyImpulse(force * 5);
|
||||
//do shredding damage
|
||||
}
|
||||
|
@ -192,11 +189,11 @@ using namespace GameLogic;
|
|||
Oyster::Math::Float angularFactor = deltaPos.GetNormalized().Dot( (objPrevVel - playerPrevVel).GetNormalized());
|
||||
|
||||
Oyster::Math::Float impactPower = deltaSpeed * angularFactor;
|
||||
Oyster::Math::Float damageFactor = 0.01f;
|
||||
Oyster::Math::Float damageFactor = 0.1f;
|
||||
|
||||
|
||||
int damageDone = 0;
|
||||
int forceThreashHold = 30; //FIX: balance this
|
||||
Oyster::Math::Float damageDone = 0.0f;
|
||||
Oyster::Math::Float forceThreashHold = 30.0f; //FIX: balance this
|
||||
|
||||
if(impactPower > forceThreashHold) //should only take damage if the force is high enough
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -68,8 +68,8 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
break;
|
||||
case ObjectSpecialType_RedExplosiveBox:
|
||||
{
|
||||
Oyster::Math::Float dmg = 120;
|
||||
Oyster::Math::Float force = 500;
|
||||
Oyster::Math::Float dmg = 50;
|
||||
Oyster::Math::Float force = 800;
|
||||
Oyster::Math::Float radie = 3;
|
||||
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objIDCounter, dmg, force, radie);
|
||||
}
|
||||
|
@ -90,8 +90,7 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
break;
|
||||
case ObjectSpecialType_CrystalFormation:
|
||||
{
|
||||
int dmg = 50;
|
||||
//gameObj = new Crystal(rigidBody);
|
||||
int dmg = 30;
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objIDCounter);
|
||||
}
|
||||
break;
|
||||
|
@ -102,7 +101,7 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
break;
|
||||
case ObjectSpecialType_JumpPad:
|
||||
{
|
||||
float power = 500; //((JumpPadAttributes*)obj)->power;
|
||||
float power = ((JumpPadAttributes*)obj)->power;
|
||||
Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction;
|
||||
Oyster::Math::Float3 pushForce = dir * power;
|
||||
gameObj = new JumpPad(rigidBody, (ObjectSpecialType)obj->specialTypeID, objIDCounter , pushForce);
|
||||
|
@ -352,7 +351,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 +367,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 +397,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 +408,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 +427,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 +451,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 +465,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,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 );
|
||||
|
|
|
@ -166,9 +166,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