// 外部呼叫函示
    public void Shoot()
    {
        if (state == ShootAnimState.NORMAL)
        {
            TimeCounter      = 0;
            WorldTimeCounter = 0;
            currentTime      = 0;
            state            = ShootAnimState.WAIT_FOR_SHOOT_ANIM;

            // 拿值
            power     = int.Parse(PowerField.text);
            pushpower = int.Parse(PushPowerField.text);
            float temp1 = float.Parse(Angle0Field.text);
            float temp2 = float.Parse(Angle1Field.text);
            angle    = Random.Range(temp1, temp2);
            autoTime = int.Parse(AutoTimesField.text);

            // 填直到 Record
            ReplayClass replay = new ReplayClass();
            replay.Params.Power     = power;
            replay.Params.PushPower = pushpower;
            replay.Params.Angle     = angle;

            replay.Params.TopCapsuleList.Clear();
            for (int i = 0; i < TopCapsuleList.Count; i++)
            {
                TopCapsuleRecord record = new TopCapsuleRecord();
                record.HorizontalOffset = TopCapsuleList[i].HorizontalOffset;
                record.VerticalOffset   = TopCapsuleList[i].VerticalOffset;
                replay.Params.TopCapsuleList.Add(record);
            }

            // 物理相關參數
            replay.Params.TopcapsuleBounciness   = float.Parse(TopcapsuleBouncinessField.text);
            replay.Params.TopcapsuleFraction     = float.Parse(TopcapsuleFractionField.text);
            replay.Params.GroupBounciness        = float.Parse(GroupBouncinessField.text);
            replay.Params.GroupFraction          = float.Parse(GroupFractionField.text);
            replay.Params.BallBounciness         = float.Parse(BallBouncinessField.text);
            replay.Params.BallFraction           = float.Parse(BallFractionField.text);
            replay.Params.SeparateLineBounciness = float.Parse(SeparateLineBouncinessField.text);
            replay.Params.SeparateLineFraction   = float.Parse(SeparateLineFractionField.text);
            replay.Params.Gravity          = float.Parse(GravityField.text);
            replay.Params.HitPinBounciness = float.Parse(HitPinBouncinessField.text);
            replay.Params.HitPinFraction   = float.Parse(HitPinFractionField.text);
            ReplayInfo.Add(replay);

            RecordCurrentBallData();
        }
        //Debug.Log(TopCapsule.transform.position.ToString("F4"));
        //Debug.Log(Pin.transform.position.ToString("F4"));
    }
    private void FixedUpdate()
    {
        // 增加時間
        TimeCounter += Time.fixedDeltaTime;
        if (TimeCounter >= 10000)
        {
            TimeCounter = 0;                    // 不要讓他抱調
        }
        // 只要他還在跑的時候
        if (state >= ShootAnimState.WAIT_FOR_SHOOT_ANIM && state <= ShootAnimState.WAIT_BALL_ANIM)
        {
            WorldTimeCounter += Time.fixedDeltaTime;
        }

        // 跑每個 State 的動畫
        switch (state)
        {
        case ShootAnimState.WAIT_FOR_SHOOT_ANIM:
        {
            // 拿力道
            float powerRatio = 1 - (float)power / 6;
            float t          = Mathf.Lerp(0, powerRatio, TimeCounter / WaitForShoot_Time);
            Pin.transform.position = Vector3.Lerp(PowerSixLocation, PowerOneLocation, t);

            // 判斷是否超過
            if (TimeCounter >= WaitForShoot_Time)
            {
                TimeCounter = 0;
                state       = ShootAnimState.FREEZE_FOR_SHOOT_ANIM;
            }
            RecordCurrentBallData();
            break;
        }

        case ShootAnimState.FREEZE_FOR_SHOOT_ANIM:
        {
            // 判斷是否超過
            if (TimeCounter >= Freeze_Shoot_Time)
            {
                TimeCounter = 0;
                state       = ShootAnimState.SHOOT_ANIM;

                // 加力量
                float t        = 1 - (float)power / 5;
                float pusht    = 1 - (float)pushpower / 5;
                float force    = Mathf.Lerp(AddForce5, AddForce1, t) + Mathf.Lerp(PushForce5, PushForce1, pusht);
                float sinForce = Mathf.Sin(angle * Mathf.Deg2Rad) * force;
                float cosForce = Mathf.Cos(angle * Mathf.Deg2Rad) * force;
                BallList[BallList.Count - 1].GetComponent <Rigidbody>().AddForce(new Vector3(sinForce, cosForce, 0));
            }
            RecordCurrentBallData();
            break;
        }

        case ShootAnimState.SHOOT_ANIM:
        {
            float t = Mathf.Clamp01(Mathf.Max(TimeCounter - Delay_Time, 0) / (Shoot_Time - Delay_Time));
            Pin.transform.position = Vector3.Lerp(Pin.transform.position, PinFirstPos, t * t * t);

            // 判斷是否超過
            if (TimeCounter >= Shoot_Time)
            {
                TimeCounter            = 0;
                Pin.transform.position = PinFirstPos;
                state = ShootAnimState.WAIT_BALL_ANIM;
            }
            RecordCurrentBallData();
            break;
        }

        case ShootAnimState.WAIT_BALL_ANIM:
        {
            // 判斷是否超過
            if (LastTimeCounter >= WaitBall_Time)
            {
                TimeCounter      = 0;
                WorldTimeCounter = 0;
                LastTimeCounter  = 0;
                LastBallPos      = BallFirstPos;

                // 重製一顆球
                currentTime++;
                BallList[BallList.Count - 1].GetComponent <Rigidbody>().velocity = Vector3.zero;

                // 重播選單更新
                ReplayInfo[ReplayInfo.Count - 1].WinAreaNumber = WinAreaNumber;
                ReplayInfo[ReplayInfo.Count - 1].Name          = ReplayM.GenerateUIItem(power, WinAreaNumber);
                ReplayInfo[ReplayInfo.Count - 1].IsFinished    = true;

                if (currentTime == autoTime)
                {
                    for (int i = BallList.Count - 1; i >= 1; i--)
                    {
                        GameObject temp = BallList[i];
                        Destroy(temp);
                        BallList.RemoveAt(i);
                    }
                    BallList[0].transform.position = BallFirstPos;

                    // 結束了
                    state = ShootAnimState.NORMAL;
                }
                else
                {
                    GameObject temp = GameObject.Instantiate(BallList[0]);
                    temp.transform.position = BallFirstPos;
                    BallList.Add(temp);

                    // 隨機參數
                    float temp1 = float.Parse(Angle0Field.text);
                    float temp2 = float.Parse(Angle1Field.text);
                    angle = Random.Range(temp1, temp2);

                    // 加重播清單
                    ReplayClass replay = new ReplayClass();
                    replay.Params.Power     = power;
                    replay.Params.PushPower = pushpower;
                    replay.Params.Angle     = angle;

                    replay.Params.TopCapsuleList.Clear();
                    for (int i = 0; i < TopCapsuleList.Count; i++)
                    {
                        TopCapsuleRecord record = new TopCapsuleRecord();
                        record.HorizontalOffset = TopCapsuleList[i].HorizontalOffset;
                        record.VerticalOffset   = TopCapsuleList[i].VerticalOffset;
                        replay.Params.TopCapsuleList.Add(record);
                    }

                    // 物理相關參數
                    replay.Params.TopcapsuleBounciness   = float.Parse(TopcapsuleBouncinessField.text);
                    replay.Params.TopcapsuleFraction     = float.Parse(TopcapsuleFractionField.text);
                    replay.Params.GroupBounciness        = float.Parse(GroupBouncinessField.text);
                    replay.Params.GroupFraction          = float.Parse(GroupFractionField.text);
                    replay.Params.BallBounciness         = float.Parse(BallBouncinessField.text);
                    replay.Params.BallFraction           = float.Parse(BallFractionField.text);
                    replay.Params.SeparateLineBounciness = float.Parse(SeparateLineBouncinessField.text);
                    replay.Params.SeparateLineFraction   = float.Parse(SeparateLineFractionField.text);
                    replay.Params.Gravity          = float.Parse(GravityField.text);
                    replay.Params.HitPinBounciness = float.Parse(HitPinBouncinessField.text);
                    replay.Params.HitPinFraction   = float.Parse(HitPinFractionField.text);
                    ReplayInfo.Add(replay);
                    //ReplayInfo.Add(new ReplayClass());

                    // 繼續
                    state = ShootAnimState.WAIT_FOR_SHOOT_ANIM;
                }
            }
            else if (Vector3.Distance(LastBallPos, BallList[BallList.Count - 1].transform.position) <= 0.1f)
            {
                // 加時間
                LastTimeCounter += Time.deltaTime;
            }
            else
            {
                LastTimeCounter = 0;
                LastBallPos     = BallList[BallList.Count - 1].transform.position;
            }
            RecordCurrentBallData();
            break;
        }
        }
    }