Exemplo n.º 1
0
    public void MatConnectionFlow()
    {
        Debug.Log("Starting Mat connection flow");
        bIsMatFlowInitialized   = true;
        bIsGameMainSceneLoading = false;
        NoMatPanel.SetActive(false);
        newMatInputController.MakeSortLayerTen();
        //newUIManager.TurnOffMainCommonButton();

#if UNITY_EDITOR
        if (!bIsGameMainSceneLoading)
        {
            StartCoroutine(LoadMainGameScene());
        }
#elif UNITY_ANDROID
        /*
         * if (currentYipliConfig.matInfo == null && !currentYipliConfig.isDeviceAndroidTV)
         * {
         *  Debug.Log("Filling te current mat Info from Device saved MAT");
         *  currentYipliConfig.matInfo = UserDataPersistence.GetSavedMat();
         * }
         */

        if (currentYipliConfig.matInfo != null || currentYipliConfig.isDeviceAndroidTV)
        {
            if (currentYipliConfig.matInfo != null)
            {
                Debug.Log("Mac Address : " + currentYipliConfig.matInfo.macAddress);
            }
            //Load Game scene if the mat is already connected.
            if (!InitBLE.getMatConnectionStatus().Equals("connected", StringComparison.OrdinalIgnoreCase))
            {
                StartCoroutine(ConnectMat());
            }
        }
        else //Current Mat not found in Db.
        {
            loadingPanel.SetActive(false);
            Debug.Log("No Mat found in cache.");
            noMatText.text = ProductMessages.Err_mat_connection_android_phone_register;
            newUIManager.UpdateButtonDisplay(NoMatPanel.tag);
            NoMatPanel.SetActive(true);
            newMatInputController.MakeSortLayerZero();
            newUIManager.TurnOffMainCommonButton();
            FindObjectOfType <YipliAudioManager>().Play("BLE_failure");
        }
#elif UNITY_STANDALONE_WIN
        if (!InitBLE.getMatConnectionStatus().Equals("connected", StringComparison.OrdinalIgnoreCase))
        {
            StartCoroutine(ConnectMat(true));
        }
#elif UNITY_IOS
        if (!InitBLE.getMatConnectionStatus().Equals("connected", StringComparison.OrdinalIgnoreCase))
        {
            StartCoroutine(ConnectMat(true));
        }
#endif
    }
Exemplo n.º 2
0
 public static string GetMatConnectionStatus()
 {
     if (!PlayerSession.Instance.currentYipliConfig.onlyMatPlayMode)
     {
         return("Connected");
     }
     Debug.Log("GetBleConnectionStatus returning : " + InitBLE.getMatConnectionStatus());
     return(InitBLE.getMatConnectionStatus());
 }
Exemplo n.º 3
0
 public void Update()
 {
     if (bIsMatFlowInitialized)
     {
         //LoadGameScene if mat connection is established
         if (InitBLE.getMatConnectionStatus().Equals("connected", StringComparison.OrdinalIgnoreCase))
         {
             if (true != bIsGameMainSceneLoading)
             {
                 StartCoroutine(LoadMainGameScene());
             }
         }
     }
 }
Exemplo n.º 4
0
    private IEnumerator ConnectMat(bool bIsReconnectMatNeeded = false)
    {
        int iTryCount = 0;

        //Initiate the connection with the mat.
        try
        {
            if (bIsReconnectMatNeeded)
            {
                RetryMatConnectionOnPC();
            }
            else
            {
                InitiateMatConnection();
            }
        }
        catch (Exception e)
        {
            Debug.LogError("mat connection failed : " + e.Message);

            loadingPanel.SetActive(false);
            newUIManager.UpdateButtonDisplay(NoMatPanel.tag);
            NoMatPanel.SetActive(true);
            newMatInputController.MakeSortLayerZero();
            yield break;
        }

        yield return(new WaitForSecondsRealtime(0.1f));

        //Turn on the Mat Find Panel, and animate
        loadingPanel.gameObject.GetComponentInChildren <TextMeshProUGUI>().text = "Finding your mat..";
        loadingPanel.SetActive(true);//Show msg till mat connection is confirmed.

        while (!InitBLE.getMatConnectionStatus().Equals("connected", StringComparison.OrdinalIgnoreCase) &&
               iTryCount < MaxBleCheckCount)
        {
#if UNITY_IOS
            yield return(new WaitForSecondsRealtime(1f));
#else
            yield return(new WaitForSecondsRealtime(0.25f));
#endif
            iTryCount++;
        }

        //Turn off the Mat Find Panel
        loadingPanel.SetActive(false);
        loadingPanel.gameObject.GetComponentInChildren <TextMeshProUGUI>().text = "Fetching player details...";

        if (!InitBLE.getMatConnectionStatus().Equals("connected", StringComparison.OrdinalIgnoreCase))
        {
            FindObjectOfType <YipliAudioManager>().Play("BLE_failure");
            Debug.Log("Mat not reachable.");

#if UNITY_ANDROID || UNITY_IOS
            noMatText.text = ProductMessages.Err_mat_connection_mat_off;
#elif UNITY_STANDALONE_WIN && UNITY_EDITOR
            if (PortTestings.CheckAvailableComPorts() == 0)
            {
                noMatText.text = ProductMessages.Err_mat_connection_no_ports;
            }
            else
            {
                noMatText.text = ProductMessages.Err_mat_connection_mat_off;
            }
#endif
            newUIManager.UpdateButtonDisplay(NoMatPanel.tag);
            NoMatPanel.SetActive(true);
            newMatInputController.MakeSortLayerZero();
        }
    }