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));
|
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 isGood() const;
|
||||||
bool isTerminated() const;
|
bool isTerminated() const;
|
||||||
void update(irr::u32 curMS);
|
void update(irr::u32 curMS);
|
||||||
|
irr::core::vector3df getPosition() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Aircraft();
|
Aircraft();
|
||||||
|
|
|
@ -7,6 +7,8 @@ using namespace irr::core;
|
||||||
|
|
||||||
Dispatcher::Dispatcher()
|
Dispatcher::Dispatcher()
|
||||||
: active(false)
|
: active(false)
|
||||||
|
, aircraftsRemaining(0)
|
||||||
|
, points(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,16 +22,26 @@ void Dispatcher::start()
|
||||||
{
|
{
|
||||||
lastDispatchMS = Globals::getDevice()->getTimer()->getRealTime();
|
lastDispatchMS = Globals::getDevice()->getTimer()->getRealTime();
|
||||||
active = true;
|
active = true;
|
||||||
|
aircraftsRemaining = 5;
|
||||||
|
points = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispatcher::execute()
|
void Dispatcher::execute()
|
||||||
{
|
{
|
||||||
u32 curTime = Globals::getDevice()->getTimer()->getRealTime();
|
u32 curTime = Globals::getDevice()->getTimer()->getRealTime();
|
||||||
|
|
||||||
if (active && (curTime - lastDispatchMS) > 10000)
|
if (active && (curTime - lastDispatchMS) > 45000)
|
||||||
{
|
{
|
||||||
dispatchAircraft();
|
if (aircraftsRemaining > 0)
|
||||||
lastDispatchMS = curTime;
|
{
|
||||||
|
dispatchAircraft();
|
||||||
|
aircraftsRemaining--;
|
||||||
|
lastDispatchMS = curTime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// loopdidoo & cleanup
|
// loopdidoo & cleanup
|
||||||
|
@ -48,6 +60,7 @@ void Dispatcher::execute()
|
||||||
|
|
||||||
void Dispatcher::stop()
|
void Dispatcher::stop()
|
||||||
{
|
{
|
||||||
|
aircrafts.clear();
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +74,9 @@ bool Dispatcher::evalShot(const core::line3df& l)
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (auto a : aircrafts)
|
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;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +84,16 @@ bool Dispatcher::evalShot(const core::line3df& l)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 Dispatcher::getAircraftsRemaining() const
|
||||||
|
{
|
||||||
|
return aircraftsRemaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 Dispatcher::getPoints() const
|
||||||
|
{
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
void Dispatcher::dispatchAircraft()
|
void Dispatcher::dispatchAircraft()
|
||||||
{
|
{
|
||||||
IRandomizer *rand = Globals::getDevice()->getRandomizer();
|
IRandomizer *rand = Globals::getDevice()->getRandomizer();
|
||||||
|
|
|
@ -15,11 +15,15 @@ public:
|
||||||
void stop();
|
void stop();
|
||||||
const Aircrafts& getAircrafts() const;
|
const Aircrafts& getAircrafts() const;
|
||||||
bool evalShot(const irr::core::line3df&);
|
bool evalShot(const irr::core::line3df&);
|
||||||
|
irr::u32 getAircraftsRemaining() const;
|
||||||
|
irr::u32 getPoints() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
irr::u32 lastDispatchMS;
|
irr::u32 lastDispatchMS;
|
||||||
Aircrafts aircrafts;
|
Aircrafts aircrafts;
|
||||||
bool active;
|
bool active;
|
||||||
|
|
||||||
|
irr::u32 aircraftsRemaining, points;
|
||||||
|
|
||||||
void dispatchAircraft();
|
void dispatchAircraft();
|
||||||
};
|
};
|
||||||
|
|
|
@ -110,5 +110,7 @@ void FlaSimApp::drawScreenSpace()
|
||||||
info += L"[RELOADING]";
|
info += L"[RELOADING]";
|
||||||
else
|
else
|
||||||
info += fireUnit.getRoundsRemaining();
|
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));
|
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()
|
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();
|
drv = dev->getVideoDriver();
|
||||||
sman = dev->getSceneManager();
|
sman = dev->getSceneManager();
|
||||||
dispatcher = new Dispatcher();
|
dispatcher = new Dispatcher();
|
||||||
|
|
Loading…
Reference in New Issue