GameServer - Merged with physics
This commit is contained in:
commit
e680da9d54
|
@ -123,7 +123,10 @@ void C_Object::SetGlowTint(Oyster::Math::Float3 tint)
|
||||||
model->GlowTint = tint;
|
model->GlowTint = tint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C_Object::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
model->Visible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// RB DEBUG
|
// RB DEBUG
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace DanBias
|
||||||
|
|
||||||
void SetTint(Oyster::Math::Float3);
|
void SetTint(Oyster::Math::Float3);
|
||||||
void SetGlowTint(Oyster::Math::Float3);
|
void SetGlowTint(Oyster::Math::Float3);
|
||||||
|
void SetVisible(bool visible);
|
||||||
|
|
||||||
// RB DEBUG
|
// RB DEBUG
|
||||||
void updateRBWorld();
|
void updateRBWorld();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "GamingUI.h"
|
#include "GamingUI.h"
|
||||||
#include "RespawnUI.h"
|
#include "RespawnUI.h"
|
||||||
#include "StatsUI.h"
|
#include "StatsUI.h"
|
||||||
|
#include <ObjectDefines.h>
|
||||||
|
|
||||||
using namespace ::DanBias::Client;
|
using namespace ::DanBias::Client;
|
||||||
using namespace ::Oyster;
|
using namespace ::Oyster;
|
||||||
|
@ -136,7 +137,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
||||||
p->InitRB( RBData );
|
p->InitRB( RBData );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
// start with runing animation
|
// start with runing animation
|
||||||
p->playAnimation( L"run_forwards", true );
|
p->playAnimation( L"idle", true );
|
||||||
|
|
||||||
(this->privData->players)[id] = p;
|
(this->privData->players)[id] = p;
|
||||||
|
|
||||||
|
@ -145,9 +146,12 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
||||||
this->privData->myId = id;
|
this->privData->myId = id;
|
||||||
this->privData->camera.SetPosition( p->getPos() );
|
this->privData->camera.SetPosition( p->getPos() );
|
||||||
Float3 offset = Float3( 0.0f );
|
Float3 offset = Float3( 0.0f );
|
||||||
|
// DEBUG position of camera so we can see the player model
|
||||||
this->privData->camera.SetHeadOffset( offset );
|
//offset.y = p->getScale().y * 5.0f;
|
||||||
this->privData->camera.UpdateOrientation();
|
//offset.z = p->getScale().z * -5.0f;
|
||||||
|
// !DEBUG
|
||||||
|
//this->privData->camera.SetHeadOffset( offset );
|
||||||
|
//this->privData->camera.UpdateOrientation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +192,7 @@ bool GameState::Render()
|
||||||
{
|
{
|
||||||
if(playerObject->second)
|
if(playerObject->second)
|
||||||
{
|
{
|
||||||
//if( this->privData->myId != playerObject->second->GetId() )
|
if( this->privData->myId != playerObject->second->GetId() )
|
||||||
{
|
{
|
||||||
playerObject->second->Render();
|
playerObject->second->Render();
|
||||||
}
|
}
|
||||||
|
@ -424,66 +428,10 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
|
|
||||||
switch(ID)
|
switch(ID)
|
||||||
{
|
{
|
||||||
case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectPickup:
|
||||||
case protocol_Gameplay_ObjectDamage:
|
|
||||||
{
|
{
|
||||||
Protocol_ObjectDamage decoded(data);
|
Protocol_ObjectPickup decoded(data);
|
||||||
if( this->privData->myId == decoded.object_ID )
|
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);
|
|
||||||
|
|
||||||
// if is this player. Remember to change camera
|
|
||||||
if( this->privData->myId == decoded.object_ID )
|
|
||||||
this->privData->camera.SetPosition( decoded.position );
|
|
||||||
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setPos( decoded.position );
|
|
||||||
// RB DEBUG
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBPos ( decoded.position );
|
|
||||||
// !RB DEBUG
|
|
||||||
}
|
|
||||||
return GameClientState::event_processed;
|
|
||||||
case protocol_Gameplay_ObjectScale:
|
|
||||||
{
|
|
||||||
Protocol_ObjectScale decoded(data);
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setScale( decoded.scale );
|
|
||||||
// RB DEBUG
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBScale ( decoded.scale );
|
|
||||||
// !RB DEBUG
|
|
||||||
}
|
|
||||||
return GameClientState::event_processed;
|
|
||||||
case protocol_Gameplay_ObjectRotation:
|
|
||||||
{
|
|
||||||
Protocol_ObjectRotation decoded(data);
|
|
||||||
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
|
||||||
|
|
||||||
// if is this player. Remember to change camera
|
|
||||||
if( this->privData->myId == decoded.object_ID )
|
|
||||||
this->privData->camera.SetRotation( rotation );
|
|
||||||
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation );
|
|
||||||
// RB DEBUG
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBRot ( rotation );
|
|
||||||
// !RB DEBUG
|
|
||||||
}
|
|
||||||
return GameClientState::event_processed;
|
|
||||||
case protocol_Gameplay_ObjectPositionRotation:
|
|
||||||
{
|
|
||||||
Protocol_ObjectPositionRotation decoded(data);
|
|
||||||
Float3 position = decoded.position;
|
|
||||||
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
|
||||||
C_Object *object;
|
C_Object *object;
|
||||||
object = (this->privData->players)[decoded.object_ID];
|
object = (this->privData->players)[decoded.object_ID];
|
||||||
if( !object)
|
if( !object)
|
||||||
|
@ -495,6 +443,142 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
if( object )
|
if( object )
|
||||||
{
|
{
|
||||||
if( this->privData->myId == decoded.object_ID )
|
if( this->privData->myId == decoded.object_ID )
|
||||||
|
{
|
||||||
|
// I picked up the pickUp!
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decoded.pickup_ID == GameLogic::PickupType::PickupType_Health)
|
||||||
|
{
|
||||||
|
// object->PickupHealth();
|
||||||
|
}
|
||||||
|
else if (decoded.pickup_ID == GameLogic::PickupType::PickupType_SpeedBoost)
|
||||||
|
{
|
||||||
|
// object->PickupSpeed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
decoded.pickup_ID;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
|
case protocol_Gameplay_ObjectDamage:
|
||||||
|
{
|
||||||
|
Protocol_ObjectDamage decoded(data);
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.objectID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.objectID )
|
||||||
|
{
|
||||||
|
// show that you took dmg
|
||||||
|
if(currGameUI == gameUI)
|
||||||
|
{
|
||||||
|
// set given players HP
|
||||||
|
((GamingUI*)currGameUI)->SetHPtext(std::to_wstring(decoded.healthLost));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
|
case protocol_Gameplay_ObjectHealthStatus:
|
||||||
|
{
|
||||||
|
// don't know if needed
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
|
case protocol_Gameplay_ObjectPosition:
|
||||||
|
{
|
||||||
|
Protocol_ObjectPosition decoded(data);
|
||||||
|
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.objectID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.objectID )
|
||||||
|
{
|
||||||
|
this->privData->camera.SetPosition( decoded.position );
|
||||||
|
}
|
||||||
|
|
||||||
|
object->setPos( decoded.position );
|
||||||
|
// RB DEBUG
|
||||||
|
object->setRBPos ( decoded.position );
|
||||||
|
// !RB DEBUG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
|
case protocol_Gameplay_ObjectScale:
|
||||||
|
{
|
||||||
|
Protocol_ObjectScale decoded(data);
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.objectID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
object->setScale( decoded.scale );
|
||||||
|
// RB DEBUG
|
||||||
|
object->setRBScale ( decoded.scale );
|
||||||
|
// !RB DEBUG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
|
case protocol_Gameplay_ObjectRotation:
|
||||||
|
{
|
||||||
|
Protocol_ObjectRotation decoded(data);
|
||||||
|
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.objectID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.objectID )
|
||||||
|
{
|
||||||
|
this->privData->camera.SetRotation( rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
object->setRot( rotation );
|
||||||
|
// RB DEBUG
|
||||||
|
object->setRBRot( rotation );
|
||||||
|
// !RB DEBUG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
|
case protocol_Gameplay_ObjectPositionRotation:
|
||||||
|
{
|
||||||
|
Protocol_ObjectPositionRotation decoded(data);
|
||||||
|
Float3 position = decoded.position;
|
||||||
|
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.objectID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.objectID )
|
||||||
{
|
{
|
||||||
this->privData->camera.SetPosition( position );
|
this->privData->camera.SetPosition( position );
|
||||||
this->privData->camera.SetRotation( rotation );
|
this->privData->camera.SetRotation( rotation );
|
||||||
|
@ -510,17 +594,46 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectEnabled:
|
||||||
|
{
|
||||||
|
Protocol_ObjectEnable decoded(data);
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.objectID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
object->SetVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectDisabled:
|
case protocol_Gameplay_ObjectDisabled:
|
||||||
{
|
{
|
||||||
Protocol_ObjectDisable decoded(data);
|
Protocol_ObjectDisable decoded(data);
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.objectID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
|
|
||||||
auto object = this->privData->dynamicObjects->find( decoded.objectID );
|
if( object )
|
||||||
|
{
|
||||||
|
object->SetVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*auto object = this->privData->dynamicObjects->find( decoded.objectID );
|
||||||
if( object != this->privData->dynamicObjects->end() )
|
if( object != this->privData->dynamicObjects->end() )
|
||||||
{
|
{
|
||||||
object->second = nullptr;
|
object->second = nullptr;
|
||||||
this->privData->dynamicObjects->erase( object );
|
this->privData->dynamicObjects->erase( object );
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectCreate:
|
case protocol_Gameplay_ObjectCreate:
|
||||||
|
@ -534,7 +647,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
modelData.rotation = Quaternion( Float3(decoded.position), decoded.rotationQ[3] );
|
modelData.rotation = Quaternion( Float3(decoded.position), decoded.rotationQ[3] );
|
||||||
modelData.scale = Float3( decoded.scale );
|
modelData.scale = Float3( decoded.scale );
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
modelData.id = decoded.object_ID;
|
modelData.id = decoded.objectID;
|
||||||
|
|
||||||
::Utility::String::StringToWstring( decoded.name, modelData.modelPath );
|
::Utility::String::StringToWstring( decoded.name, modelData.modelPath );
|
||||||
}
|
}
|
||||||
|
@ -549,14 +662,14 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
object->InitRB( RBData );
|
object->InitRB( RBData );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID] = object;
|
(*this->privData->dynamicObjects)[decoded.objectID] = object;
|
||||||
|
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectCreatePlayer:
|
case protocol_Gameplay_ObjectCreatePlayer:
|
||||||
{
|
{
|
||||||
Protocol_ObjectCreatePlayer decoded(data);
|
Protocol_ObjectCreatePlayer decoded(data);
|
||||||
this->InitiatePlayer( decoded.object_ID, decoded.meshName, decoded.position, decoded.rotationQ, decoded.scale, decoded.owner );
|
this->InitiatePlayer( decoded.objectID, decoded.meshName, decoded.position, decoded.rotationQ, decoded.scale, decoded.owner );
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
|
||||||
|
@ -595,6 +708,8 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
{
|
{
|
||||||
Protocol_ObjectDie decoded(data);
|
Protocol_ObjectDie decoded(data);
|
||||||
// if is this player. Remember to change camera
|
// if is this player. Remember to change camera
|
||||||
|
int killerID = decoded.killerID;
|
||||||
|
int victimID = decoded.objectID;
|
||||||
if( this->privData->myId == decoded.objectID )
|
if( this->privData->myId == decoded.objectID )
|
||||||
{
|
{
|
||||||
this->currGameUI = this->respawnUI;
|
this->currGameUI = this->respawnUI;
|
||||||
|
@ -615,6 +730,40 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
|
case protocol_Gameplay_ObjectAction:
|
||||||
|
{
|
||||||
|
Protocol_ObjectAction decoded(data);
|
||||||
|
|
||||||
|
C_Player *player;
|
||||||
|
player = (this->privData->players)[decoded.objectID];
|
||||||
|
|
||||||
|
if( player )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.objectID )
|
||||||
|
{
|
||||||
|
// my player animation
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// HACK for now animate my char
|
||||||
|
switch (decoded.animationID)
|
||||||
|
{
|
||||||
|
case GameLogic::PlayerAction::PlayerAction_Walk:
|
||||||
|
player->playAnimation(L"run_forwards", true);
|
||||||
|
break;
|
||||||
|
case GameLogic::PlayerAction::PlayerAction_Jump:
|
||||||
|
player->playAnimation(L"movement", true);
|
||||||
|
break;
|
||||||
|
case GameLogic::PlayerAction::PlayerAction_Idle:
|
||||||
|
player->playAnimation(L"idle", true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,18 @@ AttatchmentMassDriver::AttatchmentMassDriver(void)
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
this->heldObject = NULL;
|
this->heldObject = NULL;
|
||||||
this->hasObject = false;
|
this->hasObject = false;
|
||||||
|
this->currentEnergy = StandardMaxEnergy;
|
||||||
|
this->maxEnergy = StandardMaxEnergy;
|
||||||
|
this->rechargeRate = StandardrechargeRate;
|
||||||
|
this->force = Standardforce;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
|
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
|
||||||
{
|
{
|
||||||
|
this->currentEnergy = StandardMaxEnergy;
|
||||||
|
this->maxEnergy = StandardMaxEnergy;
|
||||||
|
this->rechargeRate = StandardrechargeRate;
|
||||||
|
this->force = Standardforce;
|
||||||
|
|
||||||
this->owner = &owner;
|
this->owner = &owner;
|
||||||
this->heldObject = NULL;
|
this->heldObject = NULL;
|
||||||
|
@ -36,15 +44,27 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
|
||||||
switch (usage)
|
switch (usage)
|
||||||
{
|
{
|
||||||
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
|
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
|
||||||
ForcePush(usage,dt);
|
if(currentEnergy >= 90.0f)
|
||||||
|
{
|
||||||
|
currentEnergy -= 90.0f;
|
||||||
|
ForcePush(usage,dt);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
|
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
|
||||||
ForcePull(usage,dt);
|
if(currentEnergy >= 1.0f)
|
||||||
|
{
|
||||||
|
currentEnergy -= 1.0f;
|
||||||
|
ForcePull(usage,dt);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS:
|
case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS:
|
||||||
ForceZip(usage,dt);
|
if(currentEnergy >= 90.0f)
|
||||||
|
{
|
||||||
|
currentEnergy -= 90.0f;
|
||||||
|
ForceZip(usage,dt);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +84,14 @@ void AttatchmentMassDriver::Update(float dt)
|
||||||
heldObject->SetPosition(pos);
|
heldObject->SetPosition(pos);
|
||||||
heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
|
heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
|
||||||
|
|
||||||
|
currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentEnergy += rechargeRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
|
@ -78,9 +105,9 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
|
||||||
|
|
||||||
if(hasObject)
|
if(hasObject)
|
||||||
{
|
{
|
||||||
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (800);
|
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force);
|
||||||
heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce);
|
heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce);
|
||||||
|
((DynamicObject*)(heldObject->GetCustomTag()))->RemoveManipulation();
|
||||||
hasObject = false;
|
hasObject = false;
|
||||||
heldObject = NULL;
|
heldObject = NULL;
|
||||||
return;
|
return;
|
||||||
|
@ -91,14 +118,13 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
|
||||||
Oyster::Math::Float lenght = 10;
|
Oyster::Math::Float lenght = 10;
|
||||||
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
|
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
|
||||||
|
|
||||||
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (400);
|
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force * 0.6f);
|
||||||
|
|
||||||
Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius);
|
Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
forcePushData args;
|
forcePushData args;
|
||||||
args.pushForce = pushForce;
|
args.pushForce = pushForce;
|
||||||
|
args.p = this->owner;
|
||||||
|
|
||||||
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
|
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
|
||||||
|
|
||||||
|
@ -110,7 +136,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void AttatchmentMassDriver::ForceZip(const WEAPON_FIRE &usage, float dt)
|
void AttatchmentMassDriver::ForceZip(const WEAPON_FIRE &usage, float dt)
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 force = Oyster::Math::Float4(this->owner->GetLookDir()) * (1000);
|
Oyster::Math::Float3 force = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force);
|
||||||
|
|
||||||
this->owner->GetRigidBody()->ApplyImpulse(force);
|
this->owner->GetRigidBody()->ApplyImpulse(force);
|
||||||
}
|
}
|
||||||
|
@ -131,11 +157,12 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
|
||||||
Oyster::Math::Float lenght = 10;
|
Oyster::Math::Float lenght = 10;
|
||||||
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
|
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
|
||||||
|
|
||||||
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100);
|
Oyster::Math::Float4 pullForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force * 0.2);
|
||||||
|
|
||||||
Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius);
|
Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius);
|
||||||
forcePushData args;
|
forcePushData args;
|
||||||
args.pushForce = -pushForce;
|
args.pushForce = -pullForce;
|
||||||
|
args.p = this->owner;
|
||||||
|
|
||||||
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
|
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,14 @@
|
||||||
#ifndef ATTATCHMENTMASSDRIVER_H
|
#ifndef ATTATCHMENTMASSDRIVER_H
|
||||||
#define ATTATCHMENTMASSDRIVER_H
|
#define ATTATCHMENTMASSDRIVER_H
|
||||||
#include "IAttatchment.h"
|
#include "IAttatchment.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
const Oyster::Math::Float StandardMaxEnergy = 100.0f;
|
||||||
|
const Oyster::Math::Float StandardrechargeRate = 0.5f;
|
||||||
|
const Oyster::Math::Float Standardforce = 1000.0f;
|
||||||
|
|
||||||
class AttatchmentMassDriver : public IAttatchment
|
class AttatchmentMassDriver : public IAttatchment
|
||||||
{
|
{
|
||||||
|
@ -53,6 +59,19 @@ namespace GameLogic
|
||||||
Oyster::Physics::ICustomBody *heldObject;
|
Oyster::Physics::ICustomBody *heldObject;
|
||||||
bool hasObject;
|
bool hasObject;
|
||||||
|
|
||||||
|
Oyster::Math::Float force;
|
||||||
|
|
||||||
|
Oyster::Math::Float maxEnergy;
|
||||||
|
Oyster::Math::Float currentEnergy;
|
||||||
|
|
||||||
|
Oyster::Math::Float rechargeRate;
|
||||||
|
|
||||||
|
struct Aim
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "Portal.h"
|
#include "Portal.h"
|
||||||
#include "ExplosiveCrate.h"
|
#include "ExplosiveCrate.h"
|
||||||
|
|
||||||
|
#include "PickupSystem/PickupHealth.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
@ -113,7 +115,7 @@ using namespace GameLogic;
|
||||||
|
|
||||||
|
|
||||||
Object *realObjA = ((Object*)(objA->GetCustomTag()));
|
Object *realObjA = ((Object*)(objA->GetCustomTag()));
|
||||||
Object *realObjB = (Object*)objB->GetCustomTag(); //needs to be changed?
|
Object *realObjB = (Object*)objB->GetCustomTag();
|
||||||
ExplosiveCrate* crate;
|
ExplosiveCrate* crate;
|
||||||
|
|
||||||
if(!realObjA)
|
if(!realObjA)
|
||||||
|
@ -166,11 +168,15 @@ using namespace GameLogic;
|
||||||
Player *hitPlayer = (Player*)realObj;
|
Player *hitPlayer = (Player*)realObj;
|
||||||
hitPlayer->DamageLife(ExplosionSource->extraDamageOnCollision);
|
hitPlayer->DamageLife(ExplosionSource->extraDamageOnCollision);
|
||||||
//hitPlayer->GetRigidBody()->ApplyImpulse(force);
|
//hitPlayer->GetRigidBody()->ApplyImpulse(force);
|
||||||
|
|
||||||
|
//hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision());
|
||||||
|
realObj->GetRigidBody()->ApplyImpulse(force * 5);
|
||||||
//do shredding damage
|
//do shredding damage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
|
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
|
||||||
|
@ -226,6 +232,58 @@ using namespace GameLogic;
|
||||||
{
|
{
|
||||||
return Physics::ICustomBody::SubscriptMessage_none;
|
return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicObject::DynamicDefaultOnCollision(Oyster::Physics::ICustomBody *objA, Oyster::Physics::ICustomBody *objB, Oyster::Math::Float kineticEnergyLoss)
|
||||||
|
{
|
||||||
|
|
||||||
|
DynamicObject *realObjA = dynamic_cast<DynamicObject*>((Object*)objA->GetCustomTag());
|
||||||
|
|
||||||
|
DynamicObject *realObjB = dynamic_cast<DynamicObject*>((Object*)objB->GetCustomTag());
|
||||||
|
|
||||||
|
if(!realObjA || !realObjB) // one of the objects cannot be cast into a dynamicObject and so we leave the function
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check which obj is the one that is already affected, if both are then use the special case of changing ownership.
|
||||||
|
if(realObjA->getAffectingPlayer() == NULL && realObjB->getAffectingPlayer() == NULL) //None of the objects have a player affecting them
|
||||||
|
{
|
||||||
|
return;//leave function as the are not to transfer any ownership
|
||||||
|
}
|
||||||
|
|
||||||
|
if(realObjA->getAffectingPlayer() != NULL && realObjB->getAffectingPlayer() == NULL)
|
||||||
|
{
|
||||||
|
//realobjA is the affectedObject, transfer this to realobjB
|
||||||
|
realObjB->SetAffectedBy(*realObjA->getAffectingPlayer());
|
||||||
|
|
||||||
|
}
|
||||||
|
if(realObjB->getAffectingPlayer() != NULL && realObjA->getAffectingPlayer() == NULL)
|
||||||
|
{
|
||||||
|
//realobjB is the affectedObject, transfer this to realobjA
|
||||||
|
realObjA->SetAffectedBy(*realObjB->getAffectingPlayer());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(realObjA->getAffectingPlayer() != NULL && realObjB->getAffectingPlayer() != NULL)
|
||||||
|
{
|
||||||
|
//Both objects have a player affecting them, now use the special case
|
||||||
|
if(realObjA->GetRigidBody()->GetState().previousVelocity.GetMagnitude() > realObjB->GetRigidBody()->GetState().previousVelocity.GetMagnitude() )
|
||||||
|
{
|
||||||
|
//realObjA is the winner and will change Bs ownership to A
|
||||||
|
realObjB->SetAffectedBy(*realObjA->getAffectingPlayer());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
realObjA->SetAffectedBy(*realObjB->getAffectingPlayer());
|
||||||
|
//realObjB is the winner and will change As ownership to B
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||||
{
|
{
|
||||||
return Physics::ICustomBody::SubscriptMessage_none;
|
return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
|
@ -250,7 +308,17 @@ using namespace GameLogic;
|
||||||
if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player || realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_World)
|
if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player || realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_World)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
obj->ApplyImpulse(((forcePushData*)(args))->pushForce);
|
obj->ApplyImpulse(((forcePushData*)(args))->pushForce);
|
||||||
|
|
||||||
|
|
||||||
|
DynamicObject *dynamicObj = dynamic_cast<DynamicObject*>(realObj);
|
||||||
|
|
||||||
|
if(dynamicObj)
|
||||||
|
{
|
||||||
|
dynamicObj->SetAffectedBy(*((forcePushData*)(args))->p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args)
|
void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args)
|
||||||
|
@ -268,12 +336,21 @@ using namespace GameLogic;
|
||||||
Object* realObj = (Object*)(obj->GetCustomTag());
|
Object* realObj = (Object*)(obj->GetCustomTag());
|
||||||
//check so that it is an object that you can pickup
|
//check so that it is an object that you can pickup
|
||||||
|
|
||||||
switch(realObj->GetObjectType())
|
DynamicObject *dynamicObj = dynamic_cast<DynamicObject*>(realObj);
|
||||||
|
|
||||||
|
if(!dynamicObj) return;
|
||||||
|
|
||||||
|
if(dynamicObj->getManipulatingPlayer() != NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(dynamicObj->GetObjectType())
|
||||||
{
|
{
|
||||||
case ObjectSpecialType::ObjectSpecialType_StandardBox:
|
case ObjectSpecialType::ObjectSpecialType_StandardBox:
|
||||||
weapon->heldObject = obj; //weapon now holds the object
|
weapon->heldObject = obj; //weapon now holds the object
|
||||||
weapon->hasObject = true;
|
weapon->hasObject = true;
|
||||||
|
dynamicObj->SetManipulatingPlayer(*weapon->owner); //TODO: add if this is to be a struggle of who has the most power in its weapon, the player that is already manipulating the object or you. if you then you take the object from the other player, if not then you do not take the object
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -282,3 +359,30 @@ using namespace GameLogic;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//General collision collision for pickups
|
||||||
|
//It calls the collision function defined in each pickup.
|
||||||
|
void Pickup::PickupCollision(Oyster::Physics::ICustomBody* objA, Oyster::Physics::ICustomBody* objB, Oyster::Math::Float kineticEnergyLoss)
|
||||||
|
{
|
||||||
|
//Check if player is a player.
|
||||||
|
Object* a = (Object*)objA->GetCustomTag();
|
||||||
|
Object* b = (Object*)objB->GetCustomTag();
|
||||||
|
|
||||||
|
if(!a)
|
||||||
|
return;
|
||||||
|
if(!b)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(b->GetObjectType() == ObjectSpecialType_Player)
|
||||||
|
{
|
||||||
|
((Pickup*)a)->OnCollision((Player*)(b));
|
||||||
|
}
|
||||||
|
else if(a->GetObjectType() != ObjectSpecialType_Player)
|
||||||
|
{
|
||||||
|
//One of the objects are not a player.
|
||||||
|
//Do nothing.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
((Pickup*)b)->OnCollision((Player*)a);
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
#include "DynamicObject.h"
|
#include "DynamicObject.h"
|
||||||
#include "CollisionManager.h"
|
#include "CollisionManager.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Oyster::Math;
|
using namespace Oyster::Math;
|
||||||
|
@ -10,6 +11,8 @@ DynamicObject::DynamicObject()
|
||||||
{
|
{
|
||||||
this->isReleased = false;
|
this->isReleased = false;
|
||||||
this->isActive = true;
|
this->isActive = true;
|
||||||
|
this->affectedBy = NULL;
|
||||||
|
this->manipulatedBy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
||||||
|
@ -17,12 +20,16 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*Ev
|
||||||
{
|
{
|
||||||
this->isReleased = false;
|
this->isReleased = false;
|
||||||
this->isActive = true;
|
this->isActive = true;
|
||||||
|
this->affectedBy = NULL;
|
||||||
|
this->manipulatedBy = NULL;
|
||||||
}
|
}
|
||||||
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)
|
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)
|
:Object(rigidBody, EventOnCollision, type, objectID)
|
||||||
{
|
{
|
||||||
this->isReleased = false;
|
this->isReleased = false;
|
||||||
this->isActive = true;
|
this->isActive = true;
|
||||||
|
this->affectedBy = NULL;
|
||||||
|
this->manipulatedBy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
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)
|
||||||
|
@ -31,6 +38,8 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*Ev
|
||||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||||
this->isReleased = false;
|
this->isReleased = false;
|
||||||
this->isActive = true;
|
this->isActive = true;
|
||||||
|
this->affectedBy = NULL;
|
||||||
|
this->manipulatedBy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
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)
|
||||||
|
@ -39,6 +48,8 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::P
|
||||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||||
this->isReleased = false;
|
this->isReleased = false;
|
||||||
this->isActive = true;
|
this->isActive = true;
|
||||||
|
this->affectedBy = NULL;
|
||||||
|
this->manipulatedBy = NULL;
|
||||||
}
|
}
|
||||||
DynamicObject::~DynamicObject(void)
|
DynamicObject::~DynamicObject(void)
|
||||||
{
|
{
|
||||||
|
@ -75,3 +86,38 @@ void DynamicObject::Activate()
|
||||||
this->isActive = true;
|
this->isActive = true;
|
||||||
this->isReleased = false;
|
this->isReleased = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicObject::SetAffectedBy(Player &player)
|
||||||
|
{
|
||||||
|
this->affectedBy = &player;
|
||||||
|
if(this->type != ObjectSpecialType::ObjectSpecialType_Player) //should not add itself to its own list if its a player
|
||||||
|
{
|
||||||
|
player.AddAffectedObject(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Player* DynamicObject::getAffectingPlayer()
|
||||||
|
{
|
||||||
|
return this->affectedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicObject::RemoveAffectedBy()
|
||||||
|
{
|
||||||
|
this->affectedBy = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLogic::Player* DynamicObject::getManipulatingPlayer()
|
||||||
|
{
|
||||||
|
return this->manipulatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicObject::SetManipulatingPlayer(GameLogic::Player &player)
|
||||||
|
{
|
||||||
|
this->manipulatedBy = &player;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicObject::RemoveManipulation()
|
||||||
|
{
|
||||||
|
this->manipulatedBy = NULL;
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
class Player;
|
||||||
class DynamicObject : public Object
|
class DynamicObject : public Object
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -28,9 +29,22 @@ namespace GameLogic
|
||||||
void Inactivate();
|
void Inactivate();
|
||||||
void Activate();
|
void Activate();
|
||||||
|
|
||||||
|
void SetAffectedBy(GameLogic::Player &player);
|
||||||
|
void SetManipulatingPlayer(GameLogic::Player &player);
|
||||||
|
void RemoveAffectedBy();
|
||||||
|
void RemoveManipulation();
|
||||||
|
GameLogic::Player* getAffectingPlayer();
|
||||||
|
GameLogic::Player* getManipulatingPlayer();
|
||||||
|
|
||||||
|
static void DynamicObject::DynamicDefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isActive;
|
bool isActive;
|
||||||
bool isReleased;
|
bool isReleased;
|
||||||
|
protected:
|
||||||
|
GameLogic::Player *affectedBy;
|
||||||
|
GameLogic::Player *manipulatedBy;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ Game::PlayerData* Game::CreatePlayer()
|
||||||
this->players[insert] = new PlayerData(freeID, 0); // user constructor with objectID and teamID
|
this->players[insert] = new PlayerData(freeID, 0); // user constructor with objectID and teamID
|
||||||
this->players[insert]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
this->players[insert]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
||||||
|
|
||||||
|
this->level->AddPlayerToGame(this->players[insert]);
|
||||||
return this->players[insert];
|
return this->players[insert];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +129,9 @@ void Game::CreateTeam()
|
||||||
|
|
||||||
bool Game::NewFrame()
|
bool Game::NewFrame()
|
||||||
{
|
{
|
||||||
|
// HACK need dynamic delta time
|
||||||
|
this->level->Update(this->frameTime);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->players[i] && this->players[i]->player) this->players[i]->player->BeginFrame();
|
if(this->players[i] && this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||||
|
@ -152,14 +156,18 @@ void Game::SetFrameTimeLength( float seconds )
|
||||||
this->frameTime = seconds;
|
this->frameTime = seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::SetSubscription(GameEvent::ObjectMovedFunction functionPointer)
|
void Game::SetMoveSubscription(GameEvent::ObjectMovedFunction functionPointer)
|
||||||
{
|
{
|
||||||
this->onMoveFnc = functionPointer;
|
this->onMoveFnc = functionPointer;
|
||||||
}
|
}
|
||||||
void Game::SetSubscription(GameEvent::ObjectDisabledFunction functionPointer)
|
void Game::SetDisableSubscription(GameEvent::ObjectDisabledFunction functionPointer)
|
||||||
{
|
{
|
||||||
this->onDisableFnc = functionPointer;
|
this->onDisableFnc = functionPointer;
|
||||||
}
|
}
|
||||||
|
void Game::SetEnableSubscription(GameEvent::ObjectEnabledFunction functionPointer)
|
||||||
|
{
|
||||||
|
this->onEnableFnc = functionPointer;
|
||||||
|
}
|
||||||
void Game::SetHpSubscription(GameEvent::ObjectHpFunction functionPointer)
|
void Game::SetHpSubscription(GameEvent::ObjectHpFunction functionPointer)
|
||||||
{
|
{
|
||||||
this->onDamageTakenFnc = functionPointer;
|
this->onDamageTakenFnc = functionPointer;
|
||||||
|
@ -172,7 +180,14 @@ void Game::SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer)
|
||||||
{
|
{
|
||||||
this->onDeadFnc = functionPointer;
|
this->onDeadFnc = functionPointer;
|
||||||
}
|
}
|
||||||
|
void Game::SetActionSubscription(GameEvent::AnimationEventFunction functionPointer)
|
||||||
|
{
|
||||||
|
this->onPlayerActionEventFnc = functionPointer;
|
||||||
|
}
|
||||||
|
void Game::SetPickupSubscription(GameEvent::PickupEventFunction functionPointer)
|
||||||
|
{
|
||||||
|
this->onPickupEventFnc = functionPointer;
|
||||||
|
}
|
||||||
bool Game::Initiate()
|
bool Game::Initiate()
|
||||||
{
|
{
|
||||||
API::Instance().Init();
|
API::Instance().Init();
|
||||||
|
@ -200,6 +215,5 @@ void Game::PhysicsOnMove(const ICustomBody *object)
|
||||||
}
|
}
|
||||||
void Game::PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<ICustomBody> proto)
|
void Game::PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<ICustomBody> proto)
|
||||||
{
|
{
|
||||||
if(gameInstance.onDisableFnc) gameInstance.onDisableFnc(0, 0);
|
if(gameInstance.onDisableFnc) gameInstance.onDisableFnc(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace GameLogic
|
||||||
ObjectSpecialType GetObjectType() const override;
|
ObjectSpecialType GetObjectType() const override;
|
||||||
void Inactivate() override;
|
void Inactivate() override;
|
||||||
void Release() override;
|
void Release() override;
|
||||||
|
Player* GetPlayer();
|
||||||
Player *player;
|
Player *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,7 +63,8 @@ namespace GameLogic
|
||||||
int getNrOfDynamicObj()const override;
|
int getNrOfDynamicObj()const override;
|
||||||
IObjectData* GetObjectAt(int ID) const override;
|
IObjectData* GetObjectAt(int ID) const override;
|
||||||
void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const override;
|
void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const override;
|
||||||
|
void Update(float deltaTime);
|
||||||
|
void AddPlayerToGame(IPlayerData *player);
|
||||||
Level *level;
|
Level *level;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,28 +79,35 @@ namespace GameLogic
|
||||||
bool NewFrame() override;
|
bool NewFrame() override;
|
||||||
void SetFPS( int FPS ) override;
|
void SetFPS( int FPS ) override;
|
||||||
void SetFrameTimeLength( float seconds ) override;
|
void SetFrameTimeLength( float seconds ) override;
|
||||||
void SetSubscription(GameEvent::ObjectMovedFunction functionPointer) override;
|
void SetMoveSubscription(GameEvent::ObjectMovedFunction functionPointer) override;
|
||||||
void SetSubscription(GameEvent::ObjectDisabledFunction functionPointer) override;
|
void SetDisableSubscription(GameEvent::ObjectDisabledFunction functionPointer) override;
|
||||||
void SetHpSubscription(GameEvent::ObjectHpFunction functionPointer) override;
|
void SetEnableSubscription(GameEvent::ObjectEnabledFunction functionPointer) override;
|
||||||
void SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer) override;
|
void SetHpSubscription(GameEvent::ObjectHpFunction functionPointer) override;
|
||||||
void SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer) override;
|
void SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer) override;
|
||||||
|
void SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer) override;
|
||||||
|
void SetActionSubscription(GameEvent::AnimationEventFunction functionPointer) override;
|
||||||
|
void SetPickupSubscription(GameEvent::PickupEventFunction functionPointer) override;
|
||||||
bool Initiate() override;
|
bool Initiate() override;
|
||||||
|
|
||||||
float GetFrameTime() const;
|
float GetFrameTime() const;
|
||||||
|
|
||||||
static void PhysicsOnMove(const Oyster::Physics::ICustomBody *object);
|
static void PhysicsOnMove(const Oyster::Physics::ICustomBody *object);
|
||||||
static void PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<Oyster::Physics::ICustomBody> proto);
|
static void PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<Oyster::Physics::ICustomBody> proto);
|
||||||
|
static void PhysicsOnDead(const Oyster::Physics::ICustomBody *object);
|
||||||
|
|
||||||
Utility::DynamicMemory::DynamicArray<PlayerData*> players;
|
Utility::DynamicMemory::DynamicArray<PlayerData*> players;
|
||||||
LevelData* level;
|
LevelData* level;
|
||||||
float frameTime;
|
float frameTime;
|
||||||
bool initiated;
|
bool initiated;
|
||||||
GameEvent::ObjectDisabledFunction onDisableFnc;
|
|
||||||
GameEvent::ObjectMovedFunction onMoveFnc;
|
GameEvent::ObjectMovedFunction onMoveFnc;
|
||||||
|
GameEvent::ObjectDisabledFunction onDisableFnc;
|
||||||
|
GameEvent::ObjectEnabledFunction onEnableFnc;
|
||||||
GameEvent::ObjectHpFunction onDamageTakenFnc;
|
GameEvent::ObjectHpFunction onDamageTakenFnc;
|
||||||
GameEvent::ObjectRespawnedFunction onRespawnFnc;
|
GameEvent::ObjectRespawnedFunction onRespawnFnc;
|
||||||
GameEvent::ObjectDeadFunction onDeadFnc;
|
GameEvent::ObjectDeadFunction onDeadFnc;
|
||||||
|
GameEvent::AnimationEventFunction onPlayerActionEventFnc;
|
||||||
|
GameEvent::PickupEventFunction onPickupEventFnc;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,13 @@ namespace GameLogic
|
||||||
namespace GameEvent
|
namespace GameEvent
|
||||||
{
|
{
|
||||||
typedef void(*ObjectMovedFunction)(IObjectData* object); // Callback method that recieves and object
|
typedef void(*ObjectMovedFunction)(IObjectData* object); // Callback method that recieves and object
|
||||||
typedef void(*ObjectDisabledFunction)(IObjectData* object, float seconds); // Callback method that recieves and object
|
typedef void(*ObjectDisabledFunction)(IObjectData* object); // Callback method that recieves and object
|
||||||
|
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(*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(*ObjectRespawnedFunction)(IObjectData* object, Oyster::Math::Float3 spawnPos ); // Callback method that sends spawnPos
|
||||||
typedef void(*ObjectDeadFunction)(IObjectData* object, float seconds); // Callback method that sends death timer
|
typedef void(*ObjectDeadFunction)(IObjectData* victim, IObjectData* killer, 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
|
||||||
//etc...
|
//etc...
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,8 +120,10 @@ namespace GameLogic
|
||||||
class ILevelData :public IObjectData
|
class ILevelData :public IObjectData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual void Update(float deltaTime) = 0;
|
||||||
virtual int getNrOfDynamicObj()const = 0;
|
virtual int getNrOfDynamicObj()const = 0;
|
||||||
virtual IObjectData* GetObjectAt(int ID) const = 0;
|
virtual IObjectData* GetObjectAt(int ID) const = 0;
|
||||||
|
virtual void AddPlayerToGame(IPlayerData *player) = 0;
|
||||||
virtual void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& destMem) const = 0;
|
virtual void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& destMem) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -175,15 +180,14 @@ namespace GameLogic
|
||||||
/** Set a specific object event subscription callback
|
/** Set a specific object event subscription callback
|
||||||
* @param
|
* @param
|
||||||
*/
|
*/
|
||||||
virtual void SetSubscription(GameEvent::ObjectMovedFunction functionPointer) = 0;
|
virtual void SetMoveSubscription(GameEvent::ObjectMovedFunction functionPointer) = 0;
|
||||||
|
virtual void SetDisableSubscription(GameEvent::ObjectDisabledFunction functionPointer) = 0;
|
||||||
/** Set a specific object event subscription callback
|
virtual void SetEnableSubscription(GameEvent::ObjectEnabledFunction functionPointer) = 0;
|
||||||
* @param
|
|
||||||
*/
|
|
||||||
virtual void SetSubscription(GameEvent::ObjectDisabledFunction functionPointer) = 0;
|
|
||||||
virtual void SetHpSubscription(GameEvent::ObjectHpFunction functionPointer) = 0;
|
virtual void SetHpSubscription(GameEvent::ObjectHpFunction functionPointer) = 0;
|
||||||
virtual void SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer) = 0;
|
virtual void SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer) = 0;
|
||||||
virtual void SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer) = 0;
|
virtual void SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer) = 0;
|
||||||
|
virtual void SetActionSubscription(GameEvent::AnimationEventFunction functionPointer) = 0;
|
||||||
|
virtual void SetPickupSubscription(GameEvent::PickupEventFunction functionPointer) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,9 @@
|
||||||
<ClInclude Include="JumpPad.h" />
|
<ClInclude Include="JumpPad.h" />
|
||||||
<ClInclude Include="Level.h" />
|
<ClInclude Include="Level.h" />
|
||||||
<ClInclude Include="Object.h" />
|
<ClInclude Include="Object.h" />
|
||||||
|
<ClInclude Include="PickupSystem\Pickup.h" />
|
||||||
|
<ClInclude Include="PickupSystem\PickupHealth.h" />
|
||||||
|
<ClInclude Include="PickupSystem\PickupSystem.h" />
|
||||||
<ClInclude Include="Player.h" />
|
<ClInclude Include="Player.h" />
|
||||||
<ClInclude Include="Portal.h" />
|
<ClInclude Include="Portal.h" />
|
||||||
<ClInclude Include="StaticObject.h" />
|
<ClInclude Include="StaticObject.h" />
|
||||||
|
@ -194,6 +197,9 @@
|
||||||
<ClCompile Include="JumpPad.cpp" />
|
<ClCompile Include="JumpPad.cpp" />
|
||||||
<ClCompile Include="Level.cpp" />
|
<ClCompile Include="Level.cpp" />
|
||||||
<ClCompile Include="Object.cpp" />
|
<ClCompile Include="Object.cpp" />
|
||||||
|
<ClCompile Include="PickupSystem\Pickup.cpp" />
|
||||||
|
<ClCompile Include="PickupSystem\PickupHealth.cpp" />
|
||||||
|
<ClCompile Include="PickupSystem\PickupSystem.cpp" />
|
||||||
<ClCompile Include="Player.cpp" />
|
<ClCompile Include="Player.cpp" />
|
||||||
<ClCompile Include="Portal.cpp" />
|
<ClCompile Include="Portal.cpp" />
|
||||||
<ClCompile Include="StaticObject.cpp" />
|
<ClCompile Include="StaticObject.cpp" />
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
#define GAMELOGICSTATES_H
|
#define GAMELOGICSTATES_H
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
class Player;
|
||||||
enum PLAYER_MOVEMENT
|
enum PLAYER_MOVEMENT
|
||||||
{
|
{
|
||||||
PLAYER_MOVEMENT_FORWARD = 0,
|
PLAYER_MOVEMENT_FORWARD = 0,
|
||||||
|
@ -18,7 +20,8 @@ namespace GameLogic
|
||||||
PLAYER_STATE_WALKING = 1,
|
PLAYER_STATE_WALKING = 1,
|
||||||
PLAYER_STATE_IDLE = 2,
|
PLAYER_STATE_IDLE = 2,
|
||||||
PLAYER_STATE_DEAD = 4,
|
PLAYER_STATE_DEAD = 4,
|
||||||
PLAYER_STATE_INVALID = 8,
|
PLAYER_STATE_DIED = 8,
|
||||||
|
PLAYER_STATE_INVALID = 16,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum WEAPON_FIRE
|
enum WEAPON_FIRE
|
||||||
|
@ -41,6 +44,7 @@ namespace GameLogic
|
||||||
struct forcePushData
|
struct forcePushData
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 pushForce;
|
Oyster::Math::Float3 pushForce;
|
||||||
|
Player *p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,17 @@ IObjectData* Game::LevelData::GetObjectAt(int ID) const
|
||||||
|
|
||||||
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
||||||
{
|
{
|
||||||
mem.Resize(level->dynamicObjects.Size());
|
mem.Resize(level->GetDynamicObject().Size());
|
||||||
for(int i = 0; i < (int)level->dynamicObjects.Size(); i++)
|
for(int i = 0; i < (int)level->GetDynamicObject().Size(); i++)
|
||||||
{
|
{
|
||||||
mem[i] = level->dynamicObjects[i];
|
mem[i] = level->GetDynamicObject()[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void Game::LevelData::Update(float deltaTime)
|
||||||
|
{
|
||||||
|
this->level->Update(deltaTime);
|
||||||
|
}
|
||||||
|
void Game::LevelData::AddPlayerToGame(IPlayerData *player)
|
||||||
|
{
|
||||||
|
this->level->AddPlayerToGame(((PlayerData*)player)->GetPlayer());
|
||||||
|
}
|
|
@ -102,3 +102,7 @@ void Game::PlayerData::Release()
|
||||||
{
|
{
|
||||||
this->player->ReleaseDynamicObject();
|
this->player->ReleaseDynamicObject();
|
||||||
}
|
}
|
||||||
|
Player* Game::PlayerData::GetPlayer()
|
||||||
|
{
|
||||||
|
return this->player;
|
||||||
|
}
|
|
@ -12,7 +12,7 @@
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
using namespace Oyster::Math;
|
||||||
|
|
||||||
Level::Level(void)
|
Level::Level(void)
|
||||||
{
|
{
|
||||||
|
@ -59,17 +59,17 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Stone:
|
case ObjectSpecialType_Stone:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
gameObj = new DynamicObject(rigidBody, DynamicObject::DynamicDefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_StandardBox:
|
case ObjectSpecialType_StandardBox:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
gameObj = new DynamicObject(rigidBody, DynamicObject::DynamicDefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_RedExplosiveBox:
|
case ObjectSpecialType_RedExplosiveBox:
|
||||||
{
|
{
|
||||||
Oyster::Math::Float dmg = 90;
|
Oyster::Math::Float dmg = 120;
|
||||||
Oyster::Math::Float force = 500;
|
Oyster::Math::Float force = 500;
|
||||||
Oyster::Math::Float radie = 3;
|
Oyster::Math::Float radie = 3;
|
||||||
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
||||||
|
@ -81,12 +81,12 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
// break;
|
// break;
|
||||||
case ObjectSpecialType_SpikeBox:
|
case ObjectSpecialType_SpikeBox:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
gameObj = new DynamicObject(rigidBody, DynamicObject::DynamicDefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Spike:
|
case ObjectSpecialType_Spike:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
gameObj = new DynamicObject(rigidBody, DynamicObject::DynamicDefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_CrystalFormation:
|
case ObjectSpecialType_CrystalFormation:
|
||||||
|
@ -98,7 +98,7 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_CrystalShard:
|
case ObjectSpecialType_CrystalShard:
|
||||||
{
|
{
|
||||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
gameObj = new DynamicObject(rigidBody, DynamicObject::DynamicDefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_JumpPad:
|
case ObjectSpecialType_JumpPad:
|
||||||
|
@ -131,6 +131,11 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ObjectSpecialType_PickupHealth:
|
||||||
|
{
|
||||||
|
gameObj = new PickupHealth(rigidBody, obj->specialTypeID, objID, ((PickupHealthAttributes*)obj)->spawnTime, ((PickupHealthAttributes*)obj)->healthValue);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||||
|
@ -203,6 +208,38 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj)
|
||||||
rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic);
|
rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic);
|
||||||
return rigidBody;
|
return rigidBody;
|
||||||
}
|
}
|
||||||
|
ICustomBody* Level::InitRigidBodyMesh( const ObjectHeader* obj)
|
||||||
|
{
|
||||||
|
ICustomBody* rigidBody = NULL;
|
||||||
|
Oyster::Math::Float3 rigidWorldPos;
|
||||||
|
Oyster::Math::Float4 rigidWorldRotation;
|
||||||
|
float rigidBodyMass;
|
||||||
|
float rigidBodyRadius;
|
||||||
|
|
||||||
|
//offset the rigidPosition from modelspace to worldspace;
|
||||||
|
rigidWorldPos = (Oyster::Math::Float3)obj->position + (Oyster::Math::Float3)obj->boundingVolume.cgMesh.position;
|
||||||
|
//scales the position so the collision geomentry is in the right place
|
||||||
|
rigidWorldPos = rigidWorldPos * obj->scale;
|
||||||
|
|
||||||
|
//offset the rigidRotation from modelspace to worldspace;
|
||||||
|
Oyster::Math::Quaternion worldPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->rotation[0],obj->rotation[1],obj->rotation[2]), obj->rotation[3]);
|
||||||
|
Oyster::Math::Quaternion physicsPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->boundingVolume.cgMesh.rotation[0],obj->boundingVolume.cgMesh.rotation[1],obj->boundingVolume.cgMesh.rotation[2]), obj->boundingVolume.cgMesh.rotation[3]);
|
||||||
|
Oyster::Math::Quaternion rigidWorldQuaternion = worldPosQuaternion * physicsPosQuaternion;
|
||||||
|
|
||||||
|
rigidWorldRotation = Oyster::Math::Float4(rigidWorldQuaternion);
|
||||||
|
|
||||||
|
|
||||||
|
//mass scaled
|
||||||
|
rigidBodyMass = obj->scale[0] * obj->scale[1] * obj->scale[2] * obj->boundingVolume.cgMesh.mass;
|
||||||
|
|
||||||
|
//Radius scaled
|
||||||
|
//rigidBodyRadius = (obj->scale[0]) * obj->boundingVolume.sphere.radius;
|
||||||
|
//rigidBodyRadius = (obj->scale[0] * obj->scale[1] * obj->scale[2]) * obj->boundingVolume.sphere.radius;
|
||||||
|
|
||||||
|
//create the rigid body
|
||||||
|
rigidBody = API::Instance().AddTriangleMesh(obj->boundingVolume.cgMesh.filename, rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.cgMesh.restitutionCoeff , obj->boundingVolume.cgMesh.frictionCoeffStatic , obj->boundingVolume.cgMesh.frictionCoeffDynamic);
|
||||||
|
return rigidBody;
|
||||||
|
}
|
||||||
bool Level::InitiateLevel(std::wstring levelPath)
|
bool Level::InitiateLevel(std::wstring levelPath)
|
||||||
{
|
{
|
||||||
LevelLoader ll;
|
LevelLoader ll;
|
||||||
|
@ -216,7 +253,6 @@ bool Level::InitiateLevel(std::wstring levelPath)
|
||||||
std::string convertedLevelPath = converterX.to_bytes(levelPath);
|
std::string convertedLevelPath = converterX.to_bytes(levelPath);
|
||||||
objects = ll.LoadLevel(convertedLevelPath);
|
objects = ll.LoadLevel(convertedLevelPath);
|
||||||
|
|
||||||
|
|
||||||
if(objects.size() == 0)
|
if(objects.size() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -260,11 +296,21 @@ bool Level::InitiateLevel(std::wstring levelPath)
|
||||||
//rigidBody_Static = InitRigidBodyCylinder(staticObjData);
|
//rigidBody_Static = InitRigidBodyCylinder(staticObjData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_CG_MESH)
|
||||||
|
{
|
||||||
|
rigidBody_Static = InitRigidBodyMesh(staticObjData);
|
||||||
|
}
|
||||||
|
|
||||||
if(rigidBody_Static != NULL)
|
if(rigidBody_Static != NULL)
|
||||||
{
|
{
|
||||||
// create game object
|
// create game object
|
||||||
Object* staticGameObj = CreateGameObj(staticObjData, rigidBody_Static);
|
Object* staticGameObj = CreateGameObj(staticObjData, rigidBody_Static);
|
||||||
if(staticGameObj != NULL)
|
|
||||||
|
if(staticObjData->specialTypeID == ObjectSpecialType_PickupHealth)
|
||||||
|
{
|
||||||
|
this->pickupSystem.CreatePickup((PickupHealth*)staticGameObj);
|
||||||
|
}
|
||||||
|
else if(staticGameObj != NULL)
|
||||||
{
|
{
|
||||||
this->staticObjects.Push((StaticObject*)staticGameObj);
|
this->staticObjects.Push((StaticObject*)staticGameObj);
|
||||||
}
|
}
|
||||||
|
@ -321,6 +367,7 @@ bool Level::InitiateLevel(std::wstring levelPath)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool Level::InitiateLevel(float radius)
|
bool Level::InitiateLevel(float radius)
|
||||||
|
@ -393,7 +440,20 @@ void Level::AddPlayerToTeam(Player *player, int teamID)
|
||||||
{
|
{
|
||||||
this->teamManager.AddPlayerToTeam(player,teamID);
|
this->teamManager.AddPlayerToTeam(player,teamID);
|
||||||
}
|
}
|
||||||
|
void Level::AddPlayerToGame(Player *player)
|
||||||
|
{
|
||||||
|
this->playerObjects.Push(player);
|
||||||
|
}
|
||||||
|
void Level::RemovePlayerFromGame(Player *player)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < (int)this->playerObjects.Size(); i++)
|
||||||
|
{
|
||||||
|
if ((Player*)this->playerObjects[i] == player)
|
||||||
|
{
|
||||||
|
//this->playerObjects[i].
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void Level::CreateTeam(int teamSize)
|
void Level::CreateTeam(int teamSize)
|
||||||
{
|
{
|
||||||
this->teamManager.CreateTeam(teamSize);
|
this->teamManager.CreateTeam(teamSize);
|
||||||
|
@ -401,9 +461,34 @@ void Level::CreateTeam(int teamSize)
|
||||||
|
|
||||||
void Level::RespawnPlayer(Player *player)
|
void Level::RespawnPlayer(Player *player)
|
||||||
{
|
{
|
||||||
this->teamManager.RespawnPlayerRandom(player);
|
//this->teamManager.RespawnPlayerRandom(player);
|
||||||
}
|
|
||||||
|
|
||||||
|
Float3 spawnPoint = spawnPoints[0];
|
||||||
|
player->Respawn(spawnPoint);
|
||||||
|
}
|
||||||
|
void Level::Update(float deltaTime)
|
||||||
|
{
|
||||||
|
// update lvl-things
|
||||||
|
for(int i = 0; i < (int)this->playerObjects.Size(); i++)
|
||||||
|
{
|
||||||
|
if (this->playerObjects[i]->GetState() == PLAYER_STATE::PLAYER_STATE_DEAD)
|
||||||
|
{
|
||||||
|
// true when timer reaches 0
|
||||||
|
if(this->playerObjects[i]->deathTimerTick(deltaTime))
|
||||||
|
RespawnPlayer(this->playerObjects[i]);
|
||||||
|
}
|
||||||
|
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
|
||||||
|
Player* killer = this->playerObjects[i]->getAffectingPlayer();
|
||||||
|
((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], this->playerObjects[i], DEATH_TIMER); // add killer ID
|
||||||
|
//((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], this->playerObjects[i]->getAffectingPlayer(), DEATH_TIMER); // add killer ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->pickupSystem.Update();
|
||||||
|
}
|
||||||
int Level::getNrOfDynamicObj()
|
int Level::getNrOfDynamicObj()
|
||||||
{
|
{
|
||||||
return this->dynamicObjects.Size();
|
return this->dynamicObjects.Size();
|
||||||
|
@ -417,10 +502,23 @@ Object* Level::GetObj( int ID) const
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::PhysicsOnMoveLevel(const ICustomBody *object)
|
void Level::PhysicsOnMoveLevel(const ICustomBody *object)
|
||||||
{
|
{
|
||||||
// function call from physics update when object was moved
|
// function call from physics update when object was moved
|
||||||
Object* temp = (Object*)object->GetCustomTag();
|
Object* temp = (Object*)object->GetCustomTag();
|
||||||
((Game*)&Game::Instance())->onMoveFnc(temp);
|
((Game*)&Game::Instance())->onMoveFnc(temp);
|
||||||
}
|
}
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<Player>> Level::GetPlayers()
|
||||||
|
{
|
||||||
|
return this->playerObjects;
|
||||||
|
}
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> Level::GetStaticObjects()
|
||||||
|
{
|
||||||
|
return this->staticObjects;
|
||||||
|
}
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> Level::GetDynamicObject()
|
||||||
|
{
|
||||||
|
return this->dynamicObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#include "DynamicArray.h"
|
#include "DynamicArray.h"
|
||||||
#include "LevelLoader.h"
|
#include "LevelLoader.h"
|
||||||
|
|
||||||
|
#include "PickupSystem\PickupSystem.h"
|
||||||
|
#include "PickupSystem\PickupHealth.h"
|
||||||
|
|
||||||
|
const int DEATH_TIMER = 5;
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -34,6 +38,8 @@ namespace GameLogic
|
||||||
bool InitiateLevel(float radius);
|
bool InitiateLevel(float radius);
|
||||||
Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj);
|
Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj);
|
||||||
Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj);
|
Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj);
|
||||||
|
Oyster::Physics::ICustomBody* InitRigidBodyMesh( const ObjectHeader* obj);
|
||||||
|
|
||||||
|
|
||||||
Object* CreateGameObj(ObjectHeader* obj, Oyster::Physics::ICustomBody* rigidBody);
|
Object* CreateGameObj(ObjectHeader* obj, Oyster::Physics::ICustomBody* rigidBody);
|
||||||
/********************************************************
|
/********************************************************
|
||||||
|
@ -48,7 +54,8 @@ namespace GameLogic
|
||||||
* @param teamID: ArrayPos of the team you want to add the player to
|
* @param teamID: ArrayPos of the team you want to add the player to
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void AddPlayerToTeam(Player *player, int teamID);
|
void AddPlayerToTeam(Player *player, int teamID);
|
||||||
|
void AddPlayerToGame(Player *player);
|
||||||
|
void RemovePlayerFromGame(Player *player);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Respawns a player on a random teammate
|
* Respawns a player on a random teammate
|
||||||
|
@ -64,13 +71,20 @@ namespace GameLogic
|
||||||
********************************************************/
|
********************************************************/
|
||||||
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
|
void Update(float deltaTime);
|
||||||
|
|
||||||
int getNrOfDynamicObj();
|
int getNrOfDynamicObj();
|
||||||
Object* GetObj( int ID ) const;
|
Object* GetObj( int ID ) const;
|
||||||
|
|
||||||
|
static void PlayerDied( Player* player );
|
||||||
static void PhysicsOnMoveLevel(const Oyster::Physics::ICustomBody *object);
|
static void PhysicsOnMoveLevel(const Oyster::Physics::ICustomBody *object);
|
||||||
|
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<Player>> GetPlayers();
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> GetStaticObjects();
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> GetDynamicObject();
|
||||||
|
|
||||||
//private:
|
private:
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<Player>> playerObjects;
|
||||||
TeamManager teamManager;
|
TeamManager teamManager;
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> dynamicObjects;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> dynamicObjects;
|
||||||
|
@ -79,6 +93,7 @@ namespace GameLogic
|
||||||
StaticObject *levelObj;
|
StaticObject *levelObj;
|
||||||
int objID;
|
int objID;
|
||||||
Utility::DynamicMemory::DynamicArray<Oyster::Math::Float3> spawnPoints;
|
Utility::DynamicMemory::DynamicArray<Oyster::Math::Float3> spawnPoints;
|
||||||
|
PickupSystem pickupSystem;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include "Pickup.h"
|
||||||
|
#include "../Game.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
Pickup::Pickup(Oyster::Physics::ICustomBody *rigidBody, EventOnCollision collisionFunc, ObjectSpecialType type, int objectID, Oyster::Math::Float spawnTime)
|
||||||
|
: StaticObject(rigidBody, collisionFunc, type, objectID)
|
||||||
|
{
|
||||||
|
this->active = true;
|
||||||
|
this->spawnTime = spawnTime;
|
||||||
|
timer.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Pickup::~Pickup()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Pickup::Update()
|
||||||
|
{
|
||||||
|
if(!active)
|
||||||
|
{
|
||||||
|
if(timer.getElapsedSeconds() >= spawnTime)
|
||||||
|
{
|
||||||
|
active = true;
|
||||||
|
((Game*)&Game::Instance())->onEnableFnc(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Pickup::IsActive()
|
||||||
|
{
|
||||||
|
return active;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef PICKUP_H
|
||||||
|
#define PICKUP_H
|
||||||
|
|
||||||
|
#include "../StaticObject.h"
|
||||||
|
#include "../Player.h"
|
||||||
|
#include "WinTimer.h"
|
||||||
|
|
||||||
|
typedef void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
class Pickup : public StaticObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Pickup(Oyster::Physics::ICustomBody *rigidBody, EventOnCollision collisionFunc, ObjectSpecialType type, int objectID, Oyster::Math::Float spawnTime);
|
||||||
|
virtual ~Pickup();
|
||||||
|
|
||||||
|
virtual void Update();
|
||||||
|
|
||||||
|
bool IsActive();
|
||||||
|
|
||||||
|
virtual void OnCollision(Player *player) = 0;
|
||||||
|
|
||||||
|
static void PickupCollision(Oyster::Physics::ICustomBody *rigidBodyCrate, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool active;
|
||||||
|
|
||||||
|
Utility::WinTimer timer;
|
||||||
|
double spawnTime;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "PickupHealth.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
PickupHealth::PickupHealth(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type, int objectID, Oyster::Math::Float spawnTime, Oyster::Math::Float healthValue)
|
||||||
|
: Pickup(rigidBody, Pickup::PickupCollision, type, objectID, spawnTime)
|
||||||
|
{
|
||||||
|
this->hpValue = healthValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PickupHealth::~PickupHealth()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void PickupHealth::OnCollision(Player *player)
|
||||||
|
{
|
||||||
|
timer.reset();
|
||||||
|
player->DamageLife(-hpValue);
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
//////////////////////////////////////
|
||||||
|
// Created by Pontus Fransson 2014 //
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef PICKUP_HEALTH_H
|
||||||
|
#define PICKUP_HEALTH_H
|
||||||
|
|
||||||
|
#include "Pickup.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
class PickupHealth : public Pickup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PickupHealth(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type, int objectID, Oyster::Math::Float spawnTime, Oyster::Math::Float HealthValue);
|
||||||
|
virtual ~PickupHealth();
|
||||||
|
|
||||||
|
|
||||||
|
void OnCollision(Player *player);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int hpValue;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include "PickupSystem.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
PickupSystem::PickupSystem()
|
||||||
|
{}
|
||||||
|
|
||||||
|
PickupSystem::~PickupSystem()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void PickupSystem::CreatePickup(Pickup* pickup)
|
||||||
|
{
|
||||||
|
pickups.push_back(pickup);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PickupSystem::Update()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < pickups.size(); i++)
|
||||||
|
{
|
||||||
|
pickups.at(i)->Update();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
//////////////////////////////////////
|
||||||
|
// Created by Pontus Fransson 2014 //
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef PICKUP_SYSTEM_H
|
||||||
|
#define PICKUP_SYSTEM_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Pickup.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
class PickupSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PickupSystem();
|
||||||
|
~PickupSystem();
|
||||||
|
|
||||||
|
void CreatePickup(Pickup* pickup);
|
||||||
|
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<Utility::DynamicMemory::SmartPointer<Pickup>> pickups;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -11,59 +11,28 @@ const float KEY_TIMER = 0.03f;
|
||||||
Player::Player()
|
Player::Player()
|
||||||
:DynamicObject()
|
:DynamicObject()
|
||||||
{
|
{
|
||||||
|
Player::initPlayerData();
|
||||||
|
AffectedObjects.Reserve(15);
|
||||||
|
this->weapon = NULL;
|
||||||
|
this->teamID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
|
Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
|
||||||
:DynamicObject(rigidBody, EventOnCollision, type, objectID)
|
:DynamicObject(rigidBody, EventOnCollision, type, objectID)
|
||||||
{
|
{
|
||||||
weapon = new Weapon(2,this);
|
this->weapon = new Weapon(2,this);
|
||||||
|
Player::initPlayerData();
|
||||||
this->life = 100;
|
AffectedObjects.Reserve(15);
|
||||||
this->teamID = teamID;
|
this->teamID = teamID;
|
||||||
this->playerState = PLAYER_STATE_IDLE;
|
|
||||||
this->lookDir = Oyster::Math::Float3(0,0,-1);
|
|
||||||
key_forward = 0;
|
|
||||||
key_backward = 0;
|
|
||||||
key_strafeRight = 0;
|
|
||||||
key_strafeLeft = 0;
|
|
||||||
key_jump = 0;
|
|
||||||
invincibleCooldown = 0;
|
|
||||||
this->deathTimeLeft = 0;
|
|
||||||
this->deathTime = 5;
|
|
||||||
|
|
||||||
this->previousPosition = Oyster::Math::Float3(0,0,0);
|
|
||||||
|
|
||||||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
|
||||||
this->moveSpeed = 100;
|
|
||||||
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
|
|
||||||
|
|
||||||
this->rotationUp = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::Player(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, int teamID)
|
Player::Player(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, int teamID)
|
||||||
:DynamicObject(rigidBody, EventOnCollision, type, objectID)
|
:DynamicObject(rigidBody, EventOnCollision, type, objectID)
|
||||||
{
|
{
|
||||||
weapon = new Weapon(2,this);
|
this->weapon = new Weapon(2,this);
|
||||||
|
Player::initPlayerData();
|
||||||
this->life = 100;
|
AffectedObjects.Reserve(15);
|
||||||
this->teamID = teamID;
|
this->teamID = teamID;
|
||||||
this->playerState = PLAYER_STATE_IDLE;
|
|
||||||
this->lookDir = Oyster::Math::Float3(0,0,-1);
|
|
||||||
key_forward = 0;
|
|
||||||
key_backward = 0;
|
|
||||||
key_strafeRight = 0;
|
|
||||||
key_strafeLeft = 0;
|
|
||||||
key_jump = 0;
|
|
||||||
invincibleCooldown = 0;
|
|
||||||
this->deathTimeLeft = 0;
|
|
||||||
this->deathTime = 5;
|
|
||||||
this->previousPosition = Oyster::Math::Float3(0,0,0);
|
|
||||||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
|
||||||
this->moveSpeed = 20;
|
|
||||||
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
|
|
||||||
|
|
||||||
this->rotationUp = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player(void)
|
Player::~Player(void)
|
||||||
|
@ -74,10 +43,29 @@ Player::~Player(void)
|
||||||
weapon = NULL;
|
weapon = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void Player::initPlayerData()
|
||||||
|
{
|
||||||
|
this->playerStats.hp = MAX_HP;
|
||||||
|
this->playerStats.movementSpeed = BASIC_SPEED;
|
||||||
|
this->playerScore.killScore = 0;
|
||||||
|
this->playerScore.deathScore = 0;
|
||||||
|
this->playerState = PLAYER_STATE_IDLE;
|
||||||
|
this->lookDir = Oyster::Math::Float3(0,0,-1);
|
||||||
|
|
||||||
|
this->key_forward = 0;
|
||||||
|
this->key_backward = 0;
|
||||||
|
this->key_strafeRight = 0;
|
||||||
|
this->key_strafeLeft = 0;
|
||||||
|
this->key_jump = 0;
|
||||||
|
this->invincibleCooldown = 0;
|
||||||
|
this->deathTimer = 0;
|
||||||
|
|
||||||
|
this->rotationUp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::BeginFrame()
|
void Player::BeginFrame()
|
||||||
{
|
{
|
||||||
if( this->playerState != PLAYER_STATE_DEAD)
|
if( this->playerState != PLAYER_STATE_DEAD && PLAYER_STATE_DIED)
|
||||||
{
|
{
|
||||||
weapon->Update(0.002f);
|
weapon->Update(0.002f);
|
||||||
|
|
||||||
|
@ -108,7 +96,7 @@ void Player::BeginFrame()
|
||||||
|
|
||||||
// Walking data
|
// Walking data
|
||||||
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
|
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
|
||||||
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2f;
|
Oyster::Math::Float walkSpeed = this->playerStats.movementSpeed*0.2f;
|
||||||
|
|
||||||
// Check for input
|
// Check for input
|
||||||
if(key_forward > 0.001)
|
if(key_forward > 0.001)
|
||||||
|
@ -145,6 +133,15 @@ void Player::BeginFrame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(walkDirection == Oyster::Math::Float3::null)
|
||||||
|
{
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING)
|
||||||
|
{
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_IDLE)
|
||||||
|
this->gameInstance->onPlayerActionEventFnc( this, PlayerAction::PlayerAction_Idle);
|
||||||
|
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Walk if walkdirection is something
|
// Walk if walkdirection is something
|
||||||
if(walkDirection != Oyster::Math::Float3::null)
|
if(walkDirection != Oyster::Math::Float3::null)
|
||||||
{
|
{
|
||||||
|
@ -174,6 +171,12 @@ void Player::BeginFrame()
|
||||||
rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z)) * walkSpeed*0.2f;
|
rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z)) * walkSpeed*0.2f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING)
|
||||||
|
{
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_WALKING)
|
||||||
|
this->gameInstance->onPlayerActionEventFnc( this, PlayerAction::PlayerAction_Walk);
|
||||||
|
this->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust velocities so no squaring occurs
|
// Adjust velocities so no squaring occurs
|
||||||
|
@ -190,26 +193,36 @@ void Player::BeginFrame()
|
||||||
if(IsWalking())
|
if(IsWalking())
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.GetNormalized();
|
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.GetNormalized();
|
||||||
this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass*20);
|
this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass * 20);
|
||||||
|
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING)
|
||||||
|
this->gameInstance->onPlayerActionEventFnc( this, PlayerAction::PlayerAction_Jump);
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
// player is dead
|
|
||||||
// TODO move this logic to lvl
|
|
||||||
this->deathTimeLeft -= gameInstance->GetFrameTime();
|
|
||||||
if( this->deathTimeLeft <= 0)
|
|
||||||
{
|
{
|
||||||
Respawn( Oyster::Math::Float3( -50, 180, 0));
|
if(this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING)
|
||||||
|
{
|
||||||
|
this->gameInstance->onPlayerActionEventFnc( this, PlayerAction::PlayerAction_Idle);
|
||||||
|
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::EndFrame()
|
void Player::EndFrame()
|
||||||
{
|
{
|
||||||
|
//check if there are any objects that can be removed from the AffectedObjects list
|
||||||
|
for(int i = 0; i < this->AffectedObjects.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->AffectedObjects[i] && (this->AffectedObjects[i]->GetRigidBody()->GetState().previousVelocity).GetMagnitude() <= 0.1f)
|
||||||
|
{
|
||||||
|
this->AffectedObjects[i]->RemoveAffectedBy();
|
||||||
|
this->AffectedObjects.Remove(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Move(const PLAYER_MOVEMENT &movement)
|
void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||||
|
@ -264,12 +277,10 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
||||||
{
|
{
|
||||||
if( this->playerState == PLAYER_STATE_DEAD)
|
if( this->playerState == PLAYER_STATE_DEAD)
|
||||||
{
|
{
|
||||||
this->life = 100;
|
Player::initPlayerData();
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
|
||||||
//this->lookDir = Oyster::Math::Float4(1,0,0);
|
|
||||||
this->rigidBody->SetPosition(spawnPoint);
|
this->rigidBody->SetPosition(spawnPoint);
|
||||||
this->gameInstance->onRespawnFnc( this, spawnPoint);
|
this->gameInstance->onRespawnFnc( this, spawnPoint);
|
||||||
this->gameInstance->onDamageTakenFnc( this, this->life);
|
this->gameInstance->onDamageTakenFnc( this, this->playerStats.hp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,15 +302,15 @@ void Player::Jump()
|
||||||
|
|
||||||
bool Player::IsWalking()
|
bool Player::IsWalking()
|
||||||
{
|
{
|
||||||
return (this->rigidBody->GetLambda() < 0.99f);
|
return (this->rigidBody->GetLambdaUp() < 0.99f);
|
||||||
}
|
}
|
||||||
bool Player::IsJumping()
|
bool Player::IsJumping()
|
||||||
{
|
{
|
||||||
return (this->rigidBody->GetLambda() < 1.0f);
|
return (this->rigidBody->GetLambdaUp() == 1.0f);
|
||||||
}
|
}
|
||||||
bool Player::IsIdle()
|
bool Player::IsIdle()
|
||||||
{
|
{
|
||||||
return (this->rigidBody->GetLambda() < 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.0001f);
|
return (this->rigidBody->GetLambdaUp() == 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.0001f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Inactivate()
|
void Player::Inactivate()
|
||||||
|
@ -330,17 +341,43 @@ PLAYER_STATE Player::GetState() const
|
||||||
|
|
||||||
void Player::DamageLife(int damage)
|
void Player::DamageLife(int damage)
|
||||||
{
|
{
|
||||||
if( this->playerState != PLAYER_STATE_DEAD)
|
this->playerStats.hp -= damage;
|
||||||
{
|
// send hp to client
|
||||||
this->life -= damage;
|
this->gameInstance->onDamageTakenFnc( this, this->playerStats.hp);
|
||||||
this->gameInstance->onDamageTakenFnc( this, this->life);
|
|
||||||
|
|
||||||
if(this->life <= 0)
|
if(this->playerStats.hp <= 0)
|
||||||
|
{
|
||||||
|
this->playerStats.hp = 0;
|
||||||
|
this->playerState = PLAYER_STATE_DIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::AddAffectedObject(DynamicObject &AffectedObject)
|
||||||
|
{
|
||||||
|
//check if object already exists in the list, if so then do not add
|
||||||
|
for(int i = 0; i < AffectedObjects.Size(); i++)
|
||||||
|
{
|
||||||
|
if(AffectedObjects[i]->GetID() == AffectedObject.GetID())
|
||||||
{
|
{
|
||||||
this->life = 0;
|
//object already exists, exit function
|
||||||
playerState = PLAYER_STATE_DEAD;
|
return;
|
||||||
this->deathTimeLeft = this->deathTime;
|
|
||||||
this->gameInstance->onDeadFnc(this, this->deathTimeLeft);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//else you add the object to the stack
|
||||||
|
AffectedObjects.Push(&AffectedObject);
|
||||||
|
}
|
||||||
|
bool Player::deathTimerTick(float dt)
|
||||||
|
{
|
||||||
|
this->deathTimer -= dt;
|
||||||
|
if( this->deathTimer <= 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void Player::setDeathTimer(float deathTimer)
|
||||||
|
{
|
||||||
|
this->deathTimer = deathTimer;
|
||||||
|
this->playerState = PLAYER_STATE_DEAD;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include "DynamicObject.h"
|
#include "DynamicObject.h"
|
||||||
|
#include "DynamicArray.h"
|
||||||
|
|
||||||
|
const float MAX_HP = 100.0f;
|
||||||
|
const float BASIC_SPEED = 30.0f;
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -15,6 +18,21 @@ namespace GameLogic
|
||||||
class Player : public DynamicObject
|
class Player : public DynamicObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
struct PlayerStats
|
||||||
|
{
|
||||||
|
Oyster::Math::Float hp;
|
||||||
|
Oyster::Math::Float movementSpeed;
|
||||||
|
//Oyster::Math::Float resistance;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PlayerScore
|
||||||
|
{
|
||||||
|
int killScore;
|
||||||
|
int deathScore;
|
||||||
|
// int assistScore;
|
||||||
|
// int suicideScore;
|
||||||
|
};
|
||||||
|
|
||||||
Player(void);
|
Player(void);
|
||||||
|
|
||||||
Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID);
|
Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID);
|
||||||
|
@ -50,6 +68,8 @@ namespace GameLogic
|
||||||
|
|
||||||
void TurnLeft(Oyster::Math3D::Float deltaRadians);
|
void TurnLeft(Oyster::Math3D::Float deltaRadians);
|
||||||
|
|
||||||
|
void AddAffectedObject(DynamicObject &AffectedObject);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
|
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
|
||||||
* Will be called when the physics detect a collision
|
* Will be called when the physics detect a collision
|
||||||
|
@ -72,6 +92,8 @@ namespace GameLogic
|
||||||
PLAYER_STATE GetState() const;
|
PLAYER_STATE GetState() const;
|
||||||
|
|
||||||
void DamageLife(int damage);
|
void DamageLife(int damage);
|
||||||
|
void setDeathTimer(float deathTimer);
|
||||||
|
bool deathTimerTick(float dt);
|
||||||
|
|
||||||
void BeginFrame();
|
void BeginFrame();
|
||||||
void EndFrame();
|
void EndFrame();
|
||||||
|
@ -79,9 +101,11 @@ namespace GameLogic
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Jump();
|
void Jump();
|
||||||
|
void initPlayerData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Oyster::Math::Float life;
|
|
||||||
|
Utility::DynamicMemory::DynamicArray<DynamicObject*> AffectedObjects;
|
||||||
int teamID;
|
int teamID;
|
||||||
Weapon *weapon;
|
Weapon *weapon;
|
||||||
PLAYER_STATE playerState;
|
PLAYER_STATE playerState;
|
||||||
|
@ -93,18 +117,15 @@ namespace GameLogic
|
||||||
float key_jump;
|
float key_jump;
|
||||||
|
|
||||||
|
|
||||||
Oyster::Math::Float3 previousPosition;
|
|
||||||
Oyster::Math::Float3 moveDir;
|
|
||||||
Oyster::Math::Float moveSpeed;
|
|
||||||
Oyster::Math::Float3 previousMoveSpeed;
|
|
||||||
|
|
||||||
Oyster::Math::Float rotationUp;
|
Oyster::Math::Float rotationUp;
|
||||||
|
|
||||||
float deathTime;
|
float deathTimer;
|
||||||
float deathTimeLeft;
|
|
||||||
|
|
||||||
bool hasTakenDamage;
|
bool hasTakenDamage;
|
||||||
float invincibleCooldown;
|
float invincibleCooldown;
|
||||||
|
PlayerStats playerStats;
|
||||||
|
PlayerScore playerScore;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -59,7 +59,7 @@ namespace GameLogic
|
||||||
//#define protocol_Gameplay_ObjectDamage 351
|
//#define protocol_Gameplay_ObjectDamage 351
|
||||||
struct Protocol_ObjectDamage :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectDamage :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
int object_ID;
|
int objectID;
|
||||||
float healthLost; //Precentage%
|
float healthLost; //Precentage%
|
||||||
|
|
||||||
Protocol_ObjectDamage()
|
Protocol_ObjectDamage()
|
||||||
|
@ -70,12 +70,12 @@ namespace GameLogic
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = -1;
|
objectID = -1;
|
||||||
healthLost = 0.0f;
|
healthLost = 0.0f;
|
||||||
}
|
}
|
||||||
Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
this->object_ID = p[1].value.netInt;
|
this->objectID = p[1].value.netInt;
|
||||||
this->healthLost = p[2].value.netFloat;
|
this->healthLost = p[2].value.netFloat;
|
||||||
}
|
}
|
||||||
Protocol_ObjectDamage(int id, float hp)
|
Protocol_ObjectDamage(int id, float hp)
|
||||||
|
@ -86,12 +86,12 @@ namespace GameLogic
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = id;
|
objectID = id;
|
||||||
healthLost = hp;
|
healthLost = hp;
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = object_ID;
|
this->protocol[1].value = objectID;
|
||||||
this->protocol[2].value = healthLost;
|
this->protocol[2].value = healthLost;
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,8 @@ namespace GameLogic
|
||||||
//#define protocol_Gameplay_ObjectHealthStatus 352
|
//#define protocol_Gameplay_ObjectHealthStatus 352
|
||||||
struct Protocol_ObjectHealthStatus :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectHealthStatus :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
|
int objectID;
|
||||||
float currentHealth;
|
float currentHealth;
|
||||||
int id;
|
|
||||||
|
|
||||||
Protocol_ObjectHealthStatus()
|
Protocol_ObjectHealthStatus()
|
||||||
{
|
{
|
||||||
|
@ -112,7 +112,7 @@ namespace GameLogic
|
||||||
this->protocol[0].value.netShort = protocol_Gameplay_ObjectHealthStatus;
|
this->protocol[0].value.netShort = protocol_Gameplay_ObjectHealthStatus;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->id = 0;
|
this->objectID = -1;
|
||||||
this->currentHealth = 0.0f;
|
this->currentHealth = 0.0f;
|
||||||
}
|
}
|
||||||
Protocol_ObjectHealthStatus(int id, float health)
|
Protocol_ObjectHealthStatus(int id, float health)
|
||||||
|
@ -121,16 +121,16 @@ namespace GameLogic
|
||||||
this->protocol[0].value.netShort = protocol_Gameplay_ObjectHealthStatus;
|
this->protocol[0].value.netShort = protocol_Gameplay_ObjectHealthStatus;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->id = id; this->currentHealth = health;
|
this->objectID = id; this->currentHealth = health;
|
||||||
}
|
}
|
||||||
Protocol_ObjectHealthStatus(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectHealthStatus(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
this->id = p[1].value.netInt;
|
this->objectID = p[1].value.netInt;
|
||||||
this->currentHealth = p[2].value.netFloat;
|
this->currentHealth = p[2].value.netFloat;
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = this->id;
|
this->protocol[1].value = this->objectID;
|
||||||
this->protocol[2].value = this->currentHealth;
|
this->protocol[2].value = this->currentHealth;
|
||||||
|
|
||||||
return protocol;
|
return protocol;
|
||||||
|
@ -143,7 +143,7 @@ namespace GameLogic
|
||||||
//#define protocol_Gameplay_ObjectPosition 353
|
//#define protocol_Gameplay_ObjectPosition 353
|
||||||
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
short object_ID;
|
short objectID;
|
||||||
float position[3];
|
float position[3];
|
||||||
|
|
||||||
Protocol_ObjectPosition()
|
Protocol_ObjectPosition()
|
||||||
|
@ -155,12 +155,12 @@ namespace GameLogic
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = 0;
|
objectID = -1;
|
||||||
memset(&position[0], 0, sizeof(float) * 3);
|
memset(&position[0], 0, sizeof(float) * 3);
|
||||||
}
|
}
|
||||||
Protocol_ObjectPosition(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectPosition(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
object_ID = p[1].value.netShort;
|
objectID = p[1].value.netShort;
|
||||||
position[0] = p[2].value.netFloat;
|
position[0] = p[2].value.netFloat;
|
||||||
position[1] = p[3].value.netFloat;
|
position[1] = p[3].value.netFloat;
|
||||||
position[2] = p[4].value.netFloat;
|
position[2] = p[4].value.netFloat;
|
||||||
|
@ -174,12 +174,12 @@ namespace GameLogic
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = id;
|
objectID = id;
|
||||||
memcpy(&position[0], &v[0], sizeof(float) * 3);
|
memcpy(&position[0], &v[0], sizeof(float) * 3);
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = object_ID;
|
this->protocol[1].value = objectID;
|
||||||
this->protocol[2].value = position[0];
|
this->protocol[2].value = position[0];
|
||||||
this->protocol[3].value = position[1];
|
this->protocol[3].value = position[1];
|
||||||
this->protocol[4].value = position[2];
|
this->protocol[4].value = position[2];
|
||||||
|
@ -193,7 +193,7 @@ namespace GameLogic
|
||||||
//#define protocol_Gameplay_ObjectScale 354
|
//#define protocol_Gameplay_ObjectScale 354
|
||||||
struct Protocol_ObjectScale :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectScale :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
short object_ID;
|
short objectID;
|
||||||
float scale[3];
|
float scale[3];
|
||||||
|
|
||||||
Protocol_ObjectScale()
|
Protocol_ObjectScale()
|
||||||
|
@ -205,12 +205,12 @@ namespace GameLogic
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = 0;
|
objectID = -1;
|
||||||
memset(&scale[0], 0, sizeof(float) * 3);
|
memset(&scale[0], 0, sizeof(float) * 3);
|
||||||
}
|
}
|
||||||
Protocol_ObjectScale(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectScale(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
object_ID = p[1].value.netShort;
|
objectID = p[1].value.netShort;
|
||||||
scale[0] = p[2].value.netFloat;
|
scale[0] = p[2].value.netFloat;
|
||||||
scale[1] = p[3].value.netFloat;
|
scale[1] = p[3].value.netFloat;
|
||||||
scale[2] = p[4].value.netFloat;
|
scale[2] = p[4].value.netFloat;
|
||||||
|
@ -224,12 +224,12 @@ namespace GameLogic
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = id;
|
objectID = id;
|
||||||
memcpy(&scale[0], &v[0], sizeof(float) * 3);
|
memcpy(&scale[0], &v[0], sizeof(float) * 3);
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = object_ID;
|
this->protocol[1].value = objectID;
|
||||||
this->protocol[2].value = scale[0];
|
this->protocol[2].value = scale[0];
|
||||||
this->protocol[3].value = scale[1];
|
this->protocol[3].value = scale[1];
|
||||||
this->protocol[4].value = scale[2];
|
this->protocol[4].value = scale[2];
|
||||||
|
@ -243,7 +243,7 @@ namespace GameLogic
|
||||||
//#define protocol_Gameplay_ObjectRotation 355
|
//#define protocol_Gameplay_ObjectRotation 355
|
||||||
struct Protocol_ObjectRotation :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectRotation :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
short object_ID;
|
short objectID;
|
||||||
float rotationQ[4];
|
float rotationQ[4];
|
||||||
|
|
||||||
Protocol_ObjectRotation()
|
Protocol_ObjectRotation()
|
||||||
|
@ -256,12 +256,12 @@ namespace GameLogic
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = 0;
|
objectID = -1;
|
||||||
memset(&rotationQ[0], 0, sizeof(float) * 4);
|
memset(&rotationQ[0], 0, sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
Protocol_ObjectRotation(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectRotation(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
object_ID = p[1].value.netShort;
|
objectID = p[1].value.netShort;
|
||||||
rotationQ[0] = p[2].value.netFloat;
|
rotationQ[0] = p[2].value.netFloat;
|
||||||
rotationQ[1] = p[3].value.netFloat;
|
rotationQ[1] = p[3].value.netFloat;
|
||||||
rotationQ[2] = p[4].value.netFloat;
|
rotationQ[2] = p[4].value.netFloat;
|
||||||
|
@ -277,12 +277,12 @@ namespace GameLogic
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = id;
|
objectID = id;
|
||||||
memcpy(&rotationQ[0], &v[0], sizeof(float) * 4);
|
memcpy(&rotationQ[0], &v[0], sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = object_ID;
|
this->protocol[1].value = objectID;
|
||||||
this->protocol[2].value = rotationQ[0];
|
this->protocol[2].value = rotationQ[0];
|
||||||
this->protocol[3].value = rotationQ[1];
|
this->protocol[3].value = rotationQ[1];
|
||||||
this->protocol[4].value = rotationQ[2];
|
this->protocol[4].value = rotationQ[2];
|
||||||
|
@ -297,7 +297,7 @@ namespace GameLogic
|
||||||
//#define protocol_Gameplay_ObjectEnabled 356
|
//#define protocol_Gameplay_ObjectEnabled 356
|
||||||
struct Protocol_ObjectPositionRotation :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectPositionRotation :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
short object_ID;
|
short objectID;
|
||||||
float position[3];
|
float position[3];
|
||||||
float rotationQ[4];
|
float rotationQ[4];
|
||||||
|
|
||||||
|
@ -316,13 +316,13 @@ namespace GameLogic
|
||||||
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
this->object_ID = 0;
|
this->objectID = -1;
|
||||||
memset(&this->position[0], 0, sizeof(float) * 3);
|
memset(&this->position[0], 0, sizeof(float) * 3);
|
||||||
memset(&this->rotationQ[0], 0, sizeof(float) * 4);
|
memset(&this->rotationQ[0], 0, sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
Protocol_ObjectPositionRotation(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectPositionRotation(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
this->object_ID = p[1].value.netShort;
|
this->objectID = p[1].value.netShort;
|
||||||
//POSITION
|
//POSITION
|
||||||
this->position[0] = p[2].value.netFloat;
|
this->position[0] = p[2].value.netFloat;
|
||||||
this->position[1] = p[3].value.netFloat;
|
this->position[1] = p[3].value.netFloat;
|
||||||
|
@ -348,13 +348,13 @@ namespace GameLogic
|
||||||
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = id;
|
objectID = id;
|
||||||
memcpy(&this->position[0], &p[0], sizeof(float) * 3);
|
memcpy(&this->position[0], &p[0], sizeof(float) * 3);
|
||||||
memcpy(&this->rotationQ[0], &r[0], sizeof(float) * 4);
|
memcpy(&this->rotationQ[0], &r[0], sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = this->object_ID;
|
this->protocol[1].value = this->objectID;
|
||||||
this->protocol[2].value = this->position[0];
|
this->protocol[2].value = this->position[0];
|
||||||
this->protocol[3].value = this->position[1];
|
this->protocol[3].value = this->position[1];
|
||||||
this->protocol[4].value = this->position[2];
|
this->protocol[4].value = this->position[2];
|
||||||
|
@ -406,35 +406,28 @@ namespace GameLogic
|
||||||
struct Protocol_ObjectDisable :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectDisable :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
int objectID;
|
int objectID;
|
||||||
float seconds;
|
|
||||||
|
|
||||||
Protocol_ObjectDisable()
|
Protocol_ObjectDisable()
|
||||||
{
|
{
|
||||||
this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
|
this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->objectID = -1;
|
||||||
this->objectID = 0;
|
|
||||||
this->seconds = 0.0f;
|
|
||||||
}
|
}
|
||||||
Protocol_ObjectDisable(int objctID, float seconds)
|
Protocol_ObjectDisable(int objctID)
|
||||||
{
|
{
|
||||||
this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
|
this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
|
||||||
this->objectID = objctID;
|
this->objectID = objctID;
|
||||||
this->seconds = seconds;
|
|
||||||
}
|
}
|
||||||
Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
this->objectID = p[1].value.netInt;
|
this->objectID = p[1].value.netInt;
|
||||||
this->seconds = p[2].value.netFloat;
|
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = this->objectID;
|
this->protocol[1].value = this->objectID;
|
||||||
this->protocol[2].value = this->seconds;
|
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +439,7 @@ namespace GameLogic
|
||||||
struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
//ObjectType type; //ie player, box or whatever
|
//ObjectType type; //ie player, box or whatever
|
||||||
int object_ID;
|
int objectID;
|
||||||
std::string name;
|
std::string name;
|
||||||
float position[3];
|
float position[3];
|
||||||
float rotationQ[4];
|
float rotationQ[4];
|
||||||
|
@ -473,13 +466,13 @@ namespace GameLogic
|
||||||
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
this->object_ID = 0;
|
this->objectID = -1;
|
||||||
memset(this->position, 0, sizeof(float) * 3);
|
memset(this->position, 0, sizeof(float) * 3);
|
||||||
memset(this->rotationQ, 0, sizeof(float) * 4);
|
memset(this->rotationQ, 0, sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
Protocol_ObjectCreate( Oyster::Network::CustomNetProtocol& p )
|
Protocol_ObjectCreate( Oyster::Network::CustomNetProtocol& p )
|
||||||
{
|
{
|
||||||
this->object_ID = p[1].value.netInt;
|
this->objectID = p[1].value.netInt;
|
||||||
this->name.assign(p[2].value.netCharPtr);
|
this->name.assign(p[2].value.netCharPtr);
|
||||||
|
|
||||||
this->position[0] = p[3].value.netFloat;
|
this->position[0] = p[3].value.netFloat;
|
||||||
|
@ -516,7 +509,7 @@ namespace GameLogic
|
||||||
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = id;
|
objectID = id;
|
||||||
this->name = path;
|
this->name = path;
|
||||||
|
|
||||||
memcpy(this->position, p, sizeof(float) * 3);
|
memcpy(this->position, p, sizeof(float) * 3);
|
||||||
|
@ -526,7 +519,7 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
|
|
||||||
this->protocol[1].value = object_ID;
|
this->protocol[1].value = objectID;
|
||||||
this->protocol.Set(2, name);
|
this->protocol.Set(2, name);
|
||||||
this->protocol[3].value = this->position[0];
|
this->protocol[3].value = this->position[0];
|
||||||
this->protocol[4].value = this->position[1];
|
this->protocol[4].value = this->position[1];
|
||||||
|
@ -546,10 +539,42 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define protocol_Gameplay_ObjectCreatePlayer 360
|
//#define protocol_Gameplay_ObjectDelete 360
|
||||||
|
struct Protocol_ObjectDelete :public Oyster::Network::CustomProtocolObject
|
||||||
|
{
|
||||||
|
int objectID;
|
||||||
|
|
||||||
|
Protocol_ObjectDelete()
|
||||||
|
{
|
||||||
|
this->protocol[0].value = protocol_Gameplay_ObjectDelete;
|
||||||
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
this->objectID = -1;
|
||||||
|
}
|
||||||
|
Protocol_ObjectDelete(int objctID)
|
||||||
|
{
|
||||||
|
this->protocol[0].value = protocol_Gameplay_ObjectDelete;
|
||||||
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
this->objectID = objctID;
|
||||||
|
}
|
||||||
|
Protocol_ObjectDelete(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;
|
||||||
|
};
|
||||||
|
//#define protocol_Gameplay_ObjectCreatePlayer 361
|
||||||
struct Protocol_ObjectCreatePlayer :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectCreatePlayer :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
/*1*/ int object_ID;
|
/*1*/ int objectID;
|
||||||
/*2*/ int teamId;
|
/*2*/ int teamId;
|
||||||
/*3*/ bool owner;
|
/*3*/ bool owner;
|
||||||
/*4*/ std::string name;
|
/*4*/ std::string name;
|
||||||
|
@ -589,7 +614,7 @@ namespace GameLogic
|
||||||
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
this->owner = p[1].value.netBool;
|
this->owner = p[1].value.netBool;
|
||||||
this->object_ID = p[2].value.netInt;
|
this->objectID = p[2].value.netInt;
|
||||||
this->teamId = p[3].value.netInt;
|
this->teamId = p[3].value.netInt;
|
||||||
|
|
||||||
this->name.assign(p[4].value.netCharPtr);
|
this->name.assign(p[4].value.netCharPtr);
|
||||||
|
@ -637,7 +662,7 @@ namespace GameLogic
|
||||||
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
this->object_ID = ObjectID;
|
this->objectID = ObjectID;
|
||||||
this->teamId = teamID;
|
this->teamId = teamID;
|
||||||
this->owner = owner;
|
this->owner = owner;
|
||||||
this->name = name;
|
this->name = name;
|
||||||
|
@ -649,7 +674,7 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = this->owner;
|
this->protocol[1].value = this->owner;
|
||||||
this->protocol[2].value = this->object_ID;
|
this->protocol[2].value = this->objectID;
|
||||||
this->protocol[3].value = this->teamId;
|
this->protocol[3].value = this->teamId;
|
||||||
|
|
||||||
this->protocol.Set(4, this->name);
|
this->protocol.Set(4, this->name);
|
||||||
|
@ -676,7 +701,7 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define protocol_Gameplay_ObjectJoinTeam 361
|
//#define protocol_Gameplay_ObjectJoinTeam 362
|
||||||
struct Protocol_ObjectJoinTeam :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectJoinTeam :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
int objectID;
|
int objectID;
|
||||||
|
@ -716,7 +741,7 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define protocol_Gameplay_ObjectLeaveTeam 362
|
//#define protocol_Gameplay_ObjectLeaveTeam 363
|
||||||
struct Protocol_ObjectLeaveTeam :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectLeaveTeam :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
int objectID;
|
int objectID;
|
||||||
|
@ -748,7 +773,7 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define protocol_Gameplay_ObjectWeaponCooldown 363
|
//#define protocol_Gameplay_ObjectWeaponCooldown 364
|
||||||
struct Protocol_ObjectWeaponCooldown :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectWeaponCooldown :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
float seconds;
|
float seconds;
|
||||||
|
@ -780,7 +805,7 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define protocol_Gameplay_ObjectWeaponEnergy 364
|
//#define protocol_Gameplay_ObjectWeaponEnergy 365
|
||||||
struct Protocol_ObjectWeaponEnergy :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectWeaponEnergy :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
float energy;
|
float energy;
|
||||||
|
@ -812,7 +837,7 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define protocol_Gameplay_ObjectRespawn 365
|
//#define protocol_Gameplay_ObjectRespawn 366
|
||||||
struct Protocol_ObjectRespawn :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectRespawn :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
int objectID;
|
int objectID;
|
||||||
|
@ -864,10 +889,11 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define protocol_Gameplay_ObjectDie 366
|
//#define protocol_Gameplay_ObjectDie 367
|
||||||
struct Protocol_ObjectDie :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectDie :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
int objectID;
|
int objectID;
|
||||||
|
int killerID;
|
||||||
float seconds;
|
float seconds;
|
||||||
|
|
||||||
Protocol_ObjectDie()
|
Protocol_ObjectDie()
|
||||||
|
@ -875,28 +901,34 @@ namespace GameLogic
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie;
|
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->objectID = 0;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->objectID = -1;
|
||||||
|
this->killerID = -1;
|
||||||
this->seconds = 0.0f;
|
this->seconds = 0.0f;
|
||||||
}
|
}
|
||||||
Protocol_ObjectDie(int objectID, float seconds)
|
Protocol_ObjectDie(int objectID, int killerID, float seconds)
|
||||||
{
|
{
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie;
|
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->objectID = objectID;
|
this->objectID = objectID;
|
||||||
|
this->killerID = killerID;
|
||||||
this->seconds = seconds;
|
this->seconds = seconds;
|
||||||
}
|
}
|
||||||
Protocol_ObjectDie(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectDie(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
this->objectID = p[1].value.netInt;
|
this->objectID = p[1].value.netInt;
|
||||||
this->seconds = p[2].value.netFloat;
|
this->killerID = p[2].value.netInt;
|
||||||
|
this->seconds = p[3].value.netFloat;
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = this->objectID;
|
this->protocol[1].value = this->objectID;
|
||||||
this->protocol[2].value = this->seconds;
|
this->protocol[2].value = this->killerID;
|
||||||
|
this->protocol[3].value = this->seconds;
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,7 +936,7 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define protocol_Gameplay_ObjectDisconnectPlayer 367
|
//#define protocol_Gameplay_ObjectDisconnectPlayer 368
|
||||||
struct Protocol_ObjectDisconnectPlayer :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectDisconnectPlayer :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
int objectID;
|
int objectID;
|
||||||
|
@ -937,33 +969,33 @@ namespace GameLogic
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//#define protocol_Gameplay_ObjectAction 368
|
//#define protocol_Gameplay_ObjectAction 369
|
||||||
struct Protocol_ObjectAction :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectAction :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
short objectID;
|
short objectID;
|
||||||
float animationID;
|
int animationID;
|
||||||
|
|
||||||
Protocol_ObjectAction()
|
Protocol_ObjectAction()
|
||||||
{
|
{
|
||||||
this->protocol[0].value = protocol_Gameplay_ObjectAction;
|
this->protocol[0].value = protocol_Gameplay_ObjectAction;
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
|
||||||
objectID = 0;
|
objectID = -1;
|
||||||
animationID = -1;
|
animationID = -1;
|
||||||
}
|
}
|
||||||
Protocol_ObjectAction(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectAction(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
objectID = p[1].value.netShort;
|
objectID = p[1].value.netShort;
|
||||||
animationID = p[2].value.netFloat;
|
animationID = p[2].value.netInt;
|
||||||
}
|
}
|
||||||
Protocol_ObjectAction(float animID, int id)
|
Protocol_ObjectAction( int id, int animID)
|
||||||
{
|
{
|
||||||
this->protocol[0].value = protocol_Gameplay_ObjectAction;
|
this->protocol[0].value = protocol_Gameplay_ObjectAction;
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
|
||||||
objectID = id;
|
objectID = id;
|
||||||
animationID = animID;
|
animationID = animID;
|
||||||
|
|
|
@ -63,15 +63,16 @@
|
||||||
#define protocol_Gameplay_ObjectEnabled 357
|
#define protocol_Gameplay_ObjectEnabled 357
|
||||||
#define protocol_Gameplay_ObjectDisabled 358
|
#define protocol_Gameplay_ObjectDisabled 358
|
||||||
#define protocol_Gameplay_ObjectCreate 359
|
#define protocol_Gameplay_ObjectCreate 359
|
||||||
#define protocol_Gameplay_ObjectCreatePlayer 360
|
#define protocol_Gameplay_ObjectDelete 360
|
||||||
#define protocol_Gameplay_ObjectJoinTeam 361
|
#define protocol_Gameplay_ObjectCreatePlayer 361
|
||||||
#define protocol_Gameplay_ObjectLeaveTeam 362
|
#define protocol_Gameplay_ObjectJoinTeam 362
|
||||||
#define protocol_Gameplay_ObjectWeaponCooldown 363
|
#define protocol_Gameplay_ObjectLeaveTeam 363
|
||||||
#define protocol_Gameplay_ObjectWeaponEnergy 364
|
#define protocol_Gameplay_ObjectWeaponCooldown 364
|
||||||
#define protocol_Gameplay_ObjectRespawn 365
|
#define protocol_Gameplay_ObjectWeaponEnergy 365
|
||||||
#define protocol_Gameplay_ObjectDie 366
|
#define protocol_Gameplay_ObjectRespawn 366
|
||||||
#define protocol_Gameplay_ObjectDisconnectPlayer 367
|
#define protocol_Gameplay_ObjectDie 367
|
||||||
#define protocol_Gameplay_ObjectAction 368
|
#define protocol_Gameplay_ObjectDisconnectPlayer 368
|
||||||
|
#define protocol_Gameplay_ObjectAction 369
|
||||||
#define protocol_GameplayMAX 399
|
#define protocol_GameplayMAX 399
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -96,13 +96,15 @@ namespace DanBias
|
||||||
void General_Status ( GameLogic::Protocol_General_Status& p, DanBias::GameClient* c );
|
void General_Status ( GameLogic::Protocol_General_Status& p, DanBias::GameClient* c );
|
||||||
void General_Text ( GameLogic::Protocol_General_Text& p, DanBias::GameClient* c );
|
void General_Text ( GameLogic::Protocol_General_Text& p, DanBias::GameClient* c );
|
||||||
|
|
||||||
//Callback method recieving from gamelogic
|
//Callback method receiving from game logic
|
||||||
static void ObjectMove ( GameLogic::IObjectData* movedObject );
|
static void ObjectMove ( GameLogic::IObjectData* movedObject );
|
||||||
static void ObjectDisabled ( GameLogic::IObjectData* movedObject, float seconds );
|
static void ObjectDisabled ( GameLogic::IObjectData* movedObject );
|
||||||
|
static void ObjectEnabled ( GameLogic::IObjectData* movedObject );
|
||||||
static void ObjectDamaged ( GameLogic::IObjectData* movedObject, float hp );
|
static void ObjectDamaged ( GameLogic::IObjectData* movedObject, float hp );
|
||||||
static void ObjectRespawned ( GameLogic::IObjectData* movedObject, Oyster::Math::Float3 spawnPos );
|
static void ObjectRespawned ( GameLogic::IObjectData* movedObject, Oyster::Math::Float3 spawnPos );
|
||||||
static void ObjectDead ( GameLogic::IObjectData* movedObject, float seconds );
|
static void ObjectDead ( GameLogic::IObjectData* victim, GameLogic::IObjectData* killer, float seconds );
|
||||||
|
static void PickupEvent ( GameLogic::IObjectData* movedObject, int pickupEffectID );
|
||||||
|
static void ActionEvent ( GameLogic::IObjectData* movedObject , int actionID );
|
||||||
//Private member variables
|
//Private member variables
|
||||||
private:
|
private:
|
||||||
Utility::DynamicMemory::DynamicArray<gClient> gClients;
|
Utility::DynamicMemory::DynamicArray<gClient> gClients;
|
||||||
|
|
|
@ -146,9 +146,13 @@ using namespace DanBias;
|
||||||
GameSession::gameSession->Send(p.GetProtocol());
|
GameSession::gameSession->Send(p.GetProtocol());
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
void GameSession::ObjectDisabled( GameLogic::IObjectData* movedObject, float seconds )
|
void GameSession::ObjectDisabled( GameLogic::IObjectData* movedObject )
|
||||||
{
|
{
|
||||||
GameSession::gameSession->Send(Protocol_ObjectDisable(movedObject->GetID(), seconds).GetProtocol());
|
GameSession::gameSession->Send(Protocol_ObjectDisable(movedObject->GetID()).GetProtocol());
|
||||||
|
}
|
||||||
|
void GameSession::ObjectEnabled( GameLogic::IObjectData* movedObject )
|
||||||
|
{
|
||||||
|
GameSession::gameSession->Send(Protocol_ObjectDisable(movedObject->GetID()).GetProtocol());
|
||||||
}
|
}
|
||||||
void GameSession::ObjectDamaged( GameLogic::IObjectData* movedObject, float hp )
|
void GameSession::ObjectDamaged( GameLogic::IObjectData* movedObject, float hp )
|
||||||
{
|
{
|
||||||
|
@ -158,9 +162,19 @@ using namespace DanBias;
|
||||||
{
|
{
|
||||||
GameSession::gameSession->Send(Protocol_ObjectRespawn(movedObject->GetID(), spawnPos).GetProtocol());
|
GameSession::gameSession->Send(Protocol_ObjectRespawn(movedObject->GetID(), spawnPos).GetProtocol());
|
||||||
}
|
}
|
||||||
void GameSession::ObjectDead( GameLogic::IObjectData* movedObject, float seconds )
|
void GameSession::ObjectDead( GameLogic::IObjectData* victim, GameLogic::IObjectData* killer, float seconds )
|
||||||
{
|
{
|
||||||
GameSession::gameSession->Send(Protocol_ObjectDie(movedObject->GetID(), seconds).GetProtocol());
|
GameSession::gameSession->Send(Protocol_ObjectDie(victim->GetID(), killer->GetID(), seconds).GetProtocol());
|
||||||
|
}
|
||||||
|
void GameSession::PickupEvent( GameLogic::IObjectData* movedObject, int pickupEffectID )
|
||||||
|
{
|
||||||
|
// send pickup protocol
|
||||||
|
GameSession::gameSession->Send(Protocol_ObjectPickup(movedObject->GetID(), pickupEffectID).GetProtocol());
|
||||||
|
}
|
||||||
|
void GameSession::ActionEvent( GameLogic::IObjectData* movedObject , int actionID )
|
||||||
|
{
|
||||||
|
// send action protocol
|
||||||
|
GameSession::gameSession->Send(Protocol_ObjectAction(movedObject->GetID(), actionID).GetProtocol());
|
||||||
}
|
}
|
||||||
//*****************************************************//
|
//*****************************************************//
|
||||||
//****************** Protocol methods *****************//
|
//****************** Protocol methods *****************//
|
||||||
|
@ -188,7 +202,6 @@ using namespace DanBias;
|
||||||
break;
|
break;
|
||||||
case protocol_Gameplay_PlayerShot: this->Gameplay_PlayerShot ( Protocol_PlayerShot (p), c );
|
case protocol_Gameplay_PlayerShot: this->Gameplay_PlayerShot ( Protocol_PlayerShot (p), c );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case protocol_Gameplay_ObjectPickup: this->Gameplay_ObjectPickup ( Protocol_ObjectPickup (p), c );
|
case protocol_Gameplay_ObjectPickup: this->Gameplay_ObjectPickup ( Protocol_ObjectPickup (p), c );
|
||||||
break;
|
break;
|
||||||
case protocol_Gameplay_ObjectDamage: this->Gameplay_ObjectDamage ( Protocol_ObjectDamage (p), c );
|
case protocol_Gameplay_ObjectDamage: this->Gameplay_ObjectDamage ( Protocol_ObjectDamage (p), c );
|
||||||
|
@ -201,7 +214,6 @@ using namespace DanBias;
|
||||||
break;
|
break;
|
||||||
case protocol_Gameplay_ObjectCreate: this->Gameplay_ObjectCreate ( Protocol_ObjectCreate (p), c );
|
case protocol_Gameplay_ObjectCreate: this->Gameplay_ObjectCreate ( Protocol_ObjectCreate (p), c );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case protocol_General_Status: this->General_Status ( Protocol_General_Status (p), c );
|
case protocol_General_Status: this->General_Status ( Protocol_General_Status (p), c );
|
||||||
break;
|
break;
|
||||||
case protocol_General_Text: this->General_Text ( Protocol_General_Text (p), c );
|
case protocol_General_Text: this->General_Text ( Protocol_General_Text (p), c );
|
||||||
|
@ -242,11 +254,8 @@ using namespace DanBias;
|
||||||
{
|
{
|
||||||
if(p.secondaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS);
|
if(p.secondaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS);
|
||||||
if(p.primaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
if(p.primaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||||
|
|
||||||
if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS);
|
if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c )
|
void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -106,11 +106,14 @@ bool GameSession::Create(GameDescription& desc, bool forceStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set some game instance data options */
|
/* Set some game instance data options */
|
||||||
this->gameInstance.SetSubscription(GameSession::ObjectMove);
|
this->gameInstance.SetMoveSubscription(GameSession::ObjectMove);
|
||||||
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
|
this->gameInstance.SetDisableSubscription(GameSession::ObjectDisabled);
|
||||||
|
this->gameInstance.SetEnableSubscription(GameSession::ObjectEnabled);
|
||||||
this->gameInstance.SetHpSubscription(GameSession::ObjectDamaged);
|
this->gameInstance.SetHpSubscription(GameSession::ObjectDamaged);
|
||||||
this->gameInstance.SetRespawnSubscription(GameSession::ObjectRespawned);
|
this->gameInstance.SetRespawnSubscription(GameSession::ObjectRespawned);
|
||||||
this->gameInstance.SetDeadSubscription(GameSession::ObjectDead);
|
this->gameInstance.SetDeadSubscription(GameSession::ObjectDead);
|
||||||
|
this->gameInstance.SetActionSubscription(GameSession::ActionEvent);
|
||||||
|
this->gameInstance.SetPickupSubscription(GameSession::PickupEvent);
|
||||||
this->gameInstance.SetFPS(60);
|
this->gameInstance.SetFPS(60);
|
||||||
|
|
||||||
this->description.clients.Clear();
|
this->description.clients.Clear();
|
||||||
|
|
|
@ -156,6 +156,21 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
objects.push_back(header);
|
objects.push_back(header);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ObjectSpecialType_PickupHealth:
|
||||||
|
{
|
||||||
|
PickupHealthAttributes* header = new PickupHealthAttributes;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
|
||||||
|
ParseObject(&buffer[counter], &header->spawnTime, 4);
|
||||||
|
counter += 4;
|
||||||
|
|
||||||
|
ParseObject(&buffer[counter], &header->healthValue, 4);
|
||||||
|
counter += 4;
|
||||||
|
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
//this is a hotfix, fix so you only load the relevant data when the file is updated
|
//this is a hotfix, fix so you only load the relevant data when the file is updated
|
||||||
default:
|
default:
|
||||||
//Couldn't find specialType
|
//Couldn't find specialType
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace GameLogic
|
||||||
ObjectSpecialType_Player,
|
ObjectSpecialType_Player,
|
||||||
ObjectSpecialType_Generic,
|
ObjectSpecialType_Generic,
|
||||||
|
|
||||||
|
ObjectSpecialType_PickupHealth,
|
||||||
|
|
||||||
ObjectSpecialType_Count,
|
ObjectSpecialType_Count,
|
||||||
ObjectSpecialType_Unknown = -1
|
ObjectSpecialType_Unknown = -1
|
||||||
|
@ -92,6 +93,23 @@ namespace GameLogic
|
||||||
WorldSize_Unknown = -1
|
WorldSize_Unknown = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum PlayerAction
|
||||||
|
{
|
||||||
|
PlayerAction_Jump,
|
||||||
|
PlayerAction_Walk,
|
||||||
|
PlayerAction_Idle,
|
||||||
|
};
|
||||||
|
enum WeaponAction
|
||||||
|
{
|
||||||
|
WeaponAtcion_PrimaryShoot,
|
||||||
|
WeaponAction_SecondaryShoot
|
||||||
|
};
|
||||||
|
|
||||||
|
enum PickupType
|
||||||
|
{
|
||||||
|
PickupType_Health,
|
||||||
|
PickupType_SpeedBoost
|
||||||
|
};
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
Structs
|
Structs
|
||||||
|
@ -246,7 +264,11 @@ namespace GameLogic
|
||||||
float skySize;
|
float skySize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PickupHealthAttributes : public ObjectHeader
|
||||||
|
{
|
||||||
|
float spawnTime;
|
||||||
|
float healthValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ namespace GameLogic
|
||||||
void ParseLight(char* buffer, BasicLight& header, int& size)
|
void ParseLight(char* buffer, BasicLight& header, int& size)
|
||||||
{
|
{
|
||||||
int start = 0;
|
int start = 0;
|
||||||
memcpy(&header.typeID, &buffer[start], 40);
|
memcpy(&header.typeID, &buffer[start], 4);
|
||||||
start += 40;
|
start += 4;
|
||||||
/*
|
|
||||||
memcpy(&header.lightType, &buffer[start], 4);
|
memcpy(&header.lightType, &buffer[start], 4);
|
||||||
start += 4;
|
start += 4;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace GameLogic
|
||||||
start += 4;
|
start += 4;
|
||||||
|
|
||||||
memcpy(&header.intensity, &buffer[start], 4);
|
memcpy(&header.intensity, &buffer[start], 4);
|
||||||
start += 4;*/
|
start += 4;
|
||||||
|
|
||||||
size += start;
|
size += start;
|
||||||
|
|
||||||
|
|
|
@ -229,15 +229,15 @@ ICustomBody* API_Impl::AddTriangleMesh(const std::wstring fileName, ::Oyster::Ma
|
||||||
SimpleRigidBody* body = new SimpleRigidBody;
|
SimpleRigidBody* body = new SimpleRigidBody;
|
||||||
SimpleRigidBody::State state;
|
SimpleRigidBody::State state;
|
||||||
|
|
||||||
btBulletWorldImporter bulletFile;
|
btBulletWorldImporter bulletFile(0);
|
||||||
|
|
||||||
typedef std::codecvt_utf8<wchar_t> convert_typeX;
|
typedef std::codecvt_utf8<wchar_t> convert_typeX;
|
||||||
std::wstring_convert<convert_typeX, wchar_t> converterX;
|
std::wstring_convert<convert_typeX, wchar_t> converterX;
|
||||||
|
|
||||||
std::string bulletPath = converterX.to_bytes(fileName);
|
//std::string bulletPath = converterX.to_bytes();
|
||||||
|
|
||||||
// Add collision shape
|
// Add collision shape
|
||||||
bulletFile.loadFile(bulletPath.c_str());
|
bulletFile.loadFile("C:\\DV1477\\Git Repository\\Danbias\\Bin\\Content\\Worlds\\cgf\\structure_corporation.bullet");
|
||||||
btCollisionShape* collisionShape = bulletFile.getCollisionShapeByIndex(0);
|
btCollisionShape* collisionShape = bulletFile.getCollisionShapeByIndex(0);
|
||||||
body->SetCollisionShape(collisionShape);
|
body->SetCollisionShape(collisionShape);
|
||||||
|
|
||||||
|
@ -247,8 +247,8 @@ ICustomBody* API_Impl::AddTriangleMesh(const std::wstring fileName, ::Oyster::Ma
|
||||||
|
|
||||||
// Add rigid body
|
// Add rigid body
|
||||||
btVector3 fallInertia(0, 0, 0);
|
btVector3 fallInertia(0, 0, 0);
|
||||||
collisionShape->calculateLocalInertia(mass, fallInertia);
|
//collisionShape->calculateLocalInertia(mass, fallInertia);
|
||||||
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass, motionState, collisionShape, fallInertia);
|
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(0, motionState, collisionShape, fallInertia);
|
||||||
btRigidBody* rigidBody = new btRigidBody(rigidBodyCI);
|
btRigidBody* rigidBody = new btRigidBody(rigidBodyCI);
|
||||||
rigidBody->setFriction(staticFriction);
|
rigidBody->setFriction(staticFriction);
|
||||||
rigidBody->setRestitution(restitution);
|
rigidBody->setRestitution(restitution);
|
||||||
|
@ -264,7 +264,7 @@ ICustomBody* API_Impl::AddTriangleMesh(const std::wstring fileName, ::Oyster::Ma
|
||||||
state.dynamicFrictionCoeff = dynamicFriction;
|
state.dynamicFrictionCoeff = dynamicFriction;
|
||||||
state.staticFrictionCoeff = staticFriction;
|
state.staticFrictionCoeff = staticFriction;
|
||||||
state.quaternion = Quaternion(Float3(rotation.xyz), rotation.w);
|
state.quaternion = Quaternion(Float3(rotation.xyz), rotation.w);
|
||||||
state.mass = mass;
|
state.mass = 0;
|
||||||
|
|
||||||
body->SetState(state);
|
body->SetState(state);
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ void API_Impl::UpdateWorld()
|
||||||
simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity());
|
simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->dynamicsWorld->stepSimulation(this->timeStep, 10, this->timeStep);
|
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);
|
||||||
|
|
||||||
ICustomBody::State state;
|
ICustomBody::State state;
|
||||||
|
|
||||||
|
@ -314,23 +314,12 @@ void API_Impl::UpdateWorld()
|
||||||
ICustomBody* bodyA = (ICustomBody*)obA->getUserPointer();
|
ICustomBody* bodyA = (ICustomBody*)obA->getUserPointer();
|
||||||
ICustomBody* bodyB = (ICustomBody*)obB->getUserPointer();
|
ICustomBody* bodyB = (ICustomBody*)obB->getUserPointer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int numContacts = contactManifold->getNumContacts();
|
int numContacts = contactManifold->getNumContacts();
|
||||||
for (int j=0;j<numContacts;j++)
|
for (int j=0;j<numContacts;j++)
|
||||||
{
|
{
|
||||||
btManifoldPoint& pt = contactManifold->getContactPoint(j);
|
btManifoldPoint& pt = contactManifold->getContactPoint(j);
|
||||||
if (pt.getDistance()<0.f)
|
if (pt.getDistance()<0.f)
|
||||||
{
|
{
|
||||||
if(bodyA->GetState().mass == 40 && bodyB->GetState().centerPos == Float3::null)
|
|
||||||
{
|
|
||||||
const char* breakPoint = "STOP";
|
|
||||||
}
|
|
||||||
if(bodyB->GetState().mass == 40 && bodyA->GetState().centerPos == Float3::null)
|
|
||||||
{
|
|
||||||
const char* breakPoint = "STOP";
|
|
||||||
}
|
|
||||||
|
|
||||||
const btVector3& ptA = pt.getPositionWorldOnA();
|
const btVector3& ptA = pt.getPositionWorldOnA();
|
||||||
const btVector3& ptB = pt.getPositionWorldOnB();
|
const btVector3& ptB = pt.getPositionWorldOnB();
|
||||||
const btVector3& normalOnB = pt.m_normalWorldOnB;
|
const btVector3& normalOnB = pt.m_normalWorldOnB;
|
||||||
|
|
|
@ -63,7 +63,8 @@ void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
|
||||||
this->rigidBody->setFriction(state.staticFrictionCoeff);
|
this->rigidBody->setFriction(state.staticFrictionCoeff);
|
||||||
this->rigidBody->setRestitution(state.restitutionCoeff);
|
this->rigidBody->setRestitution(state.restitutionCoeff);
|
||||||
btVector3 fallInertia(0, 0, 0);
|
btVector3 fallInertia(0, 0, 0);
|
||||||
collisionShape->calculateLocalInertia(state.mass, fallInertia);
|
if(state.mass != 0)
|
||||||
|
collisionShape->calculateLocalInertia(state.mass, fallInertia);
|
||||||
this->rigidBody->setMassProps(state.mass, fallInertia);
|
this->rigidBody->setMassProps(state.mass, fallInertia);
|
||||||
|
|
||||||
this->state = state;
|
this->state = state;
|
||||||
|
@ -185,7 +186,8 @@ void SimpleRigidBody::SetAngularFactor(Float factor)
|
||||||
void SimpleRigidBody::SetMass(Float mass)
|
void SimpleRigidBody::SetMass(Float mass)
|
||||||
{
|
{
|
||||||
btVector3 fallInertia(0, 0, 0);
|
btVector3 fallInertia(0, 0, 0);
|
||||||
collisionShape->calculateLocalInertia(mass, fallInertia);
|
if(mass != 0)
|
||||||
|
collisionShape->calculateLocalInertia(mass, fallInertia);
|
||||||
this->rigidBody->setMassProps(mass, fallInertia);
|
this->rigidBody->setMassProps(mass, fallInertia);
|
||||||
this->state.mass = mass;
|
this->state.mass = mass;
|
||||||
}
|
}
|
||||||
|
@ -362,29 +364,25 @@ void SimpleRigidBody::PreStep (const btCollisionWorld* collisionWorld)
|
||||||
{
|
{
|
||||||
btTransform xform;
|
btTransform xform;
|
||||||
xform = this->rigidBody->getWorldTransform ();
|
xform = this->rigidBody->getWorldTransform ();
|
||||||
Float3 normalDown = -this->state.centerPos.GetNormalized();
|
//Float3 normalDown = -xform.getBasis().getColumn(1);
|
||||||
btVector3 down(normalDown.x, normalDown.y, normalDown.z);
|
btVector3 down(-xform.getBasis().getColumn(1));
|
||||||
btVector3 forward = xform.getBasis()[2];
|
btVector3 forward(xform.getBasis().getColumn(2));
|
||||||
down.normalize ();
|
down.normalize();
|
||||||
forward.normalize();
|
forward.normalize();
|
||||||
|
|
||||||
this->raySource[0] = xform.getOrigin();
|
this->raySource[0] = xform.getOrigin();
|
||||||
this->raySource[1] = xform.getOrigin();
|
this->raySource[1] = xform.getOrigin();
|
||||||
|
|
||||||
if(this->state.reach.y < 1.0f)
|
|
||||||
|
|
||||||
|
|
||||||
Float angle = acos(Float3(0, 1, 0).Dot(this->state.centerPos.GetNormalized()));
|
|
||||||
//down.setZ(-down.z());
|
|
||||||
btVector3 targetPlus = down * this->state.reach.y * btScalar(1.1);
|
|
||||||
|
|
||||||
if(this->state.mass == 40)
|
if(this->state.mass == 40)
|
||||||
{
|
{
|
||||||
const char* breakpoint = "STOP";
|
const char* breakPoint = "STOP!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btVector3 targetPlus = down*this->state.reach.y*btScalar(1.1);
|
||||||
|
|
||||||
this->rayTarget[0] = this->raySource[0] + targetPlus;
|
this->rayTarget[0] = this->raySource[0] + targetPlus;
|
||||||
this->rayTarget[1] = this->raySource[1] + forward * this->state.reach.y * btScalar(1.1);
|
targetPlus = this->raySource[1] + forward*this->state.reach.z*btScalar(1.1);
|
||||||
|
this->rayTarget[1] = btVector3(targetPlus.x(), targetPlus.y(), targetPlus.z());
|
||||||
|
|
||||||
class ClosestNotMe : public btCollisionWorld::ClosestRayResultCallback
|
class ClosestNotMe : public btCollisionWorld::ClosestRayResultCallback
|
||||||
{
|
{
|
||||||
|
@ -415,6 +413,10 @@ void SimpleRigidBody::PreStep (const btCollisionWorld* collisionWorld)
|
||||||
if (rayCallback.hasHit())
|
if (rayCallback.hasHit())
|
||||||
{
|
{
|
||||||
this->rayLambda[i] = rayCallback.m_closestHitFraction;
|
this->rayLambda[i] = rayCallback.m_closestHitFraction;
|
||||||
|
if(i == 1 && this->state.mass == 40)
|
||||||
|
{
|
||||||
|
btVector3 hitNormal = rayCallback.m_hitNormalWorld;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -423,11 +425,16 @@ void SimpleRigidBody::PreStep (const btCollisionWorld* collisionWorld)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float SimpleRigidBody::GetLambda() const
|
float SimpleRigidBody::GetLambdaUp() const
|
||||||
{
|
{
|
||||||
return this->rayLambda[0];
|
return this->rayLambda[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SimpleRigidBody::GetLambdaForward() const
|
||||||
|
{
|
||||||
|
return this->rayLambda[1];
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::MoveToLimbo()
|
void SimpleRigidBody::MoveToLimbo()
|
||||||
{
|
{
|
||||||
this->rigidBody->setCollisionFlags(this->rigidBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
|
this->rigidBody->setCollisionFlags(this->rigidBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
|
||||||
|
|
|
@ -68,7 +68,8 @@ namespace Oyster
|
||||||
|
|
||||||
void PreStep(const btCollisionWorld* collisionWorld);
|
void PreStep(const btCollisionWorld* collisionWorld);
|
||||||
|
|
||||||
float GetLambda() const;
|
float GetLambdaUp() const;
|
||||||
|
float GetLambdaForward() const;
|
||||||
|
|
||||||
void MoveToLimbo();
|
void MoveToLimbo();
|
||||||
void ReleaseFromLimbo();
|
void ReleaseFromLimbo();
|
||||||
|
|
|
@ -185,7 +185,8 @@ namespace Oyster
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual void SetCustomTag( void *ref ) = 0;
|
virtual void SetCustomTag( void *ref ) = 0;
|
||||||
|
|
||||||
virtual float GetLambda() const = 0;
|
virtual float GetLambdaUp() const = 0;
|
||||||
|
virtual float GetLambdaForward() const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue