mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
walking when carrying a heavy object
This commit is contained in:
parent
b159bbb1cc
commit
1c4336c7f7
1 changed files with 15 additions and 2 deletions
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue