2013-11-19 11:07:14 +01:00
|
|
|
#include "Player.h"
|
2013-11-25 11:03:06 +01:00
|
|
|
#include "OysterMath.h"
|
2013-12-03 11:47:04 +01:00
|
|
|
#include "CollisionManager.h"
|
2013-12-05 11:50:39 +01:00
|
|
|
#include "Weapon.h"
|
2013-11-25 11:03:06 +01:00
|
|
|
|
2013-11-19 11:07:14 +01:00
|
|
|
using namespace GameLogic;
|
2013-11-25 11:03:06 +01:00
|
|
|
using namespace Oyster::Physics;
|
2013-11-19 11:07:14 +01:00
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
struct Player::PrivateData
|
2013-11-19 11:07:14 +01:00
|
|
|
{
|
2013-12-05 11:50:39 +01:00
|
|
|
PrivateData()
|
|
|
|
{
|
|
|
|
weapon = new Weapon();
|
2013-12-10 09:57:05 +01:00
|
|
|
|
|
|
|
life = 100;
|
|
|
|
playerState = PLAYER_STATE_IDLE;
|
|
|
|
|
|
|
|
rigidBody->SetSubscription(CollisionManager::PlayerCollision);
|
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
}
|
2013-12-10 09:57:05 +01:00
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
~PrivateData()
|
|
|
|
{
|
|
|
|
if (weapon)
|
|
|
|
{
|
|
|
|
delete weapon;
|
|
|
|
}
|
|
|
|
}
|
2013-12-10 09:57:05 +01:00
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
int life;
|
|
|
|
Weapon *weapon;
|
2013-12-10 09:57:05 +01:00
|
|
|
PLAYER_STATE playerState;
|
|
|
|
|
|
|
|
ICustomBody *rigidBody;
|
2013-12-05 11:50:39 +01:00
|
|
|
|
|
|
|
}myData;
|
|
|
|
|
|
|
|
Player::Player()
|
|
|
|
{
|
|
|
|
myData = new PrivateData();
|
|
|
|
|
2013-11-19 11:07:14 +01:00
|
|
|
}
|
|
|
|
Player::~Player(void)
|
|
|
|
{
|
2013-12-05 11:50:39 +01:00
|
|
|
delete myData;
|
2013-11-21 12:05:39 +01:00
|
|
|
}
|
2013-11-29 09:05:01 +01:00
|
|
|
|
2013-12-10 09:57:05 +01:00
|
|
|
/********************************************************
|
|
|
|
* Updates the player(is this function needed?)
|
|
|
|
********************************************************/
|
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
void Player::Update()
|
2013-11-21 12:05:39 +01:00
|
|
|
{
|
2013-12-05 11:50:39 +01:00
|
|
|
|
2013-11-21 12:05:39 +01:00
|
|
|
}
|
|
|
|
|
2013-12-10 09:57:05 +01:00
|
|
|
/********************************************************
|
|
|
|
* 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)
|
2013-11-21 12:05:39 +01:00
|
|
|
{
|
2013-12-10 09:57:05 +01:00
|
|
|
switch(movement)
|
|
|
|
{
|
|
|
|
case PLAYER_MOVEMENT_FORWARD:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLAYER_MOVEMENT_BACKWARD:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLAYER_MOVEMENT_LEFT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLAYER_MOVEMENT_RIGHT:
|
|
|
|
break;
|
2013-12-03 11:47:04 +01:00
|
|
|
|
2013-12-10 09:57:05 +01:00
|
|
|
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);
|
2013-11-21 12:05:39 +01:00
|
|
|
}
|
2013-12-10 09:57:05 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Jumps if the player is currently not in a state of jumping
|
|
|
|
* Applies a force upwards(current upwards)
|
|
|
|
********************************************************/
|
|
|
|
void Player::Jump()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
2013-11-21 12:05:39 +01:00
|
|
|
{
|
|
|
|
|
2013-11-19 11:07:14 +01:00
|
|
|
}
|