MShotgun.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * 主角散弹技能
  3. */
  4. import BObject from "../../../bullet/BObject";
  5. import FSprite, { SpriteActionType } from "../../FSprite";
  6. import SkillShotgun from "../SkillShotgun";
  7. const {ccclass, property} = cc._decorator;
  8. @ccclass
  9. export default class MShotgun extends SkillShotgun {
  10. onLoad () {
  11. this.sprite = this.node.getComponent(FSprite);
  12. }
  13. /**
  14. * 释放技能
  15. */
  16. public exe(target:FSprite,callback:()=>void){
  17. this.time = new Date().getTime();
  18. // this.sprite.setDir({x:0,y:0});
  19. //-----播放开始动画
  20. let bNode = cc.instantiate(this.mBullet)
  21. let bobject = bNode.getComponent(BObject)
  22. let sf = bobject.mStartEffect
  23. let x = this.sprite.mAtkSite.worldX * this.sprite.spine.node.scaleX
  24. let y = this.sprite.mAtkSite.worldY
  25. let pos = cc.v2(x, y);
  26. let sfNode = cc.instantiate(sf)
  27. sfNode.angle = this.sprite.wAngle
  28. sfNode.setPosition(pos);
  29. sfNode.parent = this.sprite.node
  30. let startSpine: sp.Skeleton = sfNode.getComponent(sp.Skeleton)
  31. startSpine.setCompleteListener(() => {
  32. startSpine.setCompleteListener(null);
  33. sfNode.destroy()
  34. if(callback){
  35. callback()
  36. }
  37. });
  38. startSpine.setAnimation(0, 'atk', false);
  39. //----开始动画播放结束
  40. // this.sprite.playAction(SpriteActionType.atk,false,()=>{
  41. // if(this.sprite.isWalk){
  42. // this.sprite.playAction(SpriteActionType.run,true)
  43. // }else{
  44. // this.sprite.playAction(SpriteActionType.stand,true)
  45. // }
  46. // });
  47. let tp = undefined
  48. if(target){
  49. tp = target.node.getPosition();
  50. tp.y += target.node.height/2
  51. }else{
  52. // let angle = this.sprite.wAngle;
  53. // let hd = angle * Math.PI / 180;
  54. let y = this.sprite.moveV2.y * 300 + this.node.y
  55. let x = this.sprite.moveV2.x * 300 + this.node.x;
  56. tp = cc.v2(x,y + 40)
  57. }
  58. for (let i = 0; i < this.count; i++) {
  59. this.fire(i,tp);
  60. }
  61. }
  62. }