added functionallity to player and weapon, started on the weapon design.
This commit is contained in:
parent
63addde51e
commit
97e0b1298a
|
@ -0,0 +1,38 @@
|
|||
#include "AttatchmentMassDriver.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
struct AttatchmentMassDriver::PrivateData
|
||||
{
|
||||
PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}myData;
|
||||
|
||||
|
||||
AttatchmentMassDriver::AttatchmentMassDriver(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AttatchmentMassDriver::~AttatchmentMassDriver(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef ATTATCHMENTMASSDRIVER_H
|
||||
#define ATTATCHMENTMASSDRIVER_H
|
||||
#include "IAttatchment.h"
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
class AttatchmentMassDriver : public IAttatchment
|
||||
{
|
||||
public:
|
||||
AttatchmentMassDriver(void);
|
||||
~AttatchmentMassDriver(void);
|
||||
|
||||
|
||||
void UseAttatchment(const WEAPON_FIRE &fireInput);
|
||||
|
||||
private:
|
||||
void ForcePush(const WEAPON_FIRE &fireInput);
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *myData;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#include "AttatchmentSocket.h"
|
||||
#include "IAttatchment.h"
|
||||
using namespace GameLogic;
|
||||
|
||||
struct AttatchmentSocket::PrivateData
|
||||
{
|
||||
PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IAttatchment *Attatchment;
|
||||
|
||||
|
||||
}myData;
|
||||
|
||||
AttatchmentSocket::AttatchmentSocket(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AttatchmentSocket::~AttatchmentSocket(void)
|
||||
{
|
||||
}
|
||||
|
||||
IAttatchment* AttatchmentSocket::GetAttatchment()
|
||||
{
|
||||
return myData->Attatchment;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef ATTATCHMENTSOCKET_H
|
||||
#define ATTATCHMENTSOCKET_H
|
||||
#include "IAttatchment.h"
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
class AttatchmentSocket
|
||||
{
|
||||
public:
|
||||
AttatchmentSocket(void);
|
||||
~AttatchmentSocket(void);
|
||||
|
||||
IAttatchment* GetAttatchment();
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *myData;
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -166,12 +166,14 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AttatchmentMassDriver.h" />
|
||||
<ClInclude Include="AttatchmentSocket.h" />
|
||||
<ClInclude Include="Camera.h" />
|
||||
<ClInclude Include="CollisionManager.h" />
|
||||
<ClInclude Include="DynamicObject.h" />
|
||||
<ClInclude Include="Game.h" />
|
||||
<ClInclude Include="GameMode.h" />
|
||||
<ClInclude Include="IGame.h" />
|
||||
<ClInclude Include="GameLogicStates.h" />
|
||||
<ClInclude Include="IAttatchment.h" />
|
||||
<ClInclude Include="Level.h" />
|
||||
<ClInclude Include="Object.h" />
|
||||
<ClInclude Include="Player.h" />
|
||||
|
@ -180,12 +182,13 @@
|
|||
<ClInclude Include="Weapon.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AttatchmentMassDriver.cpp" />
|
||||
<ClCompile Include="AttatchmentSocket.cpp" />
|
||||
<ClCompile Include="Camera.cpp" />
|
||||
<ClCompile Include="CollisionManager.cpp" />
|
||||
<ClCompile Include="DynamicObject.cpp" />
|
||||
<ClCompile Include="Game.cpp" />
|
||||
<ClCompile Include="GameMode.cpp" />
|
||||
<ClCompile Include="IGame.cpp" />
|
||||
<ClCompile Include="IAttatchment.cpp" />
|
||||
<ClCompile Include="Level.cpp" />
|
||||
<ClCompile Include="Object.cpp" />
|
||||
<ClCompile Include="Player.cpp" />
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef GAMELOGICSTATES_H
|
||||
#define GAMELOGICSTATES_H
|
||||
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
enum PLAYER_STATE
|
||||
{
|
||||
PLAYER_STATE_JUMPING = 0,
|
||||
PLAYER_STATE_WALKING = 1,
|
||||
PLAYER_STATE_IDLE = 2,
|
||||
};
|
||||
|
||||
enum PLAYER_MOVEMENT
|
||||
{
|
||||
PLAYER_MOVEMENT_FORWARD = 0,
|
||||
PLAYER_MOVEMENT_BACKWARD = 1,
|
||||
PLAYER_MOVEMENT_LEFT = 2,
|
||||
PLAYER_MOVEMENT_RIGHT = 4,
|
||||
PLAYER_MOVEMENT_JUMP = 8,
|
||||
};
|
||||
|
||||
enum WEAPON_FIRE
|
||||
{
|
||||
WEAPON_USE_PRIMARY_PRESS = 0,
|
||||
WEAPON_USE_PRIMARY_RELEASE = 1,
|
||||
WEAPON_USE_SECONDARY_PRESS = 2,
|
||||
WEAPON_USE_SECONDARY_RELEASE = 4,
|
||||
WEAPON_USE_UTILLITY_PRESS = 8,
|
||||
WEAPON_USE_UTILLITY_RELEASE = 16,
|
||||
};
|
||||
|
||||
enum WEAPON_STATE
|
||||
{
|
||||
WEAPON_STATE_FIREING = 0,
|
||||
WEAPON_STATE_IDLE = 1,
|
||||
WEAPON_STATE_RELOADING = 2,
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,29 @@
|
|||
#include "IAttatchment.h"
|
||||
#include "AttatchmentSocket.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
struct IAttatchment::PrivateData
|
||||
{
|
||||
PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}myData;
|
||||
|
||||
IAttatchment::IAttatchment(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
IAttatchment::~IAttatchment(void)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef IATTATCHMENT_H
|
||||
#define IATTATCHMENT_H
|
||||
#include "GameLogicStates.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
|
||||
class IAttatchment
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
IAttatchment(void);
|
||||
~IAttatchment(void);
|
||||
|
||||
virtual void UseAttatchment(const WEAPON_FIRE &fireInput) = 0;
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *myData;
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -11,7 +11,14 @@ struct Player::PrivateData
|
|||
PrivateData()
|
||||
{
|
||||
weapon = new Weapon();
|
||||
|
||||
life = 100;
|
||||
playerState = PLAYER_STATE_IDLE;
|
||||
|
||||
rigidBody->SetSubscription(CollisionManager::PlayerCollision);
|
||||
|
||||
}
|
||||
|
||||
~PrivateData()
|
||||
{
|
||||
if (weapon)
|
||||
|
@ -22,6 +29,9 @@ struct Player::PrivateData
|
|||
|
||||
int life;
|
||||
Weapon *weapon;
|
||||
PLAYER_STATE playerState;
|
||||
|
||||
ICustomBody *rigidBody;
|
||||
|
||||
}myData;
|
||||
|
||||
|
@ -35,16 +45,81 @@ Player::~Player(void)
|
|||
delete myData;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* Updates the player(is this function needed?)
|
||||
********************************************************/
|
||||
|
||||
void Player::Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Player::Move()
|
||||
/********************************************************
|
||||
* Moves the player based on client input
|
||||
* Uses the physics to move the player by adding a force in the chosen direction
|
||||
* Uses the Jump() function if the player is to jump, this is becuase jumping requires additional logic compared to normal movement
|
||||
********************************************************/
|
||||
void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||
{
|
||||
switch(movement)
|
||||
{
|
||||
case PLAYER_MOVEMENT_FORWARD:
|
||||
break;
|
||||
|
||||
case PLAYER_MOVEMENT_BACKWARD:
|
||||
break;
|
||||
|
||||
case PLAYER_MOVEMENT_LEFT:
|
||||
break;
|
||||
|
||||
case PLAYER_MOVEMENT_RIGHT:
|
||||
break;
|
||||
|
||||
case PLAYER_MOVEMENT_JUMP:
|
||||
Jump();
|
||||
break;
|
||||
}
|
||||
}
|
||||
/********************************************************
|
||||
* Uses the players weapon based on user input
|
||||
********************************************************/
|
||||
void Player::Shoot(const WEAPON_FIRE &fireInput)
|
||||
{
|
||||
myData->weapon->UseWeapon(fireInput);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* Jumps if the player is currently not in a state of jumping
|
||||
* Applies a force upwards(current upwards)
|
||||
********************************************************/
|
||||
void Player::Jump()
|
||||
{
|
||||
|
||||
}
|
||||
void Player::Shoot()
|
||||
|
||||
bool Player::IsWalking()
|
||||
{
|
||||
return (myData->playerState == PLAYER_STATE_WALKING);
|
||||
}
|
||||
bool Player::IsJumping()
|
||||
{
|
||||
return (myData->playerState == PLAYER_STATE_JUMPING);
|
||||
}
|
||||
bool Player::IsIdle()
|
||||
{
|
||||
return (myData->playerState == PLAYER_STATE_IDLE);
|
||||
}
|
||||
|
||||
//Oyster::Math::Float3 Player::GetPos()
|
||||
//{
|
||||
// return myData->rigidBody->GetCenter();
|
||||
//}
|
||||
|
||||
/********************************************************
|
||||
* Respawns the player on a new chosen position
|
||||
* This resets a set of variables such as life, ammo etcetc
|
||||
********************************************************/
|
||||
void Player::Respawn()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
//////////////////////////////////////////////////
|
||||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
#include "GameLogicStates.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
@ -13,13 +14,17 @@ namespace GameLogic
|
|||
Player(void);
|
||||
~Player(void);
|
||||
|
||||
/********************************************************
|
||||
* Update the position of the rigid body
|
||||
* This will be done with physics later
|
||||
********************************************************/
|
||||
void Update();
|
||||
void Move();
|
||||
void Shoot();
|
||||
void Move(const PLAYER_MOVEMENT &movement);
|
||||
void Shoot(const WEAPON_FIRE &fireInput);
|
||||
void Jump();
|
||||
|
||||
bool IsWalking();
|
||||
bool IsJumping();
|
||||
bool IsIdle();
|
||||
|
||||
//Oyster::Math::Float3 GetPos();
|
||||
void Respawn();
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "Weapon.h"
|
||||
#include "AttatchmentSocket.h"
|
||||
#include "AttatchmentMassDriver.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
|
@ -6,7 +8,8 @@ struct Weapon::PrivateData
|
|||
{
|
||||
PrivateData()
|
||||
{
|
||||
|
||||
weaponState = WEAPON_STATE_IDLE;
|
||||
SelectedAttatchment = new AttatchmentMassDriver();
|
||||
}
|
||||
|
||||
~PrivateData()
|
||||
|
@ -14,6 +17,13 @@ struct Weapon::PrivateData
|
|||
|
||||
}
|
||||
|
||||
WEAPON_STATE weaponState;
|
||||
|
||||
AttatchmentSocket **attatchmentSockets;
|
||||
int nrOfAttatchmentSockets;
|
||||
|
||||
IAttatchment *SelectedAttatchment;
|
||||
|
||||
}myData;
|
||||
|
||||
Weapon::Weapon()
|
||||
|
@ -26,3 +36,34 @@ Weapon::~Weapon(void)
|
|||
{
|
||||
delete myData;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* Uses the weapon based on the input given and the current state of the weapon
|
||||
********************************************************/
|
||||
void Weapon::UseWeapon(const WEAPON_FIRE &fireInput)
|
||||
{
|
||||
myData->SelectedAttatchment->UseAttatchment(fireInput);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* Specific weapon usage implementation
|
||||
********************************************************/
|
||||
|
||||
/********************************************************
|
||||
* Get functions for states
|
||||
********************************************************/
|
||||
bool Weapon::IsFireing()
|
||||
{
|
||||
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_FIREING);
|
||||
}
|
||||
|
||||
bool Weapon::IsIdle()
|
||||
{
|
||||
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_IDLE);
|
||||
}
|
||||
|
||||
bool Weapon::IsReloading()
|
||||
{
|
||||
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
//////////////////////////////////////////////////
|
||||
#ifndef WEAPON_H
|
||||
#define WEAPON_H
|
||||
#include "GameLogicStates.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
@ -11,9 +12,19 @@ namespace GameLogic
|
|||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Weapon(void);
|
||||
~Weapon(void);
|
||||
|
||||
void UseWeapon(const WEAPON_FIRE &fireInput);
|
||||
|
||||
|
||||
bool IsFireing();
|
||||
bool IsIdle();
|
||||
bool IsReloading();
|
||||
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *myData;
|
||||
|
|
Loading…
Reference in New Issue