Squaby Demo
import QtQuick 2.0
import Felgo 4.0
Row {
id: upgradeTowerHUD
UpgradeWeapon {
id: repairUpgrade
upgradeType: "repair"
source: "repair.png"
onClicked: {
towerUpgradeEffect.play();
}
visible: false
}
UpgradeWeapon {
id: rangeUpgrade
upgradeType: "range"
onClicked: {
towerUpgradeEffect.play();
}
}
UpgradeWeapon {
id: shootDelayUpgrade
upgradeType: "shootDelay"
onClicked: {
towerUpgradeEffect.play();
}
}
UpgradeWeapon {
id: sellButton
source: "sell.png"
upgradeType: "sell"
affordable: true
onClicked: {
hud.state="buildTowers"
towerSellEffect.play();
}
GameSoundEffect {
id: towerSellEffect
source: Qt.resolvedUrl("../../../assets/snd/towerDestruct.wav")
}
}
GameSoundEffect {
id: towerUpgradeEffect
source: Qt.resolvedUrl("../../../assets/snd/towerUpgrade.wav")
}
function towerSelected(message) {
var towerId = message.entityId;
var towerType = message.entityType;
if(towerType === "nailgun" || towerType === "turbine") {
shootDelayUpgrade.upgradeType = "shootDelay";
} else if(towerType === "flamethrower") {
shootDelayUpgrade.upgradeType = "damagePerSecond";
} else if(towerType === "taser") {
shootDelayUpgrade.upgradeType = "damagePerSecond";
} else if(towerType === "tesla") {
shootDelayUpgrade.upgradeType = "damagePerSecond";
}
rangeUpgrade.setUpgradeButtonFromEvent(message);
shootDelayUpgrade.setUpgradeButtonFromEvent(message);
sellButton.selectedTowerId = towerId;
sellButton.cost = -message.saleRevenue;
selectedTowerRange.x = message.towerPosition.x;
selectedTowerRange.y = message.towerPosition.y;
selectedTowerRange.colliderRadius = message.colliderRadius;
selectedTowerRange.isAllowedToBuild = true;
if(towerType === "turbine") {
repairUpgrade.setUpgradeButtonFromEvent(message);
upgradeTowerHUD.state = "upgradingTurbine";
} else {
upgradeTowerHUD.state = "";
}
hud.state = "upgrading";
selectedTowerId = towerId;
console.debug("HUD: switched hud to state", hud.state, ", selectedTowerId:", selectedTowerId);
}
states: [
State {
name: "upgradingTurbine"
PropertyChanges { target: repairUpgrade; visible: true}