Пример #1
0
 private void ActionFailure()
 {
     AILogger.CreateMessage("Action failed: " + currentAction.ToString(), agent);
     Stop();
     if (OnFinishedPlan != null)
     {
         OnFinishedPlan();
     }
 }
Пример #2
0
 public void Unpause()
 {
     if (state == States.Paused)
     {
         state = States.Running;
         // TODO Unpause state machine
     }
     else
     {
         AILogger.CreateMessage("Error, cannot unpause from non-paused state. Current state = " + state.ToString(), agent);
     }
 }
Пример #3
0
 public void Pause()
 {
     if (state == States.Running)
     {
         state = States.Paused;
         stateMachine.Pause();
     }
     else
     {
         AILogger.CreateMessage("Cannot Pause when not running. Current state = " + state.ToString(), agent);
     }
 }
Пример #4
0
 public void Stop()
 {
     if (state == States.Stopped)
     {
         AILogger.CreateMessage("Already stopped", agent);
     }
     else
     {
         state = States.Stopped;
         stateMachine.Stop();
         actionPlan    = null;
         currentAction = null;
     }
 }
Пример #5
0
        public void CalculateNewGoal()
        {
            AILogger.CreateMessage("Calculating new goal.", agent);

            List <AIGoal> goals = new List <AIGoal>(agent.GetGoals());

            goals.Sort((x, y) => x.Priority.CompareTo(y.Priority));

            if (goals.Count == 0)
            {
                return;
            }

            for (int i = 0; i < goals.Count; i++)
            {
                currentGoal = goals[i];
                if (!GoalAchieveableByActions(currentGoal))
                {
                    continue;
                }

                if (aStar.FindActionPlan(agent, this))
                {
                    actions = aStar.GetActionPlan();
                }
                else
                {
                    AILogger.CreateMessage("failed to find action plan.", agent);
                }
            }

            if (actions.Count > 0 && OnActionPlanFound != null)
            {
                OnActionPlanFound();
            }
        }