Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
lindaandersson 2014-02-14 11:07:11 +01:00
commit 9038277a2c
12 changed files with 30 additions and 74 deletions

View File

@ -8,7 +8,6 @@
#include "CollisionManager.h" #include "CollisionManager.h"
#include "JumpPad.h" #include "JumpPad.h"
#include "Portal.h" #include "Portal.h"
#include "CrystalFormation.h"
#include "ExplosiveCrate.h" #include "ExplosiveCrate.h"
using namespace Oyster; using namespace Oyster;
@ -47,7 +46,7 @@ using namespace GameLogic;
break; break;
case ObjectSpecialType::ObjectSpecialType_CrystalFormation: case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,((CrystalFormation*)realObj)->getShreddingDamage()); PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->getExtraDamageOnCollision());
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; //player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
break; break;
} }
@ -97,7 +96,6 @@ using namespace GameLogic;
int forceThreashHold = 200000; //how much force for the box to explode of the impact int forceThreashHold = 200000; //how much force for the box to explode of the impact
if(kineticEnergyLoss > forceThreashHold) if(kineticEnergyLoss > forceThreashHold)
{ {
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag()); ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
@ -117,16 +115,19 @@ using namespace GameLogic;
Object *realObj = (Object*)obj->GetCustomTag(); Object *realObj = (Object*)obj->GetCustomTag();
ExplosiveCrate* ExplosionSource = ((ExplosiveCrate*)args); ExplosiveCrate* ExplosionSource = ((ExplosiveCrate*)args);
Oyster::Math::Float3 explosionCenterPos = ExplosionSource->GetPosition();
Oyster::Math::Float3 hitObjectPos = obj->GetState().centerPos;
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->shreddingDamage); hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision());
//do shredding damage //do shredding damage
} }
realObj->GetRigidBody()->ApplyImpulse(ExplosionSource->pushForce); realObj->GetRigidBody()->ApplyImpulse(force);
} }

View File

@ -1,25 +0,0 @@
#include "CrystalFormation.h"
using namespace GameLogic;
CrystalFormation::CrystalFormation(void)
:StaticObject()
{
this->shreddingDamage = 0;
}
CrystalFormation::CrystalFormation(Oyster::Physics::ICustomBody *rigidBody, int objectID,Oyster::Math::Float shreddingDamage)
:StaticObject(rigidBody, CrystalFormation::DefaultCollisionAfter, ObjectSpecialType::ObjectSpecialType_CrystalFormation, objectID)
{
this->shreddingDamage = shreddingDamage;
}
CrystalFormation::~CrystalFormation(void)
{
}
Oyster::Math::Float CrystalFormation::getShreddingDamage()
{
return this->shreddingDamage;
}

View File

@ -1,22 +0,0 @@
#ifndef CRYSTALFORMATION_H
#define CRYSTALFORMATION_H
#include "StaticObject.h"
namespace GameLogic
{
class CrystalFormation : public StaticObject
{
public:
CrystalFormation(void);
CrystalFormation(Oyster::Physics::ICustomBody *rigidBody
,int objectID,Oyster::Math::Float shreddingDamage);
~CrystalFormation(void);
Oyster::Math::Float getShreddingDamage();
private:
Oyster::Math::Float shreddingDamage;
};
}
#endif

View File

@ -5,16 +5,15 @@ using namespace GameLogic;
ExplosiveCrate::ExplosiveCrate(void) ExplosiveCrate::ExplosiveCrate(void)
:DynamicObject() :DynamicObject()
{ {
this->shreddingDamage = 0; this->pushForceMagnitude = 0;
this->pushForce = 0;
this->ExplosionRadius = 0; this->ExplosionRadius = 0;
} }
ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type, int objectID,Oyster::Math::Float shreddingDamage, Oyster::Math::Float3 pushForce, 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)
:DynamicObject(rigidBody,ExplosiveCrate::ExplosiveCrateCollision, type, objectID) :DynamicObject(rigidBody,ExplosiveCrate::ExplosiveCrateCollision, type, objectID)
{ {
this->shreddingDamage = shreddingDamage; this->extraDamageOnCollision = extraDamageOnCollision;
this->pushForce = pushForce; this->pushForceMagnitude = pushForceMagnitude;
this->ExplosionRadius = ExplosionRadius; this->ExplosionRadius = ExplosionRadius;
} }

View File

@ -8,7 +8,7 @@ namespace GameLogic
public: public:
ExplosiveCrate(void); ExplosiveCrate(void);
ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type,int objectID,Oyster::Math::Float shreddingDamage, Oyster::Math::Float3 pushForce, Oyster::Math::Float ExplosionRadius); ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type,int objectID,Oyster::Math::Float extraDamageOnCollision, Oyster::Math::Float pushForceMagnitude, Oyster::Math::Float ExplosionRadius);
~ExplosiveCrate(void); ~ExplosiveCrate(void);
@ -16,9 +16,10 @@ namespace GameLogic
static void Explode(Oyster::Physics::ICustomBody *obj, void* args); static void Explode(Oyster::Physics::ICustomBody *obj, void* args);
private: private:
Oyster::Math::Float shreddingDamage; Oyster::Math::Float pushForceMagnitude;
Oyster::Math::Float3 pushForce;
Oyster::Math::Float ExplosionRadius; Oyster::Math::Float ExplosionRadius;
}; };
} }
#endif #endif

