public void IsNotCat()
        {
            CatDetector catDetector = new CatDetector(100);
            bool        isCat;

            isCat = catDetector.IsCat(false, 0, new IntPtr(10), new WindowsKeyboard.KBDLLHOOKSTRUCT(1, 1));

            Assert.IsFalse(isCat);
        }
        public void IsNotCatWhenDifferentKeysArePressed()
        {
            CatDetector catDetector = new CatDetector(100);
            bool        isCat;

            catDetector.IsCat(false, 0, new IntPtr(10), new WindowsKeyboard.KBDLLHOOKSTRUCT(1, 1));
            catDetector.IsCat(false, 0, new IntPtr(11), new WindowsKeyboard.KBDLLHOOKSTRUCT(1, 1));
            catDetector.IsCat(false, 0, new IntPtr(12), new WindowsKeyboard.KBDLLHOOKSTRUCT(1, 1));
            isCat = catDetector.IsCat(false, 0, new IntPtr(13), new WindowsKeyboard.KBDLLHOOKSTRUCT(1, 1));

            Assert.IsFalse(isCat);
        }
        public void IsCat()
        {
            CatDetector catDetector = new CatDetector(100);
            bool        isCat       = false;

            for (int i = 0; i < 10; i++)
            {
                isCat = isCat || catDetector.IsCat(false, 0, new IntPtr(10), new WindowsKeyboard.KBDLLHOOKSTRUCT(1, 1));
            }

            Assert.IsTrue(isCat);
        }
Example #4
0
    void gameScreen()
    {
        List <int> coordinate    = currentRoom.getCoordinate();
        List <int> catCoordinate = Cat.currentRoom.getCoordinate();

        print("x: " + coordinate [0] + " y: " + coordinate [1] + " level: " + coordinate [2]);
        print("Cat: x: " + catCoordinate [0] + " y: " + catCoordinate [1] + " level: " + catCoordinate [2]);
        if (Timer.isTimeUp())
        {
            currentState = States.End;
            isGameOn     = false;
        }
        if (CatDetector.catDistance() == 0)
        {
            isGameOn     = false;
            isWin        = true;
            currentState = States.End;
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            if (currentRoom.moveForward() != null)
            {
                counter++;
                print("Move forward successful");
                currentRoom = currentRoom.moveForward();
                Cat.catMove();
            }
            else
            {
                print("invalid move");
            }
        }
        else if (Input.GetKeyDown(KeyCode.A))
        {
            if (currentRoom.moveLeft() != null)
            {
                counter++;
                print("Move left successful");
                currentRoom = currentRoom.moveLeft();
                Cat.catMove();
            }
            else
            {
                print("invalid move");
            }
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
            if (currentRoom.moveBehind() != null)
            {
                counter++;
                print("Move behind successful");
                currentRoom = currentRoom.moveBehind();
                Cat.catMove();
            }
            else
            {
                print("invalid move");
            }
        }
        else if (Input.GetKeyDown(KeyCode.D))
        {
            if (currentRoom.moveRight() != null)
            {
                counter++;
                print("Move right successful");
                currentRoom = currentRoom.moveRight();
                Cat.catMove();
            }
            else
            {
                print("invalid move");
            }
        }
        else if (Input.GetKeyDown(KeyCode.C))
        {
            if (currentRoom.moveUp() != null)
            {
                counter++;
                print("Move up successful");
                currentRoom = currentRoom.moveUp();
                Cat.catMove();
            }
            else
            {
                print("invalid move");
            }
        }
        else if (Input.GetKeyDown(KeyCode.V))
        {
            if (currentRoom.moveDown() != null)
            {
                counter++;
                print("Move down successful");
                currentRoom = currentRoom.moveDown();
                Cat.catMove();
            }
            else
            {
                print("invalid move");
            }
        }
    }