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;
|
}myData;
|
||||||
|
@ -30,5 +30,23 @@ AttatchmentSocket::~AttatchmentSocket(void)
|
||||||
|
|
||||||
IAttatchment* AttatchmentSocket::GetAttatchment()
|
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);
|
~AttatchmentSocket(void);
|
||||||
|
|
||||||
IAttatchment* GetAttatchment();
|
IAttatchment* GetAttatchment();
|
||||||
|
void SetAttatchment(IAttatchment *attatchment);
|
||||||
|
void RemoveAttatchment();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
struct PrivateData;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
#include "CollisionManager.h"
|
#include "CollisionManager.h"
|
||||||
|
#include "RefManager.h"
|
||||||
|
#include "PhysicsAPI.h"
|
||||||
|
#include "Object.h"
|
||||||
|
#include "DynamicObject.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
|
|
||||||
|
@ -15,22 +20,21 @@ namespace GameLogic
|
||||||
|
|
||||||
switch (realObj->GetType())
|
switch (realObj->GetType())
|
||||||
{
|
{
|
||||||
case Object::OBJECT_TYPE_BOX:
|
case OBJECT_TYPE_BOX:
|
||||||
PlayerVBox(*player,(*(DynamicObject*) realObj));
|
//PlayerVBox(*player,(*(DynamicObject*) realObj));
|
||||||
break;
|
break;
|
||||||
case Object::OBJECT_TYPE_PLAYER:
|
case OBJECT_TYPE_PLAYER:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//spela ljud? ta skada? etc etc
|
|
||||||
return Physics::ICustomBody::SubscriptMessage_none;
|
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)
|
Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj)
|
||||||
{
|
{
|
||||||
|
@ -39,11 +43,11 @@ namespace GameLogic
|
||||||
|
|
||||||
switch (realObj->GetType())
|
switch (realObj->GetType())
|
||||||
{
|
{
|
||||||
case Object::OBJECT_TYPE_BOX:
|
case OBJECT_TYPE_BOX:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Object::OBJECT_TYPE_PLAYER:
|
case OBJECT_TYPE_PLAYER:
|
||||||
PlayerVBox(*(Player*)realObj,*box);
|
//PlayerVBox(*(Player*)realObj,*box);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "PhysicsAPI.h"
|
#include "PhysicsAPI.h"
|
||||||
#include "RefManager.h"
|
//#include "DynamicObject.h"
|
||||||
#include "DynamicObject.h"
|
//#include "Player.h"
|
||||||
#include "Player.h"
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -18,8 +17,8 @@ namespace GameLogic
|
||||||
Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
|
Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
|
||||||
|
|
||||||
//these are the specific collision case functions
|
//these are the specific collision case functions
|
||||||
void PlayerVBox(Player &player, DynamicObject &box);
|
//void PlayerVBox(Player &player, DynamicObject &box);
|
||||||
void BoxVBox(DynamicObject &box1, DynamicObject &box2);
|
//void BoxVBox(DynamicObject &box1, DynamicObject &box2);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,23 @@
|
||||||
#include "DynamicObject.h"
|
#include "DynamicObject.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
struct DynamicObject::PrivateData
|
|
||||||
{
|
|
||||||
PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
|
|
||||||
DynamicObject::DynamicObject()
|
DynamicObject::DynamicObject()
|
||||||
|
:Object()
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject::DynamicObject(void* collisionFunc, OBJECT_TYPE type)
|
||||||
|
:Object(collisionFunc, type)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicObject::~DynamicObject(void)
|
DynamicObject::~DynamicObject(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
|
||||||
}
|
}
|
|
@ -1,27 +1,24 @@
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
//Created by Erik and Linda of the GameLogic team
|
//Created by Erik and Linda of the GameLogic team
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#ifndef DYNAMICOBJECT_H
|
#ifndef DYNAMICOBJECT_H
|
||||||
#define DYNAMICOBJECT_H
|
#define DYNAMICOBJECT_H
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class DynamicObject
|
class DynamicObject : public Object
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DynamicObject();
|
DynamicObject();
|
||||||
|
DynamicObject(void* collisionFunc, OBJECT_TYPE type);
|
||||||
~DynamicObject(void);
|
~DynamicObject(void);
|
||||||
|
|
||||||
void Update();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
|
||||||
PrivateData *myData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,13 @@ namespace GameLogic
|
||||||
WEAPON_STATE_IDLE = 1,
|
WEAPON_STATE_IDLE = 1,
|
||||||
WEAPON_STATE_RELOADING = 2,
|
WEAPON_STATE_RELOADING = 2,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
enum OBJECT_TYPE
|
||||||
|
{
|
||||||
|
OBJECT_TYPE_PLAYER = 0,
|
||||||
|
OBJECT_TYPE_BOX = 1,
|
||||||
|
OBJECT_TYPE_UNKNOWN = 2,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -9,14 +9,10 @@ struct Level::PrivateData
|
||||||
{
|
{
|
||||||
PrivateData()
|
PrivateData()
|
||||||
{
|
{
|
||||||
gameMode = new GameMode();
|
|
||||||
}
|
}
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
{
|
{
|
||||||
if (gameMode)
|
|
||||||
{
|
|
||||||
delete gameMode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,3 +36,5 @@ Level::~Level(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
delete myData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace GameLogic
|
||||||
Level(void);
|
Level(void);
|
||||||
~Level(void);
|
~Level(void);
|
||||||
|
|
||||||
|
void CreateBox();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
struct PrivateData;
|
||||||
PrivateData *myData;
|
PrivateData *myData;
|
||||||
|
|
|
@ -1,23 +1,15 @@
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include "DllInterfaces\GFXAPI.h"
|
#include "RefManager.h"
|
||||||
#include "CollisionManager.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
using namespace Oyster::Math;
|
using namespace Oyster::Math;
|
||||||
using namespace Oyster::Graphics::Model;
|
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
|
||||||
Object::Object(std::wstring objFile)
|
Object::Object()
|
||||||
{
|
{
|
||||||
|
|
||||||
//model = new Model();
|
|
||||||
model = Oyster::Graphics::API::CreateModel(objFile);
|
|
||||||
|
|
||||||
API::SimpleBodyDescription sbDesc;
|
API::SimpleBodyDescription sbDesc;
|
||||||
//sbDesc.centerPosition =
|
//sbDesc.centerPosition =
|
||||||
|
|
||||||
|
@ -26,23 +18,33 @@ Object::Object(std::wstring objFile)
|
||||||
|
|
||||||
GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
|
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)
|
Object::~Object(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
Oyster::Graphics::API::DeleteModel(model);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::Render()
|
OBJECT_TYPE Object::GetType()
|
||||||
{
|
|
||||||
this->rigidBody->GetOrientation(model->WorldMatrix);
|
|
||||||
Oyster::Graphics::API::RenderScene(model, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Object::OBJECT_TYPE Object::GetType()
|
|
||||||
{
|
{
|
||||||
return this->type;
|
return this->type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,41 +7,24 @@
|
||||||
#define OBJECT_H
|
#define OBJECT_H
|
||||||
|
|
||||||
#include "PhysicsAPI.h"
|
#include "PhysicsAPI.h"
|
||||||
#include "DllInterfaces/GFXAPI.h"
|
#include "GameLogicStates.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
#include "Model/Model.h"
|
|
||||||
#include "Utilities.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
class Object
|
class Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Object();
|
||||||
enum OBJECT_TYPE
|
Object(void* collisionFunc, OBJECT_TYPE type);
|
||||||
{
|
~Object(void);
|
||||||
OBJECT_TYPE_PLAYER,
|
|
||||||
OBJECT_TYPE_BOX,
|
|
||||||
};
|
|
||||||
Object(std::wstring objFile );
|
|
||||||
virtual ~Object(void);
|
|
||||||
|
|
||||||
void Render();
|
|
||||||
|
|
||||||
OBJECT_TYPE GetType();
|
OBJECT_TYPE GetType();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OBJECT_TYPE type;
|
OBJECT_TYPE type;
|
||||||
|
|
||||||
protected:
|
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::Physics::ICustomBody *rigidBody;
|
||||||
Oyster::Graphics::Model::Model *model;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ struct Player::PrivateData
|
||||||
life = 100;
|
life = 100;
|
||||||
playerState = PLAYER_STATE_IDLE;
|
playerState = PLAYER_STATE_IDLE;
|
||||||
|
|
||||||
rigidBody->SetSubscription(CollisionManager::PlayerCollision);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
|
@ -30,16 +28,16 @@ struct Player::PrivateData
|
||||||
int life;
|
int life;
|
||||||
Weapon *weapon;
|
Weapon *weapon;
|
||||||
PLAYER_STATE playerState;
|
PLAYER_STATE playerState;
|
||||||
|
Oyster::Math::Float3 lookDir;
|
||||||
ICustomBody *rigidBody;
|
|
||||||
|
|
||||||
}myData;
|
}myData;
|
||||||
|
|
||||||
Player::Player()
|
Player::Player()
|
||||||
|
:Object(CollisionManager::PlayerCollision, OBJECT_TYPE_PLAYER)
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
myData = new PrivateData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player(void)
|
Player::~Player(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
delete myData;
|
||||||
|
@ -83,9 +81,9 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Uses the players weapon based on user input
|
* 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()
|
Oyster::Math::Float3 Player::GetPos()
|
||||||
{
|
{
|
||||||
return myData->rigidBody->GetCenter();
|
return rigidBody->GetCenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
#define PLAYER_H
|
#define PLAYER_H
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
class Player
|
class Player : public Object
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -17,7 +18,7 @@ namespace GameLogic
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
void Move(const PLAYER_MOVEMENT &movement);
|
void Move(const PLAYER_MOVEMENT &movement);
|
||||||
void Shoot(const WEAPON_FIRE &fireInput);
|
void UseWeapon(const WEAPON_FIRE &fireInput);
|
||||||
void Jump();
|
void Jump();
|
||||||
|
|
||||||
bool IsWalking();
|
bool IsWalking();
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include<map>
|
#include<map>
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "PhysicsAPI.h"
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,28 +2,22 @@
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
struct StaticObject::PrivateData
|
|
||||||
{
|
|
||||||
PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
|
|
||||||
StaticObject::StaticObject()
|
StaticObject::StaticObject()
|
||||||
|
:Object()
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
|
||||||
|
}
|
||||||
|
|
||||||
|
StaticObject::StaticObject(void* collisionFunc, OBJECT_TYPE type)
|
||||||
|
:Object(collisionFunc,type)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StaticObject::~StaticObject(void)
|
StaticObject::~StaticObject(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
class StaticObject
|
class StaticObject : public Object
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StaticObject();
|
StaticObject();
|
||||||
|
StaticObject(void* collisionFunc, OBJECT_TYPE type);
|
||||||
~StaticObject(void);
|
~StaticObject(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
|
||||||
PrivateData *myData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,20 +9,23 @@ struct Weapon::PrivateData
|
||||||
PrivateData()
|
PrivateData()
|
||||||
{
|
{
|
||||||
weaponState = WEAPON_STATE_IDLE;
|
weaponState = WEAPON_STATE_IDLE;
|
||||||
SelectedAttatchment = new AttatchmentMassDriver();
|
SelectedAttatchment = 0;
|
||||||
|
currentNrOfAttatchments = 0;
|
||||||
|
selectedSocketID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
{
|
{
|
||||||
delete SelectedAttatchment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAPON_STATE weaponState;
|
WEAPON_STATE weaponState;
|
||||||
|
|
||||||
AttatchmentSocket **attatchmentSockets;
|
AttatchmentSocket **attatchmentSockets;
|
||||||
int nrOfAttatchmentSockets;
|
int MaxNrOfSockets;
|
||||||
|
int currentNrOfAttatchments;
|
||||||
|
|
||||||
IAttatchment *SelectedAttatchment;
|
IAttatchment *SelectedAttatchment;
|
||||||
|
int selectedSocketID;
|
||||||
|
|
||||||
}myData;
|
}myData;
|
||||||
|
|
||||||
|
@ -31,6 +34,17 @@ Weapon::Weapon()
|
||||||
myData = new PrivateData();
|
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)
|
Weapon::~Weapon(void)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +54,7 @@ Weapon::~Weapon(void)
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Uses the weapon based on the input given and the current chosen attatchment
|
* 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);
|
myData->SelectedAttatchment->UseAttatchment(fireInput);
|
||||||
}
|
}
|
||||||
|
@ -67,3 +81,56 @@ bool Weapon::IsReloading()
|
||||||
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING);
|
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
|
#ifndef WEAPON_H
|
||||||
#define WEAPON_H
|
#define WEAPON_H
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
|
#include "IAttatchment.h"
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -15,14 +16,24 @@ namespace GameLogic
|
||||||
|
|
||||||
|
|
||||||
Weapon(void);
|
Weapon(void);
|
||||||
|
Weapon(int nrOfAttatchmentSockets);
|
||||||
~Weapon(void);
|
~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 IsFireing();
|
||||||
bool IsIdle();
|
bool IsIdle();
|
||||||
bool IsReloading();
|
bool IsReloading();
|
||||||
|
bool IsValidSocket(int socketID);
|
||||||
|
|
||||||
|
int GetCurrentSocketID();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue