public void cant_create_a_behaviour_tree_with_zero_nodes() { Init(); Assert.Throws <ApplicationException>(() => { testObject.Build(); } ); }
/// <summary> /// Parsers the specified input. /// </summary> /// <param name="input">The input.</param> public void parser(byte[] input) { //this is a parser that creates the tree by reading the //byte array that is passed in as aperamiter var builder = new MyTreeBuilder(crouched, close, medium, far); IMyBehaviourTreeNode botTree; for (int i = 0; i < input.Length; i++) { switch (input[i]) { case Root_Node: builder.Sequence("Root-Sequence-Node"); break; case Punch: builder.Punch(gw, AI, NAI); break; case Kick: builder.Kick(gw, AI, NAI); break; case Special: builder.Special(gw, AI, NAI); break; case isCrouched: builder.Condition ("is_Opponent_Crouched", t => { if (builder.Crouched == true) { return(true); } return(false); }); builder.Selector("If_Crouched"); break; case isClose: builder.Condition ("is_Opponent_Close", t => { if (builder.Close == true) { return(true); } return(false); }); builder.Selector("If_Close"); break; case isMedium: builder.Condition ("is_Opponent_Medium", t => { if (builder.Medium == true) { return(true); } return(false); }); builder.Selector("If_Medium"); break; case isFar: builder.Condition ("is_Opponent_Far", t => { if (builder.Far == true) { return(true); } return(false); }); builder.Selector("If_Far"); break; case End: builder.End().Build(); break; } } //will have gotten nodes from parser so should build botTree = builder.Build(); interp_tree_builder = builder; interp_tree = botTree; }