GameServer - Merged with GameLogic
This commit is contained in:
commit
702e143e4b
|
@ -170,12 +170,12 @@ using namespace GameLogic;
|
||||||
|
|
||||||
void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage)
|
void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage)
|
||||||
{
|
{
|
||||||
int damageDone = 0;
|
Oyster::Math::Float damageDone = 0;
|
||||||
int forceThreashHold = 200000;
|
Oyster::Math::Float forceThreashHold = 200000;
|
||||||
|
|
||||||
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
||||||
{
|
{
|
||||||
damageDone = (int)(kineticEnergyLoss * 0.10f);
|
damageDone = (kineticEnergyLoss * 0.10f);
|
||||||
damageDone += ExtraDamage;
|
damageDone += ExtraDamage;
|
||||||
//player.DamageLife(damageDone);
|
//player.DamageLife(damageDone);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ IObjectData* Game::LevelData::GetObjectAt(int ID) const
|
||||||
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
||||||
{
|
{
|
||||||
mem.Resize(level->dynamicObjects.Size());
|
mem.Resize(level->dynamicObjects.Size());
|
||||||
for(int i = 0; i < level->dynamicObjects.Size(); i++)
|
for(int i = 0; i < (int)level->dynamicObjects.Size(); i++)
|
||||||
{
|
{
|
||||||
mem[i] = level->dynamicObjects[i];
|
mem[i] = level->dynamicObjects[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,7 @@ Game::PlayerData::PlayerData()
|
||||||
}
|
}
|
||||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||||
{
|
{
|
||||||
Oyster::Physics::ICustomBody* rigidBody;
|
|
||||||
this->player = new Player();
|
this->player = new Player();
|
||||||
|
|
||||||
}
|
}
|
||||||
Game::PlayerData::~PlayerData()
|
Game::PlayerData::~PlayerData()
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,9 +63,9 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_RedExplosiveBox:
|
case ObjectSpecialType_RedExplosiveBox:
|
||||||
{
|
{
|
||||||
int dmg = 50;
|
Oyster::Math::Float dmg = 50;
|
||||||
Oyster::Math::Float force = 50;
|
Oyster::Math::Float force = 50;
|
||||||
int radie = 50;
|
Oyster::Math::Float radie = 50;
|
||||||
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -353,7 +353,7 @@ void Level::InitiateLevel(float radius)
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for(int i =0; i< nrOfBoxex; i ++)
|
for(int i =0; i< nrOfBoxex; i ++)
|
||||||
{
|
{
|
||||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
|
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(0.0f, 605.0f + i*5.0f, 10.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
|
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
||||||
}
|
}
|
||||||
|
@ -385,16 +385,16 @@ void Level::InitiateLevel(float radius)
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// add crystal
|
// add crystal
|
||||||
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f);
|
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(10.0f, 605.0f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
||||||
|
|
||||||
// add house
|
// add house
|
||||||
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f);
|
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20.0f, 20.0f, 20.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(-50.0f, 590.0f, 0.0f), 0.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++));
|
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++));
|
||||||
|
|
||||||
// add jumppad
|
// add jumppad
|
||||||
|
|
||||||
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
|
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1.0f, 1.0f, 1.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(4.0f, 600.3f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ int Level::getNrOfDynamicObj()
|
||||||
}
|
}
|
||||||
Object* Level::GetObj( int ID) const
|
Object* Level::GetObj( int ID) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this->dynamicObjects.Size(); i++)
|
for (int i = 0; i < (int)this->dynamicObjects.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->dynamicObjects[i]->GetID() == ID)
|
if(this->dynamicObjects[i]->GetID() == ID)
|
||||||
return this->dynamicObjects[i];
|
return this->dynamicObjects[i];
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace GameLogic
|
||||||
CollisionGeometryType_Box,
|
CollisionGeometryType_Box,
|
||||||
CollisionGeometryType_Sphere,
|
CollisionGeometryType_Sphere,
|
||||||
CollisionGeometryType_Cylinder,
|
CollisionGeometryType_Cylinder,
|
||||||
|
CollisionGeometryType_TriangleMesh,
|
||||||
|
|
||||||
CollisionGeometryType_Count,
|
CollisionGeometryType_Count,
|
||||||
CollisionGeometryType_Unknown = -1
|
CollisionGeometryType_Unknown = -1
|
||||||
|
@ -161,6 +162,12 @@ namespace GameLogic
|
||||||
float radius;
|
float radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BoundingVolumeTriangleMesh : public BoundingVolumeBase
|
||||||
|
{
|
||||||
|
//Null terminated
|
||||||
|
wchar_t* filename;
|
||||||
|
};
|
||||||
|
|
||||||
struct BoundingVolume
|
struct BoundingVolume
|
||||||
{
|
{
|
||||||
CollisionGeometryType geoType;
|
CollisionGeometryType geoType;
|
||||||
|
@ -169,7 +176,16 @@ namespace GameLogic
|
||||||
LevelLoaderInternal::BoundingVolumeBox box;
|
LevelLoaderInternal::BoundingVolumeBox box;
|
||||||
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
||||||
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
||||||
|
LevelLoaderInternal::BoundingVolumeTriangleMesh triangleMesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual ~BoundingVolume()
|
||||||
|
{
|
||||||
|
if(geoType == CollisionGeometryType_TriangleMesh)
|
||||||
|
{
|
||||||
|
delete[] triangleMesh.filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace GameLogic
|
||||||
|
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
for(int i = 0; i < tempSize; i++)
|
for(int i = 0; i < (int)tempSize; i++)
|
||||||
{
|
{
|
||||||
memcpy(&temp, &buffer[start], 4);
|
memcpy(&temp, &buffer[start], 4);
|
||||||
start += 4;
|
start += 4;
|
||||||
|
@ -175,6 +175,17 @@ namespace GameLogic
|
||||||
start += sizeof(volume.cylinder);
|
start += sizeof(volume.cylinder);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CollisionGeometryType_TriangleMesh:
|
||||||
|
//Get string size
|
||||||
|
memcpy(&tempSize, &buf[start], sizeof(tempSize));
|
||||||
|
start += sizeof(tempSize);
|
||||||
|
|
||||||
|
//Get actual string
|
||||||
|
volume.triangleMesh.filename = new wchar_t[tempSize+1];
|
||||||
|
memcpy(volume.triangleMesh.filename, &buf[start], tempSize);
|
||||||
|
volume.triangleMesh.filename[tempSize] = '\0';
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ void Player::BeginFrame()
|
||||||
forwardDir.Normalize();
|
forwardDir.Normalize();
|
||||||
rightDir.Normalize();
|
rightDir.Normalize();
|
||||||
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
|
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
|
||||||
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2;
|
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2f;
|
||||||
|
|
||||||
if (key_forward > 0.001)
|
if (key_forward > 0.001)
|
||||||
{
|
{
|
||||||
|
@ -122,7 +122,7 @@ void Player::BeginFrame()
|
||||||
if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f)
|
if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f)
|
||||||
{
|
{
|
||||||
/* Dampen when on the ground and not being moved by the player */
|
/* Dampen when on the ground and not being moved by the player */
|
||||||
linearVelocity *= 0.2;
|
linearVelocity *= 0.2f;
|
||||||
this->rigidBody->SetLinearVelocity (linearVelocity);
|
this->rigidBody->SetLinearVelocity (linearVelocity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -300,11 +300,11 @@ Float4x4 SimpleRigidBody::GetView( const ::Oyster::Math::Float3 &offset ) const
|
||||||
|
|
||||||
Float3 SimpleRigidBody::GetGravity() const
|
Float3 SimpleRigidBody::GetGravity() const
|
||||||
{
|
{
|
||||||
return this->rigidBody->getGravity();
|
return (Float3)this->rigidBody->getGravity();
|
||||||
}
|
}
|
||||||
Float3 SimpleRigidBody::GetLinearVelocity() const
|
Float3 SimpleRigidBody::GetLinearVelocity() const
|
||||||
{
|
{
|
||||||
return this->rigidBody->getLinearVelocity();
|
return (Float3)this->rigidBody->getLinearVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue