예제 #1
0
 public bool IsFinished(AntAIAgent aAgent, AntAICondition aWorldState)
 {
     if (_isFinished || OverlapInterrupts(aAgent.planner, aWorldState))
     {
         Reset();
         return(true);
     }
     return(false);
 }
예제 #2
0
        /// <summary>
        /// Checking if current world state is equal interruption settings.
        /// </summary>
        /// <param name="aAgent">Ref to the AntAIAgent.</param>
        /// <param name="aWorldState">Current world state.</param>
        /// <returns></returns>
        public bool OverlapInterrupts(AntAIAgent aAgent, AntAICondition aWorldState)
        {
            int index = -1;

            for (int i = 0, n = _interruptions.Count; i < n; i++)
            {
                index = aAgent.planner.GetAtomIndex(_interruptions[i]);
                if (aWorldState.GetValue(index))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
        private void OnGUI()
        {
            if (Selection.activeGameObject != null)
            {
                var p = Selection.activeGameObject.GetComponent <IAgentProvider>();
                var b = Selection.activeGameObject.GetComponent <AntAIBlackboard>();
                if (p == null)
                {
                    _nodes.Clear();
                    _genericNodes.Clear();
                    _goalNodes.Clear();
                    _titles.Clear();

                    if (_agent != null)
                    {
                        _agent.planner.EventPlanUpdated -= OnPlanUpdated;
                        _agent = null;
                    }
                }
                else if (!System.Object.ReferenceEquals(p.Agent, _agent))
                {
                    _agent      = p.Agent;
                    _blackboard = b;

                    _nodes.Clear();
                    _goalNodes.Clear();
                    _titles.Clear();

                    CreateTitle(0.0f, 0.0f, string.Format("{0}: Actions and Goals", Selection.activeGameObject.name));

                    float actionsHeight = 0.0f;
                    RebuildActionNodes(new Vector2(_totalDrag.x, _totalDrag.y + 35.0f), out actionsHeight);
                    actionsHeight += 35.0f;

                    float goalsHeight = 0.0f;
                    RebuildGoalNodes(new Vector2(_totalDrag.x, _totalDrag.y + actionsHeight), out goalsHeight);

                    CreateTitle(0.0f, actionsHeight + goalsHeight + 15.0f, string.Format("{0}: Current Plan", Selection.activeGameObject.name));
                    _planNodesPosition = new Vector2(0.0f, actionsHeight + goalsHeight + 45.0f);

                    RebuildBlackboardNode(_totalDrag + _planNodesPosition);

                    _agent.planner.EventPlanUpdated += OnPlanUpdated;
                }
            }

            if (_agent != null)
            {
                DrawGrid(20, Color.gray, 0.05f);
                DrawGrid(100, Color.gray, 0.05f);

                if (Event.current.type == EventType.Repaint)
                {
                    DrawTitles(_titles);
                    DrawLinks(_nodes, true);
                    DrawLinks(_genericNodes, false);
                    DrawCurrentStateLink();
                    DrawNodes(_nodes);
                    DrawNodes(_genericNodes);
                    Repaint();
                }

                ProcessEvents(Event.current);
            }
            else
            {
                if (Event.current.type == EventType.Repaint)
                {
                    GUI.Label(new Rect(10.0f, 10.0f, 200.0f, 50.0f),
                              "Object with AI Not Selected.", _titleStyle);
                }
            }
        }
 private void OnEnable()
 {
     _self = (AntAIAgent)target;
 }
예제 #5
0
 public bool IsFinished(AntAIAgent aAgent, AntAICondition aWorldState)
 {
     return(_isFinished || OverlapInterrupts(aAgent.planner, aWorldState));
 }