Exemplo n.º 1
0
    // Update is called once per frame
    void fall_sequence()
    {
        switch (CameraMove3d.getPositionNumber())
        {
        case 0:
            // Move Front
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                checkMoveFront();
            }

            // Move Back
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                checkMoveBack();
            }

            // Move Left
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                checkMoveLeft();
            }

            // Move Right
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                checkMoveRight();
            }


            // Rotate
            if (Input.GetKeyDown(KeyCode.A))
            {
                checkRotateXaxis(true);
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                checkRotateYaxis();
            }
            else if (Input.GetKeyDown(KeyCode.D))
            {
                checkRotateZaxis(true);
            }
            break;

        case 1:
            // Move Front
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                checkMoveRight();
            }

            // Move Back
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                checkMoveLeft();
            }

            // Move Left
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                checkMoveFront();
            }

            // Move Right
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                checkMoveBack();
            }


            // Rotate
            if (Input.GetKeyDown(KeyCode.D))
            {
                checkRotateXaxis(true);
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                checkRotateYaxis();
            }
            else if (Input.GetKeyDown(KeyCode.A))
            {
                checkRotateZaxis(true);
            }
            break;

        case 2:
            // Move Front
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                checkMoveBack();
            }

            // Move Back
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                checkMoveFront();
            }

            // Move Left
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                checkMoveRight();
            }

            // Move Right
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                checkMoveLeft();
            }


            // Rotate
            if (Input.GetKeyDown(KeyCode.A))
            {
                checkRotateXaxis(false);
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                checkRotateYaxis();
            }
            else if (Input.GetKeyDown(KeyCode.D))
            {
                checkRotateZaxis(false);
            }
            break;

        case 3:
            // Move Front
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                checkMoveLeft();
            }

            // Move Back
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                checkMoveRight();
            }

            // Move Left
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                checkMoveBack();
            }

            // Move Right
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                checkMoveFront();
            }


            // Rotate
            if (Input.GetKeyDown(KeyCode.D))
            {
                checkRotateXaxis(false);
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                checkRotateYaxis();
            }
            else if (Input.GetKeyDown(KeyCode.A))
            {
                checkRotateZaxis(false);
            }
            break;
        }



        //時間経過で落ちる
        if (Time.time - lastFall >= 1.5)
        {
            // Modify position
            transform.position += new Vector3(0, -1, 0);

            // See if valid
            if (isValidGridPos())
            {
                // It's valid. Update grid.
                updateGrid();
            }
            else
            {
                // It's not valid. revert.
                transform.position += new Vector3(0, 1, 0);
                audiosource.PlayOneShot(fallSE);

                // Clear filled horizontal lines
                Grid3d.deleteFullRows();

                Spawner3d.second_ban = false;

                // Spawn next Group
                FindObjectOfType <Spawner3d>().spawnNext();

                //影を消す
                FallPoint.resetFallPoint();

                // Disable script
                enabled = false;
            }

            lastFall = Time.time;
        }

        //一気に落ちる
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            int score = 0;

            while (true)
            {
                transform.position += new Vector3(0, -1, 0);

                if (!isValidGridPos())
                {
                    // It's not valid. revert.
                    transform.position += new Vector3(0, 1, 0);
                    audiosource.PlayOneShot(fallSE);
                    break;
                }
                score++;
            }
            updateGrid();

            //スコア加算
            ScoreText.addScore(score);

            // Clear filled horizontal lines
            Grid3d.deleteFullRows();

            Spawner3d.second_ban = false;

            // Spawn next Group
            FindObjectOfType <Spawner3d>().spawnNext();

            //影を消す
            FallPoint.resetFallPoint();

            // Disable script
            enabled = false;
        }
    }