Пример #1
0
    public Quaternion       getRotationAtPlace(float place)
    {
        int place_i = (int)place;

        if (place_i >= this.sections.Length - 1)
        {
            place_i = this.sections.Length - 1 - 1;
        }

        RoadCreator.Section section_prev = this.sections[place_i];
        //RoadCreator.Section		section_next = this.sections[place_i + 1];

        Quaternion rotation = Quaternion.LookRotation(section_prev.direction, section_prev.up);

        return(rotation);
    }
Пример #2
0
    // 求出赛道上的位置
    public Vector3  getPositionAtPlace(float place)
    {
        int   place_i = (int)place;
        float place_f = place - (float)place_i;

        if (place_i >= this.sections.Length - 1)
        {
            place_i = this.sections.Length - 1 - 1;
            place_f = 1.0f;
        }

        RoadCreator.Section section_prev = this.sections[place_i];
        RoadCreator.Section section_next = this.sections[place_i + 1];

        Vector3 position = Vector3.Lerp(section_prev.center, section_next.center, place_f);

        return(position);
    }
Пример #3
0
    public Quaternion       getSmoothRotationAtPlace(float place)
    {
        int   place_i = (int)place;
        float place_f = place - (float)place_i;

        if (place_i >= this.sections.Length - 1)
        {
            place_i = this.sections.Length - 1 - 1;
            place_f = 1.0f;
        }

        RoadCreator.Section section_prev = this.sections[place_i];
        RoadCreator.Section section_next = this.sections[place_i + 1];

        Quaternion rotation_prev = Quaternion.LookRotation(section_prev.direction, section_prev.up);
        Quaternion rotation_next = Quaternion.LookRotation(section_next.direction, section_next.up);

        Quaternion rotation = Quaternion.Lerp(rotation_prev, rotation_next, place_f);

        return(rotation);
    }
