private void NodeRecursiveAdd(NodeGraphBuilder builder, ISkillNode data) { if (data.Hide) { return; } if (data.IsGroup) { builder.AddGroup(); data.GetSortedChildren().ForEach(child => NodeRecursiveAdd(builder, child)); if (data.GroupEnd != null) { builder.EndGroup(data.GroupEnd.DisplayName, data.GroupEnd.Graphic); SetNodeDetails(builder, data.GroupEnd); data.GroupEnd.GetSortedChildren().ForEach(child => NodeRecursiveAdd(builder, child)); } builder.End(); } else { builder.Add(data.DisplayName, data.Graphic); SetNodeDetails(builder, data); data.GetSortedChildren().ForEach(child => NodeRecursiveAdd(builder, child)); builder.End(); } }
public void interpretEffect(string effect) { SkillLexer lex = new SkillLexer(effect); SkillParser parser = new SkillParser(lex); this.effect = parser.getTree(); }
ISkillNode Brack() { Eat(SkillType.LBRACKET); ISkillNode n = Maths(); Eat(SkillType.RBRACKET); return(n); }
private void SetNodeDetails(NodeGraphBuilder builder, ISkillNode data) { builder.Description(data.Description) .NodeType(data.NodeType) .Purchased(data.IsPurchased) .IsPurchasable(() => IsPurchasable(data)) .OnPurchase(() => { ChangePoints(data, -1); }) .OnRefund(() => { ChangePoints(data, 1); }) .IsLocked(() => currentLevel < data.RequiredLevel) .LockedDescription(() => $"Level {data.RequiredLevel} is required.") .OnClickNode((node) => context.Open(node)); }
ISkillNode Mult() { ISkillNode n = Pow(); while (currentToken.Type == SkillType.MULTI || currentToken.Type == SkillType.DIVIDE) { Token t = currentToken; Eat(t.Type); n = new BinOp(n, Pow(), t); } return(n); }
ISkillNode Add() { ISkillNode n = Mult(); while (currentToken.Type == SkillType.PLUS || currentToken.Type == SkillType.MINUS) { Token t = currentToken; Eat(t.Type); n = new BinOp(n, Mult(), t); } return(n); }
private bool IsPurchasable(ISkillNode data) { switch (data.NodeType) { case NodeType.Skill: return(skillPoints > 0); case NodeType.Ability: return(abilityPoints > 0); default: throw new ArgumentOutOfRangeException(); } }
private void ChangePoints(ISkillNode data, int amount) { switch (data.NodeType) { case NodeType.Skill: skillPoints += amount; break; case NodeType.Ability: abilityPoints += amount; break; default: throw new ArgumentOutOfRangeException(); } UpdatePoints(); }
public void AddStatement(ISkillNode s) { statements.Add(s); }
public SkillAssignment(ISkillNode l, ISkillNode r) { left = l as SkillStatNode; right = r; }
public BinOp(ISkillNode l, ISkillNode r, Token op) { left = l; right = r; Operation = op.Type; }