pResourceSet_->acquire();
+
+}
+
+SeaScene::~SeaScene()
+{
+ pResourceSet_->release();
+ pResourceSet_->deleteLater();
}
void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
if (vibrationAllowed_)
pShip->allowVibration(); //Vibration is disallowed by default so only allowing needs to be done explicitly
- connect(pResourceSet_,SIGNAL(resourcesGranted(const QList< ResourcePolicy::ResourceType >)),pShip,SLOT(allowVibration()));
- connect(pResourceSet_,SIGNAL(lostResources()),pShip,SLOT(disallowVibration()));
+ connect(this,SIGNAL(vibrationGranted()),pShip,SLOT(allowVibration()));
+ connect(this,SIGNAL(vibrationDenied()),pShip,SLOT(disallowVibration()));
pShip->startMoving();
movingItems_.append(pShip);
connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
scoreCounter_.start();
autopauseTimer.start(); //Start counting towards autopause
+
+ pResourceSet_->acquire(); //Ask to get the vibration resource back
}
else
levelScore_ += scoreCounter_.elapsed();
autopauseTimer.stop(); //No need to count toward autopause when already paused
+
+ pResourceSet_->release(); //Release the vibration resource
+ vibrationDenied(); //Tell the ship not to vibrate before resource is granted again
+
}
}
void SeaScene::resourcesAvailable()
{
- qDebug() << "Resources available";
+// qDebug() << "Resources available";
vibrationAllowed_ = true;
+ emit vibrationGranted();
}
{
qDebug() << "Resources lost";
vibrationAllowed_ = false;
+ emit vibrationDenied();
}