public UtilityAIClient(UtilityAI ai, IContextProvider contextProvider)
        {
            this.ai = ai;
            this.contextProvider = contextProvider as AIContextProvider;

            this.intervalMin   = this.intervalMax = 1f;
            this.startDelayMin = this.startDelayMax = 0f;
            state = UtilityAIClientState.Stopped;
        }
        public UtilityAIClient(UtilityAI ai, IContextProvider contextProvider, float intervalMin, float intervalMax, float startDelayMin, float startDelayMax)
        {
            this.ai = ai;
            this.contextProvider = contextProvider as AIContextProvider;

            this.intervalMin   = intervalMin;
            this.intervalMax   = intervalMax;
            this.startDelayMin = startDelayMin;
            this.startDelayMax = startDelayMax;
            state = UtilityAIClientState.Stopped;
        }
        public string SelectorInfo(UtilityAI s)
        {
            var selector = s.rootSelector;

            string selectorInfo = "";

            selectorInfo += string.Format("** taskNetwork Name: :  {0} **\n\n", s.GetType().Name);
            selectorInfo += string.Format("  Selector Type:  {0}\n", selector.GetType().Name);

            //  Get Selector Name and Type.
            for (int i = 0; i < selector.qualifiers.Count(); i++)
            {
                var    qualifier     = selector.qualifiers[i] as CompositeQualifier;
                string qualifierInfo = "";
                string scorerInfo    = "";
                string actionInfo    = "";

                qualifierInfo += string.Format("{0}", qualifier.GetType().Name);

                foreach (IScorer scorer in qualifier.scorers)
                {
                    scorerInfo += string.Format("    - {0}\n", scorer.GetType().Name);
                }
                actionInfo += string.Format("{0}", qualifier.action.GetType().Name);



                selectorInfo += string.Format("  Qualifier:    {0}\n", qualifierInfo);
                selectorInfo += string.Format("  Action:       {0}\n", actionInfo);
                selectorInfo += string.Format("  Number of Scorers:  {0}\n", qualifier.scorers.Count());
                selectorInfo += scorerInfo;
                selectorInfo += "\n";
            }

            return(selectorInfo);
        }
示例#4
0
        public static byte[] GetData(UtilityAI utilityAI)
        {
            ProjectAsset projectAsset = new ProjectAsset();

            MemoryStream    memoryStream    = new MemoryStream();
            BinaryFormatter binaryFormatter = new BinaryFormatter();

            //  Serialize utilityAI to memoryStream
            binaryFormatter.Serialize(memoryStream, utilityAI);
            memoryStream.Close();


            //  Store memory stream as byte array
            projectAsset.data = memoryStream.ToArray();

            memoryStream    = new MemoryStream();
            binaryFormatter = new BinaryFormatter();
            //  Serialize projectAsset to memoryStream (useful if project asset contains other data)
            binaryFormatter.Serialize(memoryStream, projectAsset);
            memoryStream.Close();


            return(memoryStream.ToArray());
        }