View File

@ -176,7 +176,6 @@
<ClInclude Include="AttatchmentMassDriver.h" /> <ClInclude Include="AttatchmentMassDriver.h" />
<ClInclude Include="AttatchmentSocket.h" /> <ClInclude Include="AttatchmentSocket.h" />
<ClInclude Include="CollisionManager.h" /> <ClInclude Include="CollisionManager.h" />
<ClInclude Include="CrystalFormation.h" />
<ClInclude Include="DynamicObject.h" /> <ClInclude Include="DynamicObject.h" />
<ClInclude Include="ExplosiveCrate.h" /> <ClInclude Include="ExplosiveCrate.h" />
<ClInclude Include="Game.h" /> <ClInclude Include="Game.h" />
@ -204,7 +203,6 @@
<ClCompile Include="AttatchmentMassDriver.cpp" /> <ClCompile Include="AttatchmentMassDriver.cpp" />
<ClCompile Include="AttatchmentSocket.cpp" /> <ClCompile Include="AttatchmentSocket.cpp" />
<ClCompile Include="CollisionManager.cpp" /> <ClCompile Include="CollisionManager.cpp" />
<ClCompile Include="CrystalFormation.cpp" />
<ClCompile Include="DynamicObject.cpp" /> <ClCompile Include="DynamicObject.cpp" />
<ClCompile Include="ExplosiveCrate.cpp" /> <ClCompile Include="ExplosiveCrate.cpp" />
<ClCompile Include="Game.cpp" /> <ClCompile Include="Game.cpp" />

View File

@ -43,12 +43,6 @@ namespace GameLogic
Oyster::Math::Float3 pushForce; Oyster::Math::Float3 pushForce;
}; };
struct ExplosionData
{
Oyster::Math::Float3 pushForce;
Oyster::Math::Float3 ShreddingDamage;
};
}; };

View File

@ -2,7 +2,6 @@
#include "CollisionManager.h" #include "CollisionManager.h"
#include "Game.h" #include "Game.h"
#include "JumpPad.h" #include "JumpPad.h"
#include "CrystalFormation.h"
#include "ExplosiveCrate.h" #include "ExplosiveCrate.h"
#include "Portal.h" #include "Portal.h"
using namespace GameLogic; using namespace GameLogic;

View File

@ -28,6 +28,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfte
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter)); this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
this->type = type; this->type = type;
this->objectID = objectID; this->objectID = objectID;
this->extraDamageOnCollision = 0;
this->rigidBody->SetCustomTag(this); this->rigidBody->SetCustomTag(this);
} }
@ -38,6 +39,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICusto
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter)); this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
this->type = type; this->type = type;
this->objectID = objectID; this->objectID = objectID;
this->extraDamageOnCollision = 0;
this->rigidBody->SetCustomTag(this); this->rigidBody->SetCustomTag(this);
} }
@ -103,4 +105,10 @@ Oyster::Math::Float4x4 Object::GetOrientation()
Oyster::Physics::ICustomBody::State state; Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState(); state = this->rigidBody->GetState();
return state.GetOrientation(); return state.GetOrientation();
}
Oyster::Math::Float Object::getExtraDamageOnCollision()
{
return this->extraDamageOnCollision;
} }

View File

@ -31,6 +31,8 @@ namespace GameLogic
Oyster::Math::Float3 GetScale() override; Oyster::Math::Float3 GetScale() override;
Oyster::Math::Float4x4 GetOrientation() override; Oyster::Math::Float4x4 GetOrientation() override;
Oyster::Math::Float getExtraDamageOnCollision();
// API overrides // API overrides
@ -58,6 +60,8 @@ namespace GameLogic
ObjectSpecialType type; ObjectSpecialType type;
int objectID; int objectID;
Oyster::Math::Float extraDamageOnCollision;
}; };
} }

View File

@ -10,8 +10,8 @@ Portal::Portal(void)
} }
Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit) Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit)
:StaticObject(rigidBody, EventOnCollision, type, objectID) :StaticObject(rigidBody, Portal::PortalActivated, type, objectID)
{ {
this->portalExit = portalExit; this->portalExit = portalExit;
} }

View File

@ -8,8 +8,7 @@ namespace GameLogic
public: public:
Portal(void); Portal(void);
Portal(Oyster::Physics::ICustomBody *rigidBody Portal(Oyster::Physics::ICustomBody *rigidBody
,void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
,ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit); ,ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit);
~Portal(void); ~Portal(void);