From 1c4336c7f718e7199563682f77c4dd386187e42d Mon Sep 17 00:00:00 2001 From: Jeena Date: Mon, 20 Jan 2014 16:37:30 +0100 Subject: [PATCH] walking when carrying a heavy object --- app/Game/Core/GameObjects/Doll.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Game/Core/GameObjects/Doll.js b/app/Game/Core/GameObjects/Doll.js index 053701a..6b3a23e 100755 --- a/app/Game/Core/GameObjects/Doll.js +++ b/app/Game/Core/GameObjects/Doll.js @@ -180,14 +180,21 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) { this.moveDirection = direction; var speed; + var isHoldingHeavyItem = this.holdingItem && this.holdingItem.options.weight > Settings.MAX_RUNNING_WEIGHT; switch(true) { - case direction == this.lookDirection && this.isStanding(): + case direction == this.lookDirection && this.isStanding() && !isHoldingHeavyItem: speed = Settings.RUN_SPEED; break; case !this.isStanding(): speed = Settings.FLY_SPEED; + + if(isHoldingHeavyItem) { + if(Settings.FLY_SPEED > Settings.WALK_SPEED) { + speed = Settings.WALK_SPEED; + } + } break; default: @@ -202,7 +209,13 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) { if(this.isStanding()) { if(this.moveDirection == this.lookDirection) { - this.setActionState("run"); + + if(isHoldingHeavyItem) { + this.setActionState("walk"); + } else { + this.setActionState("run"); + } + } else { this.setActionState("walkback"); }