UserSkillBase.ts
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { SaveDataManager } from "../../../component/SaveDataManager";
import { SoundManager } from "../../../component/SoundManager";
import { SoundName } from "../../../Global";
import { Battle } from "../Battle";
import { BattleEvent, UserSkill } from "../BattleConst";
import { BattleManager } from "../BattleManager";
export class UserSkillBase {
protected _battle: Battle;
private _skillId: UserSkill = UserSkill.NONE;
constructor(battle: Battle, skillId: UserSkill) {
this._battle = battle;
this._skillId = skillId;
}
start(free: boolean = false): boolean {
//解锁与否完全由关卡控制
let num = SaveDataManager.ins.getUserSkillNum(this._skillId);
if (num > 0 || free) {
!free && SaveDataManager.ins.setUserSkillNumDelta(this._skillId, -1);
this.dispatchEvent();
SoundManager.ins.playEffect(SoundName.USE_ITEM);
return true;
}
return false;
}
protected dispatchEvent() {
BattleManager.ins.eventNode.emit(BattleEvent.SKILL_START, this._skillId);
}
}