-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDialogueData.ts
49 lines (39 loc) · 1.39 KB
/
DialogueData.ts
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
39
40
41
42
43
44
45
46
47
48
49
namespace DialogueData {
export class Dialogue {
public get JSON() { return JSON.stringify(this); }
public static fromJSON(json: string) { return JSON.parse(json) as Dialogue; }
constructor(
public name: string,
public ownerId: string,
public lines: Line[]
) { }
}
export class Line {
private _soundwave;
private _nextLines: number[];
public set soundWave(path: string) { this._soundwave = `SoundWave'/Game/${path}'`; }
public get soundWave() { return this._soundwave.substr(16, this._soundwave.length - 18); }
public addNext(line: Line) {
if (this._nextLines.every(l => this._nextLines[l] !== line.index))
this._nextLines.push(line.index);
}
public removeNext(line: Line) {
if (this._nextLines.some(l => this._nextLines[l] === line.index))
this._nextLines.splice(this._nextLines.indexOf(line.index), 1);
}
public getNextLine(index: number) { return this._nextLines[index]; }
public nextLinesCount() { return this._nextLines.length; }
public get JSON() { return JSON.stringify(this); }
public static fromJSON(json: string) { return JSON.parse(json) as Line; }
constructor(
public readonly parentDialogue: Dialogue,
public index: number,
public text: string,
public shortText: string,
public isPlayerLine: boolean,
public isImportant: boolean,
public conditions: string[],
soundPath: string
) { this.soundWave = soundPath; }
}
}