Exemplo n.º 1
0
 public void DeleteGoalPoint(int id)
 {
     if (Goals.ContainsKey(id))
     {
         Goals.Remove(id);
     }
 }
Exemplo n.º 2
0
    void OnTriggerExit(Collider other)
    {
        C_FlockGoal goal = other.GetComponent <C_FlockGoal> ();

        if (goal != null)
        {
            Goals.Remove(goal);
        }
    }
Exemplo n.º 3
0
        private void ExcecuteDeleteGoal()
        {
            foreach (var goal in Goals)
            {
                goal.RelatesGoals.Remove(SelectedGoal.Id);
            }
            Goals.Remove(SelectedGoal);

            _repo.SaveGoals(Goals);
            Goals = _repo.GetAllGoals();
        }
Exemplo n.º 4
0
        internal static void DeleteGoal(dynamic metadata, dynamic content)
        {
            var id        = content.Id.ToString();
            var Goal      = Goals.SingleOrDefault(t => t.Id == id);
            var groupKey  = metadata.GroupKey.ToString();
            var memberKey = metadata.MemberKey.ToString();

            if (Goal != null)
            {
                Goals.Remove(Goal);
                SendFeedbackMessage(type: MsgType.Success, actionTime: GetCreateDate(metadata), action: MapAction.GoalFeedback.GoalDeleted.Name, content: new { Id = id });
            }
            else
            {
                SendFeedbackMessage(type: MsgType.Error, actionTime: GetCreateDate(metadata), action: MapAction.GoalFeedback.CannotFindGoal.Name, content: "Cannot find Goal item!");
            }
        }
Exemplo n.º 5
0
    /// <summary>
    /// Checks the driver position to see if a knot or goal point has been reached.
    /// </summary>
    public void CheckPosition()
    {
        // If the driver has reached the current knot
        PathMutex.WaitOne();
        if ((CurrentKnot != null) && (Math.Abs(X - CurrentKnot.X) < DistanceTolerance) && (Math.Abs(Y - CurrentKnot.Y) < DistanceTolerance))
        {
            // Remove it from the path
            CurrentBestPath.RemoveKnot(1);
        }
        PathMutex.ReleaseMutex();


        // If the driver has reached the current goal
        GoalMutex.WaitOne();
        if ((Math.Abs(X - CurrentGoal.X) < DistanceTolerance) && (Math.Abs(Y - CurrentGoal.Y) < DistanceTolerance))
        {
            // Move it to the end of the goals list
            Goals.Add(CurrentGoal.DeepClone());
            Goals.Remove(CurrentGoal);
        }
        GoalMutex.ReleaseMutex();
    }
Exemplo n.º 6
0
 public void DeleteGoal(GoalLineVM property)
 {
     Goals.Remove(property);
     UserSettings.Current.RemoveSelectedProperty(property.property);
 }
 private void OnRemoveGoal(object obj)
 {
     Goals.Remove(SelectedGoal);
 }
Exemplo n.º 8
0
        //---------------------------------------------------------------------------------------------

        public void RemoveGoal(Goal goal)
        {
            Goals.Remove(goal);
        }
Exemplo n.º 9
0
        protected virtual void Start()
        {
            States = new Dictionary <string, bool>();
            foreach (var item in preState)
            {
                States[item.Key] = item.Value;
            }

            IdleState idleState = new IdleState(FSM)
            {
                onStart = () => { },
                onExit  = () => { }
            };

            idleState.onUpdate = () =>
            {
                if (NextPlanTime > FSM.time)
                {
                    return;
                }
                if (T_GraphAsset == null)
                {
                    return;
                }

                NextPlanTime = FSM.time + interval;

                // 搜寻计划
                foreach (GOAPGoal goal in Goals)
                {
                    Planner.Plan(T_Graph.AvailableActions.ToArray(), States, goal, maxDepth, ref storedActionQueue);
                    if (StoredActionQueue.Count == 0)
                    {
                        CurrentGoal = goal;
                        break;
                    }
                }

                if (storedActionQueue.Count > 0)
                {
                    actionQueue.Clear();
                    foreach (var action in storedActionQueue)
                    {
                        actionQueue.Enqueue(action);
                    }

                    //通知计划找到
                    if (Provider != null)
                    {
                        Provider.PlanFound(CurrentGoal, actionQueue);
                    }
                    //转换状态
                    FSM.ChangeTo("PerformActionState");
                }
                else
                {
                    //通知计划没找到
                    if (Provider != null)
                    {
                        Provider.PlanFailed(Goals);
                    }
                    CurrentGoal = null;
                }
            };

            GOAPFSMState performActionState = new GOAPFSMState(FSM)
            {
                onStart = () => { },
                onExit  = () => { }
            };

            performActionState.onUpdate = () =>
            {
                if (HasPlan)
                {
                    // 如果当前有计划(目标尚未完成)
                    GOAPAction action = actionQueue.Peek();
                    if (CurrentAction != action)
                    {
                        CurrentAction = action;
                        action.OnPrePerform();
                    }
                    // 成功 or 失败
                    GOAPActionStatus status = action.OnPerform();

                    switch (status)
                    {
                    case GOAPActionStatus.Success:
                        foreach (var effect in action.Effects)
                        {
                            SetState(effect.Key, effect.Value);
                        }
                        action.OnPostPerform(true);
                        if (Provider != null)
                        {
                            Provider.ActionFinished(action.Effects);
                        }
                        actionQueue.Dequeue();
                        CurrentAction = null;
                        break;

                    case GOAPActionStatus.Failure:
                        if (replanOnFailed)
                        {
                            EnforceReplan();
                        }
                        else
                        {
                            AbortPlan();
                        }
                        return;

                    default:
                        break;
                    }
                }
                else
                {
                    // 如果没有计划(目标已完成)
                    // 如果目标为一次性,移除掉
                    if (CurrentGoal != null && CurrentGoal.Once)
                    {
                        Goals.Remove(CurrentGoal);
                    }

                    // 通知计划完成
                    if (Provider != null)
                    {
                        Provider.PlanFinished();
                    }

                    // 当前目标设置为空
                    CurrentGoal = null;
                    FSM.ChangeTo("IdleState");
                }
            };

            FSM.PushState("IdleState", idleState);
            FSM.PushState("PerformActionState", performActionState);
            FSM.ChangeTo("IdleState");
        }
Exemplo n.º 10
0
 void OnGoalDestroyed(C_FlockGoal goal)
 {
     Goals.Remove(goal);
 }
Exemplo n.º 11
0
 //method used to remove a goal, used in RemoveGoalForm(JE)
 public void RemoveGoal(Goal index)
 {
     Goals.Remove(index);
 }