Пример #4
0
    void    Update()
    {
        UIButton[] buttons = this.tool_gui.buttons;

        this.step_timer += Time.deltaTime;

        // ---------------------------------------------------------------- //
        // 次の状態に移るかどうかを、チェックする.

        if (this.next_step == STEP.NONE)
        {
            switch (this.step)
            {
            case STEP.EDIT:
            {
                // 車で走るボタン.
                if (buttons[(int)ToolGUI.BUTTON.RUN].trigger_on)
                {
                    if (this.road_creator.is_created)
                    {
                        this.next_step = STEP.RUN;
                    }
                }
            }
            break;

            case STEP.RUN:
            {
                if (buttons[(int)ToolGUI.BUTTON.RUN].trigger_on)
                {
                    // テスト走行終了.

                    this.game_control.stopTestRun();

                    this.car_object.gameObject.SetActive(false);

                    this.waku_object.SetActive(true);

                    this.tool_gui.onStopTestRun();


                    this.next_step = STEP.EDIT;
                }
            }
            break;
            }             // switch(this.step)
        }

        // ---------------------------------------------------------------- //
        // 状態が遷移したときの初期化.

        if (this.next_step != STEP.NONE)
        {
            switch (this.next_step)
            {
            case STEP.EDIT:
            {
                this.tool_camera.setEnable(true);
                this.car_camera.setEnable(false);

                this.forest_creator.setIsDrawIcon(true);
                this.buil_arranger.setIsDrawIcon(true);

                if (this.tunnel_creator.is_created)
                {
                    this.tunnel_creator.setIsDrawIcon(true);
                }
                if (this.jump_slope_creator.is_created)
                {
                    this.jump_slope_creator.setIsDrawIcon(true);
                }
            }
            break;

            case STEP.RUN:
            {
                // 車が生成されていなかったら作る.
                if (this.car_object == null)
                {
                    RoadCreator.Section section = this.road_creator.sections[1];

                    this.car_object = Instantiate(this.CarPrefab) as GameObject;

                    this.car_object.transform.position = section.center;
                    this.car_object.transform.Translate(0.0f, 0.1f, 0.0f);
                    this.car_object.transform.rotation = Quaternion.FromToRotation(Vector3.forward, section.direction);

                    // カメラ.

                    // ターゲット(見るもの)をセット.
                    this.car_camera.target = this.car_object.transform;

                    // 位置、注視点を初期化しておく.
                    this.car_camera.reset();
                    this.car_camera.calcPosture();

                    // イグニッション音.

                    this.GetComponent <AudioSource>().PlayOneShot(this.audio_clip_ignition);
                }

                //

                this.tool_camera.setEnable(false);
                this.car_camera.setEnable(true);

                this.tunnel_creator.setIsDrawIcon(false);
                this.forest_creator.setIsDrawIcon(false);
                this.buil_arranger.setIsDrawIcon(false);
                this.jump_slope_creator.setIsDrawIcon(false);

                // テスト走行開始.

                this.game_control.startTestRun();

                this.car_object.gameObject.SetActive(true);

                this.waku_object.SetActive(false);

                this.tool_gui.onStartTestRun();
            }
            break;
            }

            this.step      = this.next_step;
            this.next_step = STEP.NONE;

            this.step_timer = 0.0f;
        }

        // ---------------------------------------------------------------- //
        // 各状態での実行処理.


        switch (this.step)
        {
        case STEP.EDIT:
        {
        }
        break;
        }

        // -------------------------------------------------------------------------------------------- //

        if (this.step == STEP.EDIT)
        {
            //クリアーボタン.
            if (buttons[(int)ToolGUI.BUTTON.NEW].current)
            {
                // 前回済みのものを削除する.

                if (this.line_drawer.isLineDrawed())
                {
                    this.line_drawer.clear();

                    this.line_drawer.setVisible(true);
                }

                if (this.road_creator.is_created)
                {
                    this.road_creator.clearOutput();
                }

                this.tunnel_creator.clearOutput();
                this.forest_creator.clearOutput();
                this.buil_arranger.clearOutput();
                this.jump_slope_creator.clearOutput();

                this.tunnel_creator.setIsDrawIcon(false);
                this.forest_creator.setIsDrawIcon(false);
                this.buil_arranger.setIsDrawIcon(false);
                this.jump_slope_creator.setIsDrawIcon(false);

                if (this.car_object != null)
                {
                    Destroy(this.car_object);
                    this.car_object = null;
                }

                if (this.start_gate != null)
                {
                    Destroy(this.start_gate);
                    this.start_gate = null;
                }
                if (this.goal_gate != null)
                {
                    Destroy(this.goal_gate);
                    this.goal_gate = null;
                }

                //

                this.game_control.onClearOutput();

                //

                this.tool_camera.enabled = true;
                this.game_camera.enabled = false;
            }
#if UNITY_EDITOR
            // ロードボタン.
            if (buttons[(int)ToolGUI.BUTTON.LOAD].current)
            {
                FileStream   BinaryFile = new FileStream("test-cs.dat", FileMode.Open, FileAccess.Read);
                BinaryReader Reader     = new BinaryReader(BinaryFile);

                this.line_drawer.loadFromFile(Reader);

                Reader.Close();
            }

            // セーブボタン.
            if (buttons[(int)ToolGUI.BUTTON.SAVE].current)
            {
                FileStream   BinaryFile = new FileStream("test-cs.dat", FileMode.Create, FileAccess.Write);
                BinaryWriter Writer     = new BinaryWriter(BinaryFile);

                this.line_drawer.saveToFile(Writer);

                Writer.Close();
            }
#endif
        }

        // -------------------------------------------------------------------------------------------- //

        // 道を生成するボタン.
        if (buttons[(int)ToolGUI.BUTTON.CREATE_ROAD].current)
        {
            bool is_create_road = false;

            do
            {
                if (!this.line_drawer.isLineDrawed())
                {
                    break;
                }

                if (this.road_creator.is_created)
                {
                    break;
                }

                is_create_road = true;
            } while(false);

            if (is_create_road)
            {
                this.create_road();

                // トンネル.
                // 形状を作ったときに(TunnelCreator.createTunnel())再計算する.
                this.tunnel_creator.place_min = 0.0f;
                this.tunnel_creator.place_max = 0.0f;

                // 森.

                this.forest_creator.place_max = (float)this.road_creator.sections.Length - 1.0f;
                this.forest_creator.start     = this.road_creator.sections.Length * 0.25f;
                this.forest_creator.end       = this.road_creator.sections.Length * 0.75f;

                this.forest_creator.setIsDrawIcon(true);

                // ビル街.

                this.buil_arranger.place_max = (float)this.road_creator.sections.Length - 1.0f;
                this.buil_arranger.start     = this.road_creator.sections.Length * 0.25f;
                this.buil_arranger.end       = this.road_creator.sections.Length * 0.75f;

                this.buil_arranger.setIsDrawIcon(true);

                this.jump_slope_creator.place_min = 0.0f;
                this.jump_slope_creator.place_max = (float)this.road_creator.sections.Length - 1.0f;

                if (this.road_creator.sections.Length >= 5)
                {
                    // スタートゲート.

                    RoadCreator.Section gate_section;

                    gate_section = this.road_creator.sections[2];

                    this.start_gate = Instantiate(this.StartGatePrefab) as GameObject;
                    this.start_gate.transform.position = gate_section.center;
                    this.start_gate.transform.rotation = Quaternion.FromToRotation(Vector3.forward, gate_section.direction);

                    // ゴールゲート.

                    gate_section = this.road_creator.sections[this.road_creator.sections.Length - 1 - 1];

                    this.goal_gate = Instantiate(this.GoalGatePrefab) as GameObject;
                    this.goal_gate.transform.position = gate_section.center;
                    this.goal_gate.transform.rotation = Quaternion.FromToRotation(Vector3.forward, gate_section.direction);
                }

                // サウンドを鳴らす.
                this.GetComponent <AudioSource>().PlayOneShot(this.audio_clip_appear);
            }
        }


        // -------------------------------------------------------------------------------------------- //

        // トンネル作るボタン.
        if (buttons[(int)ToolGUI.BUTTON.TUNNEL_CREATE].trigger_on)
        {
            do
            {
                // 道路が出来てないとだめ.
                if (!this.road_creator.is_created)
                {
                    break;
                }

                // 生成済み.
                if (this.tunnel_creator.is_created)
                {
                    break;
                }

                //

                this.tunnel_creator.createTunnel();
            } while(false);
        }

        // トンネル移動ボタン.
        if (this.tunnel_creator.is_created)
        {
            if (buttons[(int)ToolGUI.BUTTON.TUNNEL_BACKWARD].current)
            {
                float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.TUNNEL_BACKWARD);

                this.tunnel_creator.setPlace(this.tunnel_creator.place + speed);
            }
            if (buttons[(int)ToolGUI.BUTTON.TUNNEL_FORWARD].current)
            {
                float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.TUNNEL_FORWARD);

                this.tunnel_creator.setPlace(this.tunnel_creator.place - speed);
            }
        }

        // -------------------------------------------------------------------------------------------- //

        // 森つくるボタン.
        if (buttons[(int)ToolGUI.BUTTON.FOREST_CREATE].current)
        {
            do
            {
                // 道路が出来てないとだめ.
                if (!this.road_creator.is_created)
                {
                    break;
                }

                // 生成済み.
                if (this.forest_creator.is_created)
                {
                    break;
                }

                //

                this.forest_creator.createForest();
            } while(false);
        }

        // 森in 前ボタン
        if (buttons[(int)ToolGUI.BUTTON.FOREST_START_FORWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.forest_creator.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.FOREST_START_FORWARD);

                    this.forest_creator.setStart(this.forest_creator.start + speed);
                }
            }
        }
        // 森in 後ろボタン
        if (buttons[(int)ToolGUI.BUTTON.FOREST_START_BACKWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.forest_creator.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.FOREST_START_BACKWARD);

                    this.forest_creator.setStart(this.forest_creator.start - speed);
                }
            }
        }
        // 森out 前ボタン
        if (buttons[(int)ToolGUI.BUTTON.FOREST_END_FORWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.forest_creator.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.FOREST_END_FORWARD);

                    this.forest_creator.setEnd(this.forest_creator.end + speed);
                }
            }
        }
        // 森out 後ろボタン
        if (buttons[(int)ToolGUI.BUTTON.FOREST_END_BACKWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.forest_creator.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.FOREST_END_BACKWARD);

                    this.forest_creator.setEnd(this.forest_creator.end - speed);
                }
            }
        }

        // -------------------------------------------------------------------------------------------- //

        // ビル並べるボタン.
        if (buttons[(int)ToolGUI.BUTTON.BUIL_CREATE].current)
        {
            do
            {
                // 道路が出来てないとだめ.
                if (!this.road_creator.is_created)
                {
                    break;
                }

                // 生成済み.
                if (this.buil_arranger.is_created)
                {
                    break;
                }

                //

                this.buil_arranger.base_offset = 40.0f;

                this.buil_arranger.createBuildings();
            } while(false);
        }
        // ビルin 前ボタン
        if (buttons[(int)ToolGUI.BUTTON.BUIL_START_FORWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.buil_arranger.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.BUIL_START_FORWARD);

                    this.buil_arranger.setStart(this.buil_arranger.start + speed);
                }
            }
        }
        // ビルin 後ろボタン
        if (buttons[(int)ToolGUI.BUTTON.BUIL_START_BACKWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.buil_arranger.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.BUIL_START_BACKWARD);

                    this.buil_arranger.setStart(this.buil_arranger.start - speed);
                }
            }
        }
        // ビルout 前ボタン
        if (buttons[(int)ToolGUI.BUTTON.BUIL_END_FORWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.buil_arranger.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.BUIL_END_FORWARD);

                    this.buil_arranger.setEnd(this.buil_arranger.end + speed);
                }
            }
        }
        // ビルout 後ろボタン
        if (buttons[(int)ToolGUI.BUTTON.BUIL_END_BACKWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.buil_arranger.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.BUIL_END_BACKWARD);

                    this.buil_arranger.setEnd(this.buil_arranger.end - speed);
                }
            }
        }

        // -------------------------------------------------------------------------------------------- //

        // ジャンプ台作るボタン.
        if (buttons[(int)ToolGUI.BUTTON.JUMP_CREATE].current)
        {
            do
            {
                // 道路が出来てないとだめ.
                if (!this.road_creator.is_created)
                {
                    break;
                }

                // 生成済み.
                if (this.jump_slope_creator.is_created)
                {
                    break;
                }

                //

                this.jump_slope_creator.createJumpSlope();
            } while(false);
        }
        // ジャンプ台移動ボタン.
        if (this.jump_slope_creator.is_created)
        {
            if (buttons[(int)ToolGUI.BUTTON.JUMP_FORWARD].current)
            {
                float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.JUMP_FORWARD);

                this.jump_slope_creator.setPlace(this.jump_slope_creator.place + speed);
            }
            if (buttons[(int)ToolGUI.BUTTON.JUMP_BACKWARD].current)
            {
                float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.JUMP_BACKWARD);

                this.jump_slope_creator.setPlace(this.jump_slope_creator.place - speed);
            }
        }

        /*if(this.road_creator.is_created) {
         *
         *      foreach(RoadCreator.Section section in this.road_creator.sections) {
         *
         *              Debug.DrawLine(section.positions[0], section.positions[1], Color.red, 0.0f, false);
         *      }
         * }*/

        // -------------------------------------------------------------------------------------------- //

        this.forest_creator.execute();
    }
