You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

74 lines
1.1 KiB

  1. define([
  2. 'js/rendering/effects'
  3. ], function (
  4. effects
  5. ) {
  6. return {
  7. type: 'whirlwind',
  8. source: null,
  9. row: null,
  10. col: null,
  11. frames: 4,
  12. frameDelay: 4,
  13. spriteSheet: 'attacks',
  14. delay: 32,
  15. coordinates: [],
  16. objects: null,
  17. init: async function (blueprint) {
  18. await this.getObjectsModule();
  19. if (!this.source) {
  20. this.obj.destroyed = true;
  21. return;
  22. }
  23. this.coordinates.forEach(([x, y], i) => {
  24. const wait = i * this.delay;
  25. setTimeout(this.spawnThing.bind(this, x, y), wait);
  26. });
  27. effects.register(this);
  28. },
  29. getObjectsModule: async function () {
  30. return new Promise(res => {
  31. require(['js/objects/objects'], o => {
  32. this.objects = o;
  33. res();
  34. });
  35. });
  36. },
  37. spawnThing: function (x, y) {
  38. const { frames: frameCount, row, col, spriteSheet, frameDelay } = this;
  39. this.objects.buildObject({
  40. x,
  41. y,
  42. components: [{
  43. type: 'attackAnimation',
  44. row,
  45. col,
  46. frames: frameCount,
  47. spriteSheet,
  48. frameDelay
  49. }]
  50. });
  51. },
  52. renderManual: function () {
  53. },
  54. destroy: function () {
  55. effects.unregister(this);
  56. }
  57. };
  58. });