示例#1
0
        public void TestGlobExpressions(string pattern, string positiveMatch, string negativeMatch = null)
        {
            var parser   = new Parser(pattern);
            var segments = parser.ParseTree().Segments;

            var mockFileDatas = new Dictionary <string, MockFileData>();

            if (positiveMatch != null)
            {
                mockFileDatas[Path.Combine(FileSystemRoot, positiveMatch)] = MockFileData.NullObject;
            }

            if (negativeMatch != null)
            {
                mockFileDatas[Path.Combine(FileSystemRoot, negativeMatch)] = MockFileData.NullObject;
            }

            var cache = new MockTraverseOptions(true, true, false, new MockFileSystem(mockFileDatas));

            var root    = new DirectoryInfo(FileSystemRoot);
            var results = PathTraverser.Traverse(root, segments, cache).ToArray();

            if (positiveMatch != null)
            {
                Assert.Single(results);
            }

            if (positiveMatch == null && negativeMatch != null)
            {
                Assert.Empty(results);
            }
        }
示例#2
0
 public void OnHitTarget(PathTraverser traverser, PathNode current, PathNode next)
 {
     if (current.CompareTag("Bin"))
     {
         // Also remove this item from the avo spawner, because otherwise another won't spawn until this one has poofed
         AvoSpawnerTag tag = GetComponent <AvoSpawnerTag>();
         if (tag)
         {
             tag.Spawner.OnSpawnedItemDestroyed(tag);
         }
         PerformDestroy(despawnTime);
     }
 }
示例#3
0
    public void CheckForWin()
    {
        var endPoints = OctagonsList.Where(x => x.GetComponent <OctagonControllerScript>().octagonType == Enumerations.OctagonType.Endpoint).ToList();

        var nonEmptyOctagons = OctagonsList.Where(x => x.GetComponent <OctagonControllerScript>().octagonType != Enumerations.OctagonType.Empty).ToList();
        var pathTraverser    = new PathTraverser(endPoints[0], endPoints[1], nonEmptyOctagons);

        var levelWon = pathTraverser.CanTraverse();

        if (levelWon)
        {
            LevelWon(pathTraverser.GetCorrectPath());
        }
    }
示例#4
0
    public void Stamp(PathTraverser traverser, PathNode node, PathNode nextNode)
    {
        // If this object doesn't have an avocado, then it's a fruit that should've been binned.
        // Still stamp it, but don't add any labels
        Avocado avo = traverser.GetComponent <Avocado>();

        if (avo)
        {
            // Assign the appropriate stamp to this avocado when the stamper has finished
            avocadosToStamp.Add(avo);
        }

        if (!isStamping)
        {
            StampInternal();
        }
    }
示例#5
0
    public bool CheckForWin()
    {
        var endPoints = OctagonsList.Where(x => x.GetComponent <OctagonControllerScript>().octagonType == Enumerations.OctagonType.Endpoint).ToList();

        var nonEmptyOctagons = OctagonsList.Where(x => x.GetComponent <OctagonControllerScript>().octagonType != Enumerations.OctagonType.Empty).ToList();
        var pathTraverser    = new PathTraverser(endPoints[0], endPoints[1], nonEmptyOctagons);

        var levelWon = pathTraverser.CanTraverse();

        if (levelWon)
        {
            LevelWon(pathTraverser.GetCorrectPath());
            //winDialog.GetComponent<Animator>().SetBool("Show", true);

            if (currentPuzzleIterator == PuzzleList.Count - 1)
            {
                var x = winDialog.transform.Find("CanvasGroup").Find("NextButton").gameObject;
                x.transform.Find("Text").GetComponent <Text>().text = "Category Complete";
            }

            return(true);
        }
        else if (false) // TODO: GET THIS SHIT TO WORK WILL
        {
            // Delete old pathing lines
            foreach (var octagon in OctagonsList)
            {
                foreach (var lr in octagon.GetComponents <LineRenderer>())
                {
                    Destroy(lr);
                }
            }

            // Trace lines from the endpoint the path traverser already used
            TraceCurrentPaths(pathTraverser.GetConnectedPathways());

            // Trace lines from the other endpoint
            pathTraverser = new PathTraverser(endPoints[1], endPoints[0], nonEmptyOctagons);
            pathTraverser.CanTraverse();
            TraceCurrentPaths(pathTraverser.GetConnectedPathways());
        }

        return(false);
    }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Gets the paths in this collection.
        /// </summary>
        /// <param name="node">
        ///  The start node.
        /// </param>
        /// <returns>
        ///  An enumerator that allows foreach to be used to process the paths in this collection.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public IEnumerable <GraphPath> GetPaths(NodeInfo node)
        {
            Contract.Requires(node, "node");

            try
            {
                PathTraverser.Initialize(this);
                UnicityPolicy.Reset();

                foreach (var p in PathTraverser.Traverse(node))
                {
                    yield return(p);
                }
            }
            finally
            {
                UnicityPolicy.Reset();
            }
        }
示例#7
0
        public void TestGlobExpressionsWithEmitDirectories(string pattern, string files, string matches)
        {
            var parser   = new Parser(pattern);
            var segments = parser.ParseTree().Segments;

            var mockFileDatas = new Dictionary <string, MockFileData>();

            foreach (var file in files.Split(' '))
            {
                mockFileDatas[Path.Combine(FileSystemRoot, file)] = MockFileData.NullObject;
            }

            var cache = new MockTraverseOptions(false, true, true, new MockFileSystem(mockFileDatas));

            var root        = new DirectoryInfo(FileSystemRoot);
            var results     = PathTraverser.Traverse(root, segments, cache).Select(file => file.FullName.Substring(FileSystemRoot.Length)).OrderBy(x => x).ToArray();
            var fileMatches = matches.Split(' ').Select(x => x.Replace('\\', Path.DirectorySeparatorChar)).OrderBy(x => x).ToArray();

            Assert.Equal(fileMatches, results);
        }