Ejemplo n.º 1
0
        /// <summary>
        /// Runs debug this node.
        /// </summary>
        /// <param name="parameters">AiBlackboard with global parameters.</param>
        /// <param name="trees">Readonly list with all ai trees.</param>
        /// <returns>True if debug run succeed. Otherwise false.</returns>
        public override bool DebugRun(AiBlackboard parameters, IList <AiTree> trees)
        {
            var result = trees[TreeIndex].DebugRun(parameters, trees);

            OnDebugResult(this, result);
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs this node.
        /// </summary>
        /// <param name="parameters">AiBlackboard with global parameters.</param>
        /// <param name="trees">Readonly list with all ai trees.</param>
        /// <param name="tasks">List of task scripts to bind with.</param>
        /// <returns>True if current conditions of comparition succeed. Otherwise false.</returns>
        public override bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks)
        {
            switch (_condition)
            {
            case IntCondition.Greater:
                if (parameters.IntParameters[Key] > (DynamicValue ? parameters.IntParameters[DynamicValueKey] : Value))
                {
                    return(true);
                }
                break;

            case IntCondition.Less:
                if (parameters.IntParameters[Key] < (DynamicValue ? parameters.IntParameters[DynamicValueKey] : Value))
                {
                    return(true);
                }
                break;

            case IntCondition.Equal:
                if (parameters.IntParameters[Key] == (DynamicValue ? parameters.IntParameters[DynamicValueKey] : Value))
                {
                    return(true);
                }
                break;

            case IntCondition.NotEqual:
                if (parameters.IntParameters[Key] != (DynamicValue ? parameters.IntParameters[DynamicValueKey] : Value))
                {
                    return(true);
                }
                break;
            }
            return(false);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="level">Level of how deep we are in this AiTree.</param>
 /// <param name="nodeIndex">Index of current node in parent's node. If this is root, nodeIndex is 0.</param>
 /// <returns>Always returns true.</returns>
 public override bool DebugRun(AiBlackboard parameters, IList<AiTree> trees, int level, int nodeIndex)
 {
     _node.DebugRun(parameters, trees, (level + 1), 0);
     Debug.Log(string.Format("{0}{1}. Succeeder Node. Result: <b><color=green>true</color></b>", new string('\t', level), nodeIndex));
     OnDebugResult(this, true);
     return true;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Runs debug this node.
        /// </summary>
        /// <param name="parameters">AiBlackboard with global parameters.</param>
        /// <param name="trees">Readonly list with all ai trees.</param>
        /// <returns>True if child node debug run failed. Otherwise false.</returns>
        public override bool DebugRun(AiBlackboard parameters, IList <AiTree> trees)
        {
            var result = _node.DebugRun(parameters, trees);

            OnDebugResult(this, !result);
            return(!result);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="blackboard">Blackboard to copy.</param>
 public AiBlackboard(AiBlackboard blackboard)
 {
     _intParameters    = new IntParameter(blackboard._intParameters);
     _floatParameters  = new FloatParameter(blackboard._floatParameters);
     _boolParameters   = new BoolParameter(blackboard._boolParameters);
     _stringParameters = new StringParameter(blackboard._stringParameters);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="level">Level of how deep we are in this AiTree.</param>
 /// <param name="nodeIndex">Index of current node in parent's node. If this is root, nodeIndex is 0.</param>
 /// <returns>True if child node debug run failed. Otherwise false.</returns>
 public override bool DebugRun(AiBlackboard parameters, IList<AiTree> trees, int level, int nodeIndex)
 {
     var result = _node.DebugRun(parameters, trees, (level + 1), 0);
     Debug.Log(string.Format("{0}{1}. Inverter Node. Result: <b><color={2}>{3}</color></b>", new string('\t', level), nodeIndex, result == false ? "green" : "red", !result));
     OnDebugResult(this, !result);
     return !result;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>Always returns true.</returns>
 public override bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks)
 {
     for (int i = 0; i < Repeat; ++i)
     {
         _node.Run(parameters, trees, tasks);
     }
     return(true);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a copy of this object.
 /// </summary>
 /// <returns>Deep copy of AiBlackboard.</returns>
 public AiBlackboard Clone()
 {
     var aib = new AiBlackboard();
     aib._intParameters = new IntParameter(_intParameters);
     aib._floatParameters = new FloatParameter(_floatParameters);
     aib._boolParameters = new BoolParameter(_boolParameters);
     aib._stringParameters = new StringParameter(_stringParameters);
     return aib;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <returns>Always returns true.</returns>
 public override bool DebugRun(AiBlackboard parameters, IList <AiTree> trees)
 {
     for (int i = 0; i < Repeat; ++i)
     {
         _node.DebugRun(parameters, trees);
     }
     OnDebugResult(this, true);
     return(true);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>True if at least one child node succeed. Otherwise false.</returns>
 public override bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks)
 {
     for (int i = 0; i < _nodes.Count; ++i)
     {
         if (_nodes[i].Run(parameters, trees, tasks))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with.</param>
 /// <returns>True if node succeed. Otherwise false.</returns>
 public override bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks)
 {
     for (int i = 0; i < tasks.Count; ++i)
     {
         if (tasks[i].taskKeyName == TaskKey)
         {
             return(tasks[i].task.Execute());
         }
     }
     return(false);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="level">Level of how deep we are in this AiTree.</param>
 /// <param name="nodeIndex">Index of current node in parent's node. If this is root, nodeIndex is 0.</param>
 /// <returns>True if debug run succeed. Otherwise false.</returns>
 public override bool DebugRun(AiBlackboard parameters, IList<AiTree> trees, int level, int nodeIndex)
 {
     for (int i = 0; i < _nodes.Count; ++i) {
         if (_nodes[i].DebugRun(parameters, trees, (level + 1), i)) {
             Debug.Log(string.Format("{0}{1}. Selector Node. Result: <b><color=green>true</color></b>", new string('\t', level), nodeIndex));
             OnDebugResult(this, true);
             return true;
         }
     }
     Debug.Log(string.Format("{0}{1}. Selector Node. Result: <b><color=red>false</color></b>", new string('\t', level), nodeIndex));
     OnDebugResult(this, false);
     return false;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <returns>True if debug run succeed. Otherwise false.</returns>
 public override bool DebugRun(AiBlackboard parameters, IList <AiTree> trees)
 {
     for (int i = 0; i < _nodes.Count; ++i)
     {
         if (_nodes[i].DebugRun(parameters, trees))
         {
             OnDebugResult(this, true);
             return(true);
         }
     }
     OnDebugResult(this, false);
     return(false);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Runs this node.
        /// </summary>
        /// <param name="parameters">AiBlackboard with global parameters.</param>
        /// <param name="trees">Readonly list with all ai trees.</param>
        /// <param name="tasks">List of task scripts to bind with.</param>
        /// <returns>True if current conditions of comparition succeed. Otherwise false.</returns>
        public override bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks)
        {
            switch (_condition)
            {
            case StringCondition.Equal:
                if (parameters.StringParameters[Key].Equals((DynamicValue ? parameters.StringParameters[DynamicValueKey] : Value)))
                {
                    return(true);
                }
                break;

            case StringCondition.NotEqual:
                if (!parameters.StringParameters[Key].Equals((DynamicValue ? parameters.StringParameters[DynamicValueKey] : Value)))
                {
                    return(true);
                }
                break;
            }
            return(false);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Runs debug this node.
        /// </summary>
        /// <param name="parameters">AiBlackboard with global parameters.</param>
        /// <param name="trees">Readonly list with all ai trees.</param>
        /// <returns>True if current conditions of comparition succeed. Otherwise false.</returns>
        public override bool DebugRun(AiBlackboard parameters, IList <AiTree> trees)
        {
            var result = false;

            switch (_condition)
            {
            case BoolCondition.Equal:
                if (parameters.BoolParameters[Key] == (DynamicValue ? parameters.BoolParameters[DynamicValueKey] : Value))
                {
                    result = true;
                }
                break;

            case BoolCondition.NotEqual:
                if (parameters.BoolParameters[Key] != (DynamicValue ? parameters.BoolParameters[DynamicValueKey] : Value))
                {
                    result = true;
                }
                break;
            }
            OnDebugResult(this, result);
            return(result);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>True if at least one child node succeed. Otherwise false.</returns>
 public override bool Run(AiBlackboard parameters, IList<AiTree> trees, List<ATaskScript> tasks)
 {
     for (int i = 0; i < _nodes.Count; ++i) {
         if (_nodes[i].Run(parameters, trees, tasks)) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>Always returns true.</returns>
 public override bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks)
 {
     _node.Run(parameters, trees, tasks);
     return(true);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>True if node succeed. Otherwise false.</returns>
 public abstract bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks);
Ejemplo n.º 19
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <returns>True if debug run succeed. Otherwise false.</returns>
 public abstract bool DebugRun(AiBlackboard parameters, IList <AiTree> trees);
Ejemplo n.º 20
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>True if node succeed. Otherwise false.</returns>
 public override bool Run(AiBlackboard parameters, IList<AiTree> trees, List<ATaskScript> tasks)
 {
     return trees[TreeIndex].Run(parameters, trees, tasks);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>Always returns true.</returns>
 public override bool Run(AiBlackboard parameters, IList<AiTree> trees, List<ATaskScript> tasks)
 {
     _node.Run(parameters, trees, tasks);
     return true;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Runs this tree behaviour.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>True if tree succeed. Otherwise false.</returns>
 public bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks)
 {
     return(Root.Run(parameters, trees, tasks));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Runs debug this tree behaviour.
        /// </summary>
        /// <param name="parameters">AiBlackboard with global parameters.</param>
        /// <param name="trees">Readonly list with all ai trees.</param>
        /// <returns>True if debug run succeed. Otherwise false.</returns>
        public bool DebugRun(AiBlackboard parameters, IList <AiTree> trees)
        {
            var result = Root.DebugRun(parameters, trees);

            return(result);
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="level">Level of how deep we are in this AiTree.</param>
 /// <param name="nodeIndex">Index of current node in parent's node. If this is root, nodeIndex is 0.</param>
 /// <returns>True if debug run succeed. Otherwise false.</returns>
 public abstract bool DebugRun(AiBlackboard parameters, IList<AiTree> trees, int level, int nodeIndex);
Ejemplo n.º 25
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>True if node succeed. Otherwise false.</returns>
 public abstract bool Run(AiBlackboard parameters, IList<AiTree> trees, List<ATaskScript> tasks);
Ejemplo n.º 26
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <returns>Debug run always returns true for TaskNode.</returns>
 public override bool DebugRun(AiBlackboard parameters, IList <AiTree> trees)
 {
     OnDebugResult(this, true);
     return(true);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>Always returns true.</returns>
 public override bool Run(AiBlackboard parameters, IList<AiTree> trees, List<ATaskScript> tasks)
 {
     for (int i = 0; i < Repeat; ++i) {
         _node.Run(parameters, trees, tasks);
     }
     return true;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Runs debug this tree behaviour.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="level">Level of how deep we are in this AiTree.</param>
 /// <returns>True if debug run succeed. Otherwise false.</returns>
 public bool DebugRun(AiBlackboard parameters, IList<AiTree> trees, int level)
 {
     var result = Root.DebugRun(parameters, trees, (level + 1), 0);
     level = Mathf.Clamp(level, 0, level);
     Debug.Log(string.Format("{0}<b>Tree debug run. Result: <color={1}>{2}</color></b>", new string('\t', level), result ? "green" : "red", result));
     return result;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Runs this tree behaviour.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>True if tree succeed. Otherwise false.</returns>
 public bool Run(AiBlackboard parameters, IList<AiTree> trees, List<ATaskScript> tasks)
 {
     return Root.Run(parameters, trees, tasks);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Runs debug this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="level">Level of how deep we are in this AiTree.</param>
 /// <param name="nodeIndex">Index of current node in parent's node. If this is root, nodeIndex is 0.</param>
 /// <returns>Debug run always returns true for TaskNode.</returns>
 public override bool DebugRun(AiBlackboard parameters, IList<AiTree> trees, int level, int nodeIndex)
 {
     Debug.Log(string.Format("{0}{1}. Task Node. Result in debug mode for tasks is always <b><color=orange>true</color></b>", new string('\t', level), nodeIndex));
     OnDebugResult(this, true);
     return true;
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with.</param>
 /// <returns>True if node succeed. Otherwise false.</returns>
 public override bool Run(AiBlackboard parameters, IList<AiTree> trees, List<ATaskScript> tasks)
 {
     return tasks[_taskIndex].Execute();
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Runs this node.
 /// </summary>
 /// <param name="parameters">AiBlackboard with global parameters.</param>
 /// <param name="trees">Readonly list with all ai trees.</param>
 /// <param name="tasks">List of task scripts to bind with task nodes.</param>
 /// <returns>True if node succeed. Otherwise false.</returns>
 public override bool Run(AiBlackboard parameters, IList <AiTree> trees, List <TaskBinder> tasks)
 {
     return(trees[TreeIndex].Run(parameters, trees, tasks));
 }