20
|
1 using UnityEngine;
|
|
2 using System.Collections;
|
|
3
|
|
4 namespace JungleDB {
|
|
5 public class DefaultEvaluator : Evaluator {
|
|
6 private NodePath path;
|
|
7
|
|
8 public DefaultEvaluator(NodePath _path) {
|
|
9 path = _path;
|
|
10 }
|
|
11
|
|
12 public Evaluation evaluate(TreeNode _current, int _pos){
|
|
13 Pair<int, NodePath> pop = path.pop ();
|
|
14 int head = pop.lefts ();
|
|
15
|
|
16 if (path.size () == 1) {
|
|
17 if (head == _pos) {
|
|
18 return new DefaultEvaluation (Result.GOAL, null);
|
|
19 }
|
|
20 }
|
|
21
|
|
22 DefaultEvaluator nextEvaluator;
|
|
23 Result result;
|
|
24 if (head == _pos) {
|
|
25 result = Result.ACCEPT;
|
|
26 nextEvaluator = new DefaultEvaluator (pop.rights ());
|
|
27 } else {
|
|
28 result = Result.CONTINUE;
|
|
29 nextEvaluator = null;
|
|
30 }
|
|
31
|
|
32 return new DefaultEvaluation (result, nextEvaluator);
|
|
33 }
|
|
34 }
|
|
35 }
|