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;
|
this.moveDirection = direction;
|
||||||
var speed;
|
var speed;
|
||||||
|
var isHoldingHeavyItem = this.holdingItem && this.holdingItem.options.weight > Settings.MAX_RUNNING_WEIGHT;
|
||||||
|
|
||||||
switch(true) {
|
switch(true) {
|
||||||
case direction == this.lookDirection && this.isStanding():
|
case direction == this.lookDirection && this.isStanding() && !isHoldingHeavyItem:
|
||||||
speed = Settings.RUN_SPEED;
|
speed = Settings.RUN_SPEED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case !this.isStanding():
|
case !this.isStanding():
|
||||||
speed = Settings.FLY_SPEED;
|
speed = Settings.FLY_SPEED;
|
||||||
|
|
||||||
|
if(isHoldingHeavyItem) {
|
||||||
|
if(Settings.FLY_SPEED > Settings.WALK_SPEED) {
|
||||||
|
speed = Settings.WALK_SPEED;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -202,7 +209,13 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
||||||
|
|
||||||
if(this.isStanding()) {
|
if(this.isStanding()) {
|
||||||
if(this.moveDirection == this.lookDirection) {
|
if(this.moveDirection == this.lookDirection) {
|
||||||
|
|
||||||
|
if(isHoldingHeavyItem) {
|
||||||
|
this.setActionState("walk");
|
||||||
|
} else {
|
||||||
this.setActionState("run");
|
this.setActionState("run");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.setActionState("walkback");
|
this.setActionState("walkback");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue