System.register([], function(exports_1) {
    var Pad;
    return {
        setters:[],
        execute: function() {
            Pad = (function () {
                function Pad(pad) {
                    var _this = this;
                    this.pad = pad;
                    this.update = function () {
                        var isLeft = _this.pad.game.input.keyboard.isDown(Phaser.Keyboard.LEFT) || _this.pad.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X) < -0.1;
                        var isRight = _this.pad.game.input.keyboard.isDown(Phaser.Keyboard.RIGHT) || _this.pad.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X) > 0.1;
                        var isUp = _this.pad.game.input.keyboard.isDown(Phaser.Keyboard.UP) || _this.pad.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_Y) < -0.1;
                        var isDown = _this.pad.game.input.keyboard.isDown(Phaser.Keyboard.DOWN) || _this.pad.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_Y) > 0.1;
                        if (isLeft) {
                            _this.onLeftHold();
                        }
                        if (isRight) {
                            _this.onRightHold();
                        }
                        if (isUp) {
                            _this.onUpHold();
                        }
                        if (isDown) {
                            _this.onDownHold();
                        }
                        if (!isLeft && !isRight && !isUp && !isDown) {
                            _this.onStopHold();
                        }
                    };
                    this.onAnyArrow = function () {
                    };
                    this.onStop = function () {
                    };
                    this.onUp = function () {
                    };
                    this.onDown = function () {
                    };
                    this.onLeft = function () {
                    };
                    this.onRight = function () {
                    };
                    this.onOne = function () {
                    };
                    this.onTwo = function () {
                    };
                    this.onThree = function () {
                    };
                    this.onFour = function () {
                    };
                    this.onStopHold = function () {
                    };
                    this.onUpHold = function () {
                    };
                    this.onDownHold = function () {
                    };
                    this.onLeftHold = function () {
                    };
                    this.onRightHold = function () {
                    };
                    this.setupKeyboardHandling();
                    this.setupGamePadHandling();
                }
                Pad.prototype.setupGamePadHandling = function () {
                    var _this = this;
                    this.pad.onAxisCallback = function (pad, vertical, first) {
                        if (!vertical && first < 0) {
                            _this.onLeft();
                        }
                        if (!vertical && first > 0) {
                            _this.onRight();
                        }
                        if (vertical && first < 0) {
                            _this.onUp();
                        }
                        if (vertical && first > 0) {
                            _this.onDown();
                        }
                        if (vertical === 0 && first === 0) {
                            _this.onStop();
                        }
                        _this.onAnyArrow();
                    };
                    this.pad.onDownCallback = function (button) {
                        switch (button) {
                            case 0:
                                _this.onOne();
                                break;
                            case 1:
                                _this.onTwo();
                                break;
                            case 2:
                                _this.onThree();
                                break;
                            case 3:
                                _this.onFour();
                                break;
                        }
                    };
                };
                ;
                Pad.prototype.setupKeyboardHandling = function () {
                    var _this = this;
                    this.pad.game.input.keyboard.onUpCallback = function () {
                        _this.onStop();
                    };
                    this.pad.game.input.keyboard.onDownCallback = function (keyboardEvent) {
                        switch (keyboardEvent.keyCode) {
                            case Phaser.Keyboard.UP:
                                _this.onUp();
                                break;
                            case Phaser.Keyboard.DOWN:
                                _this.onDown();
                                break;
                            case Phaser.Keyboard.LEFT:
                                _this.onLeft();
                                break;
                            case Phaser.Keyboard.RIGHT:
                                _this.onRight();
                                break;
                            case Phaser.Keyboard.Q:
                                _this.onOne();
                                break;
                            case Phaser.Keyboard.W:
                                _this.onTwo();
                                break;
                            case Phaser.Keyboard.E:
                                _this.onThree();
                                break;
                            case Phaser.Keyboard.R:
                                _this.onFour();
                                break;
                        }
                        switch (keyboardEvent.keyCode) {
                            case Phaser.Keyboard.UP:
                            case Phaser.Keyboard.DOWN:
                            case Phaser.Keyboard.LEFT:
                            case Phaser.Keyboard.RIGHT:
                                _this.onAnyArrow();
                                break;
                        }
                    };
                };
                ;
                return Pad;
            })();
            exports_1("Pad", Pad);
        }
    }
});
//# sourceMappingURL=Pad.js.map