示例#1
0
        public string GetState(string aActionName)
        {
            var action = FindAction(aActionName);

            AntLog.Assert(action == null, string.Format("Action \"{0}\" not registered!", aActionName), true);
            return(action.state);
        }
示例#2
0
        /// <summary>
        /// Выбирает новое состояние на основе текущего состояния мира.
        /// </summary>
        public string SelectNewState(AntAICondition aWorldState)
        {
            string newState = "";

            if (currentGoal != null)
            {
                planner.MakePlan(ref currentPlan, aWorldState, currentGoal);
                if (currentPlan.isSuccess)
                {
                    string actionName = planner.GetAction(currentPlan[0]).name;
                    newState = planner.GetState(actionName);

                    /* Отладочный вывод плана в консоль.
                     * AntAICondition condition = aConditions.Clone();
                     * string p = string.Format("Conditions: {0}\n", _planner.NameIt(condition.Description()));
                     * for (int i = 0; i < _currentPlan.Count; i++)
                     * {
                     *      AntAIAction action = _planner.GetAction(_currentPlan[i]);
                     *      condition.Act(action.post);
                     *      p += string.Format("<color=orange>{0}</color> => {1}\n", action.name, _planner.NameIt(condition.Description()));
                     * }
                     * AntLog.Trace(p);
                     * //*/
                }
            }
            else
            {
                AntLog.Report("AntAIAgent", "Goal not defined!");
            }

            return(newState);
        }
示例#3
0
 /// <summary>
 /// Определяет какое из состояний будет состоянием по умолчанию.
 /// </summary>
 public void DefaultStateIs(string aStateName)
 {
     defaultState = FindState(aStateName);
     if (defaultState == null)
     {
         AntLog.Report("AIControl", "Can't set \"{0}\" as Default State because it is not existing!", aStateName);
     }
 }
示例#4
0
 /// <summary>
 /// Определяет какое из состояний будет состоянием по умолчанию.
 /// </summary>
 public void DefaultStateIs(string aStateName)
 {
     defaultState = FindState(aStateName);
     if (defaultState == null)
     {
         AntLog.Report("AntAIAgent", "Can't set \"{0}\" as <b>Default State</b> because it is not existing!", aStateName);
     }
 }
示例#5
0
 /// <summary>
 /// Устанавливает указанную цель как текущую.
 /// </summary>
 public void SetGoal(string aGoalName)
 {
     currentGoal = FindGoal(aGoalName);
     if (currentGoal == null)
     {
         AntLog.Report("AIControl", "Can't find \"{0}\" goal.", aGoalName);
         SetDefaultGoal();
     }
 }
示例#6
0
        public virtual void Add <T>(int aPriority = 0)
        {
            Type            type        = typeof(T);
            ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);
            ISystem         system      = (ISystem)constructor.Invoke(null);

            AntLog.Assert(system == null, "Class \"" + AntLog.Bold(type.ToString()) + "\" not implemented ISystem interface!");
            Add(system, aPriority);
        }
示例#7
0
 /// <summary>
 /// Устанавливает цель по умолчанию как текущее.
 /// </summary>
 public void SetDefaultGoal()
 {
     if (defaultGoal != null)
     {
         currentGoal = defaultGoal;
     }
     else
     {
         AntLog.Report("AIControl", "Default Goal not defined!");
     }
 }
示例#8
0
 /// <summary>
 /// Устанавливает цель по умолчанию как текущее.
 /// </summary>
 public void SetDefaultGoal()
 {
     if (defaultGoal != null)
     {
         currentGoal = defaultGoal;
     }
     else
     {
         AntLog.Report("AntAIAgent", "Default <b>Goal</b> is not defined!");
     }
 }
示例#9
0
        /// <summary>
        /// Устанавливает состояение по умолчанию как текущее.
        /// </summary>
        public void SetDefaultState()
        {
            if (currentState != null)
            {
                currentState.Stop();
            }

            AntLog.Assert(defaultState == null, "Default <b>State</b> is not defined!", true);
            currentState = defaultState;
            currentState.Reset();
            currentState.Start();
        }
示例#10
0
        /// <summary>
        /// Устанавливает состояение по умолчанию как текущее.
        /// </summary>
        public void SetDefaultState()
        {
            if (currentState != null)
            {
                currentState.Stop();
            }

            if (defaultState != null)
            {
                currentState = defaultState;
                currentState.Reset();
                currentState.Start();
            }
            else
            {
                AntLog.Report("AIControl", "Default State not defined!");
            }
        }
示例#11
0
 /// <summary>
 /// Устанавливает указанное состояние как текущее.
 /// </summary>
 public void SetState(string aStateName, bool aForce = false)
 {
     if (aForce || !string.Equals(currentState.name, aStateName))
     {
         currentState.Stop();
         currentState = FindState(aStateName);
         if (currentState != null)
         {
             currentState.Reset();
             currentState.Start();
         }
         else
         {
             AntLog.Report("AntAIAgent", "Can't find \"{0}\" state.", aStateName);
             SetDefaultState();
         }
     }
 }
示例#12
0
 protected void Stop()
 {
     if (_isStarted)
     {
         if (AntEngine.Current != null)
         {
             AntEngine.Current.Remove((ISystem)this);
             _isStarted = false;
             if (EventStop != null)
             {
                 EventStop(this);
             }
         }
         else
         {
             AntLog.Report("AntTaskManager", "AntEngine not initialized!");
         }
     }
 }
示例#13
0
        protected void Start()
        {
            if (!_isStarted && _taskList.Count > 0)
            {
                if (AntEngine.Current != null)
                {
                    AntEngine.Current.Add((ISystem)this);
                    _currentTask = Shift();
                    _isStarted   = true;
                    _isPaused    = false;

                    if (EventStart != null)
                    {
                        EventStart(this);
                    }
                }
                else
                {
                    AntLog.Report("AntTaskManager", "AntEngine not initialized!");
                }
            }
        }