Player gets on his bicycle when entering a cycling road tile

This commit is contained in:
Blake Lingenau
2016-04-11 03:13:01 -04:00
parent e70b0595ac
commit 5c21eeea52
4 changed files with 63 additions and 13 deletions
+15
View File
@@ -1792,6 +1792,11 @@ declare module FullScreenPokemon {
*/
allowDirectionAsKeys?: boolean;
/**
* Whether the player is allowed to dismount the bicycle.
*/
canDismountBicycle: boolean;
/**
* Whether this is allowed to start walking via user input.
*/
@@ -2075,6 +2080,16 @@ declare module FullScreenPokemon {
routine?: string;
}
/**
* A Detector that forces the Player onto his/her bicycle.
*/
export interface ICyclingTriggerer extends IDetector {
/**
* Whether the Player should always be moving.
*/
alwaysMoving?: boolean;
}
/**
* General attributes for all menus.
*/
+21 -5
View File
@@ -1018,11 +1018,11 @@ var FullScreenPokemon;
* Starts the Player cycling if the current Area allows it.
*
* @param thing A Player to start cycling.
* @param area The current Area.
* @param message Whether to display a message box.
* @returns Whether the properties were changed.
*/
FullScreenPokemon.prototype.startCycling = function (thing) {
if (thing.surfing) {
FullScreenPokemon.prototype.startCycling = function (thing, message) {
if (thing.surfing || thing.cycling) {
return false;
}
if (!this.AreaSpawner.getArea().allowCycling) {
@@ -1032,7 +1032,9 @@ var FullScreenPokemon;
thing.speedOld = thing.speed;
thing.speed = this.MathDecider.compute("speedCycling", thing);
thing.FSP.addClass(thing, "cycling");
thing.FSP.displayMessage(thing, "%%%%%%%PLAYER%%%%%%% got on the bicycle!");
if (message) {
thing.FSP.displayMessage(thing, "%%%%%%%PLAYER%%%%%%% got on the bicycle!");
}
return true;
};
/**
@@ -1041,6 +1043,10 @@ var FullScreenPokemon;
* @param thing A Player to stop cycling.
*/
FullScreenPokemon.prototype.stopCycling = function (thing) {
if (!thing.canDismountBicycle) {
thing.FSP.displayMessage(thing, "You can't get off here.");
return;
}
thing.cycling = false;
thing.speed = thing.speedOld;
thing.FSP.removeClass(thing, "cycling");
@@ -1059,7 +1065,7 @@ var FullScreenPokemon;
return true;
}
else {
return thing.FSP.startCycling(thing);
return thing.FSP.startCycling(thing, true);
}
};
/* General animations
@@ -2584,6 +2590,16 @@ var FullScreenPokemon;
}
}
};
/**
* Activates a Detector to force the Player onto the bike and optionally to keep moving.
*
* @param player The Player.
* @param thing A Detector triggered by player.
*/
FullScreenPokemon.prototype.activateCyclingTriggerer = function (player, thing) {
thing.FSP.startCycling(player);
player.canDismountBicycle = false;
};
/* Physics
*/
/**
+23 -6
View File
@@ -1351,11 +1351,11 @@ module FullScreenPokemon {
* Starts the Player cycling if the current Area allows it.
*
* @param thing A Player to start cycling.
* @param area The current Area.
* @param message Whether to display a message box.
* @returns Whether the properties were changed.
*/
startCycling(thing: IPlayer): boolean {
if (thing.surfing) {
startCycling(thing: IPlayer, message?: boolean): boolean {
if (thing.surfing || thing.cycling) {
return false;
}
@@ -1369,7 +1369,9 @@ module FullScreenPokemon {
thing.FSP.addClass(thing, "cycling");
thing.FSP.displayMessage(thing, "%%%%%%%PLAYER%%%%%%% got on the bicycle!");
if (message) {
thing.FSP.displayMessage(thing, "%%%%%%%PLAYER%%%%%%% got on the bicycle!");
}
return true;
}
@@ -1379,6 +1381,11 @@ module FullScreenPokemon {
* @param thing A Player to stop cycling.
*/
stopCycling(thing: IPlayer): void {
if (!thing.canDismountBicycle) {
thing.FSP.displayMessage(thing, "You can't get off here.");
return;
}
thing.cycling = false;
thing.speed = thing.speedOld;
@@ -1399,7 +1406,7 @@ module FullScreenPokemon {
thing.FSP.stopCycling(thing);
return true;
} else {
return thing.FSP.startCycling(thing);
return thing.FSP.startCycling(thing, true);
}
}
@@ -3358,6 +3365,17 @@ module FullScreenPokemon {
}
}
/**
* Activates a Detector to force the Player onto the bike and optionally to keep moving.
*
* @param player The Player.
* @param thing A Detector triggered by player.
*/
activateCyclingTriggerer(player: IPlayer, thing: ICyclingTriggerer): void {
thing.FSP.startCycling(player);
player.canDismountBicycle = false;
}
/* Physics
*/
@@ -3504,7 +3522,6 @@ module FullScreenPokemon {
thing.shouldWalk = true;
}
/* Spawning
*/
+4 -2
View File
@@ -72,6 +72,7 @@ FullScreenPokemon.FullScreenPokemon.settings.objects = {
"Cabinet": {},
"CollisionDetector": {
"CutsceneTriggerer": {},
"CyclingTriggerer": {},
"MenuTriggerer": {},
"SightDetector": {},
"ThemePlayer": {},
@@ -801,6 +802,7 @@ FullScreenPokemon.FullScreenPokemon.settings.objects = {
"Player": {
"id": "player",
"player": true,
"canDismountBicycle": true,
"canKeyWalking": true,
"direction": 2,
"speed": FullScreenPokemon.FullScreenPokemon.unitsize / 2,
@@ -1134,8 +1136,8 @@ FullScreenPokemon.FullScreenPokemon.settings.objects = {
},
"ElderBack": [14, 14],
"PlayerBack": [14, 14],
"CyclingRoad": {
"activate": FullScreenPokemon.FullScreenPokemon.prototype.activateCyclingRoad,
"CyclingTriggerer": {
"activate": FullScreenPokemon.FullScreenPokemon.prototype.activateCyclingTriggerer,
"requireOverlap": true,
"hidden": true
},