GL - merge with Erik
This commit is contained in:
commit
e21cfe4cd4
BIN
Bin/Level.txt
BIN
Bin/Level.txt
Binary file not shown.
BIN
Bin/map.txt
BIN
Bin/map.txt
Binary file not shown.
|
@ -9,12 +9,16 @@ using namespace GameLogic;
|
||||||
AttatchmentMassDriver::AttatchmentMassDriver(void)
|
AttatchmentMassDriver::AttatchmentMassDriver(void)
|
||||||
{
|
{
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
|
this->heldObject = NULL;
|
||||||
|
this->hasObject = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
|
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
|
||||||
{
|
{
|
||||||
|
|
||||||
this->owner = &owner;
|
this->owner = &owner;
|
||||||
|
this->heldObject = NULL;
|
||||||
|
this->hasObject = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,19 +39,62 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
|
||||||
ForcePush(usage,dt);
|
ForcePush(usage,dt);
|
||||||
break;
|
break;
|
||||||
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
|
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
|
||||||
|
|
||||||
|
if(hasObject)
|
||||||
|
{
|
||||||
|
ForcePush(usage,dt);//WARNING THIS IS A CRAP TEST TO MAKE SURE YOU CAN SHOOT BOXES
|
||||||
|
break;
|
||||||
|
}
|
||||||
ForcePull(usage,dt);
|
ForcePull(usage,dt);
|
||||||
break;
|
break;
|
||||||
|
case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS:
|
||||||
|
ForceZip(usage,dt);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AttatchmentMassDriver::Update(float dt)
|
||||||
|
{
|
||||||
|
|
||||||
|
//update position of heldObject if there is an object being held
|
||||||
|
if(hasObject)
|
||||||
|
{
|
||||||
|
Oyster::Physics::ICustomBody::State state;
|
||||||
|
state = heldObject->GetState();
|
||||||
|
Oyster::Math::Float3 ownerPos = owner->GetPosition();
|
||||||
|
ownerPos.y += 2;
|
||||||
|
Oyster::Math::Float3 pos = ownerPos + owner->GetLookDir().GetNormalized()*2;
|
||||||
|
|
||||||
|
state.SetCenterPosition(pos);
|
||||||
|
|
||||||
|
heldObject->SetState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Pushes objects in a cone in front of the weapon when fired
|
* Pushes objects in a cone in front of the weapon when fired
|
||||||
|
*alternativly it puts a large force on the currently held object
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
|
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
|
||||||
{
|
{
|
||||||
|
//if the weapon has an object then it is only the object that will be shot away
|
||||||
|
Oyster::Math::Float4 pushForce;
|
||||||
|
|
||||||
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
|
if(hasObject)
|
||||||
|
{
|
||||||
|
Oyster::Physics::API::Instance().ReleaseFromLimbo(heldObject);
|
||||||
|
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (2000);
|
||||||
|
Oyster::Physics::ICustomBody::State state = heldObject->GetState();
|
||||||
|
state.ApplyLinearImpulse((Oyster::Math::Float3)pushForce);
|
||||||
|
heldObject->SetState(state);
|
||||||
|
|
||||||
|
hasObject = false;
|
||||||
|
heldObject = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
|
||||||
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
|
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
|
||||||
|
|
||||||
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
|
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
|
||||||
|
@ -61,7 +108,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
|
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
|
void AttatchmentMassDriver::ForceZip(const WEAPON_FIRE &usage, float dt)
|
||||||
{
|
{
|
||||||
Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState();
|
Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState();
|
||||||
|
|
||||||
|
@ -72,3 +119,37 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
|
||||||
|
{
|
||||||
|
if(hasObject) return; //this test checks if the weapon already has something picked up, if so then it cant use this function
|
||||||
|
|
||||||
|
PickUpObject(usage,dt); //first test if there is a nearby object to pickup
|
||||||
|
|
||||||
|
if(hasObject) return; //this test checks if the weapon has now picked up an object, if so then it shall not apply a force to suck in objects
|
||||||
|
|
||||||
|
|
||||||
|
//if no object has been picked up then suck objects towards you
|
||||||
|
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100 * dt);
|
||||||
|
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
|
||||||
|
|
||||||
|
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
|
||||||
|
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
|
||||||
|
forcePushData args;
|
||||||
|
args.pushForce = -pushForce;
|
||||||
|
|
||||||
|
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
|
||||||
|
{
|
||||||
|
//Oyster::Math::Float4 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized();
|
||||||
|
//Oyster::Collision3D::Sphere hitSphere = Oyster::Collision3D::Sphere(pos,2000);
|
||||||
|
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
|
||||||
|
|
||||||
|
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
|
||||||
|
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,this,AttemptPickUp);
|
||||||
|
}
|
||||||
|
|
|
@ -16,29 +16,42 @@ namespace GameLogic
|
||||||
|
|
||||||
|
|
||||||
void UseAttatchment(const WEAPON_FIRE &usage, float dt);
|
void UseAttatchment(const WEAPON_FIRE &usage, float dt);
|
||||||
|
void Update(float dt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Pushes objects and players in a cone in front of the player
|
* Pushes objects and players in a cone in front of the player
|
||||||
* @param fireInput: allows switching on different functionality in this specific function
|
* @param usage: allows switching on different functionality in this specific function
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void ForcePush(const WEAPON_FIRE &usage, float dt);
|
void ForcePush(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Pulls the player forward, this is a movement tool
|
* Pulls the player forward, this is a movement tool
|
||||||
* @param fireInput: allows switching on different functionality in this specific function
|
* @param usage: allows switching on different functionality in this specific function
|
||||||
|
********************************************************/
|
||||||
|
void ForceZip(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Sucks objects towards the player, the player can then pick up an object and throw it as a projectile
|
||||||
|
* @param usage: allows switching on different functionality in this specific function
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void ForcePull(const WEAPON_FIRE &usage, float dt);
|
void ForcePull(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Sucks objects towards the player, the player can then pick up an object and throw it as a projectile
|
* Sucks objects towards the player, the player can then pick up an object and throw it as a projectile
|
||||||
* @param fireInput: allows switching on different functionality in this specific function
|
* @param usage: allows switching on different functionality in this specific function
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void ForceSuck(const WEAPON_FIRE &usage, float dt);
|
void PickUpObject(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
|
|
||||||
static void ForcePushAction(Oyster::Physics::ICustomBody *obj, void* args);
|
static void ForcePushAction(Oyster::Physics::ICustomBody *obj, void* args);
|
||||||
|
static void AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Oyster::Physics::ICustomBody *heldObject;
|
||||||
|
bool hasObject;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "Level.h"
|
#include "Level.h"
|
||||||
#include "AttatchmentMassDriver.h"
|
#include "AttatchmentMassDriver.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
|
|
||||||
|
@ -77,6 +78,13 @@ using namespace GameLogic;
|
||||||
{
|
{
|
||||||
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj)
|
||||||
|
{
|
||||||
|
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||||
{
|
{
|
||||||
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
||||||
|
@ -94,3 +102,32 @@ using namespace GameLogic;
|
||||||
state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce);
|
state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce);
|
||||||
obj->SetState(state);
|
obj->SetState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args)
|
||||||
|
{
|
||||||
|
AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args);
|
||||||
|
|
||||||
|
if(weapon->hasObject)
|
||||||
|
{
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Object* realObj = (Object*)(obj->GetCustomTag());
|
||||||
|
//check so that it is an object that you can pickup
|
||||||
|
|
||||||
|
switch(realObj->GetObjectType())
|
||||||
|
{
|
||||||
|
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
||||||
|
//move obj to limbo in physics to make sure it wont collide with anything
|
||||||
|
Oyster::Physics::API::Instance().MoveToLimbo(obj);
|
||||||
|
weapon->heldObject = obj; //weapon now holds the object
|
||||||
|
weapon->hasObject = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//put general collision functions here that are not part of a specific object
|
//put general collision functions here that are not part of a specific object
|
||||||
|
static Oyster::Physics::ICustomBody::SubscriptMessage IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ShowAllFiles>true</ShowAllFiles>
|
<ShowAllFiles>false</ShowAllFiles>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
|
|
@ -12,6 +12,7 @@ Game::PlayerData::PlayerData()
|
||||||
sbDesc.mass = 70;
|
sbDesc.mass = 70;
|
||||||
sbDesc.restitutionCoeff = 0.5;
|
sbDesc.restitutionCoeff = 0.5;
|
||||||
sbDesc.rotation = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
|
sbDesc.rotation = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
|
||||||
|
|
||||||
//create rigid body
|
//create rigid body
|
||||||
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
|
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace GameLogic
|
||||||
~IAttatchment(void);
|
~IAttatchment(void);
|
||||||
|
|
||||||
virtual void UseAttatchment(const WEAPON_FIRE &usage, float dt) = 0;
|
virtual void UseAttatchment(const WEAPON_FIRE &usage, float dt) = 0;
|
||||||
|
virtual void Update(float dt) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,11 @@ void Level::InitiateLevel(float radius)
|
||||||
API::SimpleBodyDescription sbDesc_TestBox;
|
API::SimpleBodyDescription sbDesc_TestBox;
|
||||||
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(10,320,0,0);
|
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(10,320,0,0);
|
||||||
sbDesc_TestBox.ignoreGravity = false;
|
sbDesc_TestBox.ignoreGravity = false;
|
||||||
|
|
||||||
sbDesc_TestBox.mass = 50;
|
sbDesc_TestBox.mass = 50;
|
||||||
sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0);
|
sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0);
|
||||||
|
|
||||||
|
|
||||||
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
|
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
|
||||||
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);
|
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,30 @@
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
#include "LevelLoader.h"
|
#include "LevelLoader.h"
|
||||||
|
#include "LevelParser.h"
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace GameLogic::LevelFileLoader;
|
using namespace GameLogic::LevelFileLoader;
|
||||||
|
|
||||||
|
struct LevelLoader::PrivData
|
||||||
std::vector<ObjectTypeHeader> LevelLoader::LoadLevel(std::string fileName)
|
|
||||||
{
|
{
|
||||||
return parser.Parse(fileName);
|
LevelParser parser;
|
||||||
|
};
|
||||||
|
|
||||||
|
LevelLoader::LevelLoader()
|
||||||
|
: pData(new PrivData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LevelLoader::~LevelLoader()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::string fileName)
|
||||||
|
{
|
||||||
|
return pData->parser.Parse(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
|
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
|
||||||
{
|
{
|
||||||
return parser.ParseHeader(fileName);
|
return pData->parser.ParseHeader(fileName);
|
||||||
}
|
}
|
|
@ -7,36 +7,36 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <Vector.h>
|
#include "../Misc/Utilities.h"
|
||||||
#include "ObjectDefines.h"
|
#include "ObjectDefines.h"
|
||||||
#include "LevelParser.h"
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
class LevelLoader
|
class LevelLoader
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LevelLoader(){this->parser = GameLogic::LevelFileLoader::LevelParser(); }
|
LevelLoader();
|
||||||
~LevelLoader(){}
|
~LevelLoader();
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Loads the level and objects from file.
|
* Loads the level and objects from file.
|
||||||
* @param fileName: Path to the level-file that you want to load.
|
* @param fileName: Path to the level-file that you want to load.
|
||||||
* @return: Returns all structs with objects and information about the level.
|
* @return: Returns all structs with objects and information about the level.
|
||||||
********************************************************/
|
********************************************************/
|
||||||
std::vector<ObjectTypeHeader> LoadLevel(std::string fileName);
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::string fileName);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Just for fast access for the meta information about the level.
|
* Just for fast access for the meta information about the level.
|
||||||
* @param fileName: Path to the level-file that you want to load.
|
* @param fileName: Path to the level-file that you want to load.
|
||||||
* @return: Returns the meta information about the level.
|
* @return: Returns the meta information about the level.
|
||||||
********************************************************/
|
********************************************************/
|
||||||
LevelMetaData LoadLevelHeader(std::string fileName); //.
|
LevelMetaData LoadLevelHeader(std::string fileName); //.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameLogic::LevelFileLoader::LevelParser parser;
|
struct PrivData;
|
||||||
};
|
Utility::DynamicMemory::SmartPointer<PrivData> pData;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace ::LevelFileLoader;
|
using namespace ::LevelFileLoader;
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
LevelParser::LevelParser()
|
LevelParser::LevelParser()
|
||||||
{
|
{
|
||||||
|
@ -16,12 +17,12 @@ LevelParser::~LevelParser()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
|
std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filename)
|
||||||
{
|
{
|
||||||
int bufferSize = 0;
|
int bufferSize = 0;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
std::vector<ObjectTypeHeader> objects;
|
std::vector<SmartPointer<ObjectTypeHeader>> objects;
|
||||||
|
|
||||||
//Read entire level file.
|
//Read entire level file.
|
||||||
Loader loader;
|
Loader loader;
|
||||||
|
@ -42,26 +43,66 @@ std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
|
||||||
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
||||||
switch((int)typeID.typeID)
|
switch((int)typeID.typeID)
|
||||||
{
|
{
|
||||||
case ObjectType_LevelMetaData:
|
case ObjectType_LevelMetaData:
|
||||||
{
|
{
|
||||||
LevelMetaData header;
|
LevelMetaData* header = new LevelMetaData;
|
||||||
ParseLevelMetaData(&buffer[counter], header, counter);
|
ParseLevelMetaData(&buffer[counter], *header, counter);
|
||||||
objects.push_back(header);
|
objects.push_back(header);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ObjectType_Dynamic:
|
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
||||||
{
|
case ObjectType_Static: case ObjectType_Dynamic:
|
||||||
ObjectHeader header;
|
{
|
||||||
ParseObject(&buffer[counter], &header, sizeof(header));
|
ObjectHeader* header = new ObjectHeader;
|
||||||
objects.push_back(header);
|
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||||
counter += sizeof(header);
|
objects.push_back(header);
|
||||||
break;
|
counter += sizeof(*header);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
case ObjectType_Light:
|
||||||
//Couldn't find typeID. FAIL!!!!!!
|
{
|
||||||
break;
|
LightType lightType;
|
||||||
|
|
||||||
|
//Get Light type
|
||||||
|
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
||||||
|
|
||||||
|
switch(lightType)
|
||||||
|
{
|
||||||
|
case LightType_PointLight:
|
||||||
|
{
|
||||||
|
PointLight* header = new PointLight;
|
||||||
|
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||||
|
counter += sizeof(*header);
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LightType_DirectionalLight:
|
||||||
|
{
|
||||||
|
DirectionalLight* header = new DirectionalLight;
|
||||||
|
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||||
|
counter += sizeof(*header);
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LightType_SpotLight:
|
||||||
|
{
|
||||||
|
SpotLight* header = new SpotLight;
|
||||||
|
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||||
|
counter += sizeof(*header);
|
||||||
|
objects.push_back(header);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
//Undefined LightType.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
//Couldn't find typeID. FAIL!!!!!!
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "ObjectDefines.h"
|
#include "ObjectDefines.h"
|
||||||
|
#include "../Misc/Utilities.h"
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -16,7 +17,7 @@ namespace GameLogic
|
||||||
~LevelParser();
|
~LevelParser();
|
||||||
|
|
||||||
//
|
//
|
||||||
std::vector<ObjectTypeHeader> Parse(std::string filename);
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> Parse(std::string filename);
|
||||||
|
|
||||||
//
|
//
|
||||||
LevelMetaData ParseHeader(std::string filename);
|
LevelMetaData ParseHeader(std::string filename);
|
||||||
|
|
|
@ -15,11 +15,12 @@ namespace GameLogic
|
||||||
ObjectType_LevelMetaData,
|
ObjectType_LevelMetaData,
|
||||||
ObjectType_Static,
|
ObjectType_Static,
|
||||||
ObjectType_Dynamic,
|
ObjectType_Dynamic,
|
||||||
|
ObjectType_Light,
|
||||||
//Etc
|
//Etc
|
||||||
|
|
||||||
ObjectType_NUM_OF_TYPES,
|
ObjectType_NUM_OF_TYPES,
|
||||||
|
|
||||||
ObjectType_Unknown = -1,
|
ObjectType_Unknown = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UsePhysics
|
enum UsePhysics
|
||||||
|
@ -29,7 +30,17 @@ namespace GameLogic
|
||||||
UsePhysics_IgnorePhysics,
|
UsePhysics_IgnorePhysics,
|
||||||
|
|
||||||
UsePhysics_Count,
|
UsePhysics_Count,
|
||||||
UsePhysics_Unknown = -1,
|
UsePhysics_Unknown = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum LightType
|
||||||
|
{
|
||||||
|
LightType_PointLight,
|
||||||
|
LightType_DirectionalLight,
|
||||||
|
LightType_SpotLight,
|
||||||
|
|
||||||
|
LightType_Count,
|
||||||
|
LightType_Unknown = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
//Should this be moved somewhere else?
|
//Should this be moved somewhere else?
|
||||||
|
@ -40,7 +51,7 @@ namespace GameLogic
|
||||||
//Etc
|
//Etc
|
||||||
|
|
||||||
GameMode_Count,
|
GameMode_Count,
|
||||||
GameMode_Unknown = -1,
|
GameMode_Unknown = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,6 +115,36 @@ namespace GameLogic
|
||||||
//Scale
|
//Scale
|
||||||
float scale[3];
|
float scale[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/************************************
|
||||||
|
Lights
|
||||||
|
*************************************/
|
||||||
|
|
||||||
|
struct BasicLight : public ObjectTypeHeader
|
||||||
|
{
|
||||||
|
LightType lightType;
|
||||||
|
float ambientColor[3];
|
||||||
|
float diffuseColor[3];
|
||||||
|
float specularColor[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PointLight : public BasicLight
|
||||||
|
{
|
||||||
|
float position[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DirectionalLight : public BasicLight
|
||||||
|
{
|
||||||
|
float direction[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SpotLight : public BasicLight
|
||||||
|
{
|
||||||
|
float direction[3];
|
||||||
|
float range;
|
||||||
|
float attenuation[3];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -10,6 +10,14 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
namespace LevelFileLoader
|
namespace LevelFileLoader
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
These functions will copy data from where the buffer pointer points.
|
||||||
|
header is the destination where the data will be copied.
|
||||||
|
size is either the size of the data to be copied (if it is NOT sent by reference).
|
||||||
|
Or the current index that is being used to parse the entire file (if it is sent by reference) this means you have to increase size with the appropiate size after you have copied.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
void ParseObject(char* buffer, void *header, int size);
|
void ParseObject(char* buffer, void *header, int size);
|
||||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ namespace GameLogic
|
||||||
Oyster::Physics::ICustomBody* GetRigidBody();
|
Oyster::Physics::ICustomBody* GetRigidBody();
|
||||||
void ApplyLinearImpulse(Oyster::Math::Float3 force);
|
void ApplyLinearImpulse(Oyster::Math::Float3 force);
|
||||||
|
|
||||||
void BeginFrame();
|
virtual void BeginFrame();
|
||||||
void EndFrame();
|
virtual void EndFrame();
|
||||||
|
|
||||||
void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter));
|
void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter));
|
||||||
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
|
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
|
||||||
|
|
|
@ -58,6 +58,18 @@ Player::~Player(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::BeginFrame()
|
||||||
|
{
|
||||||
|
weapon->Update(0.002f);
|
||||||
|
Object::BeginFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::EndFrame()
|
||||||
|
{
|
||||||
|
|
||||||
|
Object::EndFrame();
|
||||||
|
}
|
||||||
|
|
||||||
void Player::Move(const PLAYER_MOVEMENT &movement)
|
void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||||
{
|
{
|
||||||
switch(movement)
|
switch(movement)
|
||||||
|
|
|
@ -71,6 +71,9 @@ namespace GameLogic
|
||||||
|
|
||||||
void DamageLife(int damage);
|
void DamageLife(int damage);
|
||||||
|
|
||||||
|
void BeginFrame();
|
||||||
|
void EndFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Jump();
|
void Jump();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "StaticObject.h"
|
#include "StaticObject.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
@ -17,7 +18,8 @@ StaticObject::StaticObject(OBJECT_TYPE type)
|
||||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
|
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
|
||||||
:Object(rigidBody,type)
|
:Object(rigidBody,type)
|
||||||
{
|
{
|
||||||
|
this->rigidBody->SetGravity(true);
|
||||||
|
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision));
|
||||||
}
|
}
|
||||||
|
|
||||||
StaticObject::StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
StaticObject::StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||||
|
|
|
@ -126,3 +126,8 @@ void Weapon::SelectAttatchment(int socketID)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Weapon::Update(float dt)
|
||||||
|
{
|
||||||
|
selectedAttatchment->Update(dt);
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ namespace GameLogic
|
||||||
~Weapon(void);
|
~Weapon(void);
|
||||||
|
|
||||||
void Use(const WEAPON_FIRE &usage, float dt);
|
void Use(const WEAPON_FIRE &usage, float dt);
|
||||||
|
void Update(float dt);
|
||||||
|
|
||||||
void AddNewAttatchment(IAttatchment *attatchment, Player *owner);
|
void AddNewAttatchment(IAttatchment *attatchment, Player *owner);
|
||||||
void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner);
|
void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner);
|
||||||
|
|
|
@ -185,7 +185,9 @@ namespace DanBias
|
||||||
}
|
}
|
||||||
void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c )
|
void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c )
|
||||||
{
|
{
|
||||||
c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
//c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||||
|
c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS);
|
||||||
|
//c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||||
}
|
}
|
||||||
void GameSession::Gameplay_PlayerJump ( Protocol_PlayerJump& p, DanBias::GameClient* c )
|
void GameSession::Gameplay_PlayerJump ( Protocol_PlayerJump& p, DanBias::GameClient* c )
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,8 +84,8 @@ namespace Oyster
|
||||||
*/
|
*/
|
||||||
std::string GetLanAddress();
|
std::string GetLanAddress();
|
||||||
|
|
||||||
/**
|
/** Returns the port the server is listening on.
|
||||||
*
|
* @return Returns the port the server has been initiated with.
|
||||||
*/
|
*/
|
||||||
int NetworkServer::GetPort();
|
int NetworkServer::GetPort();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue