Esempio n. 1
0
    bool isValidGridPos()
    {
        foreach (Transform child in currentFigureTransform)
        {
            Vector2 v = PlayfieldManager.roundVec2(child.position);
            // Not inside Border?
            if (!PlayfieldManager.insideBorder(v))
            {
                return(false);
            }
            // Block isn't on an empty spot
            if (PlayfieldManager.grid[(int)v.x, (int)v.y] != null &&
                PlayfieldManager.grid[(int)v.x, (int)v.y].parent != currentFigureTransform)
            {
                Debug.Log("Check if it was just spawned");
                // Check if it was just spawned
                if ((int)v.y >= 17)
                {
                    Debug.Log("GAME OVER");
                    Destroy(currentFigureTransform.gameObject);

                    int b;
                    if (scorenumber == 0)
                    {
                        b = -1;
                    }
                    else
                    {
                        b = CheckScoreBoard.isScoreToBeInBoard(scorenumber);
                    }
                    if (b != -1)
                    {
                        SceneManager.LoadScene(loadPlayerName);
                    }
                    else
                    {
                        Application.Quit();
                        EditorApplication.isPlaying = false;
                    }
                }
                return(false);
            }
        }
        return(true);
    }
Esempio n. 2
0
    void ReadScoreBoard()
    {
        string path = "Assets/txt/ScoreTable.txt";

        string buff1, buff2;

        StreamReader reader = new StreamReader(path);

        if ((!File.Exists(path)))
        {
            Debug.Log("File must be created");
            CheckScoreBoard.createNewScoreBoard();
        }

        for (int i = 0; !reader.EndOfStream; i++)
        {
            buff1             = reader.ReadLine();
            buff2             = reader.ReadLine();
            buff1             = (i + 1).ToString() + ". " + buff1 + "......" + buff2;
            scoreText[i].text = buff1;
        }
        reader.Close();
    }