예제 #1
0
 // 初期化
 private void Intialize()
 {
     // field を初期化
     for (int i = 0; i < FieldData.FIELD_HEIGHT; i++)
     {
         if (i == FieldData.FIELD_HEIGHT - 1)
         {
             for (int j = 0; j < FieldData.FIELD_WIDTH; j++)
             {
                 field[i, j] = (int)Rotation.eFieldValue.WallBlock;
             }
         }
         else
         {
             for (int j = 0; j < FieldData.FIELD_WIDTH; j++)
             {
                 if (j == 0 || j == FieldData.FIELD_WIDTH - 1)
                 {
                     field[i, j] = (int)Rotation.eFieldValue.WallBlock;
                 }
                 else
                 {
                     field[i, j] = (int)Rotation.eFieldValue.Empty;
                 }
             }
         }
     }
     score      = 0;                        // スコア
     isActive   = true;                     // 操作可能かどうか
     minoAngle  = MinoData.eMinoAngle.ang0; // ミノの向き
     _minoAngle = minoAngle;
     holdMino   = MinoData.eMinoType.MAX;   // ホールド中のミノ
     isHold     = false;                    // ホールド可能かどうか
     makeMino   = true;                     // 次のミノを生成
 }
예제 #2
0
        // minoArrayに生成するミノのデータを代入する
        public void SetMinoData(out int[] minoArray, MinoData.eMinoType type)
        {
            if (type == MinoData.eMinoType.MAX)
            {
                minoArray = null;
                return;
            }

            int size;

            // Iミノは 4 * 4 の配列なので size が変わる
            if (type == MinoData.eMinoType.I)
            {
                size = MinoData.I_MINO_SIZE;
            }
            // Oミノは 2 * 2 の配列なので size が変わる
            else if (type == MinoData.eMinoType.O)
            {
                size = MinoData.O_MINO_SIZE;
            }
            else
            {
                size = MinoData.MINO_SIZE;
            }

            minoArray = new int[size];

            MinoData.MinoArrays[(int)type].CopyTo(minoArray, 0);
        }
예제 #3
0
    public static Vector2 GetKickData(MinoData.eMinoType type, MinoData.eRotateInfo info, int testNum)
    {
        int i = (int)info;

        if (type == MinoData.eMinoType.I)
        {
            return(testWallKickForIMino[i, testNum]);
        }
        else
        {
            return(testWallKickForAnyMinos[i, testNum]);
        }
    }
예제 #4
0
    // Minoを描画
    public void DrawMino(int xPos, int yPos, ref int[] minoArray, MinoData.eMinoType type)
    {
        int size;
        int sideLength;

        yPos = Tetris.Field.FieldData.FIELD_HEIGHT - 1 - yPos;

        // Iミノのみ特殊
        if (type == MinoData.eMinoType.I)
        {
            size       = MinoData.I_MINO_SIZE;
            sideLength = MinoData.I_MINO_SIDE_LENGTH;
        }
        else if (type == MinoData.eMinoType.O)
        {
            size       = MinoData.O_MINO_SIZE;
            sideLength = MinoData.O_MINO_SIDE_LENGTH;
        }
        else
        {
            size       = MinoData.MINO_SIZE;
            sideLength = MinoData.MINO_SIDE_LENGTH;
        }

        int[,] array = new int[sideLength, sideLength];

        for (int i = 0; i < size; i++)
        {
            // 配列を2次元配列にコピー
            int indexX = i % sideLength;
            int indexY = i / sideLength;

            array[indexY, indexX] = minoArray[i];
        }

        // 1次元配列のミノのデータを Field の座標に変換
        int count  = 0;
        int length = minoArray.Length;

        for (int i = 0; i < length; i++)
        {
            int x = i % sideLength;
            int y = i / sideLength;

            if (minoArray[i] == (int)Rotation.eFieldValue.MinoBlock)
            {
                Instantiate(minoBlock, new Vector3(xPos + x, yPos - y, 74), Quaternion.identity);
            }
        }
    }
예제 #5
0
    public void HoldMino(int[,] field, ref MinoData.eMinoType currentMino, ref MinoData.eMinoType holdMino)
    {
        for (int i = 1; i < field.GetLength(0) - 1; i++)
        {
            for (int j = 1; j < field.GetLength(1) - 1; j++)
            {
                // fieldにある
                if (field[i, j] == (int)Rotation.eFieldValue.MinoBlock)
                {
                    field[i, j] = (int)Rotation.eFieldValue.Empty;
                }
            }
        }

        // ホールドの画像を入れ替える
        m_Image.sprite = m_Sprite[(int)holdMino];
    }
