GameLogic - Modified some names and cleand up some junk

This commit is contained in:
dean11 2014-02-19 10:36:45 +01:00
parent 484b055338
commit 0e23bcfc82
4 changed files with 43 additions and 90 deletions

View File

@ -46,7 +46,7 @@ using namespace GameLogic;
break;
case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->getExtraDamageOnCollision());
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->GetExtraDamageOnCollision());
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
break;
}
@ -181,7 +181,7 @@ using namespace GameLogic;
}
}
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
return Physics::ICustomBody::SubscriptMessage_none;
}

View File

@ -26,14 +26,14 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
{
case ObjectSpecialType_None:
{
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_Sky:
{
float skySize = ((SkyAttributes*)obj)->skySize;
//gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
//gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_World:
@ -44,21 +44,21 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
float worldSize = ((WorldAttributes*)obj)->worldSize;
float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize;
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_Building:
{
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
case ObjectSpecialType_Stone:
{
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_StandardBox:
{
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_RedExplosiveBox:
@ -75,24 +75,24 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
// break;
case ObjectSpecialType_SpikeBox:
{
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_Spike:
{
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_CrystalFormation:
{
int dmg = 50;
//gameObj = new Crystal(rigidBody);
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_CrystalShard:
{
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
case ObjectSpecialType_JumpPad:
@ -122,12 +122,12 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
break;
case ObjectSpecialType_Generic:
{
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
default:
{
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
}
break;
}
@ -355,14 +355,14 @@ void Level::InitiateLevel(float radius)
{
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
}
/*offset += nrOfBoxex;
for(int i =0; i< nrOfBoxex; i ++)
{
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0,5, -605 -( i*5)), 5);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
}
@ -371,7 +371,7 @@ void Level::InitiateLevel(float radius)
{
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(200, 620 + ( i*7), 0), 5);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
}
offset += nrOfBoxex;
@ -379,18 +379,18 @@ void Level::InitiateLevel(float radius)
{
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(5, 605 + i*5, 0), 5);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
}*/
// add crystal
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f);
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
// add house
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f);
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++));
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultOnCollision, ObjectSpecialType_Generic, idCount++));
// add jumppad

View File

@ -15,11 +15,11 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance());
Object::Object()
{
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
this->type = ObjectSpecialType_Unknown;
this->objectID = -1;
this->scale = Float3(1.0f, 1.0f, 1.0f);
}
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
@ -48,39 +48,12 @@ Object::~Object(void)
}
ObjectSpecialType Object::GetObjectType() const
void Object::SetOnCollision(OnCollisionCallback func)
{
return this->type;
}
int Object::GetID() const
{
return this->objectID;
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(func));
}
Oyster::Physics::ICustomBody* Object::GetRigidBody()
{
return this->rigidBody;
}
void Object::BeginFrame()
{
}
// update physic
void Object::EndFrame()
{
}
void Object::setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter))
{
//this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(collisionFuncBefore));
}
void Object::setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss))
{
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
}
Oyster::Math::Float3 Object::GetPosition()
{
@ -94,21 +67,9 @@ Oyster::Math::Quaternion Object::GetRotation()
state = this->rigidBody->GetState();
return state.quaternion;
}
Oyster::Math::Float3 Object::GetScale()
{
Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState();
return Float3();
}
Oyster::Math::Float4x4 Object::GetOrientation()
{
Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState();
return state.GetOrientation();
}
Oyster::Math::Float Object::getExtraDamageOnCollision()
{
return this->extraDamageOnCollision;
}

View File

@ -17,46 +17,38 @@ namespace GameLogic
class Object :public IObjectData
{
public:
Object();
typedef Oyster::Physics::ICustomBody::SubscriptMessage (*OnCollisionCallback)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss);
public:
Object();
Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
~Object(void);
ObjectSpecialType GetObjectType() const override;
int GetID() const override;
void setID(int id);
Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override;
Oyster::Math::Float4x4 GetOrientation() override;
inline ObjectSpecialType GetObjectType() const override { return this->type; }
inline int GetID() const override { return this->objectID; }
inline Oyster::Math::Float3 GetScale() override { return this->scale; }
inline Oyster::Math::Float3 GetPosition() override;
inline Oyster::Math::Quaternion GetRotation() override;
inline Oyster::Math::Float4x4 GetOrientation() override;
inline Oyster::Physics::ICustomBody* GetRigidBody() { return this->rigidBody; }
inline Oyster::Math::Float GetExtraDamageOnCollision() { return this->extraDamageOnCollision; }
Oyster::Math::Float getExtraDamageOnCollision();
virtual void BeginFrame() { };
virtual void EndFrame() { };
// API overrides
Oyster::Physics::ICustomBody* GetRigidBody();
virtual void BeginFrame();
virtual void EndFrame();
void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter));
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
public: //TODO: Hax This should be private when level is dynamic
void SetOnCollision(OnCollisionCallback func);
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
protected:
Oyster::Physics::ICustomBody *rigidBody;
static const Game* gameInstance;
Oyster::Math::Float3 currLook;
Oyster::Math::Float3 newLook;
Oyster::Math::Float3 lookDirection; //The look direction for the camera
Oyster::Math::Float3 forwardDirection; //The forward direction of the rigid body
Oyster::Math::Float3 scale; //The scale of both rigid body and the mesh
ObjectSpecialType type;
int objectID;