Permalink
Browse files

added scores info

  • Loading branch information...
1 parent 3563114 commit 7cf8b8e138ce0e66ed56ce1142e1253ae8ed46b8 @playerx playerx committed Feb 26, 2014
@@ -97,7 +97,7 @@ public class Play {
}
/// <summary>
- /// Looks up a localized string similar to .
+ /// Looks up a localized string similar to Game Finished..
/// </summary>
public static string A005 {
get {
@@ -106,7 +106,7 @@ public class Play {
}
/// <summary>
- /// Looks up a localized string similar to .
+ /// Looks up a localized string similar to Your Score is: .
/// </summary>
public static string A006 {
get {
@@ -130,10 +130,10 @@
<value>Play Again</value>
</data>
<data name="A005" xml:space="preserve">
- <value />
+ <value>Game Finished.</value>
</data>
<data name="A006" xml:space="preserve">
- <value />
+ <value>Your Score is: </value>
</data>
<data name="A007" xml:space="preserve">
<value />
@@ -10,6 +10,10 @@ var Game = {
userHP: 5,
+ score: 0,
+
+ isFinished: true,
+
lastDeviceRotateTime: Date.now(),
//bgAudio: undefined,
@@ -114,7 +118,6 @@ var Game = {
},
UIPlayAgain: function () {
- $('#Game .balance span').html(100);
$('#Menu').hide();
Game.startGame();
@@ -223,35 +226,47 @@ var Game = {
startGame: function () {
+ this.score = 0;
this.userHP = 5;
var newImg = new Image();
newImg.src = RootUrl + 'Images/user_avatar_hp_' + this.userHP + '.png';
this.userImg.setImage(newImg);
+ $('#Game .balance span').html(this.score);
+
this.tomatoFireHandler = setTimeout(this.autoFireTomato.bind(this), 500);
+ this.isFinished = false;
//this.bgAudio.play();
},
autoFireTomato: function () {
var x = ($('#Game').width() - 200) * Math.random() + 100;
var y = ($('#Game').height() - 600) * Math.random() + 270;
- var tomatosCount = $('#Game .balance span').html();
+ var tomatosCount = (this.score || 1) / 10;
+ if (tomatosCount < 1)
+ tomatosCount = 1;
this.fireTomato2(x, y);
- this.tomatoFireHandler = setTimeout(this.autoFireTomato.bind(this), 5 * tomatosCount + Math.random() * 500);
+ this.tomatoFireHandler = setTimeout(this.autoFireTomato.bind(this), 500 / tomatosCount + Math.random() * 300);
},
finishGame: function (isWinner) {
- $('#Menu .finish .results').html(isWinner ? ML.A002 : ML.A003);
+
+ if (this.isFinished) return;
+
+ //$('#Menu .finish .results').html(isWinner ? ML.A002 : ML.A003);
+ $('#Menu .finish .results').html(ML.A006 + ' ' + this.score);
$('#Menu .finish').show();
$('#Menu .start').hide();
$('#Menu').show();
clearTimeout(this.tomatoFireHandler);
+ this.isFinished = true;
+
//if (bgAudio) {
// bgAudio.stop();
// bgAudio.load('http://stop.me');
@@ -314,15 +329,11 @@ var Game = {
fireTomato2: function (x, y) {
- var count = $('#Game .balance span').html();
- if (!count || count <= 0) {
- return;
- }
+ //if (!count || count <= 0) {
+ // return;
+ //}
- count--;
- $('#Game .balance span').html(count);
-
var img = new Image();
img.src = RootUrl + '/Images/tomato.png';
var tomatoImg = new Kinetic.Image({
@@ -380,6 +391,11 @@ var Game = {
}
else {
+ if (!_this.isFinished) {
+ _this.score++;
+ $('#Game .balance span').html(_this.score);
+ }
+
_this.fxMissPlay();
@@ -397,13 +413,32 @@ var Game = {
}).play();
}
- if ($('#Game .balance span').html() <= 0) {
- _this.finishGame(true);
- }
+ //if ($('#Game .balance span').html() <= 0) {
+ // _this.finishGame(true);
+ //}
}
}).play();
},
}
-Game.init();
+Game.init();
+
+
+
+if (window.JM) {
+ function onSuccess(acceleration) {
+ alert('Acceleration X: ' + acceleration.x + '\n' +
+ 'Acceleration Y: ' + acceleration.y + '\n' +
+ 'Acceleration Z: ' + acceleration.z + '\n' +
+ 'Timestamp: ' + acceleration.timestamp + '\n');
+ };
+
+ function onError() {
+ alert('onError!');
+ };
+
+ var options = { frequency: 50 };
+
+ var watchID = window.JM.accelerometer.watchAcceleration(onSuccess, onError, options);
+}
@@ -7,6 +7,7 @@
var ML = {
A002: '@R.A002',
A003: '@R.A003',
+ A006: '@R.A006',
}
var RootUrl = '@System.Configuration.ConfigurationManager.AppSettings["SiteUrl"]';
</script>

0 comments on commit 7cf8b8e

Please sign in to comment.