예제 #1
0
        public T GetValue(Blackboard bb)
        {
            if (type == BehaviorPropertyType.Blackboard)
            {
                LastValue = bb.Get <T>(variableVal);
                return(LastValue);
            }
            else if (type == BehaviorPropertyType.Func)
            {
                LastValue = funcVal(bb);
                return(LastValue);
            }
            else if (type == BehaviorPropertyType.Static)
            {
                LastValue = staticVal;
                return(LastValue);
            }

            throw new ArgumentException("BehaviorProperty has an invalid type");
        }
예제 #2
0
        bool CheckConditionFor(Blackboard blackboard, object item)
        {
            object old_val = null;

            if (blackboard.Contains(VariableName))
            {
                old_val = blackboard.Get <object>(VariableName);
            }

            blackboard.Set(VariableName, item);

            bool can_run = Child.CheckCondition(blackboard);

            // Restore old blackboard value
            if (old_val != null)
            {
                blackboard.Set(VariableName, old_val);
            }

            return(can_run);
        }
예제 #3
0
        public override bool CheckCondition(Blackboard blackboard)
        {
            int test_index = 0;

            while (true)
            {
                if (test_index >= currentList.Count)
                {
                    return(false);
                }

                object old_val = null;
                if (blackboard.Contains("current"))
                {
                    old_val = blackboard.Get <object>("current");
                }

                blackboard.Set("current", currentList[test_index]);

                bool can_run = Child.CheckCondition(blackboard);
                if (!can_run)
                {
                    test_index++;
                }

                // Restore old blackboard value
                if (old_val != null)
                {
                    blackboard.Set("current", old_val);
                }

                if (can_run)
                {
                    return(true);
                }
            }
        }
예제 #4
0
 public T Get(Blackboard bb)
 {
     return(bb.Get <T>(Name));
 }