diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp
index 18324149..c6639953 100644
--- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp
+++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp
@@ -1,4 +1,5 @@
#include "AttatchmentMassDriver.h"
+#include "PhysicsAPI.h"
using namespace GameLogic;
@@ -19,11 +20,20 @@ struct AttatchmentMassDriver::PrivateData
AttatchmentMassDriver::AttatchmentMassDriver(void)
{
+ myData = new PrivateData();
+ this->owner = 0;
+}
+
+AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
+{
+ myData = new PrivateData();
+ this->owner = &owner;
}
AttatchmentMassDriver::~AttatchmentMassDriver(void)
{
+ delete myData;
}
/********************************************************
@@ -31,7 +41,17 @@ AttatchmentMassDriver::~AttatchmentMassDriver(void)
********************************************************/
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput)
{
- ForcePush(fireInput);
+ //switch case to determin what functionallity to use in the attatchment
+ switch (fireInput)
+ {
+ case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
+ ForcePush(fireInput);
+ break;
+ case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
+ ForcePull(fireInput);
+ break;
+ }
+
}
/********************************************************
@@ -39,7 +59,13 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInp
********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput)
{
-
+ //create coneRigidBody that will then collide with object and push them in the aimed direction
+}
+
+
+void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &fireInput)
+{
+ Oyster::Physics::API::Instance().ApplyForceAt(owner->GetRigidBody(), owner->GetRigidBody()->GetCenter(), owner->GetLookDir() * 100);
}
diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.h b/Code/Game/GameLogic/AttatchmentMassDriver.h
index bc95c327..879938fe 100644
--- a/Code/Game/GameLogic/AttatchmentMassDriver.h
+++ b/Code/Game/GameLogic/AttatchmentMassDriver.h
@@ -8,6 +8,7 @@ namespace GameLogic
{
public:
AttatchmentMassDriver(void);
+ AttatchmentMassDriver(Player &owner);
~AttatchmentMassDriver(void);
@@ -15,6 +16,7 @@ namespace GameLogic
private:
void ForcePush(const WEAPON_FIRE &fireInput);
+ void ForcePull(const WEAPON_FIRE &fireInput);
private:
struct PrivateData;
diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp
index b19c7de3..3d1af2a1 100644
--- a/Code/Game/GameLogic/CollisionManager.cpp
+++ b/Code/Game/GameLogic/CollisionManager.cpp
@@ -1,5 +1,4 @@
#include "CollisionManager.h"
-#include "RefManager.h"
#include "PhysicsAPI.h"
#include "Object.h"
#include "DynamicObject.h"
@@ -13,15 +12,18 @@ namespace GameLogic
namespace CollisionManager
{
+ void PlayerVBox(Player &player, DynamicObject &box);
+
+
Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj)
{
- Player *player = ((Player*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyPlayer));
- Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj);
+ Player *player = ((Player*)(rigidBodyPlayer->gameObjectRef));
+ Object *realObj = (Object*)obj->gameObjectRef;
switch (realObj->GetType())
{
case OBJECT_TYPE_BOX:
- //PlayerVBox(*player,(*(DynamicObject*) realObj));
+ PlayerVBox(*player,(*(DynamicObject*) realObj));
break;
case OBJECT_TYPE_PLAYER:
@@ -31,15 +33,15 @@ namespace GameLogic
return Physics::ICustomBody::SubscriptMessage_none;
}
- /* void PlayerVBox(Player &player, DynamicObject &box)
+ void PlayerVBox(Player &player, DynamicObject &box)
{
- spela ljud? ta skada? etc etc
- }*/
+ player.DamageLife(20);
+ }
Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj)
{
- DynamicObject *box = ((DynamicObject*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyBox));
- Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj);
+ DynamicObject *box = (DynamicObject*)rigidBodyBox->gameObjectRef;
+ Object *realObj = (Object*)obj->gameObjectRef;
switch (realObj->GetType())
{
diff --git a/Code/Game/GameLogic/CollisionManager.h b/Code/Game/GameLogic/CollisionManager.h
index 86a05906..d19ce8e3 100644
--- a/Code/Game/GameLogic/CollisionManager.h
+++ b/Code/Game/GameLogic/CollisionManager.h
@@ -3,8 +3,6 @@
#include "Object.h"
#include "PhysicsAPI.h"
-//#include "DynamicObject.h"
-//#include "Player.h"
namespace GameLogic
{
diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj
index 03430feb..13491d28 100644
--- a/Code/Game/GameLogic/GameLogic.vcxproj
+++ b/Code/Game/GameLogic/GameLogic.vcxproj
@@ -176,7 +176,6 @@
-
@@ -191,7 +190,6 @@
-
diff --git a/Code/Game/GameLogic/IAttatchment.cpp b/Code/Game/GameLogic/IAttatchment.cpp
index c1e2a997..4b0b1961 100644
--- a/Code/Game/GameLogic/IAttatchment.cpp
+++ b/Code/Game/GameLogic/IAttatchment.cpp
@@ -3,22 +3,6 @@
using namespace GameLogic;
-struct IAttatchment::PrivateData
-{
- PrivateData()
- {
-
- }
-
- ~PrivateData()
- {
-
- }
-
-
-
-}myData;
-
IAttatchment::IAttatchment(void)
{
}
diff --git a/Code/Game/GameLogic/IAttatchment.h b/Code/Game/GameLogic/IAttatchment.h
index c134026f..0b6cb061 100644
--- a/Code/Game/GameLogic/IAttatchment.h
+++ b/Code/Game/GameLogic/IAttatchment.h
@@ -1,6 +1,7 @@
#ifndef IATTATCHMENT_H
#define IATTATCHMENT_H
#include "GameLogicStates.h"
+#include "Player.h"
namespace GameLogic
{
@@ -16,9 +17,10 @@ namespace GameLogic
virtual void UseAttatchment(const WEAPON_FIRE &fireInput) = 0;
- private:
- struct PrivateData;
- PrivateData *myData;
+ private:
+
+ protected:
+ Player *owner;
};
}
diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp
index 7eb4b57f..dcd32bf1 100644
--- a/Code/Game/GameLogic/Object.cpp
+++ b/Code/Game/GameLogic/Object.cpp
@@ -1,6 +1,6 @@
#include "Object.h"
#include "OysterMath.h"
-#include "RefManager.h"
+#include "CollisionManager.h"
using namespace GameLogic;
@@ -16,7 +16,7 @@ Object::Object()
//poi
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
- GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
+ rigidBody->gameObjectRef = this;
this->type = OBJECT_TYPE_UNKNOWN;
@@ -32,7 +32,7 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
- GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
+ rigidBody->gameObjectRef = this;
this->type = type;
}
@@ -48,3 +48,8 @@ OBJECT_TYPE Object::GetType()
{
return this->type;
}
+
+Oyster::Physics::ICustomBody* Object::GetRigidBody()
+{
+ return this->rigidBody;
+}
diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h
index e2c1bee4..c79c5de1 100644
--- a/Code/Game/GameLogic/Object.h
+++ b/Code/Game/GameLogic/Object.h
@@ -8,7 +8,7 @@
#include "PhysicsAPI.h"
#include "GameLogicStates.h"
-#include "CollisionManager.h"
+
namespace GameLogic
{
@@ -21,6 +21,8 @@ namespace GameLogic
OBJECT_TYPE GetType();
+ Oyster::Physics::ICustomBody* GetRigidBody();
+
private:
OBJECT_TYPE type;
protected:
diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp
index f7bdc4a6..3ebf979f 100644
--- a/Code/Game/GameLogic/Player.cpp
+++ b/Code/Game/GameLogic/Player.cpp
@@ -59,13 +59,16 @@ void Player::Update()
********************************************************/
void Player::Move(const PLAYER_MOVEMENT &movement)
{
+ Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
+
switch(movement)
{
case PLAYER_MOVEMENT_FORWARD:
-
+ API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);
break;
case PLAYER_MOVEMENT_BACKWARD:
+ API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100);
break;
case PLAYER_MOVEMENT_LEFT:
@@ -93,7 +96,7 @@ void Player::UseWeapon(const WEAPON_FIRE &fireInput)
********************************************************/
void Player::Jump()
{
-
+ API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-Oyster::Math::Float3(0,1,0) * 100);
}
bool Player::IsWalking()
@@ -114,6 +117,11 @@ Oyster::Math::Float3 Player::GetPos()
return rigidBody->GetCenter();
}
+Oyster::Math::Float3 Player::GetLookDir()
+{
+ return myData->lookDir;
+}
+
/********************************************************
* Respawns the player on a new chosen position
* This resets a set of variables such as life, ammo etcetc
@@ -122,3 +130,9 @@ void Player::Respawn()
{
}
+
+
+void Player::DamageLife(int damage)
+{
+ myData->life -= damage;
+}
\ No newline at end of file
diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h
index 44b28ceb..7cf7187b 100644
--- a/Code/Game/GameLogic/Player.h
+++ b/Code/Game/GameLogic/Player.h
@@ -26,8 +26,12 @@ namespace GameLogic
bool IsIdle();
Oyster::Math::Float3 GetPos();
+ Oyster::Math::Float3 GetLookDir();
+
void Respawn();
+ void DamageLife(int damage);
+
private:
struct PrivateData;
PrivateData *myData;
diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h
index b5239b6e..cdd1a3b7 100644
--- a/Code/Game/GameLogic/Weapon.h
+++ b/Code/Game/GameLogic/Weapon.h
@@ -5,6 +5,7 @@
#define WEAPON_H
#include "GameLogicStates.h"
#include "IAttatchment.h"
+#include "Player.h"
namespace GameLogic
{
@@ -21,8 +22,8 @@ namespace GameLogic
void Use(const WEAPON_FIRE &fireInput);
- void AddNewAttatchment(IAttatchment *attatchment);
- void SwitchAttatchment(IAttatchment *attatchment, int socketID);
+ void AddNewAttatchment(IAttatchment *attatchment, Player *owner);
+ void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner);
void RemoveAttatchment(int socketID);
void SelectAttatchment(int socketID);