示例#1
0
 internal void ChangeCurrentStep(AStarStep currentStep)
 {
     if (OnStepChanged != null)
     {
         OnStepChanged(currentStep);
     }
 }
示例#2
0
        } // nav_GoalReached(sender, e)

        #endregion

        #region KeyboardInput_KeyRelease
        /// <summary>
        /// Handle Key Release
        /// Q = Select Mode
        /// W = Move Mode
        /// Delete = Delete Nodes
        /// C = Connect two selected nodes
        /// X = Break connection between nodes
        /// Strg + s Saves Node Network
        /// Strg + o Loads Node network
        /// </summary>
        /// <param name="keys">Keyboard keys</param>
        /// <param name="keyState">Keyboard State</param>
        /// <returns></returns>
        void KeyboardInput_KeyRelease(Keys key, KeyboardState keyState)
        {
            if (key == Keys.Q)
            {
                this.editMode = EditMode.Select;
            }
            else if (key == Keys.W)
            {
                this.editMode = EditMode.Move;
            }
            else if (key == Keys.Delete)
            {
                // Delete everything that is selected
                foreach (var actor in Actor.Selection)
                {
                    actor.Delete();
                }

                // make sure everything is cleared
                Actor.Selection.Clear();
            } // if (Delete)
            else if (key == Keys.C && Actor.Selection.Count >= 2)
            {
                for (int i = 1; i < Actor.Selection.Count; i++)
                {
                    Node nodeA = Actor.Selection[i - 1] as Node;
                    Node nodeB = Actor.Selection[i] as Node;

                    if (nodeA != null && nodeB != null)
                    {
                        nodeA.BidiConnect(nodeB);
                    }
                }
            } // if(C)
            else if (key == Keys.X && Actor.Selection.Count >= 2)
            {
                for (int i = 1; i < Actor.Selection.Count; i++)
                {
                    Node nodeA = Actor.Selection[i - 1] as Node;
                    Node nodeB = Actor.Selection[i] as Node;

                    if (nodeA != null && nodeB != null)
                    {
                        nodeA.BidiDisconnect(nodeB);
                    }
                }
            } // if(X)
            else if (key == Keys.P && Actor.Selection.Count >= 2) // AStarStep Begin
            {
                Node start = Actor.Selection[0] as Node;
                Node goal  = Actor.LastSelected as Node;

                if (start != null && goal != null)
                {
                    AStarStep.Begin(start, goal);
                    AStarStep.Continue();
                } // if (start && goal)
            }
            else if (key == Keys.Space)         // AstarStep Continue
            {
                if (AStarStep.InProgress)
                {
                    AStarStep.Continue();
                }
            } // if (Space)

            else if (key == Keys.Enter)  // AStar Actor navigation
            {
                Node start = Node.GetClosestNode(bot.Position); // get closest node to our AI Actor
                Node goal  = Actor.LastSelected as Node;
                NavigateToNode(start, goal);
            } // if (enter)
            else if (key == Keys.S && ScreenManager.Input.IsControlDown)
            {
                //NodeIO.SaveNodes("nodes.txt");
                NodeIO.ShowSaveDialog();
            } // if (ctrl + s)
            else if (key == Keys.O && ScreenManager.Input.IsControlDown)
            {
                // NodeIO.LoadNodes("nodes.txt");
                NodeIO.ShowLoadDialog();
            } // if (ctrl + o)
        }