Close #32 : Recently stolen treasure appears along the bottom of the UI layer
This commit is contained in:
@@ -288,7 +288,9 @@
|
|||||||
"properties":
|
"properties":
|
||||||
{
|
{
|
||||||
"sprite_canmove":"true",
|
"sprite_canmove":"true",
|
||||||
|
"sprite_facing":"left",
|
||||||
"sprite_group":"townsfolk-female",
|
"sprite_group":"townsfolk-female",
|
||||||
|
"sprite_has_treasure":"true",
|
||||||
"sprite_name":"townsfolk-female-2"
|
"sprite_name":"townsfolk-female-2"
|
||||||
},
|
},
|
||||||
"type":"AI",
|
"type":"AI",
|
||||||
@@ -303,7 +305,10 @@
|
|||||||
"name":"BigTopCustomer2",
|
"name":"BigTopCustomer2",
|
||||||
"properties":
|
"properties":
|
||||||
{
|
{
|
||||||
|
"sprite_canmove":"true",
|
||||||
|
"sprite_facing":"right",
|
||||||
"sprite_group":"townsfolk-male",
|
"sprite_group":"townsfolk-male",
|
||||||
|
"sprite_has_treasure":"true",
|
||||||
"sprite_name":"townsfolk-male-3"
|
"sprite_name":"townsfolk-male-3"
|
||||||
},
|
},
|
||||||
"type":"AI",
|
"type":"AI",
|
||||||
@@ -319,7 +324,9 @@
|
|||||||
"properties":
|
"properties":
|
||||||
{
|
{
|
||||||
"sprite_canmove":"true",
|
"sprite_canmove":"true",
|
||||||
|
"sprite_facing":"up",
|
||||||
"sprite_group":"townsfolk-female",
|
"sprite_group":"townsfolk-female",
|
||||||
|
"sprite_has_treasure":"true",
|
||||||
"sprite_name":"townsfolk-female-4"
|
"sprite_name":"townsfolk-female-4"
|
||||||
},
|
},
|
||||||
"type":"AI",
|
"type":"AI",
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
SCREEN_WIDTH = 640;
|
SCREEN_WIDTH = 640;
|
||||||
SCREEN_HEIGHT = 480;
|
SCREEN_HEIGHT = 480;
|
||||||
|
|
||||||
|
SCREEN_OFFSET_RECENTLYSTOLEN = new Phaser.Point(400, SCREEN_HEIGHT - 40);
|
||||||
|
RECENTLYSTOLEN_MAX = 5;
|
||||||
|
|
||||||
SPEED_WALKING = 8;
|
SPEED_WALKING = 8;
|
||||||
SPEED_RUNNING = 14;
|
SPEED_RUNNING = 14;
|
||||||
|
|
||||||
@@ -59,5 +62,6 @@ SCORE_ALERTED = -50;
|
|||||||
SCORE_CONCERNED = 0;
|
SCORE_CONCERNED = 0;
|
||||||
|
|
||||||
MAX_TREASURES = 384;
|
MAX_TREASURES = 384;
|
||||||
|
TREASURE_SHEET_WIDTH = 16;
|
||||||
|
|
||||||
STEAL_DISTANCE = 16;
|
STEAL_DISTANCE = 16;
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ GameState.prototype.create = function()
|
|||||||
this.bubble_group = game.add.group();
|
this.bubble_group = game.add.group();
|
||||||
|
|
||||||
this.uigroup = game.add.group();
|
this.uigroup = game.add.group();
|
||||||
|
this.recentlyStolenGroup = game.add.group();
|
||||||
this.game.time.advancedTiming = true;
|
this.game.time.advancedTiming = true;
|
||||||
|
|
||||||
this.clockText = this.game.add.text(
|
this.clockText = this.game.add.text(
|
||||||
@@ -218,6 +219,8 @@ GameState.prototype.check_input = function()
|
|||||||
|
|
||||||
if ( controls.steal.justReleased() == true ) {
|
if ( controls.steal.justReleased() == true ) {
|
||||||
addState(player, STATE_STEALING);
|
addState(player, STATE_STEALING);
|
||||||
|
} else {
|
||||||
|
delState(player, STATE_STEALING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( controls.up.isDown) {
|
if ( controls.up.isDown) {
|
||||||
@@ -323,8 +326,8 @@ GameState.prototype.update = function()
|
|||||||
}
|
}
|
||||||
if ( this.physics.arcade.collide(x, player) == true )
|
if ( this.physics.arcade.collide(x, player) == true )
|
||||||
x.setAwarenessEffect(STATE_ALERTED);
|
x.setAwarenessEffect(STATE_ALERTED);
|
||||||
if ( hasState(player, STATE_STEALING) == true ) {
|
if ( hasState(player, STATE_STEALING) == true &&
|
||||||
delState(player, STATE_STEALING);
|
x.sprite_has_treasure == true ) {
|
||||||
var prevpos = player.body.position;
|
var prevpos = player.body.position;
|
||||||
player.body.position = new Phaser.Point();
|
player.body.position = new Phaser.Point();
|
||||||
player.body.x = prevpos.x;
|
player.body.x = prevpos.x;
|
||||||
@@ -348,9 +351,35 @@ GameState.prototype.update = function()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( this.physics.arcade.collide(x, player) == true ) {
|
if ( this.physics.arcade.collide(x, player) == true ) {
|
||||||
|
delState(player, STATE_STEALING);
|
||||||
x.sprite_has_treasure = false;
|
x.sprite_has_treasure = false;
|
||||||
player.score += moonlightTreasures[x.sprite_treasure]['value'];
|
var stolen = moonlightTreasures[x.sprite_treasure];
|
||||||
|
player.score += stolen['value'];
|
||||||
x.sprite_treasure = null;
|
x.sprite_treasure = null;
|
||||||
|
if ( this.recentlyStolenGroup.total >= RECENTLYSTOLEN_MAX ) {
|
||||||
|
this.recentlyStolenGroup.remove(
|
||||||
|
this.recentlyStolenGroup.getBottom(),
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
this.recentlyStolenGroup.addAll('cameraOffset.x', 24);
|
||||||
|
var rs = game.add.sprite(
|
||||||
|
SCREEN_OFFSET_RECENTLYSTOLEN.x + 12,
|
||||||
|
SCREEN_OFFSET_RECENTLYSTOLEN.y + 12,
|
||||||
|
'treasure',
|
||||||
|
(stolen['y'] * TREASURE_SHEET_WIDTH) + stolen['x'],
|
||||||
|
this.recentlyStolenGroup);
|
||||||
|
rs.anchor.setTo(0.5, 0.5);
|
||||||
|
rs.scale.x = 3;
|
||||||
|
rs.scale.y = 3;
|
||||||
|
rs.angle = 0;
|
||||||
|
tween = game.add.tween(rs);
|
||||||
|
tween.to({angle: 360}, 1000, null);
|
||||||
|
tween.onComplete.add(function(){this.angle=0;}, this);
|
||||||
|
tween.start();
|
||||||
|
tween = game.add.tween(rs.scale);
|
||||||
|
tween.to({x: 1, y: 1}, 1000, null);
|
||||||
|
tween.start();
|
||||||
|
rs.fixedToCamera = true;
|
||||||
}
|
}
|
||||||
player.body.position = prevpos;
|
player.body.position = prevpos;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user