diff --git a/Bin/Content/Shaders/DebugVertex.cso b/Bin/Content/Shaders/DebugVertex.cso index e35466e1..4e8292c6 100644 Binary files a/Bin/Content/Shaders/DebugVertex.cso and b/Bin/Content/Shaders/DebugVertex.cso differ diff --git a/Code/Game/GameLogic/AttatchmentSocket.cpp b/Code/Game/GameLogic/AttatchmentSocket.cpp index 86e0850b..288a1a4e 100644 --- a/Code/Game/GameLogic/AttatchmentSocket.cpp +++ b/Code/Game/GameLogic/AttatchmentSocket.cpp @@ -14,7 +14,7 @@ struct AttatchmentSocket::PrivateData } - IAttatchment *Attatchment; + IAttatchment *attatchment; }myData; @@ -30,5 +30,23 @@ AttatchmentSocket::~AttatchmentSocket(void) IAttatchment* AttatchmentSocket::GetAttatchment() { - return myData->Attatchment; + return myData->attatchment; +} + +void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment) +{ + if (myData->attatchment) + { + delete myData->attatchment; + } + + myData->attatchment = attatchment; +} + +void AttatchmentSocket::RemoveAttatchment() +{ + if (myData->attatchment) + { + delete myData->attatchment; + } } diff --git a/Code/Game/GameLogic/AttatchmentSocket.h b/Code/Game/GameLogic/AttatchmentSocket.h index 1067e339..f9be588b 100644 --- a/Code/Game/GameLogic/AttatchmentSocket.h +++ b/Code/Game/GameLogic/AttatchmentSocket.h @@ -11,6 +11,8 @@ namespace GameLogic ~AttatchmentSocket(void); IAttatchment* GetAttatchment(); + void SetAttatchment(IAttatchment *attatchment); + void RemoveAttatchment(); private: struct PrivateData; diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 52eaa4f3..b19c7de3 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -1,4 +1,9 @@ #include "CollisionManager.h" +#include "RefManager.h" +#include "PhysicsAPI.h" +#include "Object.h" +#include "DynamicObject.h" +#include "Player.h" using namespace Oyster; @@ -15,22 +20,21 @@ namespace GameLogic switch (realObj->GetType()) { - case Object::OBJECT_TYPE_BOX: - PlayerVBox(*player,(*(DynamicObject*) realObj)); + case OBJECT_TYPE_BOX: + //PlayerVBox(*player,(*(DynamicObject*) realObj)); break; - case Object::OBJECT_TYPE_PLAYER: + case OBJECT_TYPE_PLAYER: break; } - //spela ljud? ta skada? etc etc return Physics::ICustomBody::SubscriptMessage_none; } - void PlayerVBox(Player &player, DynamicObject &box) + /* void PlayerVBox(Player &player, DynamicObject &box) { - //spela ljud? ta skada? etc etc - } + spela ljud? ta skada? etc etc + }*/ Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj) { @@ -39,11 +43,11 @@ namespace GameLogic switch (realObj->GetType()) { - case Object::OBJECT_TYPE_BOX: + case OBJECT_TYPE_BOX: break; - case Object::OBJECT_TYPE_PLAYER: - PlayerVBox(*(Player*)realObj,*box); + case OBJECT_TYPE_PLAYER: + //PlayerVBox(*(Player*)realObj,*box); break; } diff --git a/Code/Game/GameLogic/CollisionManager.h b/Code/Game/GameLogic/CollisionManager.h index f88404cc..86a05906 100644 --- a/Code/Game/GameLogic/CollisionManager.h +++ b/Code/Game/GameLogic/CollisionManager.h @@ -3,9 +3,8 @@ #include "Object.h" #include "PhysicsAPI.h" -#include "RefManager.h" -#include "DynamicObject.h" -#include "Player.h" +//#include "DynamicObject.h" +//#include "Player.h" namespace GameLogic { @@ -18,8 +17,8 @@ namespace GameLogic Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj); //these are the specific collision case functions - void PlayerVBox(Player &player, DynamicObject &box); - void BoxVBox(DynamicObject &box1, DynamicObject &box2); + //void PlayerVBox(Player &player, DynamicObject &box); + //void BoxVBox(DynamicObject &box1, DynamicObject &box2); }; diff --git a/Code/Game/GameLogic/DynamicObject.cpp b/Code/Game/GameLogic/DynamicObject.cpp index 8786255c..a8ea1ab4 100644 --- a/Code/Game/GameLogic/DynamicObject.cpp +++ b/Code/Game/GameLogic/DynamicObject.cpp @@ -1,29 +1,23 @@ #include "DynamicObject.h" +#include "CollisionManager.h" using namespace GameLogic; -struct DynamicObject::PrivateData -{ - PrivateData() - { - - } - - ~PrivateData() - { - - } - -}myData; - DynamicObject::DynamicObject() + :Object() { - myData = new PrivateData(); + +} + +DynamicObject::DynamicObject(void* collisionFunc, OBJECT_TYPE type) + :Object(collisionFunc, type) +{ + } DynamicObject::~DynamicObject(void) { - delete myData; + } \ No newline at end of file diff --git a/Code/Game/GameLogic/DynamicObject.h b/Code/Game/GameLogic/DynamicObject.h index ecf1e905..70bb8c11 100644 --- a/Code/Game/GameLogic/DynamicObject.h +++ b/Code/Game/GameLogic/DynamicObject.h @@ -1,27 +1,24 @@ ////////////////////////////////////////////////// //Created by Erik and Linda of the GameLogic team ////////////////////////////////////////////////// - - #ifndef DYNAMICOBJECT_H #define DYNAMICOBJECT_H +#include "Object.h" namespace GameLogic { - class DynamicObject + class DynamicObject : public Object { public: DynamicObject(); + DynamicObject(void* collisionFunc, OBJECT_TYPE type); ~DynamicObject(void); - void Update(); - private: - struct PrivateData; - PrivateData *myData; + }; } diff --git a/Code/Game/GameLogic/GameLogicStates.h b/Code/Game/GameLogic/GameLogicStates.h index 3c2b9997..3e72647e 100644 --- a/Code/Game/GameLogic/GameLogicStates.h +++ b/Code/Game/GameLogic/GameLogicStates.h @@ -36,6 +36,13 @@ namespace GameLogic WEAPON_STATE_IDLE = 1, WEAPON_STATE_RELOADING = 2, }; -} + + enum OBJECT_TYPE + { + OBJECT_TYPE_PLAYER = 0, + OBJECT_TYPE_BOX = 1, + OBJECT_TYPE_UNKNOWN = 2, + }; +}; #endif \ No newline at end of file diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index c83056c6..38865f63 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -9,14 +9,10 @@ struct Level::PrivateData { PrivateData() { - gameMode = new GameMode(); + } ~PrivateData() { - if (gameMode) - { - delete gameMode; - } } @@ -40,3 +36,5 @@ Level::~Level(void) { delete myData; } + + diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 217a60e4..9c7adb1a 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -14,6 +14,8 @@ namespace GameLogic Level(void); ~Level(void); + void CreateBox(); + private: struct PrivateData; PrivateData *myData; diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 67385874..7eb4b57f 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -1,23 +1,15 @@ #include "Object.h" #include "OysterMath.h" -#include "DllInterfaces\GFXAPI.h" -#include "CollisionManager.h" +#include "RefManager.h" using namespace GameLogic; using namespace Oyster::Math; -using namespace Oyster::Graphics::Model; - -using namespace Utility::DynamicMemory; using namespace Oyster::Physics; -Object::Object(std::wstring objFile) -{ - - //model = new Model(); - model = Oyster::Graphics::API::CreateModel(objFile); - +Object::Object() +{ API::SimpleBodyDescription sbDesc; //sbDesc.centerPosition = @@ -26,23 +18,33 @@ Object::Object(std::wstring objFile) GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this); + this->type = OBJECT_TYPE_UNKNOWN; + +} + +Object::Object(void* collisionFunc, OBJECT_TYPE type) +{ + API::SimpleBodyDescription sbDesc; + //sbDesc.centerPosition = + + //poi + ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); + + rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); + + GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this); + + this->type = type; } Object::~Object(void) { - Oyster::Graphics::API::DeleteModel(model); } -void Object::Render() -{ - this->rigidBody->GetOrientation(model->WorldMatrix); - Oyster::Graphics::API::RenderScene(model, 1); -} - -Object::OBJECT_TYPE Object::GetType() +OBJECT_TYPE Object::GetType() { return this->type; } diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index 1c1c2830..e2c1bee4 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -7,41 +7,24 @@ #define OBJECT_H #include "PhysicsAPI.h" -#include "DllInterfaces/GFXAPI.h" - -#include "Model/Model.h" -#include "Utilities.h" - - +#include "GameLogicStates.h" +#include "CollisionManager.h" namespace GameLogic { class Object { public: - - enum OBJECT_TYPE - { - OBJECT_TYPE_PLAYER, - OBJECT_TYPE_BOX, - }; - Object(std::wstring objFile ); - virtual ~Object(void); - - void Render(); + Object(); + Object(void* collisionFunc, OBJECT_TYPE type); + ~Object(void); OBJECT_TYPE GetType(); private: OBJECT_TYPE type; - protected: - //either a model pointer or an ID to an arraypos filled with models that are to be rendered - //rigidBody - Oyster::Physics::ICustomBody *rigidBody; - Oyster::Graphics::Model::Model *model; - }; } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 9bc9d752..ad81bf61 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -15,8 +15,6 @@ struct Player::PrivateData life = 100; playerState = PLAYER_STATE_IDLE; - rigidBody->SetSubscription(CollisionManager::PlayerCollision); - } ~PrivateData() @@ -30,16 +28,16 @@ struct Player::PrivateData int life; Weapon *weapon; PLAYER_STATE playerState; - - ICustomBody *rigidBody; + Oyster::Math::Float3 lookDir; }myData; Player::Player() + :Object(CollisionManager::PlayerCollision, OBJECT_TYPE_PLAYER) { myData = new PrivateData(); - } + Player::~Player(void) { delete myData; @@ -83,9 +81,9 @@ void Player::Move(const PLAYER_MOVEMENT &movement) /******************************************************** * Uses the players weapon based on user input ********************************************************/ -void Player::Shoot(const WEAPON_FIRE &fireInput) +void Player::UseWeapon(const WEAPON_FIRE &fireInput) { - myData->weapon->UseWeapon(fireInput); + myData->weapon->Use(fireInput); } /******************************************************** @@ -112,7 +110,7 @@ bool Player::IsIdle() Oyster::Math::Float3 Player::GetPos() { - return myData->rigidBody->GetCenter(); + return rigidBody->GetCenter(); } /******************************************************** diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 20fc8de6..44b28ceb 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -5,10 +5,11 @@ #define PLAYER_H #include "GameLogicStates.h" #include "OysterMath.h" +#include "Object.h" namespace GameLogic { - class Player + class Player : public Object { public: @@ -17,7 +18,7 @@ namespace GameLogic void Update(); void Move(const PLAYER_MOVEMENT &movement); - void Shoot(const WEAPON_FIRE &fireInput); + void UseWeapon(const WEAPON_FIRE &fireInput); void Jump(); bool IsWalking(); diff --git a/Code/Game/GameLogic/RefManager.h b/Code/Game/GameLogic/RefManager.h index a184e220..fa4080c9 100644 --- a/Code/Game/GameLogic/RefManager.h +++ b/Code/Game/GameLogic/RefManager.h @@ -8,7 +8,6 @@ #include #include "Object.h" -#include "PhysicsAPI.h" namespace GameLogic { diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp index c58fb83c..155834fe 100644 --- a/Code/Game/GameLogic/StaticObject.cpp +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -2,28 +2,22 @@ using namespace GameLogic; -struct StaticObject::PrivateData -{ - PrivateData() - { - - } - - ~PrivateData() - { - - } - -}myData; StaticObject::StaticObject() + :Object() { - myData = new PrivateData(); + +} + +StaticObject::StaticObject(void* collisionFunc, OBJECT_TYPE type) + :Object(collisionFunc,type) +{ + } StaticObject::~StaticObject(void) { - delete myData; + } diff --git a/Code/Game/GameLogic/StaticObject.h b/Code/Game/GameLogic/StaticObject.h index 2f292795..31121447 100644 --- a/Code/Game/GameLogic/StaticObject.h +++ b/Code/Game/GameLogic/StaticObject.h @@ -11,16 +11,16 @@ namespace GameLogic { - class StaticObject + class StaticObject : public Object { public: StaticObject(); + StaticObject(void* collisionFunc, OBJECT_TYPE type); ~StaticObject(void); private: - struct PrivateData; - PrivateData *myData; + }; } diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index 2a575039..4bf4311c 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -9,20 +9,23 @@ struct Weapon::PrivateData PrivateData() { weaponState = WEAPON_STATE_IDLE; - SelectedAttatchment = new AttatchmentMassDriver(); + SelectedAttatchment = 0; + currentNrOfAttatchments = 0; + selectedSocketID = 0; } ~PrivateData() { - delete SelectedAttatchment; } WEAPON_STATE weaponState; AttatchmentSocket **attatchmentSockets; - int nrOfAttatchmentSockets; + int MaxNrOfSockets; + int currentNrOfAttatchments; IAttatchment *SelectedAttatchment; + int selectedSocketID; }myData; @@ -31,6 +34,17 @@ Weapon::Weapon() myData = new PrivateData(); } +Weapon::Weapon(int MaxNrOfSockets) +{ + myData = new PrivateData(); + myData->MaxNrOfSockets = MaxNrOfSockets; + myData->attatchmentSockets = new AttatchmentSocket*[MaxNrOfSockets]; + for (int i = 0; i < MaxNrOfSockets; i++) + { + myData->attatchmentSockets[i] = new AttatchmentSocket(); + } +} + Weapon::~Weapon(void) { @@ -40,7 +54,7 @@ Weapon::~Weapon(void) /******************************************************** * Uses the weapon based on the input given and the current chosen attatchment ********************************************************/ -void Weapon::UseWeapon(const WEAPON_FIRE &fireInput) +void Weapon::Use(const WEAPON_FIRE &fireInput) { myData->SelectedAttatchment->UseAttatchment(fireInput); } @@ -67,3 +81,56 @@ bool Weapon::IsReloading() return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING); } +bool Weapon::IsValidSocket(int socketID) +{ + if(socketID < myData->MaxNrOfSockets && socketID >= 0) + { + if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0) + { + return true; + } + } + + return false; +} + +int Weapon::GetCurrentSocketID() +{ + return myData->selectedSocketID; +} + + +void Weapon::AddNewAttatchment(IAttatchment *attatchment) +{ + if(myData->currentNrOfAttatchments < myData->MaxNrOfSockets) + { + myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment); + myData->currentNrOfAttatchments++; + } +} + +void Weapon::SwitchAttatchment(IAttatchment *attatchment, int socketID) +{ + if (IsValidSocket(socketID)) + { + myData->attatchmentSockets[socketID]->SetAttatchment(attatchment); + } +} + +void Weapon::RemoveAttatchment(int socketID) +{ + if (IsValidSocket(socketID)) + { + myData->attatchmentSockets[socketID]->RemoveAttatchment(); + } +} + +void Weapon::SelectAttatchment(int socketID) +{ + if (IsValidSocket(socketID)) + { + myData->SelectedAttatchment = myData->attatchmentSockets[socketID]->GetAttatchment(); + myData->selectedSocketID = socketID; + } + +} \ No newline at end of file diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h index 74a408e9..b5239b6e 100644 --- a/Code/Game/GameLogic/Weapon.h +++ b/Code/Game/GameLogic/Weapon.h @@ -4,6 +4,7 @@ #ifndef WEAPON_H #define WEAPON_H #include "GameLogicStates.h" +#include "IAttatchment.h" namespace GameLogic { @@ -15,14 +16,24 @@ namespace GameLogic Weapon(void); + Weapon(int nrOfAttatchmentSockets); ~Weapon(void); - void UseWeapon(const WEAPON_FIRE &fireInput); + void Use(const WEAPON_FIRE &fireInput); + void AddNewAttatchment(IAttatchment *attatchment); + void SwitchAttatchment(IAttatchment *attatchment, int socketID); + void RemoveAttatchment(int socketID); + + void SelectAttatchment(int socketID); bool IsFireing(); bool IsIdle(); bool IsReloading(); + bool IsValidSocket(int socketID); + + int GetCurrentSocketID(); + private: