updated the weapon system, collisionManager and redid the "object" heirarki
This commit is contained in:
parent
4b9f2671bf
commit
e11d7d94f7
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace GameLogic
|
|||
~AttatchmentSocket(void);
|
||||
|
||||
IAttatchment* GetAttatchment();
|
||||
void SetAttatchment(IAttatchment *attatchment);
|
||||
void RemoveAttatchment();
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace GameLogic
|
|||
Level(void);
|
||||
~Level(void);
|
||||
|
||||
void CreateBox();
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *myData;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include<map>
|
||||
#include "Object.h"
|
||||
#include "PhysicsAPI.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue