Roboman.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. // designate component
  8. "atomic component";
  9. //A RoboMan component
  10. var Roboman = (function (_super) {
  11. __extends(Roboman, _super);
  12. function Roboman() {
  13. _super.apply(this, arguments);
  14. this.idle = true;
  15. }
  16. Roboman.prototype.start = function () {
  17. this.animCtrl = this.node.getComponent("AnimationController");
  18. this.controller = this.node.getJSComponent("AvatarController");
  19. //get main camera of the current scene
  20. var camera = this.node.scene.getMainCamera();
  21. //if it exist
  22. if (camera) {
  23. camera.node.position = [0, 0, -10];
  24. camera.node.pitch(20);
  25. }
  26. this.animCtrl.playExclusive("Idle", 0, true, 0.0);
  27. //rotate current node around Y axis
  28. this.node.yaw(180);
  29. };
  30. Roboman.prototype.update = function (timeStep) {
  31. //rotate current node around Y axis
  32. this.node.yaw(180);
  33. if (this.idle != this.controller.idle) {
  34. this.idle = this.controller.idle;
  35. if (this.idle) {
  36. this.animCtrl.playExclusive("Idle", 0, true, 0.1);
  37. }
  38. else {
  39. this.animCtrl.playExclusive("Run", 0, true, 0.1);
  40. }
  41. }
  42. };
  43. return Roboman;
  44. }(Atomic.JSComponent));
  45. module.exports = Roboman;