Reading hp pickups from levelformat. Updating pickups.
This commit is contained in:
parent
d91fa3073f
commit
a8d4ff2c89
|
@ -131,6 +131,11 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_PickupHealth:
|
||||
{
|
||||
gameObj = new PickupHealth(rigidBody, obj->specialTypeID, objID, ((PickupHealthAttributes*)obj)->spawnTime, ((PickupHealthAttributes*)obj)->healthValue);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
|
@ -216,7 +221,6 @@ bool Level::InitiateLevel(std::wstring levelPath)
|
|||
std::string convertedLevelPath = converterX.to_bytes(levelPath);
|
||||
objects = ll.LoadLevel(convertedLevelPath);
|
||||
|
||||
|
||||
if(objects.size() == 0)
|
||||
return false;
|
||||
|
||||
|
@ -264,7 +268,12 @@ bool Level::InitiateLevel(std::wstring levelPath)
|
|||
{
|
||||
// create game object
|
||||
Object* staticGameObj = CreateGameObj(staticObjData, rigidBody_Static);
|
||||
if(staticGameObj != NULL)
|
||||
|
||||
if(staticObjData->specialTypeID == ObjectSpecialType_PickupHealth)
|
||||
{
|
||||
this->pickupSystem.CreatePickup((PickupHealth*)staticGameObj);
|
||||
}
|
||||
else if(staticGameObj != NULL)
|
||||
{
|
||||
this->staticObjects.Push((StaticObject*)staticGameObj);
|
||||
}
|
||||
|
@ -321,6 +330,7 @@ bool Level::InitiateLevel(std::wstring levelPath)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool Level::InitiateLevel(float radius)
|
||||
|
@ -438,7 +448,7 @@ void Level::Update(float deltaTime)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
this->pickupSystem.Update();
|
||||
}
|
||||
int Level::getNrOfDynamicObj()
|
||||
{
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
#include "DynamicArray.h"
|
||||
#include "LevelLoader.h"
|
||||
|
||||
#include "PickupSystem\PickupSystem.h"
|
||||
#include "PickupSystem\PickupHealth.h"
|
||||
|
||||
const int DEATH_TIMER = 5;
|
||||
namespace GameLogic
|
||||
{
|
||||
|
@ -88,6 +91,7 @@ namespace GameLogic
|
|||
StaticObject *levelObj;
|
||||
int objID;
|
||||
Utility::DynamicMemory::DynamicArray<Oyster::Math::Float3> spawnPoints;
|
||||
PickupSystem pickupSystem;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "Pickup.h"
|
||||
#include "../Game.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
|
@ -7,6 +8,7 @@ Pickup::Pickup(Oyster::Physics::ICustomBody *rigidBody, EventOnCollision collisi
|
|||
{
|
||||
this->active = true;
|
||||
this->spawnTime = spawnTime;
|
||||
timer.reset();
|
||||
}
|
||||
|
||||
Pickup::~Pickup()
|
||||
|
@ -19,6 +21,7 @@ void Pickup::Update()
|
|||
if(timer.getElapsedSeconds() >= spawnTime)
|
||||
{
|
||||
active = true;
|
||||
((Game*)&Game::Instance())->onEnableFnc(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,6 +156,21 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
objects.push_back(header);
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_PickupHealth:
|
||||
{
|
||||
PickupHealthAttributes* header = new PickupHealthAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
ParseObject(&buffer[counter], &header->spawnTime, 4);
|
||||
counter += 4;
|
||||
|
||||
ParseObject(&buffer[counter], &header->healthValue, 4);
|
||||
counter += 4;
|
||||
|
||||
objects.push_back(header);
|
||||
break;
|
||||
}
|
||||
//this is a hotfix, fix so you only load the relevant data when the file is updated
|
||||
default:
|
||||
//Couldn't find specialType
|
||||
|
|
|
@ -259,7 +259,11 @@ namespace GameLogic
|
|||
float skySize;
|
||||
};
|
||||
|
||||
|
||||
struct PickupHealthAttributes : public ObjectHeader
|
||||
{
|
||||
float spawnTime;
|
||||
float healthValue;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue