Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
fa02814ca0
|
@ -35,7 +35,7 @@ using namespace GameLogic;
|
||||||
//return Physics::ICustomBody::SubscriptMessage_none;
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
break;
|
break;
|
||||||
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
|
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
|
||||||
int test = 5;
|
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,14 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
|
|
||||||
//Read format version
|
//Read format version
|
||||||
FormatVersion levelFormatVersion;
|
FormatVersion levelFormatVersion;
|
||||||
//ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
|
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion));
|
||||||
|
counter += sizeof(levelFormatVersion);
|
||||||
if(this->formatVersion != levelFormatVersion)
|
if(this->formatVersion != levelFormatVersion)
|
||||||
{
|
{
|
||||||
//Do something if it's not the same version
|
//Do something if it's not the same version
|
||||||
}
|
}
|
||||||
|
|
||||||
while(counter < bufferSize)
|
while(counter < bufferSize)
|
||||||
{
|
{
|
||||||
//Get typeID
|
//Get typeID
|
||||||
ObjectTypeHeader typeID;
|
ObjectTypeHeader typeID;
|
||||||
|
@ -55,9 +56,8 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
case ObjectType_Static: case ObjectType_Dynamic:
|
case ObjectType_Static: case ObjectType_Dynamic:
|
||||||
{
|
{
|
||||||
ObjectHeader* header = new ObjectHeader;
|
ObjectHeader* header = new ObjectHeader;
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
ParseObject(&buffer[counter], *header, counter);
|
||||||
objects.push_back(header);
|
objects.push_back(header);
|
||||||
counter += sizeof(*header);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,8 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
||||||
|
|
||||||
//Read format version
|
//Read format version
|
||||||
FormatVersion levelFormatVersion;
|
FormatVersion levelFormatVersion;
|
||||||
//ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
|
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
|
||||||
|
counter += sizeof(levelFormatVersion);
|
||||||
if(this->formatVersion != levelFormatVersion)
|
if(this->formatVersion != levelFormatVersion)
|
||||||
{
|
{
|
||||||
//Do something if it's not the same version
|
//Do something if it's not the same version
|
||||||
|
@ -142,11 +143,42 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
||||||
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
|
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
|
||||||
return levelHeader;
|
return levelHeader;
|
||||||
break;
|
break;
|
||||||
case ObjectType_Dynamic:
|
|
||||||
//Do not call parse this object, since we are only interested in the LevelMetaData
|
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
||||||
//Only increase the counter size
|
case ObjectType_Static: case ObjectType_Dynamic:
|
||||||
counter += sizeof(ObjectHeader);
|
{
|
||||||
|
ObjectHeader header;
|
||||||
|
ParseObject(&buffer[counter], header, counter);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectType_Light:
|
||||||
|
{
|
||||||
|
LightType lightType;
|
||||||
|
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
||||||
|
|
||||||
|
switch(lightType)
|
||||||
|
{
|
||||||
|
case LightType_PointLight:
|
||||||
|
{
|
||||||
|
counter += sizeof(PointLight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LightType_DirectionalLight:
|
||||||
|
{
|
||||||
|
counter += sizeof(DirectionalLight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LightType_SpotLight:
|
||||||
|
{
|
||||||
|
counter += sizeof(SpotLight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
//Undefined LightType.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//Couldn't find typeID. FAIL!!!!!!
|
//Couldn't find typeID. FAIL!!!!!!
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace GameLogic
|
||||||
UsePhysics_UseFullPhysics,
|
UsePhysics_UseFullPhysics,
|
||||||
UsePhysics_IgnoreGravity,
|
UsePhysics_IgnoreGravity,
|
||||||
UsePhysics_IgnorePhysics,
|
UsePhysics_IgnorePhysics,
|
||||||
|
UsePhysics_IgnoreCollision,
|
||||||
|
|
||||||
UsePhysics_Count,
|
UsePhysics_Count,
|
||||||
UsePhysics_Unknown = -1
|
UsePhysics_Unknown = -1
|
||||||
|
@ -82,12 +83,13 @@ namespace GameLogic
|
||||||
|
|
||||||
struct PhysicsObject
|
struct PhysicsObject
|
||||||
{
|
{
|
||||||
|
UsePhysics usePhysics;
|
||||||
float mass;
|
float mass;
|
||||||
float elasticity;
|
float inertiaMagnitude[3];
|
||||||
|
float inertiaRotation[3];
|
||||||
float frictionCoeffStatic;
|
float frictionCoeffStatic;
|
||||||
float frictionCoeffDynamic;
|
float frictionCoeffDynamic;
|
||||||
float inertiaTensor[16];
|
|
||||||
UsePhysics usePhysics;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LevelMetaData : ObjectTypeHeader
|
struct LevelMetaData : ObjectTypeHeader
|
||||||
|
@ -97,17 +99,15 @@ namespace GameLogic
|
||||||
std::string levelDescription;
|
std::string levelDescription;
|
||||||
std::string levelAuthor;
|
std::string levelAuthor;
|
||||||
int maxNumberOfPlayer;
|
int maxNumberOfPlayer;
|
||||||
float worldSize;
|
int worldSize;
|
||||||
int overviewPictureID;
|
std::string overviewPicturePath;
|
||||||
std::vector<GameMode> gameModesSupported;
|
std::vector<GameMode> gameModesSupported;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ObjectHeader : public ObjectTypeHeader
|
struct ObjectHeader : public ObjectTypeHeader
|
||||||
{
|
{
|
||||||
//Model,
|
//Model,
|
||||||
int ModelID;
|
std::string ModelFile;
|
||||||
//Texture
|
|
||||||
int TextureID;
|
|
||||||
//Position
|
//Position
|
||||||
float position[3];
|
float position[3];
|
||||||
//Rotation
|
//Rotation
|
||||||
|
|
|
@ -20,11 +20,33 @@ namespace GameLogic
|
||||||
memcpy(header, buffer, size);
|
memcpy(header, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ParseObject(char* buffer, ObjectHeader& header, int& size)
|
||||||
|
{
|
||||||
|
char tempName[128];
|
||||||
|
int tempSize = 0;
|
||||||
|
int start = 0;
|
||||||
|
|
||||||
|
memcpy(&header.typeID, &buffer[start], 4);
|
||||||
|
start += 4;
|
||||||
|
|
||||||
|
memcpy(&tempSize, &buffer[start], 4);
|
||||||
|
start += 4;
|
||||||
|
|
||||||
|
memcpy(&tempName, &buffer[start], tempSize);
|
||||||
|
header.ModelFile.assign(&tempName[0], &tempName[tempSize]);
|
||||||
|
start += tempSize;
|
||||||
|
|
||||||
|
memcpy(&header.position, &buffer[start], 36);
|
||||||
|
start += 36;
|
||||||
|
|
||||||
|
size += start;
|
||||||
|
}
|
||||||
|
|
||||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size)
|
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size)
|
||||||
{
|
{
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int tempSize;
|
int tempSize;
|
||||||
char tempName[100];
|
char tempName[128];
|
||||||
|
|
||||||
memcpy(&header.typeID, &buffer[start], 4);
|
memcpy(&header.typeID, &buffer[start], 4);
|
||||||
start += 4;
|
start += 4;
|
||||||
|
@ -59,9 +81,13 @@ namespace GameLogic
|
||||||
memcpy(&header.worldSize, &buffer[start], 4);
|
memcpy(&header.worldSize, &buffer[start], 4);
|
||||||
start += 4;
|
start += 4;
|
||||||
|
|
||||||
memcpy(&header.overviewPictureID, &buffer[start], 4);
|
memcpy(&tempSize, &buffer[start], 4);
|
||||||
start += 4;
|
start += 4;
|
||||||
|
|
||||||
|
memcpy(&tempName, &buffer[start], tempSize);
|
||||||
|
header.overviewPicturePath.assign(&tempName[0], &tempName[tempSize]);
|
||||||
|
start += tempSize;
|
||||||
|
|
||||||
memcpy(&tempSize, &buffer[start], 4);
|
memcpy(&tempSize, &buffer[start], 4);
|
||||||
start += 4;
|
start += 4;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace GameLogic
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParseObject(char* buffer, void *header, int size);
|
void ParseObject(char* buffer, void *header, int size);
|
||||||
|
void ParseObject(char* buffer, ObjectHeader& header, int& size);
|
||||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ Player::~Player(void)
|
||||||
void Player::BeginFrame()
|
void Player::BeginFrame()
|
||||||
{
|
{
|
||||||
weapon->Update(0.002f);
|
weapon->Update(0.002f);
|
||||||
|
if(playerState == PLAYER_STATE_DEAD) Respawn(Oyster::Math::Float3(0,308,0));
|
||||||
Object::BeginFrame();
|
Object::BeginFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +137,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
||||||
this->life = 100;
|
this->life = 100;
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||||
this->lookDir = Oyster::Math::Float4(1,0,0);
|
this->lookDir = Oyster::Math::Float4(1,0,0);
|
||||||
|
this->setState.SetCenterPosition(spawnPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
|
void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
|
||||||
|
@ -197,5 +199,13 @@ PLAYER_STATE Player::GetState() const
|
||||||
void Player::DamageLife(int damage)
|
void Player::DamageLife(int damage)
|
||||||
{
|
{
|
||||||
this->life -= damage;
|
this->life -= damage;
|
||||||
|
this->life = 0;
|
||||||
|
|
||||||
|
if(this->life <= 0)
|
||||||
|
{
|
||||||
|
this->life = 0;
|
||||||
|
playerState = PLAYER_STATE_DEAD;
|
||||||
|
//do stuff that makes you dead
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue