예제 #1
0
        } // GetActorAt(position)

        #endregion

        #region NavigateToNode
        /// <summary>
        /// Navigates the bot to the Node
        /// </summary>
        /// <param name="start">start node</param>
        /// <param name="goal">goal node</param>
        /// <returns></returns>
        void NavigateToNode(Node start, Node goal)
        {
            if (start != null && goal != null)
            {
                List <Node> path = AStar.FindPath(start, goal);

                if (path != null)
                {
                    nav.BeginNavigation(path);
                    bot.Speed = 1f;
                } // if
            }     // if
        }         // NavigateToNode(start, goal)
예제 #2
0
        } // enemyNav_NodeReached

        #endregion

        #region NavigateToActor
        /// <summary>
        /// Navigates an Enemy Actor to an Actor
        /// </summary>
        /// <param name="actor">The Actor to Navigate to</param>
        void NavigateToActor(Actor actor)
        {
            Node start = Node.GetClosestNode(Position);
            Node goal  = Node.GetClosestNode(actor.Position);

            if (start != null && goal != null)  // Make sure both nodes are valid
            {
                List <Node> path = AStar.FindPath(start, goal);
                if (path != null)
                {
                    if (path.Count > 1)
                    {
                        path[0].InPath = false;
                        path.RemoveAt(0);
                    }

                    enemyNav.BeginNavigation(path);
                }
            } // if
        }     // NavigateToActor(actor)