示例#1
0
        /**
         * Check if the given tile is a vertex.
         * If it is, add it to the given graph reference.
         */
        private static void ComputeVertex(String name, int x, int y, ref Graph.Graph graph)
        {
            // Prepare the regex matcher.
            RegEx rgx = new RegEx();

            rgx.Compile("^Wall._[TBLR]{2}$|^(Tower)");

            // Get and check the result of the regex.
            RegExMatch result = rgx.Search(name);

            if (result != null)
            {
                // Check wether a tower was selected.
                bool bIsTower = result.GetString(1).Equals("Tower");

                // Create a new Vertex instance.
                Graph.Vertex vtx = new Graph.Vertex(x, y, graph.GetWallAt(new Vector2(x, y)));

                // Add the instance to the graph.
                graph.AddVertex(vtx);
            }
        }