public Info_GameApplication(bool pa1, SM_State state)
 {
     sw_autorun           = pa1;
     f_sm_state           = state;
     sw_freegame_waitslot = false;
     sw_freegame_waitgui  = false;
     idx_freegame         = 0;
     credit_endgame       = 0;
 }
    public void OnStop(bool win, bool b_scatter, SM_State state, JsonData jd)
    {
        // 更改局號
        string WagersID = (jd["WagersID"]).ToString();

        displayManager.Set_TableNumber(WagersID);

        if (win || b_scatter)
        {
            StartCoroutine(GetFlow(state, jd, b_scatter));
        }
        else
        {
            StartCoroutine(WaitAWhile(1.0f, IguiManager2GM.Finish_OnStop));
        }
    }
 public void OnTransitionPass(SM_State TargetState)
 {
     if (ManagedStates.Contains(TargetState))
     {
         SM_State CurrentState = GetComponentInChildren <SM_State>();
         if (CurrentState != TargetState)
         {
             CurrentState.gameObject.SetActive(false);
             TargetState.gameObject.SetActive(true);
         }
     }
     else
     {
         Debug.LogError($"This manager ({name}) is not set to manage target state ({TargetState.name})");
     }
 }
 public bool IsDoneWaiting(SM_State state) => state.CompareActiveDuration(WaitTime);
    IEnumerator GetFlow(SM_State state, JsonData jd, bool sw_scatter)
    {
        JsonData jd_lines = jd["Lines"];
        int      len_arr  = jd_lines.Count;

        if (sw_scatter)
        {
            len_arr += 1;
        }

        int[]    arr_lineid      = new int[len_arr];
        string[] arr_payoff      = new string[len_arr];
        int      sum_line_payoff = 0;

        // 剖析每一條線的資料
        string output = "output :\n";

        for (int i = 0; i < jd_lines.Count; i++)
        {
            double dou = (double)jd_lines[i]["LineID"];
            arr_lineid[i]    = Convert.ToInt32(dou);
            arr_payoff[i]    = (jd_lines[i]["Payoff"]).ToString().Split('.')[0];
            sum_line_payoff += Convert.ToInt32(arr_payoff[i]);

            output += "i " + i + " , arr_lineid[i] " + arr_lineid[i] + " , arr_payoff[i] " + arr_payoff[i] + "\n";
        }

        if (sw_scatter)
        {
            double dou_id         = (double)jd["Scatter"]["ID"];
            int    lineid_scatter = Convert.ToInt32(dou_id);
            double dou_payoff     = (double)jd["Scatter"]["Payoff"];
            int    payoff_scatter = Convert.ToInt32(dou_payoff);

            arr_lineid[len_arr - 1] = lineid_scatter;
            arr_payoff[len_arr - 1] = payoff_scatter.ToString();

            sum_line_payoff += payoff_scatter;
            LogServer.Instance.print("Add a line of Scatter. payoff is " + payoff_scatter);
        }

        output += "sum_line_payoff is " + sum_line_payoff;
        LogServer.Instance.print(output);

        yield return(new WaitForSeconds(1.0f));

        for (int i = 0; i < jd_lines.Count; i++)
        {
            bingoManger.OpenBingoLine(arr_lineid[i]);
        }

        // 顯示贏得分數
        displayManager.Set_WinScore(sum_line_payoff.ToString());

        yield return(new WaitForSeconds(1.0f));

        bingoManger.CloseAllBingoLine();


        if (state == SM_State.AUTOSPIN)
        {
            int score_now = GetNowScore();
            // 加上本次贏分
            score_now += sum_line_payoff;
            // 贏得分數歸零、現在分數增加
            displayManager.Set_WinScore("0");
            displayManager.Set_NowScore(score_now.ToString());

            IguiManager2GM.Finish_OnStop();
        }
        else if (state == SM_State.FREEGAME)
        {
        }
        else
        {
            // 執行等待得分流程
            playbutManager.Allow_GetScore();
            sw_animation = true;
            int cnt_idx = 0;

            while (sw_animation)
            {
                bingoManger.OpenBingoLine(arr_lineid[cnt_idx]);

                bingoManger.ShowPayoff(arr_lineid[cnt_idx], arr_payoff[cnt_idx]);

                // 當按下得分
                if (!sw_animation)
                {
                    bingoManger.CloseAllBingoLine();

                    bingoManger.ClosePayoff();
                    break;
                }

                yield return(new WaitForSeconds(1.0f));

                bingoManger.CloseAllBingoLine();

                bingoManger.ClosePayoff();


                cnt_idx++;

                if (cnt_idx == arr_lineid.Length)
                {
                    cnt_idx = 0;
                }
            }

            int score_now = GetNowScore();
            // 加上本次贏分
            score_now += sum_line_payoff;
            // 贏得分數歸零、現在分數增加
            displayManager.Set_WinScore("0");
            displayManager.Set_NowScore(score_now.ToString());

            IguiManager2GM.Finish_OnStop();
        }
    }