2013-11-19 11:07:14 +01:00
|
|
|
#include "Level.h"
|
2013-12-05 11:50:39 +01:00
|
|
|
#include "StaticObject.h"
|
|
|
|
#include "DynamicObject.h"
|
|
|
|
#include "GameMode.h"
|
2013-12-13 11:06:03 +01:00
|
|
|
#include "Player.h"
|
2013-12-18 08:30:58 +01:00
|
|
|
#include "PhysicsAPI.h"
|
|
|
|
#include "TeamManager.h"
|
2014-01-14 10:28:12 +01:00
|
|
|
#include "DynamicArray.h"
|
2013-11-19 11:07:14 +01:00
|
|
|
|
|
|
|
using namespace GameLogic;
|
2014-01-14 10:28:12 +01:00
|
|
|
using namespace Utility::DynamicMemory;
|
2014-01-16 11:40:29 +01:00
|
|
|
using namespace Oyster::Physics;
|
2013-11-19 11:07:14 +01:00
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
struct Level::PrivateData
|
|
|
|
{
|
2014-01-10 10:08:42 +01:00
|
|
|
PrivateData()
|
2013-12-05 11:50:39 +01:00
|
|
|
{
|
2013-12-12 09:36:14 +01:00
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
}
|
|
|
|
~PrivateData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-14 10:28:12 +01:00
|
|
|
SmartPointer<TeamManager> teamManager;
|
2013-12-05 11:50:39 +01:00
|
|
|
|
2014-01-14 10:28:12 +01:00
|
|
|
DynamicArray<SmartPointer<StaticObject>> staticObjects;
|
|
|
|
|
|
|
|
DynamicArray<SmartPointer<DynamicObject>> dynamicObjects;
|
2013-12-05 11:50:39 +01:00
|
|
|
|
2014-01-14 10:28:12 +01:00
|
|
|
SmartPointer<GameMode> gameMode;
|
2013-12-05 11:50:39 +01:00
|
|
|
|
2014-01-16 11:40:29 +01:00
|
|
|
SmartPointer<ICustomBody> rigidBodyLevel;
|
2013-12-18 08:30:58 +01:00
|
|
|
|
2013-12-05 11:50:39 +01:00
|
|
|
}myData;
|
|
|
|
|
2013-11-19 11:07:14 +01:00
|
|
|
Level::Level(void)
|
|
|
|
{
|
2013-12-05 11:50:39 +01:00
|
|
|
myData = new PrivateData();
|
2013-11-19 11:07:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Level::~Level(void)
|
|
|
|
{
|
2013-12-05 11:50:39 +01:00
|
|
|
delete myData;
|
2013-11-19 11:07:14 +01:00
|
|
|
}
|
2013-12-12 09:36:14 +01:00
|
|
|
|
2013-12-13 11:06:03 +01:00
|
|
|
void Level::InitiateLevel(std::string levelPath)
|
|
|
|
{
|
|
|
|
|
2014-01-16 11:40:29 +01:00
|
|
|
}
|
|
|
|
void Level::InitiateLevel(float radius)
|
|
|
|
{
|
|
|
|
API::SphericalBodyDescription sbDesc;
|
2014-01-16 12:08:24 +01:00
|
|
|
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
|
2014-01-16 11:40:29 +01:00
|
|
|
sbDesc.ignoreGravity = true;
|
|
|
|
sbDesc.radius = radius;
|
2014-01-16 12:08:24 +01:00
|
|
|
sbDesc.mass = 1e16; //10^16
|
2014-01-16 11:40:29 +01:00
|
|
|
sbDesc.subscription = CollisionManager::LevelCollision;
|
|
|
|
|
|
|
|
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
2014-01-16 12:08:24 +01:00
|
|
|
API::Instance().AddObject(rigidBody);
|
2014-01-16 11:40:29 +01:00
|
|
|
|
2014-01-16 12:08:24 +01:00
|
|
|
API::Gravity gravityWell;
|
|
|
|
|
|
|
|
gravityWell.gravityType = API::Gravity::GravityType_Well;
|
|
|
|
gravityWell.well.mass = (float)1e16;
|
|
|
|
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
|
|
|
|
|
|
|
|
API::Instance().AddGravity(gravityWell);
|
2014-01-16 11:40:29 +01:00
|
|
|
|
2013-12-13 11:06:03 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 08:30:58 +01:00
|
|
|
void Level::AddPlayerToTeam(Player *player, int teamID)
|
|
|
|
{
|
|
|
|
myData->teamManager->AddPlayerToTeam(player,teamID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Level::CreateTeam(int teamSize)
|
|
|
|
{
|
|
|
|
myData->teamManager->CreateTeam(teamSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Level::RespawnPlayer(Player *player)
|
|
|
|
{
|
|
|
|
myData->teamManager->RespawnPlayerRandom(player);
|
|
|
|
}
|
|
|
|
|
2013-12-12 09:36:14 +01:00
|
|
|
|