コード例 #1
0
    // Get new tetrimino
    private void NewTetrimino()
    {
        int bagIndex, index;

        if (upNext == null)
        {
            if (bag.Count == 0)
            {
                for (int i = 0; i < Tetrominos.Length; i++)
                {
                    bag.Add(i);
                }
            }

            bagIndex = (int)Random.Range(0, bag.Count);
            index    = bag[bagIndex];
            bag.RemoveAt(bagIndex);
            upNext       = Instantiate(Tetrominos[index], new Vector3(-10, 14, 0), Quaternion.identity);
            upNext.speed = levelNum + 1;
        }

        upNext.transform.position = new Vector3(5, 17, 0);
        upNext.Enable();
        if (!CheckPos(upNext.transform))
        {
            Destroy(upNext.transform.gameObject);
            gameOver = true;
            Scoring.GameOver();
        }

        if (bag.Count == 0)
        {
            for (int i = 0; i < Tetrominos.Length; i++)
            {
                bag.Add(i);
            }
        }

        bagIndex = (int)Random.Range(0, bag.Count);
        index    = bag[bagIndex];
        bag.RemoveAt(bagIndex);

        upNext       = Instantiate(Tetrominos[index], new Vector3(-10, 14, 0), Quaternion.identity);
        upNext.speed = levelNum + 1;
    }