Пример #5
0
    public void modifyShape()
    {
        Mesh mesh = this.instance.GetComponent <MeshFilter>().mesh;

        Vector3[] vertices = mesh.vertices;

        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i] = this.vertices_org[i];

            float z = this.place;

            // Z座標を、道路の中心線上の位置に変換する.
            // 整数部 … 制御点のインデックス.
            // 小数部 … 制御点間での比率.

            z += vertices[i].z / RoadCreator.PolygonSize.z;

            int   place_i = (int)z;                             // 整数部 … 制御点のインデックス.
            float place_f = z - (float)place_i;                 // 小数部 … 制御点間での比率.

            if (place_i >= this.road_creator.sections.Length - 1)
            {
                place_i = this.road_creator.sections.Length - 1 - 1;
                place_f = 1.0f;
            }

            RoadCreator.Section section_prev = this.road_creator.sections[place_i];
            RoadCreator.Section section_next = this.road_creator.sections[place_i + 1];

            // Z 軸が道路の中心線と同じ向きになるように回転する.

            vertices[i].z = 0.0f;
            vertices[i]   = Quaternion.LookRotation(section_prev.direction, section_prev.up) * vertices[i];

            // 前後の制御点の間を小数部で補間する.

            vertices[i] += Vector3.Lerp(section_prev.center, section_next.center, place_f);
        }

        //
        {
            int   place_i = (int)place;
            float place_f = place - (float)place_i;

            RoadCreator.Section section_prev = this.road_creator.sections[place_i];
            RoadCreator.Section section_next = this.road_creator.sections[place_i + 1];

            this.instance.transform.position = Vector3.Lerp(section_prev.center, section_next.center, place_f);
            this.instance.transform.rotation = Quaternion.LookRotation(section_prev.direction, section_prev.up);

            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i] = this.instance.transform.InverseTransformPoint(vertices[i]);
            }
        }

        //

        mesh.vertices = vertices;
    }
    public void modifyShape()
    {
        Mesh mesh = this.instance.GetComponent <MeshFilter>().mesh;

        Vector3[] vertices = mesh.vertices;

        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i] = this.vertices_org[i];

            float z = this.place;

            // 将Z坐标变换到道路中心线上的位置
            // 整数部分⋯⋯ 控制点的索引位置
            // 小数部分⋯⋯ 控制点间的距离比例

            z += vertices[i].z / RoadCreator.PolygonSize.z;

            int   place_i = (int)z;                             // 整数部分⋯⋯ 控制点的索引位置
            float place_f = z - (float)place_i;                 // 小数部分⋯⋯ 控制点间的距离比例

            if (place_i >= this.road_creator.sections.Length - 1)
            {
                place_i = this.road_creator.sections.Length - 1 - 1;
                place_f = 1.0f;
            }

            RoadCreator.Section section_prev = this.road_creator.sections[place_i];
            RoadCreator.Section section_next = this.road_creator.sections[place_i + 1];

            // 旋转使Z轴和道路中心线保持相同方向

            vertices[i].z = 0.0f;
            vertices[i]   = Quaternion.LookRotation(section_prev.direction, section_prev.up) * vertices[i];

            // 对前后控制点之间的小数部分进行补间

            vertices[i] += Vector3.Lerp(section_prev.center, section_next.center, place_f);
        }

        //
        {
            int   place_i = (int)place;
            float place_f = place - (float)place_i;

            RoadCreator.Section section_prev = this.road_creator.sections[place_i];
            RoadCreator.Section section_next = this.road_creator.sections[place_i + 1];

            this.instance.transform.position = Vector3.Lerp(section_prev.center, section_next.center, place_f);
            this.instance.transform.rotation = Quaternion.LookRotation(section_prev.direction, section_prev.up);

            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i] = this.instance.transform.InverseTransformPoint(vertices[i]);
            }
        }

        //

        mesh.vertices = vertices;
    }