예제 #6
0
 //------------------------------------
 // 入力処理
 //------------------------------------
 // ホールド
 private void Hold()
 {
     if (Input.GetKeyDown(KeyCode.Q) && isHold == false)
     {
         if (holdMino == MinoData.eMinoType.MAX) // ホールドしてるミノがないとき
         {
             holdMino = currentMino;
             Script_hold.HoldMino(field, ref currentMino, ref holdMino);
             makeMino = true;
         }
         else
         {
             MinoData.eMinoType createType = holdMino;
             holdMino    = currentMino;
             currentMino = createType;
             Script_hold.HoldMino(field, ref currentMino, ref holdMino);
             Script_render.DeleteMino();
             minoCreate.SetMinoData(out minoArray, currentMino);
             Script_render.DrawMino(minoPosX, minoPosY, ref minoArray, currentMino);
         }
         isHold = true;
     }
 }
예제 #7
0
    public void NextChanger(ref MinoData.eMinoType currentMino, ref MinoData.eMinoType nextMino)
    {
        currentMino = (MinoData.eMinoType) this.nextMino[0];
        nextMino    = (MinoData.eMinoType) this.nextMino[1];
        // nextMinoの中身を繰り上げ配列の最後を空にする
        var empty = 7;

        for (int i = 0; i < this.nextMino.Length - 1; i++)
        {
            this.nextMino[i] = this.nextMino[i + 1];
        }
        this.nextMino[13] = empty;

        // 7個消費したらネクストミノを補充
        if (this.nextMino[7] == empty)
        {
            MinoDraw();
            for (int i = 0; i < minoBox.Length; i++)
            {
                this.nextMino[7 + i] = minoBox[i];
            }
        }
        // スプライトを変更する処理
        switch (this.nextMino[0])
        {
        case 0:     // T

            Image_next1.sprite = m_Sprite[0];

            break;

        case 1:     // S

            Image_next1.sprite = m_Sprite[1];

            break;

        case 2:     // Z

            Image_next1.sprite = m_Sprite[2];

            break;

        case 3:     // L

            Image_next1.sprite = m_Sprite[3];

            break;

        case 4:     // J

            Image_next1.sprite = m_Sprite[4];

            break;

        case 5:     // O

            Image_next1.sprite = m_Sprite[5];

            break;

        case 6:     // I

            Image_next1.sprite = m_Sprite[6];

            break;
        }
        switch (this.nextMino[1])
        {
        case 0:     // T

            Image_next2.sprite = m_Sprite[0];

            break;

        case 1:     // S

            Image_next2.sprite = m_Sprite[1];

            break;

        case 2:     // Z

            Image_next2.sprite = m_Sprite[2];

            break;

        case 3:     // L

            Image_next2.sprite = m_Sprite[3];

            break;

        case 4:     // J

            Image_next2.sprite = m_Sprite[4];

            break;

        case 5:     // O

            Image_next2.sprite = m_Sprite[5];

            break;

        case 6:     // I

            Image_next2.sprite = m_Sprite[6];

            break;
        }
        switch (this.nextMino[2])
        {
        case 0:     // T

            Image_next3.sprite = m_Sprite[0];

            break;

        case 1:     // S

            Image_next3.sprite = m_Sprite[1];

            break;

        case 2:     // Z

            Image_next3.sprite = m_Sprite[2];

            break;

        case 3:     // L

            Image_next3.sprite = m_Sprite[3];

            break;

        case 4:     // J

            Image_next3.sprite = m_Sprite[4];

            break;

        case 5:     // O

            Image_next3.sprite = m_Sprite[5];

            break;

        case 6:     // I

            Image_next3.sprite = m_Sprite[6];

            break;
        }
        switch (this.nextMino[3])
        {
        case 0:     // T

            Image_next4.sprite = m_Sprite[0];

            break;

        case 1:     // S

            Image_next4.sprite = m_Sprite[1];

            break;

        case 2:     // Z

            Image_next4.sprite = m_Sprite[2];

            break;

        case 3:     // L

            Image_next4.sprite = m_Sprite[3];

            break;

        case 4:     // J

            Image_next4.sprite = m_Sprite[4];

            break;

        case 5:     // O

            Image_next4.sprite = m_Sprite[5];

            break;

        case 6:     // I

            Image_next4.sprite = m_Sprite[6];

            break;
        }
        switch (this.nextMino[4])
        {
        case 0:     // T

            Image_next5.sprite = m_Sprite[0];

            break;

        case 1:     // S

            Image_next5.sprite = m_Sprite[1];

            break;

        case 2:     // Z

            Image_next5.sprite = m_Sprite[2];

            break;

        case 3:     // L

            Image_next5.sprite = m_Sprite[3];

            break;

        case 4:     // J

            Image_next5.sprite = m_Sprite[4];

            break;

        case 5:     // O

            Image_next5.sprite = m_Sprite[5];

            break;

        case 6:     // I

            Image_next5.sprite = m_Sprite[6];

            break;
        }
    }