This commit is contained in:
@@ -621,7 +621,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this.carries_light = parseBoolean(this.carries_light);
|
this.carries_light = parseBoolean(this.carries_light);
|
||||||
this.sprite_has_treasure = parseBoolean(this.sprite_has_treasure);
|
this.sprite_has_treasure = parseBoolean(this.sprite_has_treasure);
|
||||||
if ( this.sprite_has_treasure ) {
|
if ( this.sprite_has_treasure ) {
|
||||||
this.treasure = getRandomTreasure();
|
this.sprite_treasure = getRandomTreasure();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.path_maximum_steps = parseInt(this.path_maximum_steps);
|
this.path_maximum_steps = parseInt(this.path_maximum_steps);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ STATE_MOVING = 1 << 10;
|
|||||||
STATE_RUNNINGTOLIGHT = 1 << 11;
|
STATE_RUNNINGTOLIGHT = 1 << 11;
|
||||||
STATE_RUNNINGTOREPORT = 1 << 12;
|
STATE_RUNNINGTOREPORT = 1 << 12;
|
||||||
STATE_LOOKINGFORTARGET = 1 << 13;
|
STATE_LOOKINGFORTARGET = 1 << 13;
|
||||||
|
STATE_STEALING = 1 << 13;
|
||||||
|
|
||||||
STATES_AWARENESS = (STATE_UNAWARE | STATE_CONCERNED | STATE_ALERTED | STATE_LOSTHIM);
|
STATES_AWARENESS = (STATE_UNAWARE | STATE_CONCERNED | STATE_ALERTED | STATE_LOSTHIM);
|
||||||
STATES_MOVEMENT = (STATE_MOVING | STATE_RUNNING);
|
STATES_MOVEMENT = (STATE_MOVING | STATE_RUNNING);
|
||||||
@@ -58,3 +59,5 @@ SCORE_ALERTED = -50;
|
|||||||
SCORE_CONCERNED = 0;
|
SCORE_CONCERNED = 0;
|
||||||
|
|
||||||
MAX_TREASURES = 384;
|
MAX_TREASURES = 384;
|
||||||
|
|
||||||
|
STEAL_DISTANCE = 16;
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ GameState.prototype.create = function()
|
|||||||
|
|
||||||
this.camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN);
|
this.camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN);
|
||||||
controls = game.input.keyboard.createCursorKeys();
|
controls = game.input.keyboard.createCursorKeys();
|
||||||
|
controls.steal = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
|
||||||
|
|
||||||
this.effectSprites = game.add.group();
|
this.effectSprites = game.add.group();
|
||||||
this.map.createFromObjects('EffectSprites', 5, 'player', 0, true, false, this.effectSprites, EffectSprite);
|
this.map.createFromObjects('EffectSprites', 5, 'player', 0, true, false, this.effectSprites, EffectSprite);
|
||||||
@@ -215,6 +216,10 @@ GameState.prototype.check_input = function()
|
|||||||
velocityMod = 0;
|
velocityMod = 0;
|
||||||
var newstate = 0;
|
var newstate = 0;
|
||||||
|
|
||||||
|
if ( controls.steal.justReleased() == true ) {
|
||||||
|
addState(player, STATE_STEALING);
|
||||||
|
}
|
||||||
|
|
||||||
if ( controls.up.isDown) {
|
if ( controls.up.isDown) {
|
||||||
if ( controls.up.shiftKey ) {
|
if ( controls.up.shiftKey ) {
|
||||||
newstate = (STATE_FACE_UP | STATE_MOVING | STATE_RUNNING);
|
newstate = (STATE_FACE_UP | STATE_MOVING | STATE_RUNNING);
|
||||||
@@ -240,7 +245,7 @@ GameState.prototype.check_input = function()
|
|||||||
newstate = (STATE_FACE_RIGHT | STATE_MOVING );
|
newstate = (STATE_FACE_RIGHT | STATE_MOVING );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newstate = STATE_NONE;
|
newstate = getFaceState(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMovingState(player, newstate);
|
setMovingState(player, newstate);
|
||||||
@@ -301,9 +306,7 @@ GameState.prototype.update = function()
|
|||||||
return;
|
return;
|
||||||
if ( x.canSeeSprite(player, false) == true ) {
|
if ( x.canSeeSprite(player, false) == true ) {
|
||||||
x.lastSawPlayerAt = new Phaser.Sprite(game, player.x, player.y, null);
|
x.lastSawPlayerAt = new Phaser.Sprite(game, player.x, player.y, null);
|
||||||
if ( this.physics.arcade.collide(x, player) ) {
|
if ( player.lightmeter >= x.sprite_can_see_lightmeter ) {
|
||||||
x.setAwarenessEffect(STATE_ALERTED);
|
|
||||||
} else if ( player.lightmeter >= x.sprite_can_see_lightmeter ) {
|
|
||||||
x.setAwarenessEffect(STATE_ALERTED);
|
x.setAwarenessEffect(STATE_ALERTED);
|
||||||
} else {
|
} else {
|
||||||
x.setAwarenessEffect(STATE_CONCERNED);
|
x.setAwarenessEffect(STATE_CONCERNED);
|
||||||
@@ -318,7 +321,39 @@ GameState.prototype.update = function()
|
|||||||
x.setAwarenessEffect(STATE_UNAWARE);
|
x.setAwarenessEffect(STATE_UNAWARE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.physics.arcade.collide(x, player);
|
if ( this.physics.arcade.collide(x, player) == true )
|
||||||
|
x.setAwarenessEffect(STATE_ALERTED);
|
||||||
|
if ( hasState(player, STATE_STEALING) == true ) {
|
||||||
|
delState(player, STATE_STEALING);
|
||||||
|
var prevpos = player.body.position;
|
||||||
|
player.body.position = new Phaser.Point();
|
||||||
|
player.body.x = prevpos.x;
|
||||||
|
player.body.y = prevpos.y;
|
||||||
|
switch ( getFaceState(player) ) {
|
||||||
|
case STATE_FACE_LEFT: {
|
||||||
|
player.body.x -= STEAL_DISTANCE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STATE_FACE_RIGHT: {
|
||||||
|
player.body.x += STEAL_DISTANCE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STATE_FACE_DOWN: {
|
||||||
|
player.body.y += STEAL_DISTANCE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STATE_FACE_UP: {
|
||||||
|
player.body.y -= STEAL_DISTANCE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( this.physics.arcade.collide(x, player) == true ) {
|
||||||
|
x.sprite_has_treasure = false;
|
||||||
|
player.score += moonlightTreasures[x.sprite_treasure]['value'];
|
||||||
|
x.sprite_treasure = null;
|
||||||
|
}
|
||||||
|
player.body.position = prevpos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.effectSprites.forEach(_inner_collide, this);
|
this.effectSprites.forEach(_inner_collide, this);
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ function setSpriteMovement(spr, velocity)
|
|||||||
velocity = ( typeof velocity == undefined ? velocity : [SPEED_WALKING,
|
velocity = ( typeof velocity == undefined ? velocity : [SPEED_WALKING,
|
||||||
SPEED_RUNNING] );
|
SPEED_RUNNING] );
|
||||||
|
|
||||||
spr.body.setSize(16, 16, 8, 16);
|
//spr.body.setSize(16, 16, 8, 16);
|
||||||
|
|
||||||
if ( hasState(spr, STATE_RUNNING) ) {
|
if ( hasState(spr, STATE_RUNNING) ) {
|
||||||
if ( velocity !== false )
|
if ( velocity !== false )
|
||||||
|
|||||||
Reference in New Issue
Block a user