Пример #1
0
 public void AddPoints(int points, string text)
 {
     total_score += points;
     total_points.AddPoints(0);
     cur_points.AddPoints(points);
     points_text.SetText(text);
     waiting_s_duration = 0;
     waiting_c_duration = 0;
     waiting_score_c    = true;
     waiting_score_t    = false;
     waiting_comment    = true;
 }
Пример #2
0
    // Checks for a full row in the playspace and removes full rows
    public static void CheckRows()
    {
        int rowsCleared = 0;

        for (int i = 0; i < h; i++)
        {
            bool empty = false;
            for (int j = 0; j < w; j++)
            {
                if (playspace[j, i] == null)
                {
                    empty = true;
                    break;
                }
            }

            if (!empty)
            {
                //Debug.Log("Found full row!");
                for (int y = i; y < h; y++)
                {
                    bool nonEmpty = false;

                    for (int x = 0; x < w; x++)
                    {
                        if (playspace[x, y] != null)
                        {
                            if (y == i)
                            {
                                Destroy(playspace[x, y].gameObject);
                            }
                        }

                        /**
                         * else
                         *  nonEmpty = true;
                         **/

                        if (y + 1 < h)
                        {
                            playspace[x, y] = playspace[x, y + 1];
                        }
                        else
                        {
                            playspace[x, y] = null;
                        }

                        if (playspace[x, y] != null)
                        {
                            playspace[x, y].position += new Vector3(0, -1, 0);
                        }
                    }

                    if (nonEmpty)
                    {
                        break;
                    }
                }

                rowsCleared += 1;
                i--;
            }
        }

        switch (rowsCleared)
        {
        case 1:
            Scoring.AddPoints(40 * (levelNum + 1));
            break;

        case 2:
            Scoring.AddPoints(100 * (levelNum + 1));
            break;

        case 3:
            Scoring.AddPoints(300 * (levelNum + 1));
            break;

        case 4:
            Scoring.AddPoints(1200 * (levelNum + 1));
            break;

        default:
            break;
        }

        linesClearedThisLevel += rowsCleared;
        if (linesClearedThisLevel >= levelNum * 10 + 10)
        {
            NextLevel();
        }
    }