예제 #1
0
    /**
     * Updates the current goal
     */
    public void UpdateCurrentGoal()
    {
        if (CurrentGoal != null)
        {
            if (CurrentGoal.UpdateGoal())
            {
                if (CurrentGoal.ReplanRequired())
                {
                    ReplanCurrentGoal();
                }

                if (CurrentGoal.IsPlanFinished())                   // goal is finished, so clear it and make new one

                {
                    CurrentGoal.Deactivate();
                    CurrentGoal = null;
                }
            }
            else
            {
                CurrentGoal.Deactivate();
                CurrentGoal = null;
            }
        }
    }
예제 #2
0
    public void Loop()
    {
        if (_currGoal == null)
        {
            _currGoal = FindNewGoal();
            if (_currGoal == null)
            {
                return;
            }

            _currGoal.BuildPlan(actions, _ws);
        }
        else if (_currGoal.IsInterruptible())
        {
            GOAPGoal newGoal = FindNewGoal(); // 遇见更优的目标
            if (newGoal != null && /*newGoal.GoalType != _currGoal.GoalType &&*/ newGoal.Weight > _currGoal.Weight)
            {
                GOAPGoalFactory.Collect(_currGoal);
                _currGoal = newGoal;
                _currGoal.BuildPlan(actions, _ws);
            }
        }

        if (!_currGoal.UpdateGoal(_ws))
        {
            GOAPGoalFactory.Collect(_currGoal);
            _currGoal = null;
        }
    }
예제 #3
0
    /**
     * Updates the current goal
     */

    public void UpdateCurrentGoal()
    {
        if (CurrentGoal != null)
        {
            if (CurrentGoal.UpdateGoal())
            {
                if (CurrentGoal.ReplanRequired())
                {
                    if (Owner.debugGOAP)
                    {
                        Debug.Log(Time.timeSinceLevelLoad + " " + CurrentGoal.ToString() + " - REPLAN required !!");
                    }
                    ReplanCurrentGoal();
                }

                if (CurrentGoal.IsPlanFinished())
                {
// goal is finished, so clear it and make new one

                    if (Owner.debugGOAP)
                    {
                        Debug.Log(Time.timeSinceLevelLoad + " " + CurrentGoal.ToString() + " - FINISHED");
                    }
                    CurrentGoal.Deactivate();
                    CurrentGoal = null;
                }
            }
            else             // something bad happened, clear it
            {
                CurrentGoal.Deactivate();
                CurrentGoal = null;
            }
        }
    }