public void ScreenAnalyzer_ValidData_RyanAirMatched()
        {
            var            matcher  = new TestMatcher();
            IDataProvider  dataBase = new DataProvider();
            ScreenAnalyzer sa       = new ScreenAnalyzer(dataBase, matcher);

            var projectDir = TestContext.CurrentContext.TestDirectory;

            int end = projectDir.LastIndexOf("bin");

            projectDir = projectDir.Substring(0, end);

            var picturePath = projectDir + @"\TestResources\2.jpg";

            Bitmap pic = new Bitmap(picturePath);

            var expected = new Dictionary <string, bool>()
            {
                { "bmw", false },
                { "ryanair", true }
            };

            matcher._counter        = 1;
            matcher._indexOfPattern = 1;

            sa.AnalyzeScreenAsync(pic);

            var result = dataBase.GetUserActivity();

            var dict3 = result.Where(entry => expected[entry.Key] != entry.Value)
                        .ToDictionary(entry => entry.Key, entry => entry.Value);

            //if it is 0 there is match between both dictionaries
            Assert.That(dict3.Count, Is.Zero);
        }
    void HealthyMovement()
    {
        distance = Vector2.Distance(transform.position, player.transform.position);

        if (distance < minDistance)
        {
            transform.position = Vector2.MoveTowards(transform.position, player.transform.position, enemySpeed * Time.deltaTime);
            stoppedChasing     = false;
        }
        else
        {
            // transform.position = this.transform.position;

            if (stoppedChasing == false)
            {
                stopPos        = this.transform.position;
                stoppedChasing = true;
            }

            transform.position = this.transform.position;
            //Invoke("perlinMovement", 1);
            perlinMovement();
        }

        Vector3 clampedPos = ScreenAnalyzer.ClampPointToScreen(transform.position);

        transform.position = clampedPos;
    }
Beispiel #3
0
    void SpawnEnemy()
    {
        Vector3 newEnemyPosition = ScreenAnalyzer.RandomScreenPoint();

        newEnemyPosition.z = 0f;
        GameObject newEnemy = Instantiate(enemyPrefab, newEnemyPosition, Quaternion.identity);
    }
Beispiel #4
0
 private void SolvePuzzle(ScreenAnalyzer analyzer)
 {
     try
     {
         var screen   = analyzer.Analyze();
         var solver   = new PuzzleSolver(screen.GetPuzzle());
         var solution = solver.Solve();
         new SolutionRenderer(solution, screen).Render();
     }
     catch (AbortException)
     {
         sm_log.Info("Solution aborted");
     }
     catch (AnalysisException e)
     {
         HandleError("A problem occurred while analyzing the screen. Please ensure a puzzle is open." +
                     Environment.NewLine + Environment.NewLine + "Error message: " + e.Message, e);
     }
     catch (SolverException e)
     {
         HandleError("Unable to solve this puzzle: " + e.Message, e);
     }
     catch (RenderException e)
     {
         HandleError("A problem occurred while rendering the solution: " + e.Message, e);
     }
     catch (Exception e)
     {
         HandleError("Internal error: " + e.ToString(), e);
     }
 }
Beispiel #5
0
    void SpawnSprite()
    {
        Vector3    newPosition = ScreenAnalyzer.RandomScreenPoint();
        GameObject newSprite   = Instantiate(spritePrefab, newPosition, Quaternion.identity);

        newSprite.GetComponent <SpriteRenderer>().sprite = imageList[Random.Range(0, imageList.Count - 1)];
        newSprite.transform.localScale = Vector3.one * Random.Range(0.5f, 1.5f);
        sprites.Add(newSprite);
    }
        public void ScreenAnalyzer_WrongImagePath_BitmapThrowsException()
        {
            IDataProvider  dataBase = new DataProvider();
            ScreenAnalyzer sa       = new ScreenAnalyzer(dataBase, null);

            Bitmap pic = new Bitmap(@"arGUI\CoreTest\TestResources\2.jpg");

            sa.AnalyzeScreenAsync(pic);
        }
Beispiel #7
0
    private void FixedUpdate()
    {
        // Clamp new position to screen.
        Vector3 nextPosition = transform.position + velocity;

        nextPosition = ScreenAnalyzer.ClampPointToScreen(nextPosition);

        // Move
        m_Rigidbody.MovePosition(nextPosition);

        // Update scraping audio values.
        screenAnalyzer.testPoint       = Camera.main.WorldToScreenPoint(transform.position);
        m_ScrapingScript.overlapAmount = GetColorBrightness(screenAnalyzer.lastPixelColor);
    }
        public void ScreenAnalyzer_InvalidPictureMatcher_ExceptionThrown()
        {
            IDataProvider  dataBase = new DataProvider();
            ScreenAnalyzer sa       = new ScreenAnalyzer(dataBase, null);

            var projectDir = TestContext.CurrentContext.TestDirectory;

            int end = projectDir.LastIndexOf("bin");

            projectDir = projectDir.Substring(0, end);

            var picturePath = projectDir + @"\TestResources\2.jpg";

            Bitmap pic = new Bitmap(picturePath);

            Task task = sa.AnalyzeScreenAsync(null)
                        .ContinueWith(innerTask =>
            {
                // ... assertions here ...
            });
        }
        public void ScreenAnalyzer_NoPatternMatch_ScreenIsUploaded()
        {
            var matcher = new TestMatcher(true);

            var            dataBase = new DataProvider();
            ScreenAnalyzer sa       = new ScreenAnalyzer(dataBase, matcher);

            var projectDir = TestContext.CurrentContext.TestDirectory;

            int end = projectDir.LastIndexOf("bin");

            projectDir = projectDir.Substring(0, end);

            var picturePath = projectDir + @"\TestResources\2.jpg";

            Bitmap pic = new Bitmap(picturePath);

            var expected = new Dictionary <string, bool>()
            {
                { "bmw", false },
                { "ryanair", false }
            };

            sa.AnalyzeScreenAsync(pic);

            var result = dataBase.GetUserActivity();

            var dict3 = result.Where(entry => expected[entry.Key] != entry.Value)
                        .ToDictionary(entry => entry.Key, entry => entry.Value);

            //if it is 0 there is match between both dictionaries
            Assert.That(dict3.Count, Is.Zero);

            var comparisonResult = ByteArrayCompare(BitmapByteConverter.ConvertBitmapToByteArray(pic), dataBase.getScreen());

            Assert.That(comparisonResult, Is.True);
        }
Beispiel #10
0
 private void Start()
 {
     anchorPointObject.transform.parent = null;
     screenAnalyzer = FindObjectOfType <ScreenAnalyzer>();
 }
Beispiel #11
0
 void AddCongregationPoint()
 {
     congregationPoints.Add(ScreenAnalyzer.RandomScreenPoint());
 }