2014-01-14 10:28:12 +01:00
|
|
|
#include "Game.h"
|
|
|
|
#include "Player.h"
|
|
|
|
|
|
|
|
using namespace GameLogic;
|
|
|
|
|
|
|
|
Game::PlayerData::PlayerData()
|
2014-01-29 14:33:21 +01:00
|
|
|
{
|
2014-02-20 11:59:26 +01:00
|
|
|
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,180,0);
|
2014-02-19 22:07:53 +01:00
|
|
|
Oyster::Math::Float height = 2.0f;
|
|
|
|
Oyster::Math::Float radius = 0.5f;
|
|
|
|
Oyster::Math::Float mass = 40;
|
2014-02-14 10:09:03 +01:00
|
|
|
Oyster::Math::Float restitutionCoeff = 0.5f;
|
|
|
|
Oyster::Math::Float frictionCoeff_Static = 0.4f;
|
|
|
|
Oyster::Math::Float frictionCoeff_Dynamic = 0.3f;
|
2014-02-03 10:42:40 +01:00
|
|
|
|
2014-01-29 13:18:17 +01:00
|
|
|
//create rigid body
|
2014-02-19 22:07:53 +01:00
|
|
|
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCharacter( height, radius, Oyster::Math::Float4(0, 0, 0, 1),
|
|
|
|
centerPosition, mass, restitutionCoeff,
|
|
|
|
frictionCoeff_Static, frictionCoeff_Dynamic );
|
2014-02-11 13:41:38 +01:00
|
|
|
rigidBody->SetAngularFactor(0.0f);
|
2014-01-29 13:18:17 +01:00
|
|
|
//create player with this rigid body
|
2014-02-19 22:07:53 +01:00
|
|
|
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player, 0, 0);
|
2014-01-14 10:28:12 +01:00
|
|
|
}
|
2014-01-15 11:03:25 +01:00
|
|
|
Game::PlayerData::PlayerData(int playerID,int teamID)
|
|
|
|
{
|
2014-02-19 10:15:52 +01:00
|
|
|
|
2014-02-20 11:59:26 +01:00
|
|
|
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,180,0);
|
2014-02-19 15:53:28 +01:00
|
|
|
Oyster::Math::Float height = 2.0f;
|
|
|
|
Oyster::Math::Float radius = 0.5f;
|
|
|
|
Oyster::Math::Float mass = 40;
|
2014-02-19 10:15:52 +01:00
|
|
|
Oyster::Math::Float restitutionCoeff = 0.5f;
|
|
|
|
Oyster::Math::Float frictionCoeff_Static = 0.4f;
|
|
|
|
Oyster::Math::Float frictionCoeff_Dynamic = 0.3f;
|
|
|
|
|
|
|
|
//create rigid body
|
2014-02-19 22:07:53 +01:00
|
|
|
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCharacter( height, radius, Oyster::Math::Float4(0, 0, 0, 1),
|
|
|
|
centerPosition, mass, restitutionCoeff,
|
|
|
|
frictionCoeff_Static, frictionCoeff_Dynamic );
|
2014-02-19 10:15:52 +01:00
|
|
|
rigidBody->SetAngularFactor(0.0f);
|
|
|
|
//create player with this rigid body
|
|
|
|
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,playerID,teamID);
|
2014-01-15 11:03:25 +01:00
|
|
|
}
|
|
|
|
Game::PlayerData::~PlayerData()
|
|
|
|
{
|
2014-01-20 15:47:52 +01:00
|
|
|
delete this->player;
|
2014-01-15 11:03:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
|
|
|
|
{
|
|
|
|
this->player->Move(movement);
|
|
|
|
}
|
2014-01-16 11:07:45 +01:00
|
|
|
void Game::PlayerData::UseWeapon(const WEAPON_FIRE &usage)
|
2014-01-14 10:28:12 +01:00
|
|
|
{
|
2014-01-16 11:07:45 +01:00
|
|
|
this->player->UseWeapon(usage);
|
2014-01-14 10:28:12 +01:00
|
|
|
}
|
2014-01-15 11:03:25 +01:00
|
|
|
Oyster::Math::Float3 Game::PlayerData::GetPosition()
|
|
|
|
{
|
|
|
|
return this->player->GetPosition();
|
|
|
|
}
|
2014-02-11 13:03:37 +01:00
|
|
|
Oyster::Math::Quaternion Game::PlayerData::GetRotation()
|
|
|
|
{
|
|
|
|
return this->player->GetRotation();
|
|
|
|
}
|
|
|
|
Oyster::Math::Float3 Game::PlayerData::GetScale()
|
|
|
|
{
|
|
|
|
return this->player->GetScale();
|
|
|
|
}
|
2014-01-15 11:03:25 +01:00
|
|
|
Oyster::Math::Float4x4 Game::PlayerData::GetOrientation()
|
|
|
|
{
|
|
|
|
return this->player->GetOrientation();
|
|
|
|
}
|
|
|
|
PLAYER_STATE Game::PlayerData::GetState() const
|
|
|
|
{
|
|
|
|
return this->player->GetState();
|
|
|
|
}
|
|
|
|
int Game::PlayerData::GetID() const
|
|
|
|
{
|
|
|
|
return this->player->GetID();
|
|
|
|
}
|
|
|
|
int Game::PlayerData::GetTeamID() const
|
|
|
|
{
|
|
|
|
return this->player->GetTeamID();
|
2014-01-20 15:47:52 +01:00
|
|
|
}
|
2014-01-28 15:04:25 +01:00
|
|
|
|
2014-02-12 14:48:58 +01:00
|
|
|
ObjectSpecialType Game::PlayerData::GetObjectType() const
|
2014-01-20 15:47:52 +01:00
|
|
|
{
|
2014-01-30 09:40:58 +01:00
|
|
|
return this->player->GetObjectType();
|
2014-01-21 09:52:48 +01:00
|
|
|
}
|
2014-02-21 11:10:47 +01:00
|
|
|
void Game::PlayerData::SetLookDir(const Oyster::Math3D::Float3& lookDir)
|
2014-01-21 09:52:48 +01:00
|
|
|
{
|
2014-02-21 11:10:47 +01:00
|
|
|
this->player->SetLookDir(lookDir);
|
2014-02-19 13:47:49 +01:00
|
|
|
}
|
|
|
|
void Game::PlayerData::TurnLeft(Oyster::Math3D::Float deltaLeftRadians )
|
|
|
|
{
|
|
|
|
this->player->TurnLeft(deltaLeftRadians);
|
2014-02-20 16:52:36 +01:00
|
|
|
}
|
|
|
|
void Game::PlayerData::Inactivate()
|
|
|
|
{
|
|
|
|
this->player->Inactivate();
|
|
|
|
}
|
|
|
|
void Game::PlayerData::Release()
|
|
|
|
{
|
|
|
|
this->player->ReleaseDynamicObject();
|
2014-01-15 11:03:25 +01:00
|
|
|
}
|