mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
This commit is contained in:
parent
502cf72a7e
commit
c87997c774
13 changed files with 134 additions and 27 deletions
|
|
@ -27,76 +27,86 @@ function (Parent, Nc, KeyboardAndMouse, Gamepad, PointerLockManager) {
|
|||
};
|
||||
|
||||
PlayerController.prototype.moveLeft = function () {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Parent.prototype.moveLeft.call(this);
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'moveLeft');
|
||||
}
|
||||
|
||||
PlayerController.prototype.moveRight = function () {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Parent.prototype.moveRight.call(this);
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'moveRight');
|
||||
}
|
||||
|
||||
// always allow to stop, to prevent endless running
|
||||
PlayerController.prototype.stop = function () {
|
||||
Parent.prototype.stop.call(this);
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'stop');
|
||||
}
|
||||
|
||||
PlayerController.prototype.jump = function () {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Parent.prototype.jump.call(this);
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'jump');
|
||||
}
|
||||
|
||||
// always allow to stop.
|
||||
PlayerController.prototype.jumpStop = function () {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
Parent.prototype.jumpStop.call(this);
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'jumpStop');
|
||||
}
|
||||
|
||||
PlayerController.prototype.setXY = function(x, y) {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
var options = {x:x, y:y};
|
||||
Parent.prototype.lookAt.call(this, options);
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'lookAt', options);
|
||||
};
|
||||
|
||||
PlayerController.prototype.suicide = function() {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, "suicide");
|
||||
};
|
||||
|
||||
PlayerController.prototype.handActionRequest = function(options) {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, "handActionRequest", options);
|
||||
};
|
||||
|
||||
PlayerController.prototype.showInfo = function() {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Nc.trigger(Nc.ns.client.game.gameStats.toggle, true);
|
||||
};
|
||||
|
||||
PlayerController.prototype.hideInfo = function() {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Nc.trigger(Nc.ns.client.game.gameStats.toggle, false);
|
||||
};
|
||||
|
||||
PlayerController.prototype.zoomIn = function() {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Nc.trigger(Nc.ns.client.game.zoomIn, true);
|
||||
};
|
||||
|
||||
PlayerController.prototype.zoomOut = function() {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Nc.trigger(Nc.ns.client.game.zoomOut, false);
|
||||
};
|
||||
|
||||
PlayerController.prototype.zoomReset = function() {
|
||||
if (!PointerLockManager.isLocked()) return;
|
||||
if (!this.isPlayerInputAllowed()) return;
|
||||
Nc.trigger(Nc.ns.client.game.zoomReset, false);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Client overwrite - allow player input if PointerLock is locked to canvas
|
||||
* and is not in between games
|
||||
*/
|
||||
PlayerController.prototype.isPlayerInputAllowed = function() {
|
||||
return PointerLockManager.isLocked()
|
||||
&& Parent.prototype.isPlayerInputAllowed.call(this);
|
||||
};
|
||||
|
||||
|
||||
return PlayerController;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue