import { _decorator, animation, Animation, AnimationClip, macro, Node, Sprite, tween } from 'cc'; import { Tower } from '../Tower'; import { GameMgr } from './GameMgr'; import { BulletMgr } from './BulletMgr'; import { Tools } from '../Tools/Tools'; const { ccclass, property } = _decorator; @ccclass('InsTower') //发射子弹类型的塔 export class ShootTower extends Tower { protected _attack(): void { //发射子弹 // this.schedule(() => { //this._ani.play(); // this._ani.on(Animation.EventType.FINISHED,()=>{ // GameMgr.Instance.getModuler(BulletMgr).createBullet( // this.node.position, this._targetAngle, this._bulletFrames); // }) // }, 1, macro.REPEAT_FOREVER, 0) } protected stopAttack(): void { this.unscheduleAllCallbacks(); } } //太阳 export class ExpandTower extends Tower { private _weapon: Animation = null; protected _attack(): void { if (!this._weapon) { // 创建动画 const node = Tools.createSprite(null, this.node); this._weapon = Tools.createAnimation(this._bulletFrames, 15, node); node.active = false; // const node = new Node(); // node.addComponent(Sprite); // this._weapon = node.addComponent(Animation) // //添加动画剪辑 // const clip = AnimationClip.createWithSpriteFrames(this._bulletFrames, 15); // this._weapon.addClip(clip); // this._weapon.defaultClip = clip; // node.active = false; // node.parent = this.node; } this.schedule(()=>{ this._weapon.node.active = true; //tween(this._chassis).by(0.2,{angle: -20}).start(); this._weapon.play(); //动画组件注册事件 this._weapon.on(Animation.EventType.FINISHED,()=>{ this._weapon.node.active = false; if(!this._isFire){ this.unscheduleAllCallbacks(); } }) }, 1) this._weapon.play(); } } // export class LaserTower extends Tower { } export class MShootTower extends Tower { } export class StickTower extends Tower { }