12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /**
- * 主角散弹技能
- */
- import BObject from "../../../bullet/BObject";
- import FSprite, { SpriteActionType } from "../../FSprite";
- import SkillShotgun from "../SkillShotgun";
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class MShotgun extends SkillShotgun {
- onLoad () {
- this.sprite = this.node.getComponent(FSprite);
- }
- /**
- * 释放技能
- */
- public exe(target:FSprite,callback:()=>void){
- this.time = new Date().getTime();
- // this.sprite.setDir({x:0,y:0});
-
- //-----播放开始动画
- let bNode = cc.instantiate(this.mBullet)
- let bobject = bNode.getComponent(BObject)
- let sf = bobject.mStartEffect
- let x = this.sprite.mAtkSite.worldX * this.sprite.spine.node.scaleX
- let y = this.sprite.mAtkSite.worldY
- let pos = cc.v2(x, y);
- let sfNode = cc.instantiate(sf)
- sfNode.angle = this.sprite.wAngle
- sfNode.setPosition(pos);
- sfNode.parent = this.sprite.node
- let startSpine: sp.Skeleton = sfNode.getComponent(sp.Skeleton)
- startSpine.setCompleteListener(() => {
- startSpine.setCompleteListener(null);
- sfNode.destroy()
- if(callback){
- callback()
- }
- });
- startSpine.setAnimation(0, 'atk', false);
- //----开始动画播放结束
- // this.sprite.playAction(SpriteActionType.atk,false,()=>{
- // if(this.sprite.isWalk){
- // this.sprite.playAction(SpriteActionType.run,true)
- // }else{
- // this.sprite.playAction(SpriteActionType.stand,true)
- // }
- // });
- let tp = undefined
- if(target){
- tp = target.node.getPosition();
- tp.y += target.node.height/2
- }else{
- // let angle = this.sprite.wAngle;
- // let hd = angle * Math.PI / 180;
- let y = this.sprite.moveV2.y * 300 + this.node.y
- let x = this.sprite.moveV2.x * 300 + this.node.x;
- tp = cc.v2(x,y + 40)
- }
- for (let i = 0; i < this.count; i++) {
- this.fire(i,tp);
- }
- }
- }
|