/// <summary>
        /// Обновляет ноду описывающую конкретное действие из плана ИИ.
        /// </summary>
        private void UpdatePlanNode(Action aAction, GoapAIDebuggerNode aNode)
        {
            aNode.value = aAction.name;

            int numLines;

            aNode.title       = DescribePlanAction(_agent, aAction, out numLines);
            aNode.rect.height = CalcHeight(numLines);

            // if ( _currentPlan.isSuccess ) {
            //  aNode.defaultNodeStyle =
            //      ( aAction.name.Equals ( _agent.currentPlan[ 0 ] ) ) ? _activePlanStyle : _planStyle;
            // }
            // else {
            //  aNode.defaultNodeStyle = ( aAction.name.Equals ( _agent.currentPlan[ 0 ] ) )
            //      ? _activeFailedPlanStyle
            //      : _failedPlanStyle;
            // }
            if (_currentPlan != null && _currentPlan.Count != 0)
            {
                aNode.defaultNodeStyle = aAction == _currentPlan.Peek() ? _activePlanStyle : _planStyle;
            }
            else
            {
                aNode.defaultNodeStyle = _planStyle;
            }

            aNode.currentStyle = aNode.defaultNodeStyle;
        }
        // ---

        private GoapAIDebuggerNode AddNode(string aText, float aWidth, float aHeight,
                                           GUIStyle aStyle, GUIStyle aActiveStyle, ref Vector2 aPosition,
                                           bool aAddToList = true)
        {
            GoapAIDebuggerNode node = new GoapAIDebuggerNode(aPosition.x, aPosition.y, aWidth, aHeight, aStyle, aActiveStyle);

            node.title = aText;
            if (aAddToList)
            {
                _nodes.Add(node);
            }

            aPosition.x += aWidth;
            return(node);
        }
        /// <summary>
        /// Обновляет информацию уже существующей ноды описывающей состояние мира (условий ИИ).
        /// </summary>
        private void UpdateWorldStateNode(AIScenarioAgent agent, GoapAIDebuggerNode aNode)
        {
            List <string> desc = new List <string> ();

            desc.Add(string.Format("<b><color={0}>WORLD STATE</color></b>", _titleColor));
            desc.Add("   <b>Current Conditions</b>");
            DescribeCurrentWorldState(agent, ref desc);

            StringBuilder text = new StringBuilder();

            for (int i = 0, n = desc.Count; i < n; i++)
            {
                text.AppendLine(desc[i]);
            }

            aNode.title       = text.ToString();
            aNode.rect.height = CalcHeight(desc.Count);
        }
        /// <summary>
        /// Создает ноду состояния.
        /// </summary>
        private GoapAIDebuggerNode CreateStateNode(string aState, Vector2 aNodePosition, bool isDefault)
        {
            string title;
            float  height = 40.0f;

            if (isDefault)
            {
                title = string.Format(
                    "<b><color={1}>STATE</color> '<color={2}>{0}</color>'</b>\n\r   <color=#51a9b0>This is Default state</color>",
                    aState, _titleColor, _nameColor);
                height += 14.0f;
            }
            else
            {
                title = string.Format("<b><color={1}>STATE</color> '<color={2}>{0}</color>'</b>",
                                      aState, _titleColor, _nameColor);
            }

            GoapAIDebuggerNode node = AddNode(title, 220.0f, height, _stateStyle, _stateStyle, ref aNodePosition);

            node.value = aState;
            return(node);
        }
示例#5
0
 public void LinkTo(GoapAIDebuggerNode aNode, Color aColor)
 {
     links.Add(new KeyValuePair <GoapAIDebuggerNode, Color> (aNode, aColor));
 }