super-hero/assets/cc-game/scripts/game_play/hero/ActiveSkillBase.ts

48 lines
1.3 KiB
TypeScript

import { Sprite } from 'cc';
import { Color } from 'cc';
import { Vec3 } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { UmUtil } from '../../../../cc-common/cc-util/UmUtil';
import { GameDefine } from '../../config/GameDefine';
import { UmClientEvent } from '../../../../cc-common/cc-util/UmOneToMultiListener';
const { ccclass, property } = _decorator;
@ccclass('ActiveSkillBase')
export class ActiveSkillBase extends Component {
@property(Sprite) theme: Sprite = null!;
isDestroying = false;
skillType: number = -1;
speed: number = 360;
mana: number = 10;
dmg: number = 10;
range: number = 5;
useTime: number = 1;
public enableActiveSkill(data, parent = null) {
this.mana = data?.mana || this.mana;
this.dmg = data?.dmg || this.dmg;
this.range = data?.range || this.range;
this.useTime = data?.useTime || this.useTime;
}
public getColor(): Color {
return this.theme?.color;
}
public destroyNode() {
if (this.isDestroying) return;
this.isDestroying = true;
UmClientEvent.dispatchEvent(GameDefine.EVENT_END_USE_ACTIVE_SKILL);
UmUtil.stopAllTweenTarget(this.node);
//must destroy on thread
this.scheduleOnce(() => {
this.node?.destroy();
}, 0);
}
}