2013-11-19 11:07:14 +01:00
|
|
|
#include "Level.h"
|
2014-01-20 15:47:52 +01:00
|
|
|
#include "CollisionManager.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
|
|
|
|
2013-11-19 11:07:14 +01:00
|
|
|
Level::Level(void)
|
|
|
|
{
|
2014-01-28 15:04:25 +01:00
|
|
|
|
2013-11-19 11:07:14 +01:00
|
|
|
}
|
|
|
|
Level::~Level(void)
|
|
|
|
{
|
|
|
|
}
|
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)
|
|
|
|
{
|
2014-01-29 14:33:21 +01:00
|
|
|
|
2014-01-29 13:18:17 +01:00
|
|
|
// add level sphere
|
2014-01-21 14:28:27 +01:00
|
|
|
API::SphericalBodyDescription sbDesc;
|
|
|
|
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
|
|
|
|
sbDesc.ignoreGravity = true;
|
2014-01-30 15:12:53 +01:00
|
|
|
sbDesc.radius = 300;
|
2014-01-21 14:28:27 +01:00
|
|
|
sbDesc.mass = 10e12f;
|
2014-01-23 09:14:04 +01:00
|
|
|
|
2014-01-21 14:28:27 +01:00
|
|
|
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
2014-01-28 15:04:25 +01:00
|
|
|
|
2014-01-21 14:28:27 +01:00
|
|
|
ICustomBody::State state;
|
|
|
|
rigidBody->GetState(state);
|
2014-01-29 13:18:17 +01:00
|
|
|
state.SetRestitutionCoeff(0.01);
|
2014-01-21 14:28:27 +01:00
|
|
|
rigidBody->SetState(state);
|
2014-01-29 14:33:21 +01:00
|
|
|
|
|
|
|
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
|
2014-01-28 15:04:25 +01:00
|
|
|
rigidBody->SetCustomTag(levelObj);
|
|
|
|
|
2014-01-28 15:44:32 +01:00
|
|
|
|
2014-01-30 15:12:53 +01:00
|
|
|
// add box
|
2014-01-27 14:43:39 +01:00
|
|
|
API::SimpleBodyDescription sbDesc_TestBox;
|
2014-01-31 09:12:15 +01:00
|
|
|
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(4,320,0,0);
|
2014-01-27 14:43:39 +01:00
|
|
|
sbDesc_TestBox.ignoreGravity = false;
|
|
|
|
sbDesc_TestBox.mass = 10;
|
2014-01-31 14:05:52 +01:00
|
|
|
sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0);
|
2014-01-28 15:04:25 +01:00
|
|
|
|
2014-01-27 13:54:57 +01:00
|
|
|
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
|
2014-01-28 15:04:25 +01:00
|
|
|
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);
|
2014-01-29 14:33:21 +01:00
|
|
|
|
|
|
|
testBox = new DynamicObject(rigidBody_TestBox, OBJECT_TYPE::OBJECT_TYPE_BOX);
|
2014-01-28 15:04:25 +01:00
|
|
|
rigidBody_TestBox->SetCustomTag(testBox);
|
|
|
|
rigidBody_TestBox->GetState(state);
|
2014-01-31 09:39:44 +01:00
|
|
|
state.ApplyLinearImpulse(Oyster::Math::Float3(0,20,0));
|
2014-01-28 15:04:25 +01:00
|
|
|
rigidBody_TestBox->SetState(state);
|
|
|
|
|
2014-01-29 13:18:17 +01:00
|
|
|
|
|
|
|
// add gravitation
|
2014-01-28 15:04:25 +01:00
|
|
|
API::Gravity gravityWell;
|
2014-01-21 14:28:27 +01:00
|
|
|
gravityWell.gravityType = API::Gravity::GravityType_Well;
|
2014-01-30 15:12:53 +01:00
|
|
|
gravityWell.well.mass = 1e15f;
|
2014-01-21 14:28:27 +01:00
|
|
|
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
|
|
|
|
API::Instance().AddGravity(gravityWell);
|
2013-12-13 11:06:03 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 08:30:58 +01:00
|
|
|
void Level::AddPlayerToTeam(Player *player, int teamID)
|
|
|
|
{
|
2014-01-20 15:47:52 +01:00
|
|
|
this->teamManager.AddPlayerToTeam(player,teamID);
|
2013-12-18 08:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Level::CreateTeam(int teamSize)
|
|
|
|
{
|
2014-01-20 15:47:52 +01:00
|
|
|
this->teamManager.CreateTeam(teamSize);
|
2013-12-18 08:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Level::RespawnPlayer(Player *player)
|
|
|
|
{
|
2014-01-20 15:47:52 +01:00
|
|
|
this->teamManager.RespawnPlayerRandom(player);
|
2013-12-18 08:30:58 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 15:04:25 +01:00
|
|
|
Object* Level::GetObj( int ID) const
|
|
|
|
{
|
2014-01-29 13:18:17 +01:00
|
|
|
if( ID == 0 )
|
|
|
|
return (Object*)levelObj;
|
|
|
|
else
|
|
|
|
return (Object*)testBox;
|
2014-01-28 15:04:25 +01:00
|
|
|
}
|
|
|
|
void Level::PhysicsOnMoveLevel(const ICustomBody *object)
|
|
|
|
{
|
|
|
|
// function call from physics update when object was moved
|
|
|
|
Object* temp = (Object*)object->GetCustomTag();
|
|
|
|
}
|