mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
refactored grabbing
This commit is contained in:
parent
1c4336c7f7
commit
38b5023410
7 changed files with 124 additions and 62 deletions
|
|
@ -23,22 +23,41 @@ function (Parent, NotificationCenter) {
|
|||
}
|
||||
|
||||
if(item) {
|
||||
|
||||
this.handAction(x, y, isHolding, item);
|
||||
|
||||
var message = {
|
||||
handActionResponse: {
|
||||
playerId: this.id,
|
||||
isHolding: isHolding,
|
||||
itemUid: item.uid,
|
||||
x: x,
|
||||
y: y
|
||||
}
|
||||
};
|
||||
|
||||
NotificationCenter.trigger("sendControlCommandToAllUsers", "gameCommand", message);
|
||||
}
|
||||
}
|
||||
|
||||
Player.prototype.handAction = function(x, y, isHolding, item) {
|
||||
|
||||
var options = {
|
||||
playerId: this.id,
|
||||
itemUid: item.uid
|
||||
}
|
||||
|
||||
var message = {
|
||||
handActionResponse: options
|
||||
}
|
||||
|
||||
if (isHolding) {
|
||||
// throw
|
||||
if(item.isReleasingAllowed()) {
|
||||
this.throw(x, y, item);
|
||||
|
||||
options.action = "throw";
|
||||
options.x = x;
|
||||
options.y = y;
|
||||
NotificationCenter.trigger("sendControlCommandToAllUsers", "gameCommand", message);
|
||||
}
|
||||
} else {
|
||||
// grab
|
||||
if(item.isGrabbingAllowed()) {
|
||||
this.grab(item);
|
||||
|
||||
options.action = "grab";
|
||||
NotificationCenter.trigger("sendControlCommandToAllUsers", "gameCommand", message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return Player;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue