1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 import QtQuick.Particles 2.0
47 property bool readySetGo: false
50 property int misses: 0
51 property real ratio: hits/(misses?misses:1)
53 property Ship redVar1: Ship {shipType: 1; gunType: 1}
54 property Ship redVar2: Ship {shipType: 1; gunType: 2}
55 property Ship redVar3: Ship {shipType: 1; gunType: 3}
56 property Ship greenVar1: Ship {shipType: 3; gunType: 1}
57 property Ship greenVar2: Ship {shipType: 2; gunType: 2}
58 property Ship greenVar3: Ship {shipType: 1; gunType: 3}
59 property string winner: "0"
60 property int players: 0
61 function aiSet(ship) {
62 ship.gunType = Math.floor(Math.random() * 3) + 1
63 ship.shipType = Math.floor(Math.random() * 3) + 1
73 anchors.centerIn: parent
74 source: "../images/finalfrontier.png"
79 PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane
82 Component.onCompleted: advance();
89 anchors.verticalCenter: parent.verticalCenter
103 shape: MaskShape {source:"content/pics/TitleText.png"}
107 speed: AngleDirection {angleVariation:360; magnitudeVariation: 6}
112 onClicked: {root.players = 1; pageControl.advance();}
113 anchors.horizontalCenter: parent.horizontalCenter
117 onClicked: {root.players = 2; pageControl.advance();}
118 anchors.horizontalCenter: parent.horizontalCenter
122 anchors.horizontalCenter: parent.horizontalCenter
123 onClicked: {root.players = 0;
130 pageControl.at = 5;//TODO: Not a magic number
131 pageControl.advance();}
135 anchors.horizontalCenter: parent.horizontalCenter
137 pageControl.at = 7;//TODO: Not a magic number
138 pageControl.advance();
143 anchors.horizontalCenter: parent.horizontalCenter
144 onClicked: Qt.quit();
158 anchors.centerIn: parent
163 horizontalAlignment: Text.AlignHCenter
167 onClicked: pageControl.advance()
182 anchors.horizontalCenter: parent.horizontalCenter
196 anchors.horizontalCenter: parent.horizontalCenter
199 if (root.players < 2) {
203 pageControl.at = 5;//TODO: Not a magic number
205 pageControl.advance();
220 anchors.centerIn: parent
225 horizontalAlignment: Text.AlignHCenter
229 onClicked: pageControl.advance()
244 anchors.horizontalCenter: parent.horizontalCenter
258 anchors.horizontalCenter: parent.horizontalCenter
260 onClicked: pageControl.advance()
269 Component.onCompleted: root.readySetGo = true
270 Component.onDestruction: root.readySetGo = false
271 property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0
273 if (redShip3.hp <= 0) {
274 if (greenShip3.hp <= 0) {
289 onTriggered: pageControl.advance();
293 shipParticle: "redTeam"
297 shipType: redVar1.shipType
298 gunType: redVar1.gunType
299 targets: [greenShip1, greenShip2, greenShip3]
303 shipParticle: "redTeam"
307 shipType: redVar2.shipType
308 gunType: redVar2.gunType
309 targets: [greenShip1, greenShip2, greenShip3]
313 shipParticle: "redTeam"
317 shipType: redVar3.shipType
318 gunType: redVar3.gunType
319 targets: [greenShip1, greenShip2, greenShip3]
324 shipParticle: "greenTeam"
328 shipType: greenVar1.shipType
329 gunType: greenVar1.gunType
330 targets: [redShip1, redShip2, redShip3]
334 shipParticle: "greenTeam"
338 shipType: greenVar2.shipType
339 gunType: greenVar2.gunType
340 targets: [redShip1, redShip2, redShip3]
344 shipParticle: "greenTeam"
348 shipType: greenVar3.shipType
349 gunType: greenVar3.gunType
350 targets: [redShip1, redShip2, redShip3]
364 Text {//TODO: Particle Text?
369 text: "Player " + root.winner + " wins!"
370 wrapMode: Text.WordWrap
371 horizontalAlignment: Text.AlignHCenter
372 verticalAlignment: Text.AlignVCenter
376 onClicked: {pageControl.at = 0; pageControl.advance();}
381 onExitDesired: {pageControl.at = 0; pageControl.advance();}