Merge branch 'GameClient' of https://github.com/dean11/Danbias into GameServer
This commit is contained in:
commit
7f067b0010
|
@ -3,6 +3,7 @@
|
||||||
using namespace DanBias::Client;
|
using namespace DanBias::Client;
|
||||||
|
|
||||||
C_DynamicObj::C_DynamicObj(void)
|
C_DynamicObj::C_DynamicObj(void)
|
||||||
|
:C_Object()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
using namespace DanBias::Client;
|
using namespace DanBias::Client;
|
||||||
|
|
||||||
C_StaticObj::C_StaticObj(void)
|
C_StaticObj::C_StaticObj(void)
|
||||||
|
:C_Object()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,6 +217,8 @@ bool GameState::Render()
|
||||||
|
|
||||||
playerObject = this->privData->players.begin();
|
playerObject = this->privData->players.begin();
|
||||||
for( ; playerObject != this->privData->players.end(); ++playerObject )
|
for( ; playerObject != this->privData->players.end(); ++playerObject )
|
||||||
|
{
|
||||||
|
if(playerObject->second)
|
||||||
{
|
{
|
||||||
if( playerObject->second->getBRtype() == RB_Type_Cube)
|
if( playerObject->second->getBRtype() == RB_Type_Cube)
|
||||||
{
|
{
|
||||||
|
@ -227,6 +229,7 @@ bool GameState::Render()
|
||||||
Oyster::Graphics::API::RenderDebugSphere( playerObject->second->getRBWorld());
|
Oyster::Graphics::API::RenderDebugSphere( playerObject->second->getRBWorld());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
staticObject = this->privData->staticObjects->begin();
|
staticObject = this->privData->staticObjects->begin();
|
||||||
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
||||||
|
|
|
@ -33,7 +33,7 @@ bool GamingUI::Init()
|
||||||
// z value should be between 0.5 - 0.9 so that it will be behind other states
|
// z value should be between 0.5 - 0.9 so that it will be behind other states
|
||||||
// add textures and text
|
// add textures and text
|
||||||
this->plane = new Plane_UI(L"box_tex.png", Float3(0.5f, 0.0f, 0.5f), Float2(0.3f, 0.1f));
|
this->plane = new Plane_UI(L"box_tex.png", Float3(0.5f, 0.0f, 0.5f), Float2(0.3f, 0.1f));
|
||||||
this->text = new Text_UI(L"hej", Float3(0.5f,0.0f,0.1f), Float2(0.1f,0.1f));
|
this->text = new Text_UI(L"hej", Float3(0.3f,0.0f,0.1f), Float2(0.1f,0.1f));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,19 +56,14 @@ void AttatchmentMassDriver::Update(float dt)
|
||||||
//update position of heldObject if there is an object being held
|
//update position of heldObject if there is an object being held
|
||||||
if(hasObject)
|
if(hasObject)
|
||||||
{
|
{
|
||||||
//Oyster::Physics::ICustomBody::State state;
|
|
||||||
//state = heldObject->GetState();
|
|
||||||
Oyster::Math::Float3 ownerPos = owner->GetPosition();
|
Oyster::Math::Float3 ownerPos = owner->GetPosition();
|
||||||
Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState();
|
Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState();
|
||||||
Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2];
|
Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2];
|
||||||
up *= -0.3f;
|
up *= -0.3f;
|
||||||
Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*5);
|
Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*2);
|
||||||
|
|
||||||
//state.centerPos = pos;
|
|
||||||
heldObject->SetPosition(pos);
|
heldObject->SetPosition(pos);
|
||||||
heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
|
heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
|
||||||
|
|
||||||
//heldObject->SetState(state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +144,7 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
|
||||||
|
|
||||||
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
|
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*5;
|
Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*2;
|
||||||
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10);
|
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10);
|
||||||
|
|
||||||
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp);
|
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp);
|
||||||
|
|
|
@ -108,13 +108,31 @@ using namespace GameLogic;
|
||||||
obj.SetPosition(target);
|
obj.SetPosition(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExplosiveCrate::ExplosiveCrateCollision(Oyster::Physics::ICustomBody *rigidBodyCrate, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
void ExplosiveCrate::ExplosiveCrateCollision(Oyster::Physics::ICustomBody *objA, Oyster::Physics::ICustomBody *objB, Oyster::Math::Float kineticEnergyLoss)
|
||||||
{
|
{
|
||||||
int forceThreashHold = 200000; //how much force for the box to explode of the impact
|
|
||||||
|
|
||||||
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
|
|
||||||
|
|
||||||
switch (realObj->GetObjectType())
|
Object *realObjA = ((Object*)(objA->GetCustomTag()));
|
||||||
|
Object *realObjB = (Object*)objB->GetCustomTag(); //needs to be changed?
|
||||||
|
ExplosiveCrate* crate;
|
||||||
|
|
||||||
|
if(!realObjA)
|
||||||
|
return;
|
||||||
|
if(!realObjB)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//check who is player and who is the object
|
||||||
|
if(realObjA->GetObjectType() == ObjectSpecialType::ObjectSpecialType_RedExplosiveBox)
|
||||||
|
{
|
||||||
|
crate = (ExplosiveCrate*)realObjA;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crate = (ExplosiveCrate*)realObjB;
|
||||||
|
realObjB = realObjA;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (realObjB->GetObjectType())
|
||||||
{
|
{
|
||||||
case ObjectSpecialType::ObjectSpecialType_Generic:
|
case ObjectSpecialType::ObjectSpecialType_Generic:
|
||||||
break;
|
break;
|
||||||
|
@ -122,29 +140,15 @@ using namespace GameLogic;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType::ObjectSpecialType_Player:
|
case ObjectSpecialType::ObjectSpecialType_Player:
|
||||||
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
|
if(crate->hasExploaded) return;
|
||||||
|
Oyster::Math::Float3 pos = crate->GetRigidBody()->GetState().centerPos;
|
||||||
|
|
||||||
Oyster::Math::Float3 pos = rigidBodyCrate->GetState().centerPos;
|
|
||||||
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius);
|
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius);
|
||||||
|
|
||||||
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
|
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
|
||||||
|
crate->hasExploaded = true;
|
||||||
delete hitSphere;
|
delete hitSphere;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*if(kineticEnergyLoss > forceThreashHold)
|
|
||||||
{
|
|
||||||
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
|
|
||||||
|
|
||||||
|
|
||||||
Oyster::Math::Float3 pos = rigidBodyCrate->GetState().centerPos;
|
|
||||||
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius);
|
|
||||||
|
|
||||||
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
|
|
||||||
|
|
||||||
delete hitSphere;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExplosiveCrate::Explode(Oyster::Physics::ICustomBody *obj, void* args)
|
void ExplosiveCrate::Explode(Oyster::Physics::ICustomBody *obj, void* args)
|
||||||
|
@ -156,15 +160,16 @@ using namespace GameLogic;
|
||||||
Oyster::Math::Float3 hitObjectPos = obj->GetState().centerPos;
|
Oyster::Math::Float3 hitObjectPos = obj->GetState().centerPos;
|
||||||
Oyster::Math::Float3 force = (((hitObjectPos- explosionCenterPos).GetNormalized()) * ExplosionSource->pushForceMagnitude);
|
Oyster::Math::Float3 force = (((hitObjectPos- explosionCenterPos).GetNormalized()) * ExplosionSource->pushForceMagnitude);
|
||||||
|
|
||||||
|
|
||||||
if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player)
|
if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player)
|
||||||
{
|
{
|
||||||
Player *hitPlayer = (Player*)realObj;
|
Player *hitPlayer = (Player*)realObj;
|
||||||
|
hitPlayer->DamageLife(ExplosionSource->extraDamageOnCollision);
|
||||||
//hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision());
|
//hitPlayer->GetRigidBody()->ApplyImpulse(force);
|
||||||
//do shredding damage
|
//do shredding damage
|
||||||
}
|
}
|
||||||
|
|
||||||
realObj->GetRigidBody()->ApplyImpulse(force);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,11 +186,11 @@ using namespace GameLogic;
|
||||||
Oyster::Math::Float angularFactor = deltaPos.GetNormalized().Dot( (objPrevVel - playerPrevVel).GetNormalized());
|
Oyster::Math::Float angularFactor = deltaPos.GetNormalized().Dot( (objPrevVel - playerPrevVel).GetNormalized());
|
||||||
|
|
||||||
Oyster::Math::Float impactPower = deltaSpeed * angularFactor;
|
Oyster::Math::Float impactPower = deltaSpeed * angularFactor;
|
||||||
Oyster::Math::Float damageFactor = 0.1f;
|
Oyster::Math::Float damageFactor = 0.01f;
|
||||||
|
|
||||||
|
|
||||||
int damageDone = 0;
|
int damageDone = 0;
|
||||||
int forceThreashHold = 100; //FIX: balance this
|
int forceThreashHold = 30; //FIX: balance this
|
||||||
|
|
||||||
if(impactPower > forceThreashHold) //should only take damage if the force is high enough
|
if(impactPower > forceThreashHold) //should only take damage if the force is high enough
|
||||||
{
|
{
|
||||||
|
@ -198,7 +203,7 @@ using namespace GameLogic;
|
||||||
damageDone = (impactPower * obj.GetRigidBody()->GetState().mass)* damageFactor;
|
damageDone = (impactPower * obj.GetRigidBody()->GetState().mass)* damageFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//player.DamageLife(damageDone);
|
player.DamageLife(damageDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ ExplosiveCrate::ExplosiveCrate(void)
|
||||||
{
|
{
|
||||||
this->pushForceMagnitude = 0;
|
this->pushForceMagnitude = 0;
|
||||||
this->ExplosionRadius = 0;
|
this->ExplosionRadius = 0;
|
||||||
|
this->hasExploaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type, int objectID,Oyster::Math::Float extraDamageOnCollision, Oyster::Math::Float pushForceMagnitude, Oyster::Math::Float ExplosionRadius)
|
ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type, int objectID,Oyster::Math::Float extraDamageOnCollision, Oyster::Math::Float pushForceMagnitude, Oyster::Math::Float ExplosionRadius)
|
||||||
|
@ -15,6 +16,7 @@ ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpe
|
||||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||||
this->pushForceMagnitude = pushForceMagnitude;
|
this->pushForceMagnitude = pushForceMagnitude;
|
||||||
this->ExplosionRadius = ExplosionRadius;
|
this->ExplosionRadius = ExplosionRadius;
|
||||||
|
this->hasExploaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExplosiveCrate::~ExplosiveCrate(void)
|
ExplosiveCrate::~ExplosiveCrate(void)
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace GameLogic
|
||||||
private:
|
private:
|
||||||
Oyster::Math::Float pushForceMagnitude;
|
Oyster::Math::Float pushForceMagnitude;
|
||||||
Oyster::Math::Float ExplosionRadius;
|
Oyster::Math::Float ExplosionRadius;
|
||||||
|
bool hasExploaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,9 @@ Game::Game(void)
|
||||||
: initiated(false)
|
: initiated(false)
|
||||||
, onMoveFnc(0)
|
, onMoveFnc(0)
|
||||||
, onDisableFnc(0)
|
, onDisableFnc(0)
|
||||||
|
, onDamageTakenFnc(0)
|
||||||
|
, onRespawnFnc(0)
|
||||||
|
, onDeadFnc(0)
|
||||||
, frameTime(1.0f/120.0f)
|
, frameTime(1.0f/120.0f)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -156,7 +159,18 @@ void Game::SetSubscription(GameEvent::ObjectMovedFunction functionPointer)
|
||||||
void Game::SetSubscription(GameEvent::ObjectDisabledFunction functionPointer)
|
void Game::SetSubscription(GameEvent::ObjectDisabledFunction functionPointer)
|
||||||
{
|
{
|
||||||
this->onDisableFnc = functionPointer;
|
this->onDisableFnc = functionPointer;
|
||||||
|
}
|
||||||
|
void Game::SetHpSubscription(GameEvent::ObjectHpFunction functionPointer)
|
||||||
|
{
|
||||||
|
this->onDamageTakenFnc = functionPointer;
|
||||||
|
}
|
||||||
|
void Game::SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer)
|
||||||
|
{
|
||||||
|
this->onRespawnFnc = functionPointer;
|
||||||
|
}
|
||||||
|
void Game::SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer)
|
||||||
|
{
|
||||||
|
this->onDeadFnc = functionPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::Initiate()
|
bool Game::Initiate()
|
||||||
|
|
|
@ -80,6 +80,10 @@ namespace GameLogic
|
||||||
void SetFrameTimeLength( float seconds ) override;
|
void SetFrameTimeLength( float seconds ) override;
|
||||||
void SetSubscription(GameEvent::ObjectMovedFunction functionPointer) override;
|
void SetSubscription(GameEvent::ObjectMovedFunction functionPointer) override;
|
||||||
void SetSubscription(GameEvent::ObjectDisabledFunction functionPointer) override;
|
void SetSubscription(GameEvent::ObjectDisabledFunction functionPointer) override;
|
||||||
|
void SetHpSubscription(GameEvent::ObjectHpFunction functionPointer) override;
|
||||||
|
void SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer) override;
|
||||||
|
void SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer) override;
|
||||||
|
|
||||||
bool Initiate() override;
|
bool Initiate() override;
|
||||||
|
|
||||||
float GetFrameTime() const;
|
float GetFrameTime() const;
|
||||||
|
@ -93,7 +97,9 @@ namespace GameLogic
|
||||||
bool initiated;
|
bool initiated;
|
||||||
GameEvent::ObjectDisabledFunction onDisableFnc;
|
GameEvent::ObjectDisabledFunction onDisableFnc;
|
||||||
GameEvent::ObjectMovedFunction onMoveFnc;
|
GameEvent::ObjectMovedFunction onMoveFnc;
|
||||||
|
GameEvent::ObjectHpFunction onDamageTakenFnc;
|
||||||
|
GameEvent::ObjectRespawnedFunction onRespawnFnc;
|
||||||
|
GameEvent::ObjectDeadFunction onDeadFnc;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
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, float seconds); // Callback method that recieves and object
|
||||||
|
typedef void(*ObjectHpFunction)(IObjectData* object, float hp); // Callback method that sends obj HP
|
||||||
|
typedef void(*ObjectRespawnedFunction)(IObjectData* object, Oyster::Math::Float3 spawnPos ); // Callback method that sends spawnPos
|
||||||
|
typedef void(*ObjectDeadFunction)(IObjectData* object, float seconds); // Callback method that sends death timer
|
||||||
//etc...
|
//etc...
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -178,6 +181,9 @@ namespace GameLogic
|
||||||
* @param
|
* @param
|
||||||
*/
|
*/
|
||||||
virtual void SetSubscription(GameEvent::ObjectDisabledFunction functionPointer) = 0;
|
virtual void SetSubscription(GameEvent::ObjectDisabledFunction functionPointer) = 0;
|
||||||
|
virtual void SetHpSubscription(GameEvent::ObjectHpFunction functionPointer) = 0;
|
||||||
|
virtual void SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer) = 0;
|
||||||
|
virtual void SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,9 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_RedExplosiveBox:
|
case ObjectSpecialType_RedExplosiveBox:
|
||||||
{
|
{
|
||||||
Oyster::Math::Float dmg = 50;
|
Oyster::Math::Float dmg = 90;
|
||||||
Oyster::Math::Float force = 50;
|
Oyster::Math::Float force = 500;
|
||||||
Oyster::Math::Float radie = 50;
|
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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -422,5 +422,5 @@ 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ namespace GameLogic
|
||||||
|
|
||||||
int getNrOfDynamicObj();
|
int getNrOfDynamicObj();
|
||||||
Object* GetObj( int ID ) const;
|
Object* GetObj( int ID ) const;
|
||||||
|
|
||||||
static void PhysicsOnMoveLevel(const Oyster::Physics::ICustomBody *object);
|
static void PhysicsOnMoveLevel(const Oyster::Physics::ICustomBody *object);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)
|
||||||
key_strafeLeft = 0;
|
key_strafeLeft = 0;
|
||||||
key_jump = 0;
|
key_jump = 0;
|
||||||
invincibleCooldown = 0;
|
invincibleCooldown = 0;
|
||||||
|
this->deathTimeLeft = 0;
|
||||||
|
this->deathTime = 5;
|
||||||
|
|
||||||
this->previousPosition = Oyster::Math::Float3(0,0,0);
|
this->previousPosition = Oyster::Math::Float3(0,0,0);
|
||||||
|
|
||||||
|
@ -54,7 +56,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
|
||||||
key_strafeLeft = 0;
|
key_strafeLeft = 0;
|
||||||
key_jump = 0;
|
key_jump = 0;
|
||||||
invincibleCooldown = 0;
|
invincibleCooldown = 0;
|
||||||
|
this->deathTimeLeft = 0;
|
||||||
|
this->deathTime = 5;
|
||||||
this->previousPosition = Oyster::Math::Float3(0,0,0);
|
this->previousPosition = Oyster::Math::Float3(0,0,0);
|
||||||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
this->moveDir = Oyster::Math::Float3(0,0,0);
|
||||||
this->moveSpeed = 20;
|
this->moveSpeed = 20;
|
||||||
|
@ -74,8 +77,9 @@ Player::~Player(void)
|
||||||
|
|
||||||
void Player::BeginFrame()
|
void Player::BeginFrame()
|
||||||
{
|
{
|
||||||
|
if( this->playerState != PLAYER_STATE_DEAD)
|
||||||
|
{
|
||||||
weapon->Update(0.002f);
|
weapon->Update(0.002f);
|
||||||
//Object::BeginFrame();
|
|
||||||
|
|
||||||
Oyster::Math::Float maxSpeed = 30;
|
Oyster::Math::Float maxSpeed = 30;
|
||||||
|
|
||||||
|
@ -194,18 +198,22 @@ void Player::BeginFrame()
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// player is dead
|
||||||
//this->weapon->Update(0.01f);
|
// TODO move this logic to lvl
|
||||||
|
this->deathTimeLeft -= gameInstance->GetFrameTime();
|
||||||
|
if( this->deathTimeLeft <= 0)
|
||||||
|
{
|
||||||
|
Respawn( Oyster::Math::Float3( -50, 180, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::EndFrame()
|
void Player::EndFrame()
|
||||||
{
|
{
|
||||||
|
|
||||||
//Object::EndFrame();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Move(const PLAYER_MOVEMENT &movement)
|
void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||||
|
@ -258,10 +266,15 @@ void Player::UseWeapon(const WEAPON_FIRE &usage)
|
||||||
|
|
||||||
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
||||||
{
|
{
|
||||||
|
if( this->playerState == PLAYER_STATE_DEAD)
|
||||||
|
{
|
||||||
this->life = 100;
|
this->life = 100;
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||||
this->lookDir = Oyster::Math::Float4(1,0,0);
|
//this->lookDir = Oyster::Math::Float4(1,0,0);
|
||||||
this->rigidBody->SetPosition(spawnPoint);
|
this->rigidBody->SetPosition(spawnPoint);
|
||||||
|
this->gameInstance->onRespawnFnc( this, spawnPoint);
|
||||||
|
this->gameInstance->onDamageTakenFnc( this, this->life);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetLookDir(const Oyster::Math3D::Float3& lookDir)
|
void Player::SetLookDir(const Oyster::Math3D::Float3& lookDir)
|
||||||
|
@ -321,13 +334,17 @@ PLAYER_STATE Player::GetState() const
|
||||||
|
|
||||||
void Player::DamageLife(int damage)
|
void Player::DamageLife(int damage)
|
||||||
{
|
{
|
||||||
|
if( this->playerState != PLAYER_STATE_DEAD)
|
||||||
|
{
|
||||||
this->life -= damage;
|
this->life -= damage;
|
||||||
this->life = 0;
|
this->gameInstance->onDamageTakenFnc( this, this->life);
|
||||||
|
|
||||||
if(this->life <= 0)
|
if(this->life <= 0)
|
||||||
{
|
{
|
||||||
this->life = 0;
|
this->life = 0;
|
||||||
playerState = PLAYER_STATE_DEAD;
|
playerState = PLAYER_STATE_DEAD;
|
||||||
this->gameInstance->onDisableFnc(this, 0.0f);
|
this->deathTimeLeft = this->deathTime;
|
||||||
|
this->gameInstance->onDeadFnc(this, this->deathTimeLeft);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,8 @@ namespace GameLogic
|
||||||
|
|
||||||
Oyster::Math::Float rotationUp;
|
Oyster::Math::Float rotationUp;
|
||||||
|
|
||||||
|
float deathTime;
|
||||||
|
float deathTimeLeft;
|
||||||
|
|
||||||
bool hasTakenDamage;
|
bool hasTakenDamage;
|
||||||
float invincibleCooldown;
|
float invincibleCooldown;
|
||||||
|
|
|
@ -75,13 +75,15 @@ namespace GameLogic
|
||||||
}
|
}
|
||||||
Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
|
this->object_ID = p[1].value.netInt;
|
||||||
|
this->healthLost = p[2].value.netFloat;
|
||||||
}
|
}
|
||||||
Protocol_ObjectDamage(int id, float hp)
|
Protocol_ObjectDamage(int id, float hp)
|
||||||
{
|
{
|
||||||
this->protocol[0].value = protocol_Gameplay_ObjectDamage;
|
this->protocol[0].value = protocol_Gameplay_ObjectDamage;
|
||||||
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[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
object_ID = id;
|
object_ID = id;
|
||||||
|
|
|
@ -99,6 +99,9 @@ namespace DanBias
|
||||||
//Callback method recieving from gamelogic
|
//Callback method recieving from gamelogic
|
||||||
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, float seconds );
|
||||||
|
static void ObjectDamaged ( GameLogic::IObjectData* movedObject, float hp );
|
||||||
|
static void ObjectRespawned ( GameLogic::IObjectData* movedObject, Oyster::Math::Float3 spawnPos );
|
||||||
|
static void ObjectDead ( GameLogic::IObjectData* movedObject, float seconds );
|
||||||
|
|
||||||
//Private member variables
|
//Private member variables
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -90,7 +90,7 @@ using namespace DanBias;
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->gClients[i] )
|
if(this->gClients[i] && !this->gClients[i]->IsInvalid())
|
||||||
{
|
{
|
||||||
this->gClients[i]->UpdateClient();
|
this->gClients[i]->UpdateClient();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ using namespace DanBias;
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->gClients[i])
|
if(this->gClients[i] && !this->gClients[i]->IsInvalid())
|
||||||
{
|
{
|
||||||
this->gClients[i]->GetClient()->Send(message);
|
this->gClients[i]->GetClient()->Send(message);
|
||||||
returnValue = true;
|
returnValue = true;
|
||||||
|
@ -115,7 +115,7 @@ using namespace DanBias;
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->gClients[i] && this->gClients[i]->GetClient()->GetID() == ID)
|
if(this->gClients[i] && !this->gClients[i]->IsInvalid() && this->gClients[i]->GetClient()->GetID() == ID)
|
||||||
{
|
{
|
||||||
this->gClients[i]->GetClient()->Send(protocol);
|
this->gClients[i]->GetClient()->Send(protocol);
|
||||||
return true;
|
return true;
|
||||||
|
@ -150,7 +150,18 @@ using namespace DanBias;
|
||||||
{
|
{
|
||||||
GameSession::gameSession->Send(Protocol_ObjectDisable(movedObject->GetID(), seconds).GetProtocol());
|
GameSession::gameSession->Send(Protocol_ObjectDisable(movedObject->GetID(), seconds).GetProtocol());
|
||||||
}
|
}
|
||||||
|
void GameSession::ObjectDamaged( GameLogic::IObjectData* movedObject, float hp )
|
||||||
|
{
|
||||||
|
GameSession::gameSession->Send(Protocol_ObjectDamage(movedObject->GetID(), hp).GetProtocol());
|
||||||
|
}
|
||||||
|
void GameSession::ObjectRespawned( GameLogic::IObjectData* movedObject, Oyster::Math::Float3 spawnPos )
|
||||||
|
{
|
||||||
|
GameSession::gameSession->Send(Protocol_ObjectRespawn(movedObject->GetID(), spawnPos).GetProtocol());
|
||||||
|
}
|
||||||
|
void GameSession::ObjectDead( GameLogic::IObjectData* movedObject, float seconds )
|
||||||
|
{
|
||||||
|
GameSession::gameSession->Send(Protocol_ObjectDie(movedObject->GetID(), seconds).GetProtocol());
|
||||||
|
}
|
||||||
//*****************************************************//
|
//*****************************************************//
|
||||||
//****************** Protocol methods *****************//
|
//****************** Protocol methods *****************//
|
||||||
//******************************************************************************************************************//
|
//******************************************************************************************************************//
|
||||||
|
|
|
@ -36,8 +36,8 @@ GameSession::GameSession()
|
||||||
this->isCreated = false;
|
this->isCreated = false;
|
||||||
this->isRunning = false;
|
this->isRunning = false;
|
||||||
this->gameSession = this;
|
this->gameSession = this;
|
||||||
this->logicFrameTime = DELTA_TIME_20;
|
this->logicFrameTime = DELTA_TIME_60;
|
||||||
this->networkFrameTime = DELTA_TIME_20;
|
this->networkFrameTime = DELTA_TIME_60;
|
||||||
this->networkTimer.reset();
|
this->networkTimer.reset();
|
||||||
this->logicTimer.reset();
|
this->logicTimer.reset();
|
||||||
|
|
||||||
|
@ -108,6 +108,9 @@ 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.SetSubscription(GameSession::ObjectMove);
|
||||||
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
|
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
|
||||||
|
this->gameInstance.SetHpSubscription(GameSession::ObjectDamaged);
|
||||||
|
this->gameInstance.SetRespawnSubscription(GameSession::ObjectRespawned);
|
||||||
|
this->gameInstance.SetDeadSubscription(GameSession::ObjectDead);
|
||||||
this->gameInstance.SetFPS(60);
|
this->gameInstance.SetFPS(60);
|
||||||
|
|
||||||
this->description.clients.Clear();
|
this->description.clients.Clear();
|
||||||
|
|
|
@ -32,7 +32,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
||||||
GameServerAPI::GameSetGameMode(L"free-for-all");
|
GameServerAPI::GameSetGameMode(L"free-for-all");
|
||||||
GameServerAPI::GameSetGameName(L"DebugServer");
|
GameServerAPI::GameSetGameName(L"DebugServer");
|
||||||
GameServerAPI::GameSetGameTime(15);
|
GameServerAPI::GameSetGameTime(15);
|
||||||
GameServerAPI::GameSetMapName(L"2ofAll.bias");
|
GameServerAPI::GameSetMapName(L"erik_250.bias");
|
||||||
GameServerAPI::GameSetMaxClients(10);
|
GameServerAPI::GameSetMaxClients(10);
|
||||||
|
|
||||||
if(GameServerAPI::GameStart(true))
|
if(GameServerAPI::GameStart(true))
|
||||||
|
|
|
@ -291,7 +291,7 @@ void API_Impl::UpdateWorld()
|
||||||
simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity());
|
simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);
|
this->dynamicsWorld->stepSimulation(this->timeStep, 10, this->timeStep);
|
||||||
|
|
||||||
ICustomBody::State state;
|
ICustomBody::State state;
|
||||||
|
|
||||||
|
@ -314,9 +314,34 @@ 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();
|
||||||
|
for (int j=0;j<numContacts;j++)
|
||||||
|
{
|
||||||
|
btManifoldPoint& pt = contactManifold->getContactPoint(j);
|
||||||
|
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& ptB = pt.getPositionWorldOnB();
|
||||||
|
const btVector3& normalOnB = pt.m_normalWorldOnB;
|
||||||
|
|
||||||
bodyA->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f);
|
bodyA->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f);
|
||||||
bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f);
|
bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ SimpleRigidBody::SimpleRigidBody()
|
||||||
this->state.restitutionCoeff = 0.0f;
|
this->state.restitutionCoeff = 0.0f;
|
||||||
this->state.reach = Float3(0.0f, 0.0f, 0.0f);
|
this->state.reach = Float3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
this->collisionFlags = 0;
|
||||||
|
|
||||||
this->afterCollision = NULL;
|
this->afterCollision = NULL;
|
||||||
this->onMovement = NULL;
|
this->onMovement = NULL;
|
||||||
|
|
||||||
|
@ -85,7 +87,7 @@ void SimpleRigidBody::SetMotionState(btDefaultMotionState* motionState)
|
||||||
void SimpleRigidBody::SetRigidBody(btRigidBody* rigidBody)
|
void SimpleRigidBody::SetRigidBody(btRigidBody* rigidBody)
|
||||||
{
|
{
|
||||||
this->rigidBody = rigidBody;
|
this->rigidBody = rigidBody;
|
||||||
|
this->collisionFlags = rigidBody->getCollisionFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::SetSubscription(EventAction_AfterCollisionResponse function)
|
void SimpleRigidBody::SetSubscription(EventAction_AfterCollisionResponse function)
|
||||||
|
@ -421,7 +423,7 @@ void SimpleRigidBody::MoveToLimbo()
|
||||||
|
|
||||||
void SimpleRigidBody::ReleaseFromLimbo()
|
void SimpleRigidBody::ReleaseFromLimbo()
|
||||||
{
|
{
|
||||||
this->rigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
|
this->rigidBody->setCollisionFlags(this->collisionFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::SetPreviousVelocity(::Oyster::Math::Float3 velocity)
|
void SimpleRigidBody::SetPreviousVelocity(::Oyster::Math::Float3 velocity)
|
||||||
|
|
|
@ -93,6 +93,8 @@ namespace Oyster
|
||||||
btVector3 raySource[2];
|
btVector3 raySource[2];
|
||||||
btVector3 rayTarget[2];
|
btVector3 rayTarget[2];
|
||||||
btScalar rayLambda[2];
|
btScalar rayLambda[2];
|
||||||
|
|
||||||
|
int collisionFlags;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue