diff Main/jungle-main/traverser/DefaultEvaluator.cs @ 20:1f99e150f336

fix folder and add Object Mapper.
author Kazuma Takeda
date Thu, 15 Dec 2016 22:52:48 +0900
parents
children f2ea780b3e80
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Main/jungle-main/traverser/DefaultEvaluator.cs	Thu Dec 15 22:52:48 2016 +0900
@@ -0,0 +1,35 @@
+using UnityEngine;
+using System.Collections;
+
+namespace JungleDB {
+	public class DefaultEvaluator : Evaluator {
+		private NodePath path;
+
+		public DefaultEvaluator(NodePath _path) {
+			path = _path;
+		}
+
+		public Evaluation evaluate(TreeNode _current, int _pos){
+			Pair<int, NodePath> pop = path.pop ();
+			int head = pop.lefts ();
+
+			if (path.size () == 1) {
+				if (head == _pos) {
+					return new DefaultEvaluation (Result.GOAL, null);
+				}
+			}
+
+			DefaultEvaluator nextEvaluator;
+			Result result;
+			if (head == _pos) {
+				result = Result.ACCEPT;
+				nextEvaluator = new DefaultEvaluator (pop.rights ());
+			} else {
+				result = Result.CONTINUE;
+				nextEvaluator = null;
+			}
+
+			return new DefaultEvaluation (result, nextEvaluator);
+		}
+	}
+}