コード例 #1
0
    private void input(InRec inp)
    {
        if (!active)
        {
            return;
        }

        // check if a move leads out of bounds or through a wall
        if (!isAllowedMove(inp))
        {
            audioData.PlayOneShot(fail);
            reset();
            return;
        }

        // move
        currentPosition += inp.toVector();

        start.SetActive(false);

        if (foundSolution())
        {
            audioData.PlayOneShot(win);
            reset();
            if ((completed++) == 3)
            {
                OnGameComplete.Invoke();
            }
        }
    }
コード例 #2
0
    private bool isAllowedMove(InRec input)
    {
        Vector2 nextPosition = currentPosition + input.toVector();

        if (nextPosition.x > 5f || nextPosition.x < 0f || nextPosition.y > 5f || nextPosition.y < 0f)
        {
            return(false);
        }

        // check for walls
        Wall blockingWall = Array.Find(walls[mazeNr], element => element.blocks(currentPosition, nextPosition, input));

        return(blockingWall == null);
    }