Danbias/Code/Game/GameLogic/Level.cpp

89 lines
1.7 KiB
C++
Raw Normal View History

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"
#include "Player.h"
#include "PhysicsAPI.h"
#include "TeamManager.h"
#include "DynamicArray.h"
2013-11-19 11:07:14 +01:00
using namespace GameLogic;
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
{
PrivateData()
2013-12-05 11:50:39 +01:00
{
2013-12-05 11:50:39 +01:00
}
~PrivateData()
{
}
SmartPointer<TeamManager> teamManager;
2013-12-05 11:50:39 +01:00
DynamicArray<SmartPointer<StaticObject>> staticObjects;
DynamicArray<SmartPointer<DynamicObject>> dynamicObjects;
2013-12-05 11:50:39 +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-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
}
void Level::InitiateLevel(std::string levelPath)
{
2014-01-16 11:40:29 +01:00
}
void Level::InitiateLevel(float radius)
{
API::SphericalBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
2014-01-16 11:40:29 +01:00
sbDesc.ignoreGravity = true;
sbDesc.radius = radius;
sbDesc.mass = 1e16; //10^16
2014-01-16 11:40:29 +01:00
sbDesc.subscription = CollisionManager::LevelCollision;
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
API::Instance().AddObject(rigidBody);
2014-01-16 11:40:29 +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
}
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);
}