diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index d5311ece..24bb6bba 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -6,12 +6,14 @@ #include "AttatchmentMassDriver.h" #include "Game.h" #include "CollisionManager.h" +#include "JumpPad.h" using namespace Oyster; using namespace GameLogic; void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss); + void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force); //Physics::ICustomBody::SubscriptMessage void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) @@ -41,6 +43,34 @@ using namespace GameLogic; //return Physics::ICustomBody::SubscriptMessage_none; } + + void JumpPad::JumpPadActivated(Oyster::Physics::ICustomBody *rigidBodyJumpPad, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) + { + JumpPad *jumpPad = (JumpPad*)(rigidBodyJumpPad->GetCustomTag()); + Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed? + + switch (realObj->GetObjectType()) + { + case OBJECT_TYPE::OBJECT_TYPE_GENERIC: + break; + case OBJECT_TYPE::OBJECT_TYPE_BOX: + break; + case OBJECT_TYPE::OBJECT_TYPE_PLAYER: + SendObjectFlying(*obj, jumpPad->pushForce); + break; + case OBJECT_TYPE::OBJECT_TYPE_WORLD: + break; + } + } + + void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force) + { + Oyster::Physics::ICustomBody::State state; + + state = obj.GetState(); + state.ApplyLinearImpulse(force); + obj.SetState(state); + } void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss) diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index d9973821..6aecc900 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -42,7 +42,7 @@ GameAPI& GameAPI::Instance() Game::Game(void) : initiated(false) , onMoveFnc(0) - , onDeadFnc(0) + , onDisableFnc(0) , frameTime(1.0f/120.0f) {} @@ -151,7 +151,7 @@ void Game::SetSubscription(GameEvent::ObjectEventFunctionType type, GameEvent::O this->onMoveFnc = functionPointer; break; case GameLogic::GameEvent::ObjectEventFunctionType_OnDead: - this->onDeadFnc = functionPointer; + this->onDisableFnc = functionPointer; break; } @@ -183,6 +183,6 @@ void Game::PhysicsOnMove(const ICustomBody *object) } void Game::PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer proto) { - if(gameInstance.onDeadFnc) gameInstance.onDeadFnc(0); + if(gameInstance.onDisableFnc) gameInstance.onDisableFnc(0); } diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h index 55f3e4cf..ddcfc086 100644 --- a/Code/Game/GameLogic/Game.h +++ b/Code/Game/GameLogic/Game.h @@ -73,16 +73,14 @@ namespace GameLogic float GetFrameTime() const; - private: static void PhysicsOnMove(const Oyster::Physics::ICustomBody *object); static void PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer proto); - private: Utility::DynamicMemory::DynamicArray players; LevelData* level; float frameTime; bool initiated; - GameEvent::ObjectEventFunction onDeadFnc; + GameEvent::ObjectEventFunction onDisableFnc; GameEvent::ObjectEventFunction onMoveFnc; }; diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj index 809c82b5..674773bf 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -183,6 +183,7 @@ + @@ -206,6 +207,7 @@ + diff --git a/Code/Game/GameLogic/JumpPad.cpp b/Code/Game/GameLogic/JumpPad.cpp new file mode 100644 index 00000000..c60e248c --- /dev/null +++ b/Code/Game/GameLogic/JumpPad.cpp @@ -0,0 +1,21 @@ +#include "JumpPad.h" +#include "PhysicsAPI.h" + +using namespace GameLogic; +using namespace Oyster::Physics; + +JumpPad::JumpPad(void) +{ +} + +JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce) + :StaticObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +{ + +} + + + +JumpPad::~JumpPad(void) +{ +} diff --git a/Code/Game/GameLogic/JumpPad.h b/Code/Game/GameLogic/JumpPad.h new file mode 100644 index 00000000..b9fe2253 --- /dev/null +++ b/Code/Game/GameLogic/JumpPad.h @@ -0,0 +1,26 @@ +#ifndef JUMPPAD_H +#define JUMPPAD_H +#include "StaticObject.h" +namespace GameLogic +{ + class JumpPad : public StaticObject + { + public: + JumpPad(void); + + JumpPad(Oyster::Physics::ICustomBody *rigidBody + ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter) + ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss) + ,OBJECT_TYPE type, Oyster::Math::Float3 pushForce); + + ~JumpPad(void); + + static void JumpPadActivated(Oyster::Physics::ICustomBody *rigidBodyJumpPad, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); + + private: + Oyster::Math::Float3 pushForce; + + + }; +} +#endif diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 29fc77cb..e9510f57 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -60,8 +60,7 @@ Player::~Player(void) void Player::BeginFrame() { - weapon->Update(0.002f); - //if(playerState == PLAYER_STATE_DEAD) Respawn(Oyster::Math::Float3(0,308,0)); + weapon->Update(0.002f); Object::BeginFrame(); } @@ -205,7 +204,7 @@ void Player::DamageLife(int damage) { this->life = 0; playerState = PLAYER_STATE_DEAD; - //do stuff that makes you dead + this->gameInstance->onDisableFnc(this); } }