From 25b0162b59c51f0422323e367c4994df6e4be29c Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Fri, 14 Feb 2014 13:54:50 +0100 Subject: [PATCH] GL - explosive crate testing --- Code/Game/GameLogic/CollisionManager.cpp | 24 ++++++++++++++++++-- Code/Game/GameLogic/Game_PlayerData.cpp | 4 ++-- Code/Game/GameLogic/Level.cpp | 6 +---- Code/Game/GameLogic/Player.cpp | 29 ------------------------ 4 files changed, 25 insertions(+), 38 deletions(-) diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 80562b2c..0b817975 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -95,9 +95,16 @@ using namespace GameLogic; { int forceThreashHold = 200000; //how much force for the box to explode of the impact + Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed? - if(kineticEnergyLoss > forceThreashHold) + switch (realObj->GetObjectType()) { + case ObjectSpecialType::ObjectSpecialType_Generic: + break; + case ObjectSpecialType::ObjectSpecialType_StandardBox: + + break; + case ObjectSpecialType::ObjectSpecialType_Player: ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag()); @@ -107,7 +114,20 @@ using namespace GameLogic; Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode); delete hitSphere; + 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) @@ -123,7 +143,7 @@ using namespace GameLogic; { Player *hitPlayer = (Player*)realObj; - hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision()); + //hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision()); //do shredding damage } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 275866b9..1b725b02 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -17,12 +17,12 @@ Game::PlayerData::PlayerData() //sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0); //create rigid body - Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCharacter(2.0f, 0.5f, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); + Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); rigidBody->SetAngularFactor(0.0f); //create player with this rigid body this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0); - this->player->GetRigidBody()->SetCustomTag(this); + //this->player->GetRigidBody()->SetCustomTag(this); player->EndFrame(); } Game::PlayerData::PlayerData(int playerID,int teamID) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 11c8324e..1b1692d9 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -57,11 +57,7 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) break; case ObjectSpecialType_StandardBox: { - int dmg = 50; - Oyster::Math::Float force = 50; - int radie = 10; - gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie); - //gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); } break; case ObjectSpecialType_RedExplosiveBox: diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index b6888bf2..625a0663 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -17,20 +17,6 @@ Player::Player() 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) { - this->rigidBody = rigidBody; - - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,400,0); - - Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f); - Oyster::Math::Float mass = 60; - Oyster::Math::Float restitutionCoeff = 0.5; - Oyster::Math::Float frictionCoeff_Static = 0.4; - Oyster::Math::Float frictionCoeff_Dynamic = 0.3; - - - this->rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); - this->rigidBody->SetAngularFactor(0.0f); - weapon = new Weapon(2,this); this->life = 100; @@ -52,20 +38,6 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision) 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) { - this->rigidBody = rigidBody; - - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,400,0); - - Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f); - Oyster::Math::Float mass = 60; - Oyster::Math::Float restitutionCoeff = 0.5; - Oyster::Math::Float frictionCoeff_Static = 0.4; - Oyster::Math::Float frictionCoeff_Dynamic = 0.3; - - - this->rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); - this->rigidBody->SetAngularFactor(0.0f); - weapon = new Weapon(2,this); this->life = 100; @@ -81,7 +53,6 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom this->moveDir = Oyster::Math::Float3(0,0,0); this->moveSpeed = 100; this->previousMoveSpeed = Oyster::Math::Float3(0,0,0); - } Player::~Player(void)