Пример #1
0
    public static Vector2[] GetForm(TetBlockShape shape)
    {
        Vector2[] position = new Vector2[4];
        position[0].Set(0.0f, 0.0f);
        switch (shape)
        {
        case TetBlockShape.I:
            position[1].Set(-2, 0);
            position[2].Set(-1, 0);
            position[3].Set(1, 0);

            break;

        case TetBlockShape.T:
            position[1].Set(1, 0);
            position[2].Set(-1, 0);
            position[3].Set(0, -1);

            break;

        case TetBlockShape.S:
            position[1].Set(-1, 0);
            position[2].Set(0, -1);
            position[3].Set(1, -1);

            break;

        case TetBlockShape.Z:
            position[1].Set(-1, -1);
            position[2].Set(0, -1);
            position[3].Set(1, 0);

            break;

        case TetBlockShape.L:
            position[1].Set(-1, 0);
            position[2].Set(1, 0);
            position[3].Set(1, -1);

            break;

        case TetBlockShape.J:
            position[1].Set(1, 0);
            position[2].Set(-1, 0);
            position[3].Set(-1, -1);
            break;

        case TetBlockShape.O:
            position[1].Set(1, 0);
            position[2].Set(0, 1);
            position[3].Set(1, 1);
            break;

        default:
            Debug.Log("Unknown Block Type");
            break;
        } // 모양 할당
        return(position);
    }
Пример #2
0
    public TetBlock(TetBlockShape shape)
    {
        this.shape    = shape;
        this.position = TetBlockForm.GetForm(shape);
        slotPosition  = new Vector2(4, 0);
        switch (shape)
        {
        case TetBlockShape.I:
            color = Color.cyan;
            break;

        case TetBlockShape.T:
            color = Color.magenta;
            break;

        case TetBlockShape.S:
            color = Color.green;
            break;

        case TetBlockShape.Z:
            color = Color.red;
            break;

        case TetBlockShape.L:
            color = new Color(1.0f, 0.368f, 0.0f);
            break;

        case TetBlockShape.J:
            color = Color.blue;
            break;

        case TetBlockShape.O:
            isRotationable = false;
            color          = Color.yellow;
            break;

        default:
            Debug.Log("Unknown Block Type");
            break;
        }
        UpdateIndex();
    }
Пример #3
0
    public static Vector2[] GetRotationKick(TetBlockShape shape, TetBlockRotation prevRotation, TetBlockRotation cw_ccw)
    {
        //rotation 0 clockwise 1 counterclockwise

        Vector2[] kickVector = new Vector2[4];
        if (shape == TetBlockShape.I)
        {
            switch (prevRotation)
            {
            case TetBlockRotation.UP:     //0
                if (cw_ccw == TetBlockRotation.CLOCKWISE)
                {
                    kickVector[0].Set(-2, 0);
                    kickVector[1].Set(1, 0);
                    kickVector[2].Set(-2, 1);
                    kickVector[3].Set(1, -2);
                }
                else     // counter clock wise
                {
                    kickVector[0].Set(-1, 0);
                    kickVector[1].Set(2, 0);
                    kickVector[2].Set(-1, -2);
                    kickVector[3].Set(2, 1);
                }
                break;

            case TetBlockRotation.RIGHT:     //1
                if (cw_ccw == TetBlockRotation.CLOCKWISE)
                {
                    kickVector[0].Set(-1, 0);
                    kickVector[1].Set(2, 0);
                    kickVector[2].Set(-1, -2);
                    kickVector[3].Set(2, 1);
                }
                else     // counter clock wise
                {
                    kickVector[0].Set(2, 0);
                    kickVector[1].Set(-1, 0);
                    kickVector[2].Set(2, -1);
                    kickVector[3].Set(-1, 2);
                }
                break;

            case TetBlockRotation.DOWN:     //2
                if (cw_ccw == TetBlockRotation.CLOCKWISE)
                {
                    kickVector[0].Set(2, 0);
                    kickVector[1].Set(-1, 0);
                    kickVector[2].Set(2, -1);
                    kickVector[3].Set(-1, 2);
                }
                else     // counter clock wise
                {
                    kickVector[0].Set(1, 0);
                    kickVector[1].Set(-2, 0);
                    kickVector[2].Set(1, 2);
                    kickVector[3].Set(-2, -1);
                }
                break;

            case TetBlockRotation.LEFT:     //3
                if (cw_ccw == TetBlockRotation.CLOCKWISE)
                {
                    kickVector[0].Set(1, 0);
                    kickVector[1].Set(-2, 0);
                    kickVector[2].Set(1, 2);
                    kickVector[3].Set(-2, 1);
                }
                else     // counter clock wise
                {
                    kickVector[0].Set(-2, 0);
                    kickVector[1].Set(1, 0);
                    kickVector[2].Set(-2, 1);
                    kickVector[3].Set(1, -2);
                }
                break;

            default:
                Debug.Log("unknown rotation form");
                break;
            }
        }
        else // I를 제외한 블록
        {
            switch (prevRotation)
            {
            case TetBlockRotation.UP:     //0
                if (cw_ccw == TetBlockRotation.CLOCKWISE)
                {
                    kickVector[0].Set(-1, 0);
                    kickVector[1].Set(-1, -1);
                    kickVector[2].Set(0, 2);
                    kickVector[3].Set(-1, 2);
                }
                else     // counterclockwise
                {
                    kickVector[0].Set(1, 0);
                    kickVector[1].Set(1, -1);
                    kickVector[2].Set(0, 2);
                    kickVector[3].Set(1, 2);
                }
                break;

            case TetBlockRotation.RIGHT:     //1
                if (cw_ccw == TetBlockRotation.CLOCKWISE)
                {
                    kickVector[0].Set(1, 0);
                    kickVector[1].Set(1, 1);
                    kickVector[2].Set(0, -2);
                    kickVector[3].Set(1, -2);
                }
                else
                {
                    kickVector[0].Set(1, 0);
                    kickVector[1].Set(1, 1);
                    kickVector[2].Set(0, -2);
                    kickVector[3].Set(1, -2);
                }
                break;

            case TetBlockRotation.DOWN:     //2
                if (cw_ccw == TetBlockRotation.CLOCKWISE)
                {
                    kickVector[0].Set(1, 0);
                    kickVector[1].Set(1, -1);
                    kickVector[2].Set(0, 2);
                    kickVector[3].Set(1, 2);
                }
                else
                {
                    kickVector[0].Set(-1, 0);
                    kickVector[1].Set(-1, -1);
                    kickVector[2].Set(0, 2);
                    kickVector[3].Set(-1, 2);
                }
                break;

            case TetBlockRotation.LEFT:     //3
                if (cw_ccw == TetBlockRotation.CLOCKWISE)
                {
                    kickVector[0].Set(-1, 0);
                    kickVector[1].Set(-1, 1);
                    kickVector[2].Set(0, -2);
                    kickVector[3].Set(-1, -2);
                }
                else
                {
                    kickVector[0].Set(-1, 0);
                    kickVector[1].Set(-1, 1);
                    kickVector[2].Set(0, 2);
                    kickVector[3].Set(-1, -2);
                }
                break;

            default:
                Debug.Log("unknown rotation form");
                break;
            }
        }

        return(kickVector);
    }