Пример #7
0
    void    Update()
    {
        UIButton[] buttons = this.tool_gui.buttons;

        this.step_timer += Time.deltaTime;

        // ---------------------------------------------------------------- //
        // 检测是否迁移到下一个状态

        if (this.next_step == STEP.NONE)
        {
            switch (this.step)
            {
            case STEP.EDIT:
            {
                // 启动赛车的按钮
                if (buttons[(int)ToolGUI.BUTTON.RUN].trigger_on)
                {
                    if (this.road_creator.is_created)
                    {
                        this.next_step = STEP.RUN;
                    }
                }
            }
            break;

            case STEP.RUN:
            {
                if (buttons[(int)ToolGUI.BUTTON.RUN].trigger_on)
                {
                    // 测试运行结束

                    this.game_control.stopTestRun();

                    this.car_object.gameObject.SetActive(false);

                    this.waku_object.SetActive(true);

                    this.tool_gui.onStopTestRun();


                    this.next_step = STEP.EDIT;
                }
            }
            break;
            }             // switch(this.step)
        }

        // ---------------------------------------------------------------- //
        // 状态迁移时的初始化

        if (this.next_step != STEP.NONE)
        {
            switch (this.next_step)
            {
            case STEP.EDIT:
            {
                this.tool_camera.setEnable(true);
                this.car_camera.setEnable(false);

                this.forest_creator.setIsDrawIcon(true);
                this.buil_arranger.setIsDrawIcon(true);

                if (this.tunnel_creator.is_created)
                {
                    this.tunnel_creator.setIsDrawIcon(true);
                }
                if (this.jump_slope_creator.is_created)
                {
                    this.jump_slope_creator.setIsDrawIcon(true);
                }
            }
            break;

            case STEP.RUN:
            {
                // 如果没有赛车则创建
                if (this.car_object == null)
                {
                    RoadCreator.Section section = this.road_creator.sections[1];

                    this.car_object = Instantiate(this.CarPrefab) as GameObject;

                    this.car_object.transform.position = section.center;
                    this.car_object.transform.Translate(0.0f, 0.1f, 0.0f);
                    this.car_object.transform.rotation = Quaternion.FromToRotation(Vector3.forward, section.direction);

                    // 摄像机

                    // 设置目标(可见物体)
                    this.car_camera.target = this.car_object.transform;

                    // 初始化位置,注视点
                    this.car_camera.reset();
                    this.car_camera.calcPosture();

                    // 引擎点火音效

                    this.GetComponent <AudioSource>().PlayOneShot(this.audio_clip_ignition);
                }

                //

                this.tool_camera.setEnable(false);
                this.car_camera.setEnable(true);

                this.tunnel_creator.setIsDrawIcon(false);
                this.forest_creator.setIsDrawIcon(false);
                this.buil_arranger.setIsDrawIcon(false);
                this.jump_slope_creator.setIsDrawIcon(false);

                // 开始运行测试

                this.game_control.startTestRun();

                this.car_object.gameObject.SetActive(true);

                this.waku_object.SetActive(false);

                this.tool_gui.onStartTestRun();
            }
            break;
            }

            this.step      = this.next_step;
            this.next_step = STEP.NONE;

            this.step_timer = 0.0f;
        }

        // ---------------------------------------------------------------- //
        // 各个状态的执行处理


        switch (this.step)
        {
        case STEP.EDIT:
        {
        }
        break;
        }

        // -------------------------------------------------------------------------------------------- //

        if (this.step == STEP.EDIT)
        {
            //清空按钮
            if (buttons[(int)ToolGUI.BUTTON.NEW].current)
            {
                // 删除上一次处理完成的对象

                if (this.line_drawer.isLineDrawed())
                {
                    this.line_drawer.clear();

                    this.line_drawer.setVisible(true);
                }

                if (this.road_creator.is_created)
                {
                    this.road_creator.clearOutput();
                }

                this.tunnel_creator.clearOutput();
                this.forest_creator.clearOutput();
                this.buil_arranger.clearOutput();
                this.jump_slope_creator.clearOutput();

                this.tunnel_creator.setIsDrawIcon(false);
                this.forest_creator.setIsDrawIcon(false);
                this.buil_arranger.setIsDrawIcon(false);
                this.jump_slope_creator.setIsDrawIcon(false);

                if (this.car_object != null)
                {
                    Destroy(this.car_object);
                    this.car_object = null;
                }

                if (this.start_gate != null)
                {
                    Destroy(this.start_gate);
                    this.start_gate = null;
                }
                if (this.goal_gate != null)
                {
                    Destroy(this.goal_gate);
                    this.goal_gate = null;
                }

                //

                this.game_control.onClearOutput();

                //

                this.tool_camera.enabled = true;
                this.game_camera.enabled = false;
            }

            // 载入按钮
            if (buttons[(int)ToolGUI.BUTTON.LOAD].current)
            {
                FileStream   BinaryFile = new FileStream("test-cs.dat", FileMode.Open, FileAccess.Read);
                BinaryReader Reader     = new BinaryReader(BinaryFile);

                this.line_drawer.loadFromFile(Reader);

                Reader.Close();
            }

            // 保存按钮
            if (buttons[(int)ToolGUI.BUTTON.SAVE].current)
            {
                FileStream   BinaryFile = new FileStream("test-cs.dat", FileMode.Create, FileAccess.Write);
                BinaryWriter Writer     = new BinaryWriter(BinaryFile);

                this.line_drawer.saveToFile(Writer);

                Writer.Close();
            }
        }

        // -------------------------------------------------------------------------------------------- //

        // 生成道路按钮
        if (buttons[(int)ToolGUI.BUTTON.CREATE_ROAD].current)
        {
            bool is_create_road = false;

            do
            {
                if (!this.line_drawer.isLineDrawed())
                {
                    break;
                }

                if (this.road_creator.is_created)
                {
                    break;
                }

                is_create_road = true;
            } while(false);

            if (is_create_road)
            {
                this.create_road();

                // 隧道
                // 创建形状时(TunnelCreator.createTunnel())再次计算
                this.tunnel_creator.place_min = 0.0f;
                this.tunnel_creator.place_max = 0.0f;

                // 树林

                this.forest_creator.place_max = (float)this.road_creator.sections.Length - 1.0f;
                this.forest_creator.start     = this.road_creator.sections.Length * 0.25f;
                this.forest_creator.end       = this.road_creator.sections.Length * 0.75f;

                this.forest_creator.setIsDrawIcon(true);

                // 建筑街道

                this.buil_arranger.place_max = (float)this.road_creator.sections.Length - 1.0f;
                this.buil_arranger.start     = this.road_creator.sections.Length * 0.25f;
                this.buil_arranger.end       = this.road_creator.sections.Length * 0.75f;

                this.buil_arranger.setIsDrawIcon(true);

                this.jump_slope_creator.place_min = 0.0f;
                this.jump_slope_creator.place_max = (float)this.road_creator.sections.Length - 1.0f;

                if (this.road_creator.sections.Length >= 5)
                {
                    // 起点门

                    RoadCreator.Section gate_section;

                    gate_section = this.road_creator.sections[2];

                    this.start_gate = Instantiate(this.StartGatePrefab) as GameObject;
                    this.start_gate.transform.position = gate_section.center;
                    this.start_gate.transform.rotation = Quaternion.FromToRotation(Vector3.forward, gate_section.direction);

                    // 终点门

                    gate_section = this.road_creator.sections[this.road_creator.sections.Length - 1 - 1];

                    this.goal_gate = Instantiate(this.GoalGatePrefab) as GameObject;
                    this.goal_gate.transform.position = gate_section.center;
                    this.goal_gate.transform.rotation = Quaternion.FromToRotation(Vector3.forward, gate_section.direction);
                }

                // 播放音效
                this.GetComponent <AudioSource>().PlayOneShot(this.audio_clip_appear);
            }
        }


        // -------------------------------------------------------------------------------------------- //

        // 创建隧道的按钮
        if (buttons[(int)ToolGUI.BUTTON.TUNNEL_CREATE].trigger_on)
        {
            do
            {
                // 如果道路未出现
                if (!this.road_creator.is_created)
                {
                    break;
                }

                // 生成完毕
                if (this.tunnel_creator.is_created)
                {
                    break;
                }

                //

                this.tunnel_creator.createTunnel();
            } while(false);
        }

        // 移动隧道的按钮
        if (this.tunnel_creator.is_created)
        {
            if (buttons[(int)ToolGUI.BUTTON.TUNNEL_BACKWARD].current)
            {
                float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.TUNNEL_BACKWARD);

                this.tunnel_creator.setPlace(this.tunnel_creator.place + speed);
            }
            if (buttons[(int)ToolGUI.BUTTON.TUNNEL_FORWARD].current)
            {
                float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.TUNNEL_FORWARD);

                this.tunnel_creator.setPlace(this.tunnel_creator.place - speed);
            }
        }

        // -------------------------------------------------------------------------------------------- //

        // 创建树林的按钮
        if (buttons[(int)ToolGUI.BUTTON.FOREST_CREATE].current)
        {
            do
            {
                // 不允许出现道路未创建的情况
                if (!this.road_creator.is_created)
                {
                    break;
                }

                // 已经生成
                if (this.forest_creator.is_created)
                {
                    break;
                }

                //

                this.forest_creator.createForest();
            } while(false);
        }

        // 树林in 向前按钮
        if (buttons[(int)ToolGUI.BUTTON.FOREST_START_FORWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.forest_creator.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.FOREST_START_FORWARD);

                    this.forest_creator.setStart(this.forest_creator.start + speed);
                }
            }
        }
        // 树林in 向后按钮
        if (buttons[(int)ToolGUI.BUTTON.FOREST_START_BACKWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.forest_creator.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.FOREST_START_BACKWARD);

                    this.forest_creator.setStart(this.forest_creator.start - speed);
                }
            }
        }
        // 树林out 向前按钮
        if (buttons[(int)ToolGUI.BUTTON.FOREST_END_FORWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.forest_creator.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.FOREST_END_FORWARD);

                    this.forest_creator.setEnd(this.forest_creator.end + speed);
                }
            }
        }
        // 树林out 向后按钮
        if (buttons[(int)ToolGUI.BUTTON.FOREST_END_BACKWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.forest_creator.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.FOREST_END_BACKWARD);

                    this.forest_creator.setEnd(this.forest_creator.end - speed);
                }
            }
        }

        // -------------------------------------------------------------------------------------------- //

        // 排列建筑的按钮
        if (buttons[(int)ToolGUI.BUTTON.BUIL_CREATE].current)
        {
            do
            {
                // 不允许出现道路未创建的情况
                if (!this.road_creator.is_created)
                {
                    break;
                }

                // 已经生成
                if (this.buil_arranger.is_created)
                {
                    break;
                }

                //

                this.buil_arranger.base_offset = 40.0f;

                this.buil_arranger.createBuildings();
            } while(false);
        }
        // 建筑in 向前按钮
        if (buttons[(int)ToolGUI.BUTTON.BUIL_START_FORWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.buil_arranger.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.BUIL_START_FORWARD);

                    this.buil_arranger.setStart(this.buil_arranger.start + speed);
                }
            }
        }
        // 建筑in 向后按钮
        if (buttons[(int)ToolGUI.BUTTON.BUIL_START_BACKWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.buil_arranger.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.BUIL_START_BACKWARD);

                    this.buil_arranger.setStart(this.buil_arranger.start - speed);
                }
            }
        }
        // 建筑out 向前按钮
        if (buttons[(int)ToolGUI.BUTTON.BUIL_END_FORWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.buil_arranger.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.BUIL_END_FORWARD);

                    this.buil_arranger.setEnd(this.buil_arranger.end + speed);
                }
            }
        }
        // 建筑out 向后按钮
        if (buttons[(int)ToolGUI.BUTTON.BUIL_END_BACKWARD].current)
        {
            if (this.road_creator.is_created)
            {
                if (!this.buil_arranger.is_created)
                {
                    float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.BUIL_END_BACKWARD);

                    this.buil_arranger.setEnd(this.buil_arranger.end - speed);
                }
            }
        }

        // -------------------------------------------------------------------------------------------- //

        // 创建跳台的按钮
        if (buttons[(int)ToolGUI.BUTTON.JUMP_CREATE].current)
        {
            do
            {
                // 不允许出现道路未创建的情况
                if (!this.road_creator.is_created)
                {
                    break;
                }

                // 生成完毕
                if (this.jump_slope_creator.is_created)
                {
                    break;
                }

                //

                this.jump_slope_creator.createJumpSlope();
            } while(false);
        }
        // 移动跳台按钮
        if (this.jump_slope_creator.is_created)
        {
            if (buttons[(int)ToolGUI.BUTTON.JUMP_FORWARD].current)
            {
                float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.JUMP_FORWARD);

                this.jump_slope_creator.setPlace(this.jump_slope_creator.place + speed);
            }
            if (buttons[(int)ToolGUI.BUTTON.JUMP_BACKWARD].current)
            {
                float speed = this.calc_icon_move_speed(ToolGUI.BUTTON.JUMP_BACKWARD);

                this.jump_slope_creator.setPlace(this.jump_slope_creator.place - speed);
            }
        }

        /*if(this.road_creator.is_created) {
         *
         *      foreach(RoadCreator.Section section in this.road_creator.sections) {
         *
         *              Debug.DrawLine(section.positions[0], section.positions[1], Color.red, 0.0f, false);
         *      }
         * }*/

        // -------------------------------------------------------------------------------------------- //

        this.forest_creator.execute();
    }