예제 #1
0
파일: Game.cs 프로젝트: ariemiku/tetris
    // ブロックが消える時の色の点滅処理
    void ChangeDeleteColor()
    {
        BLOCKCOLOR[,] formerDeleteColor = new BLOCKCOLOR[4, 10];
        for (int i = 0; i < index; i++)
        {
            for (int x = 0; x < 10; x++)
            {
                formerDeleteColor[i, x] = color[deleteY[i], x];
            }
        }

        deleteTimer += Time.deltaTime;

        for (int i = 0; i < index; i++)
        {
            for (int x = 0; x < 10; x++)
            {
                Renderer renderer = m_aObject [deleteY[i], x].GetComponent <Renderer> ();
                if ((deleteTimer > 0.2f && deleteTimer <= 0.4f) ||
                    (deleteTimer > 0.6f))
                {
                    // 元々の色をセットする
                    switch (formerDeleteColor[i, x])
                    {
                    case BLOCKCOLOR.RED:
                        deleteColor = red;
                        break;

                    case BLOCKCOLOR.BLUE:
                        deleteColor = blue;
                        break;

                    case BLOCKCOLOR.LIGHT_BLUE:
                        deleteColor = lightBlue;
                        break;

                    case BLOCKCOLOR.YELLO:
                        deleteColor = yello;
                        break;

                    case BLOCKCOLOR.YELLO_GREEN:
                        deleteColor = yelloGreen;
                        break;

                    case BLOCKCOLOR.PURPLE:
                        deleteColor = purple;
                        break;

                    case BLOCKCOLOR.ORANGE:
                        deleteColor = orange;
                        break;

                    default:
                        break;
                    }
                    // 色を変える
                    renderer.material = new Material(deleteColor);
                }
                else
                {
                    renderer.material = new Material(backColor);
                }
            }
        }
    }
예제 #2
0
파일: Game.cs 프로젝트: ariemiku/tetris
    public bool leftRotate  = false;    // 左回転を行っている状態かどうか

    // ブロックの種類をランダムで選択し、セットする関数
    void SetBlockType()
    {
        myBlock.square        = new int[5, 5];
        myBlock.blockPosition = new Vector2[4];

        nowBlock = next;
        next     = Random.Range(0, 7);
        Debug.Log("NEXT:" + next);

        switch (nowBlock)
        {
        case I_TETRIMINO:
            myBlock.square = new int [, ] {
                { 0, 0, 1, 0, 0 },
                { 0, 0, 1, 0, 0 },
                { 0, 0, 1, 0, 0 },
                { 0, 0, 1, 0, 0 },
                { 0, 0, 0, 0, 0 }
            };

            myBlock.blockPosition[0] = new Vector2(2, 0);
            myBlock.blockPosition[1] = new Vector2(2, 1);
            myBlock.blockPosition[2] = new Vector2(2, 2);
            myBlock.blockPosition[3] = new Vector2(2, 3);

            nowColorMaterial = lightBlue;
            nowColor         = BLOCKCOLOR.LIGHT_BLUE;

            break;

        case O_TETRIMINO:
            myBlock.square = new int [, ] {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 1, 1, 0, 0 },
                { 0, 1, 1, 0, 0 },
                { 0, 0, 0, 0, 0 }
            };

            myBlock.blockPosition[0] = new Vector2(1, 2);
            myBlock.blockPosition[1] = new Vector2(1, 3);
            myBlock.blockPosition[2] = new Vector2(2, 2);
            myBlock.blockPosition[3] = new Vector2(2, 3);

            nowColorMaterial = yello;
            nowColor         = BLOCKCOLOR.YELLO;

            break;

        case S_TETRIMINO:
            myBlock.square = new int [, ] {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 1, 1, 0 },
                { 0, 1, 1, 0, 0 },
                { 0, 0, 0, 0, 0 }
            };

            myBlock.blockPosition[0] = new Vector2(1, 3);
            myBlock.blockPosition[1] = new Vector2(2, 2);
            myBlock.blockPosition[2] = new Vector2(2, 3);
            myBlock.blockPosition[3] = new Vector2(3, 2);

            nowColorMaterial = yelloGreen;
            nowColor         = BLOCKCOLOR.YELLO_GREEN;

            break;

        case Z_TETRIMINO:
            myBlock.square = new int [, ] {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 1, 1, 0, 0 },
                { 0, 0, 1, 1, 0 },
                { 0, 0, 0, 0, 0 }
            };

            myBlock.blockPosition[0] = new Vector2(1, 2);
            myBlock.blockPosition[1] = new Vector2(2, 2);
            myBlock.blockPosition[2] = new Vector2(2, 3);
            myBlock.blockPosition[3] = new Vector2(3, 3);

            nowColorMaterial = red;
            nowColor         = BLOCKCOLOR.RED;

            break;

        case J_TETRIMINO:
            myBlock.square = new int [, ] {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 1, 0, 0 },
                { 0, 0, 1, 0, 0 },
                { 0, 1, 1, 0, 0 },
                { 0, 0, 0, 0, 0 }
            };

            myBlock.blockPosition[0] = new Vector2(1, 3);
            myBlock.blockPosition[1] = new Vector2(2, 1);
            myBlock.blockPosition[2] = new Vector2(2, 2);
            myBlock.blockPosition[3] = new Vector2(2, 3);

            nowColorMaterial = blue;
            nowColor         = BLOCKCOLOR.BLUE;

            break;

        case L_TETRIMINO:
            myBlock.square = new int [, ] {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 1, 0, 0 },
                { 0, 0, 1, 0, 0 },
                { 0, 0, 1, 1, 0 },
                { 0, 0, 0, 0, 0 }
            };

            myBlock.blockPosition[0] = new Vector2(2, 1);
            myBlock.blockPosition[1] = new Vector2(2, 2);
            myBlock.blockPosition[2] = new Vector2(2, 3);
            myBlock.blockPosition[3] = new Vector2(3, 3);

            nowColorMaterial = orange;
            nowColor         = BLOCKCOLOR.ORANGE;

            break;

        case T_TETRIMINO:
            myBlock.square = new int [, ] {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 1, 1, 1, 0 },
                { 0, 0, 1, 0, 0 },
                { 0, 0, 0, 0, 0 }
            };

            myBlock.blockPosition[0] = new Vector2(1, 2);
            myBlock.blockPosition[1] = new Vector2(2, 2);
            myBlock.blockPosition[2] = new Vector2(2, 3);
            myBlock.blockPosition[3] = new Vector2(3, 2);

            nowColorMaterial = purple;
            nowColor         = BLOCKCOLOR.PURPLE;

            break;

        default:
            break;
        }
        myBlock.nowPosition = new Vector2(3, -4);
        blockCount++;
        speedUp = false;

        SetNext();
    }