예제 #1
0
    /// <summary>
    /// ステージスライド処理
    /// </summary>
    /// <param name="num"></param>
    /// <param name="dir"></param>
    public void SrideStage(int num, Direction dir)
    {
        if (isMove)
        {
            return;
        }

        GameObject temp;
        Vector3    tempPos = new Vector3();
        Vector3    turnPos = new Vector3();

        float mapSize  = 40;
        int   mapCount = 0;

        mMapController.miniMapSride(dir);
        switch (dir)
        {
        // 上-------------------------------------------------------------------
        case Direction.UP:

            // 一番上を保持
            turnPos   = Maps[stageLength - 1][num].transform.position;
            turnPos.z = 90;

            // 折り返しMap以外をスライド
            for (int i = stageLength - 1; i >= 0; i--)
            {
                tempPos   = Maps[i][num].transform.position;
                tempPos.z = 90;
                StartCoroutine(SrideAnimation(Maps[i][num], turnPos, new Vector2(tempPos.x, tempPos.y + mapSize), mapCount));

                mapCount++;
            }

            // スライド終了時の配列内入れ替え
            temp = Maps[0][num];

            for (int i = 0; i < stageLength - 1; i++)
            {
                Maps[i][num] = Maps[i + 1][num];
                Maps[i][num].GetComponent <MapInfo>().MapNumY = i;
            }
            Maps[stageLength - 1][num] = temp;

            Maps[stageLength - 1][num].GetComponent <MapInfo>().MapNumY = 2;
            break;

        // 上-------------------------------------------------------------------*

        // 下-------------------------------------------------------------------
        case Direction.DOWN:

            // 折り返し座標を保持
            turnPos   = Maps[0][num].transform.position;
            turnPos.z = 90;

            // 折り返しMap以外をスライド
            for (int i = 0; i <= stageLength - 1; i++)
            {
                tempPos   = Maps[i][num].transform.position;
                tempPos.z = 90;

                StartCoroutine(SrideAnimation(Maps[i][num], turnPos, new Vector2(tempPos.x, tempPos.y - mapSize), mapCount));

                mapCount++;
            }

            // スライド終了時の配列内入れ替え
            temp = Maps[stageLength - 1][num];

            for (int i = 0; i < stageLength - 1; i++)
            {
                Maps[stageLength - 1 - i][num] = Maps[stageLength - 2 - i][num];
                Maps[stageLength - 1 - i][num].GetComponent <MapInfo>().MapNumY = stageLength - 1 - i;
            }
            Maps[0][num] = temp;

            Maps[0][num].GetComponent <MapInfo>().MapNumY = 0;
            break;

        // 下-------------------------------------------------------------------*

        // 右-------------------------------------------------------------------
        case Direction.RIGHT:
            // 折り返し座標を保持
            turnPos   = Maps[num][0].transform.position;
            turnPos.z = 90;

            // 折り返しMap以外をスライド
            for (int i = 0; i <= stageLength - 1; i++)
            {
                tempPos   = Maps[num][i].transform.position;
                tempPos.z = 90;
                StartCoroutine(SrideAnimation(Maps[num][i], turnPos, new Vector2(tempPos.x + mapSize, tempPos.y), mapCount));

                mapCount++;
            }

            // スライド終了時の配列内入れ替え
            temp = Maps[num][stageLength - 1];
            for (int i = 0; i < stageLength - 1; i++)
            {
                Maps[num][stageLength - 1 - i] = Maps[num][stageLength - 2 - i];
                Maps[num][stageLength - 1 - i].GetComponent <MapInfo>().MapNumX = stageLength - 1 - i;
            }
            Maps[num][0] = temp;

            Maps[num][0].GetComponent <MapInfo>().MapNumX = 0;
            break;

        // 右-------------------------------------------------------------------*

        // 左-------------------------------------------------------------------
        case Direction.LEFT:
            turnPos   = Maps[num][stageLength - 1].transform.position;
            turnPos.z = 90;

            // 折り返しMap以外をスライド
            for (int i = stageLength - 1; i >= 0; i--)
            {
                tempPos   = Maps[num][i].transform.position;
                tempPos.z = 90;
                StartCoroutine(SrideAnimation(Maps[num][i], turnPos, new Vector2(tempPos.x - mapSize, tempPos.y), mapCount));

                mapCount++;
            }

            // スライド終了時の配列内入れ替え
            temp = Maps[num][0];

            for (int i = 0; i < stageLength - 1; i++)
            {
                Maps[num][i] = Maps[num][i + 1];
                Maps[num][i].GetComponent <MapInfo>().MapNumX = i;
            }
            Maps[num][stageLength - 1] = temp;

            Maps[num][stageLength - 1].GetComponent <MapInfo>().MapNumX = 2;

            break;

        // 左-------------------------------------------------------------------*
        default:
            break;
        }
    }