Пример #1
0
        public void GetColor_BlueTextBox_ReturnsBlue()
        {
            var textBox = UI.GetChild(By.AutomationId("CUI_Blue_TextBox"), From.Element(_testWindow));

            var color = ColorDetector.GetColor(textBox, At.BottomRight(50, 50));

            Assert.AreEqual(Color.FromArgb(255, 0, 0, 255), color);
        }
Пример #2
0
        public void GetColor_RedTextBox_ReturnsRed()
        {
            var textBox = UI.GetChild(By.AutomationId("CUI_Red_TextBox"), From.Element(_testWindow));

            var color = ColorDetector.GetColor(textBox);

            Assert.AreEqual(Color.FromArgb(255, 255, 0, 0), color);
        }
Пример #3
0
        public LoadRemoverComponent(LiveSplitState state)
        {
            Settings = new LoadRemoverComponentSettings();

            bitmapFeatureDetector = new BitmapFeatureDetector();
            colorDetector         = new ColorDetector(Settings.ColorTolerance);

            timer = new TimerModel {
                CurrentState = state
            };
            timer.CurrentState.OnStart += Timer_OnStart;
        }
Пример #4
0
    IEnumerator TakePhoto()   // Start this Coroutine on some button click
    {
        // NOTE - you almost certainly have to do this here:

        yield return(new WaitForEndOfFrame());

        // it's a rare case where the Unity doco is pretty clear,
        // http://docs.unity3d.com/ScriptReference/WaitForEndOfFrame.html
        // be sure to scroll down to the SECOND long example on that doco page

        Texture2D photo = new Texture2D(activeCameraTexture.width, activeCameraTexture.height);

        photo.SetPixels(activeCameraTexture.GetPixels());
        photo.Apply();

        squareImageSize = Math.Min(activeCameraTexture.width, activeCameraTexture.height);
        Debug.Log("Image size: " + squareImageSize);

        //Encode to a PNG
        byte[] bytes = photo.EncodeToPNG();
        File.WriteAllBytes(Application.dataPath + "/photo.png", bytes);
        Debug.Log("Saved photo: " + Application.dataPath);

        gridToPhotoScale = (squareImageSize / (float)gridImageSize);
        int smallPhotoSize = (int)(gridCellSize * gridToPhotoScale);

        cellSpaceFromBorder = (int)(realCellSpaceFromBorder * gridToPhotoScale);
        Debug.Log("SPS: " + smallPhotoSize);
        int firstXPosition = (int)(activeCameraTexture.width / 2f - squareImageSize / 2f + cellSpaceFromBorder);
        int firstYPosition = (int)(activeCameraTexture.height / 2f - squareImageSize / 2f + cellSpaceFromBorder);

        Debug.Log("GCS: " + gridCellSize * gridToPhotoScale);
        Debug.Log("x: " + firstXPosition);
        Debug.Log("y: " + firstYPosition);
        Debug.Log("CSFB: " + cellSpaceFromBorder);

        Color[][] colors = new Color[9][];

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                int xPosition = firstXPosition + j * ((int)(gridCellSize * gridToPhotoScale) + (cellSpaceFromBorder * 2));
                int yPosition = firstYPosition + i * ((int)(gridCellSize * gridToPhotoScale) + (cellSpaceFromBorder * 2));
                colors[3 * i + j] = activeCameraTexture.GetPixels(xPosition, yPosition, smallPhotoSize, smallPhotoSize);
            }
        }
        ColorDetector.AddFaceColor(colors, smallPhotoSize);
    }
Пример #5
0
    void OnMouseUp()
    {
        if (GameManager.GetInstance().GetIsInputAllowed())
        {
            if (!busy && moving)
            {
                busy = true;

                RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, 1.0f, BrainbowGameManager.GetInstance().foodLayerMask);

                if (hit.collider != null && hit.collider.gameObject.GetComponent <ColorDetector> ().color == GetComponent <Food> ().color)
                {
                    BrainbowGameManager.GetInstance().SetActiveFood(null);

                    ColorDetector detector = hit.collider.gameObject.GetComponent <ColorDetector> ();
                    SoundManager.GetInstance().PlaySFXClip(BrainbowGameManager.GetInstance().correctSound);
                    Vector3 oldPos = gameObject.transform.position;
                    detector.AddFood(gameObject);

                    if (Random.value < 0.3f)
                    {
                        int randomClipIndex = Random.Range(0, BrainbowGameManager.GetInstance().correctMatchClips.Length);
                        SoundManager.GetInstance().PlayVoiceOverClip(BrainbowGameManager.GetInstance().correctMatchClips [randomClipIndex]);
                    }

                    gameObject.GetComponent <Collider2D> ().enabled = false;
                    BrainbowGameManager.GetInstance().Replace(gameObject);
                }
                else
                {
                    MoveBack();
                    int randomClipIndex = Random.Range(0, BrainbowGameManager.GetInstance().wrongMatchClips.Length);
                    SoundManager.GetInstance().PlayVoiceOverClip(BrainbowGameManager.GetInstance().wrongMatchClips [randomClipIndex]);
                }
            }
            moving = false;
            busy   = false;
            Debug.Log("About to hide sutitle");
            StartCoroutine(HideSubtitle());
        }
    }