Squaby Demo
import QtQuick 2.0
import Felgo 4.0
import Felgo 4.0
TowerBase {
id: nailgun
entityType: "nailgun"
shootDelayInMilliSeconds: level.balancingSettings.nailgun.shootDelayInMilliSeconds
cost: level.balancingSettings.nailgun.cost
saleRevenue: level.balancingSettings.nailgun.saleRevenue
upgradeLevels: level.balancingSettings.nailgun.upgradeLevels
NailgunSprite {
id: sprite
}
GameSoundEffect {
id: shootEffect
source: Qt.resolvedUrl("../../assets/snd/nailgunShoot04.wav")
volume: 0.7
}
Timer {
id: shootTimer
interval: shootDelayInMilliSeconds
repeat: true
triggeredOnStart: true
onTriggered: {
console.debug("Nailgun: shootTimer triggered! this:", shootTimer)
shoot();
}
}
onAimingAtTargetChanged: aimingAtTarget => {
console.debug("aimingAtTarget of nailgun changed to:", aimingAtTarget);
if(aimingAtTarget && !shootTimer.running) {
shootTimer.running = true;
}
}
onTargetRemoved: {
shootTimer.running = false;
}
onEntityDestroyed: {
shootTimer.running = false;
}
function shoot() {
if(!targetEntity) {
shootTimer.running = false;
return;
}
sprite.playShootAnimation();
shootEffect.play();