working dispatcher scenario and game points
This commit is contained in:
parent
61d4b4fe39
commit
73b9141d3b
|
@ -86,3 +86,8 @@ void Aircraft::update(u32 curMS)
|
|||
flybySound->move(cAudio::cVector3(p.X, p.Y, p.Z));
|
||||
}
|
||||
}
|
||||
|
||||
vector3df Aircraft::getPosition() const
|
||||
{
|
||||
return model->getAbsolutePosition();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
bool isGood() const;
|
||||
bool isTerminated() const;
|
||||
void update(irr::u32 curMS);
|
||||
irr::core::vector3df getPosition() const;
|
||||
|
||||
private:
|
||||
Aircraft();
|
||||
|
|
|
@ -7,6 +7,8 @@ using namespace irr::core;
|
|||
|
||||
Dispatcher::Dispatcher()
|
||||
: active(false)
|
||||
, aircraftsRemaining(0)
|
||||
, points(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -20,16 +22,26 @@ void Dispatcher::start()
|
|||
{
|
||||
lastDispatchMS = Globals::getDevice()->getTimer()->getRealTime();
|
||||
active = true;
|
||||
aircraftsRemaining = 5;
|
||||
points = 0;
|
||||
}
|
||||
|
||||
void Dispatcher::execute()
|
||||
{
|
||||
u32 curTime = Globals::getDevice()->getTimer()->getRealTime();
|
||||
|
||||
if (active && (curTime - lastDispatchMS) > 10000)
|
||||
if (active && (curTime - lastDispatchMS) > 45000)
|
||||
{
|
||||
dispatchAircraft();
|
||||
lastDispatchMS = curTime;
|
||||
if (aircraftsRemaining > 0)
|
||||
{
|
||||
dispatchAircraft();
|
||||
aircraftsRemaining--;
|
||||
lastDispatchMS = curTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
// loopdidoo & cleanup
|
||||
|
@ -48,6 +60,7 @@ void Dispatcher::execute()
|
|||
|
||||
void Dispatcher::stop()
|
||||
{
|
||||
aircrafts.clear();
|
||||
active = false;
|
||||
}
|
||||
|
||||
|
@ -61,8 +74,9 @@ bool Dispatcher::evalShot(const core::line3df& l)
|
|||
bool ret = false;
|
||||
for (auto a : aircrafts)
|
||||
{
|
||||
if (a->evalShot(l))
|
||||
if (a->isGood() && a->evalShot(l))
|
||||
{
|
||||
points += 1000 + a->getPosition().getDistanceFrom(vector3df(0.f, 0.f, 0.f));
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +84,16 @@ bool Dispatcher::evalShot(const core::line3df& l)
|
|||
return ret;
|
||||
}
|
||||
|
||||
u32 Dispatcher::getAircraftsRemaining() const
|
||||
{
|
||||
return aircraftsRemaining;
|
||||
}
|
||||
|
||||
u32 Dispatcher::getPoints() const
|
||||
{
|
||||
return points;
|
||||
}
|
||||
|
||||
void Dispatcher::dispatchAircraft()
|
||||
{
|
||||
IRandomizer *rand = Globals::getDevice()->getRandomizer();
|
||||
|
|
|
@ -15,11 +15,15 @@ public:
|
|||
void stop();
|
||||
const Aircrafts& getAircrafts() const;
|
||||
bool evalShot(const irr::core::line3df&);
|
||||
irr::u32 getAircraftsRemaining() const;
|
||||
irr::u32 getPoints() const;
|
||||
|
||||
private:
|
||||
irr::u32 lastDispatchMS;
|
||||
Aircrafts aircrafts;
|
||||
bool active;
|
||||
|
||||
irr::u32 aircraftsRemaining, points;
|
||||
|
||||
void dispatchAircraft();
|
||||
};
|
||||
|
|
|
@ -110,5 +110,7 @@ void FlaSimApp::drawScreenSpace()
|
|||
info += L"[RELOADING]";
|
||||
else
|
||||
info += fireUnit.getRoundsRemaining();
|
||||
info += L"\nAIRCFT REMAIN: "; info += Globals::getDispatcher()->getAircraftsRemaining();
|
||||
info += L"\nPOINTS: "; info += Globals::getDispatcher()->getPoints();
|
||||
Globals::getFont()->draw(info, core::recti(10, 10, 100, 100), video::SColor(255, 255, 255, 255));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ Globals* Globals::instance = nullptr;
|
|||
|
||||
Globals::Globals()
|
||||
{
|
||||
dev = createDevice(video::EDT_OPENGL, core::dimension2du(1280, 800), 32, false, false, true);
|
||||
dev = createDevice(video::EDT_OPENGL, core::dimension2du(1600, 900), 32, false, false, true);
|
||||
drv = dev->getVideoDriver();
|
||||
sman = dev->getSceneManager();
|
||||
dispatcher = new Dispatcher();
|
||||
|
|
Loading…
Reference in New Issue