123456789101112131415161718192021222324252627 |
- /// <reference path="DialogueNode.ts" />
- class DialogueBranch extends DialogueNode {
- public type = NodeType.Branch;
- public variable : () => any = () => {return false;}
- public branchIds : Array<string> = [];
- public branchConditions : Array<() => any> = [];
- public setVariable (varFunc : () => any) {
- this.variable = varFunc;
- }
- public addBranch (targetid : string, valueFunc : () => any) {
- this.branchIds.push(targetid);
- this.branchConditions.push(valueFunc);
- }
- public getNext () {
- let variable = this.variable();
- for (let i = 0; i < this.branchIds.length; i++) {
- let comparing = this.branchConditions[i]();
- if (comparing == variable) {
- return this.branchIds[i];
- }
- }
- return this.next;
- }
- }
|