UserSkillBomb.ts 864 Bytes
import { UserSkillBase } from "./UserSkillBase";

export class UserSkillBomb extends UserSkillBase {

    private static _isLock: boolean = false;

    private _tweenObj: object = {};

    start(free:boolean = false): boolean {
        if (!UserSkillBomb._isLock && super.start(free)) {

            UserSkillBomb._isLock = true; //锁定,动画播完了再解锁

            cc.tween(this._tweenObj).delay(1.5).call(this.onAniFinish.bind(this)).start();
            // this.dispatchEvent();

            return true;
        }

        return false;
    }

    private onAniFinish(): void {
        this._battle.mapData.blockData.forEach((value, key, map) => {

            let hurt = Math.ceil(value.hp * 0.4);

            if (hurt > 0) {
                value.adJustHp(-hurt);
            }

        }, this);

        UserSkillBomb._isLock = false;
    }
}