public string GetState(string aActionName) { var action = FindAction(aActionName); AntLog.Assert(action == null, string.Format("Action \"{0}\" not registered!", aActionName), true); return(action.state); }
/// <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); }
/// <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); } }
/// <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); } }
/// <summary> /// Устанавливает указанную цель как текущую. /// </summary> public void SetGoal(string aGoalName) { currentGoal = FindGoal(aGoalName); if (currentGoal == null) { AntLog.Report("AIControl", "Can't find \"{0}\" goal.", aGoalName); SetDefaultGoal(); } }
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); }
/// <summary> /// Устанавливает цель по умолчанию как текущее. /// </summary> public void SetDefaultGoal() { if (defaultGoal != null) { currentGoal = defaultGoal; } else { AntLog.Report("AIControl", "Default Goal not defined!"); } }
/// <summary> /// Устанавливает цель по умолчанию как текущее. /// </summary> public void SetDefaultGoal() { if (defaultGoal != null) { currentGoal = defaultGoal; } else { AntLog.Report("AntAIAgent", "Default <b>Goal</b> is not defined!"); } }
/// <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(); }
/// <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!"); } }
/// <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(); } } }
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!"); } } }
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!"); } } }