예제 #1
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);
        }
예제 #2
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);
     }
 }
예제 #3
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);
     }
 }
예제 #4
0
 /// <summary>
 /// Устанавливает указанную цель как текущую.
 /// </summary>
 public void SetGoal(string aGoalName)
 {
     currentGoal = FindGoal(aGoalName);
     if (currentGoal == null)
     {
         AntLog.Report("AIControl", "Can't find \"{0}\" goal.", aGoalName);
         SetDefaultGoal();
     }
 }
예제 #5
0
 /// <summary>
 /// Устанавливает цель по умолчанию как текущее.
 /// </summary>
 public void SetDefaultGoal()
 {
     if (defaultGoal != null)
     {
         currentGoal = defaultGoal;
     }
     else
     {
         AntLog.Report("AIControl", "Default Goal not defined!");
     }
 }
예제 #6
0
 /// <summary>
 /// Устанавливает цель по умолчанию как текущее.
 /// </summary>
 public void SetDefaultGoal()
 {
     if (defaultGoal != null)
     {
         currentGoal = defaultGoal;
     }
     else
     {
         AntLog.Report("AntAIAgent", "Default <b>Goal</b> is not defined!");
     }
 }
예제 #7
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!");
            }
        }
예제 #8
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();
         }
     }
 }
예제 #9
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!");
         }
     }
 }
예제 #10
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!");
                }
            }
        }