mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
update of client data by server
This commit is contained in:
parent
2cb401bbd3
commit
c8d0a48489
11 changed files with 239 additions and 120 deletions
|
|
@ -1,17 +1,11 @@
|
|||
define(["Chuck/Control/KeyboardInput"], function(KeyboardInput){
|
||||
define(["Chuck/Control/InputController", "Chuck/Control/KeyboardInput"], function(InputController, KeyboardInput){
|
||||
|
||||
function InputControlUnit(me) {
|
||||
function InputControlUnit(me, clientProcessor) {
|
||||
|
||||
this._keyboardInput = new KeyboardInput(this);
|
||||
this._me = me;
|
||||
this.clientProcessor = clientProcessor;
|
||||
this.inputController = new InputController(me);
|
||||
|
||||
this._shift;
|
||||
this._isJumping;
|
||||
|
||||
this.KEY_LEFT = 65;
|
||||
this.KEY_RIGHT = 68;
|
||||
this.KEY_UP = 87;
|
||||
this.KEY_DOWN = 83;
|
||||
this.keyboardInput = new KeyboardInput(this);
|
||||
|
||||
var keys = {
|
||||
w:87,
|
||||
|
|
@ -30,67 +24,70 @@ define(["Chuck/Control/KeyboardInput"], function(KeyboardInput){
|
|||
|
||||
InputControlUnit.prototype.init = function(keys) {
|
||||
|
||||
this._keyboardInput.registerKey(keys.a, 'moveLeft', 'stop', 'moveLeft');
|
||||
this._keyboardInput.registerKey(keys.left, 'moveLeft', 'stop', 'moveLeft');
|
||||
this.keyboardInput.registerKey(keys.a, 'moveLeft', 'stop', 'moveLeft');
|
||||
this.keyboardInput.registerKey(keys.left, 'moveLeft', 'stop', 'moveLeft');
|
||||
|
||||
this._keyboardInput.registerKey(keys.d, 'moveRight', 'stop', 'moveRight');
|
||||
this._keyboardInput.registerKey(keys.right, 'moveRight', 'stop', 'moveRight');
|
||||
this.keyboardInput.registerKey(keys.d, 'moveRight', 'stop', 'moveRight');
|
||||
this.keyboardInput.registerKey(keys.right, 'moveRight', 'stop', 'moveRight');
|
||||
|
||||
this._keyboardInput.registerKey(keys.w, 'jump', 'jumped', 'jumping');
|
||||
this._keyboardInput.registerKey(keys.up, 'jump', 'jumped', 'jumping');
|
||||
this.keyboardInput.registerKey(keys.w, 'jump', 'jumped', 'jumping');
|
||||
this.keyboardInput.registerKey(keys.up, 'jump', 'jumped', 'jumping');
|
||||
|
||||
this._keyboardInput.registerKey(keys.s, 'duck', 'standUp', 'duck');
|
||||
this._keyboardInput.registerKey(keys.down, 'duck', 'standUp', 'duck');
|
||||
this.keyboardInput.registerKey(keys.s, 'duck', 'standUp', 'duck');
|
||||
this.keyboardInput.registerKey(keys.down, 'duck', 'standUp', 'duck');
|
||||
|
||||
this._keyboardInput.registerKey(keys.s, 'activateShift', 'activateShift', 'deactivateShift');
|
||||
this._keyboardInput.registerKey(keys.down, 'activateShift', 'activateShift', 'deactivateShift');
|
||||
this.keyboardInput.registerKey(keys.s, 'activateShift', 'activateShift', 'deactivateShift');
|
||||
this.keyboardInput.registerKey(keys.down, 'activateShift', 'activateShift', 'deactivateShift');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.moveLeft = function() {
|
||||
this._me.move(-1);
|
||||
this.inputController.moveLeft();
|
||||
this.clientProcessor.sendGameCommand('moveLeft');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.moveRight = function() {
|
||||
this._me.move(1);
|
||||
this.inputController.moveRight();
|
||||
this.clientProcessor.sendGameCommand('moveRight');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.stop = function() {
|
||||
this._me.stop();
|
||||
this.inputController.stop();
|
||||
this.clientProcessor.sendGameCommand('stop');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.jump = function() {
|
||||
this._isJumping = true;
|
||||
this._me.jump();
|
||||
this.inputController.jump();
|
||||
this.clientProcessor.sendGameCommand('jump');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.jumped = function() {
|
||||
this._isJumping = false;
|
||||
this.inputController.jumped();
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.jumping = function() {
|
||||
if (this._isJumping) {
|
||||
this._me.jumping();
|
||||
}
|
||||
this.inputController.jumping();
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.duck = function() {
|
||||
this._me.duck();
|
||||
this.inputController.duck();
|
||||
this.clientProcessor.sendGameCommand('duck');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.standUp = function() {
|
||||
this._me.standUp();
|
||||
this.inputController.standUp();
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.activateShift = function() {
|
||||
this._shift = true;
|
||||
this.inputController.activateShift();
|
||||
this.clientProcessor.sendGameCommand('activateShift');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.deactivateShift = function() {
|
||||
this._shift = false;
|
||||
this.inputController.deactivateShift();
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.update = function() {
|
||||
this._keyboardInput.update();
|
||||
this.keyboardInput.update();
|
||||
}
|
||||
|
||||
return InputControlUnit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue