Exemple #1
0
        private IEnumerator PlayGame()
        {
            while (!partidaCompleta)
            {
                sco.StartSampling();

                if (ppasso)
                {
                    CleanScene();

                    while (!scp.IsConnected && !scm.IsConnected && !scc.IsConnected)
                    {
                        passo = -1;
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Nenhum dispositivo de controle conectado! Conecte e volte ao menu principal.";
                        yield return(null);
                    }

                    // Se o PITACO estiver conectado
                    if (scp.IsConnected)
                    {
                        switch (passo)
                        {
                        case 1:
                            displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir dentro do tempo.";
                            break;

                        case 2:

                            scp.StartSampling();
                            scp.Recalibrate();

                            displayHowTo.text = "";

                            TextPanel.SetActive(false);

                            while (player.sensorValuePitaco <= Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                yield return(null);
                            }

                            StopCountdown();
                            paraTempo = true;

                            //saiu do 0
                            while (player.sensorValuePitaco > Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                FlowAction(player.picoExpiratorio, 1);
                                yield return(null);
                            }

                            scp.StopSampling();

                            //voltou pro 0
                            finalScoreMenu.pikeString[0] = player.picoExpiratorio.ToString();
                            TextPanel.SetActive(true);

                            if (jogou)
                            {
                                displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                SoundManager.Instance.PlaySound("Success");
                            }

                            break;

                        case 3:
                            FindObjectOfType <MinigameLogger>().WriteMinigameRound(1, finalScore[0], player.picoExpiratorio);
                            RestauraVariaveis();
                            displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir";
                            break;

                        case 4:

                            scp.StartSampling();
                            scp.Recalibrate();

                            displayHowTo.text = "";
                            TextPanel.SetActive(false);
                            while (player.sensorValuePitaco <= Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                yield return(null);
                            }

                            StopCountdown();
                            paraTempo = true;

                            //saiu do 0
                            while (player.sensorValuePitaco > Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                FlowAction(player.picoExpiratorio, 2);
                                yield return(null);
                            }

                            scp.StopSampling();

                            //voltou pro 0
                            finalScoreMenu.pikeString[1] = player.picoExpiratorio.ToString();
                            TextPanel.SetActive(true);

                            if (jogou)
                            {
                                displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                SoundManager.Instance.PlaySound("Success");
                            }

                            break;

                        case 5:
                            FindObjectOfType <MinigameLogger>().WriteMinigameRound(2, finalScore[1], player.picoExpiratorio);
                            RestauraVariaveis();
                            displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir";
                            break;

                        case 6:

                            scp.StartSampling();
                            scp.Recalibrate();

                            displayHowTo.text = "";
                            TextPanel.SetActive(false);
                            while (player.sensorValuePitaco <= Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                yield return(null);
                            }

                            StopCountdown();
                            paraTempo = true;

                            //saiu do 0
                            while (player.sensorValuePitaco > Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                FlowAction(player.picoExpiratorio, 3);
                                yield return(null);
                            }

                            scp.StopSampling();

                            //voltou pro 0
                            finalScoreMenu.pikeString[2] = player.picoExpiratorio.ToString();
                            TextPanel.SetActive(true);

                            if (jogou)
                            {
                                displayHowTo.text = "Parabéns!\nPressione [Enter] para ver a sua pontuação.";
                                SoundManager.Instance.PlaySound("Success");
                            }

                            player.picoExpiratorio = 0;
                            break;

                        case 7:
                            FindObjectOfType <MinigameLogger>().WriteMinigameRound(3, finalScore[2], player.picoExpiratorio);

                            TextPanel.SetActive(false);
                            finalScoreMenu.DisplayFinalScore(finalScore[0], finalScore[1], finalScore[2]);
                            finalScoreMenu.ToggleScoreMenu();

                            Debug.Log("Saving minigame data...");
                            GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(true);
                            FindObjectOfType <MinigameLogger>().Save(GameDevice.Pitaco, RespiratoryExercise.ExpiratoryPeak, Minigame.CakeGame);
                            GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(false);
                            Debug.Log("Minigame logs saved.");

                            player.picoExpiratorio = 0;

                            partidaCompleta = true;
                            break;
                        }
                        ppasso = false;
                    }

                    #region Other Controllers

                    else
                    {
                        // Se o MANO estiver conectado
                        if (scm.IsConnected)
                        {
                            switch (passo)
                            {
                            case 1:
                                displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir dentro do tempo.";
                                break;

                            case 2:

                                scm.StartSampling();
                                scm.Recalibrate();

                                displayHowTo.text = "";

                                TextPanel.SetActive(false);

                                while (player.sensorValueMano <= Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    yield return(null);
                                }

                                StopCountdown();
                                paraTempo = true;

                                //saiu do 0
                                while (player.sensorValueMano > Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    FlowAction(player.picoExpiratorio, 1);
                                    yield return(null);
                                }

                                scm.StopSampling();

                                //voltou pro 0
                                finalScoreMenu.pikeString[0] = player.picoExpiratorio.ToString();
                                TextPanel.SetActive(true);

                                if (jogou)
                                {
                                    displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                    SoundManager.Instance.PlaySound("Success");
                                }

                                break;

                            case 3:
                                FindObjectOfType <MinigameLogger>().WriteMinigameRound(1, finalScore[0], player.picoExpiratorio);
                                RestauraVariaveis();
                                displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir";
                                break;

                            case 4:

                                scm.StartSampling();
                                scm.Recalibrate();

                                displayHowTo.text = "";
                                TextPanel.SetActive(false);
                                while (player.sensorValueMano <= Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    yield return(null);
                                }

                                StopCountdown();
                                paraTempo = true;

                                //saiu do 0
                                while (player.sensorValueMano > Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    FlowAction(player.picoExpiratorio, 2);
                                    yield return(null);
                                }

                                scm.StopSampling();

                                //voltou pro 0
                                finalScoreMenu.pikeString[1] = player.picoExpiratorio.ToString();
                                TextPanel.SetActive(true);

                                if (jogou)
                                {
                                    displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                    SoundManager.Instance.PlaySound("Success");
                                }

                                break;

                            case 5:
                                FindObjectOfType <MinigameLogger>().WriteMinigameRound(2, finalScore[1], player.picoExpiratorio);
                                RestauraVariaveis();
                                displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir";
                                break;

                            case 6:

                                scm.StartSampling();
                                scm.Recalibrate();

                                displayHowTo.text = "";
                                TextPanel.SetActive(false);
                                while (player.sensorValueMano <= Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    yield return(null);
                                }

                                StopCountdown();
                                paraTempo = true;

                                //saiu do 0
                                while (player.sensorValueMano > Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    FlowAction(player.picoExpiratorio, 3);
                                    yield return(null);
                                }

                                scm.StopSampling();

                                //voltou pro 0
                                finalScoreMenu.pikeString[2] = player.picoExpiratorio.ToString();
                                TextPanel.SetActive(true);

                                if (jogou)
                                {
                                    displayHowTo.text = "Parabéns!\nPressione [Enter] para ver a sua pontuação.";
                                    SoundManager.Instance.PlaySound("Success");
                                }

                                player.picoExpiratorio = 0;
                                break;

                            case 7:
                                FindObjectOfType <MinigameLogger>().WriteMinigameRound(3, finalScore[2], player.picoExpiratorio);

                                TextPanel.SetActive(false);
                                finalScoreMenu.DisplayFinalScore(finalScore[0], finalScore[1], finalScore[2]);
                                finalScoreMenu.ToggleScoreMenu();

                                Debug.Log("Saving minigame data...");
                                GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(true);
                                FindObjectOfType <MinigameLogger>().Save(GameDevice.Mano, RespiratoryExercise.ExpiratoryPeak, Minigame.CakeGame);
                                GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(false);
                                Debug.Log("Minigame logs saved.");

                                player.picoExpiratorio = 0;

                                partidaCompleta = true;
                                break;
                            }
                            ppasso = false;
                        }
                        else
                        {
                            // Se o CINTA estiver conectado
                            if (scc.IsConnected)
                            {
                                switch (passo)
                                {
                                case 1:
                                    displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir dentro do tempo.";
                                    break;

                                case 2:

                                    scc.StartSampling();
                                    scc.Recalibrate();

                                    displayHowTo.text = "";

                                    TextPanel.SetActive(false);

                                    while (player.sensorValueCinta <= Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        yield return(null);
                                    }

                                    StopCountdown();
                                    paraTempo = true;

                                    //saiu do 0
                                    while (player.sensorValueCinta > Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        FlowAction(player.picoExpiratorio, 1);
                                        yield return(null);
                                    }

                                    scc.StopSampling();

                                    //voltou pro 0
                                    finalScoreMenu.pikeString[0] = player.picoExpiratorio.ToString();
                                    TextPanel.SetActive(true);

                                    if (jogou)
                                    {
                                        displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                        SoundManager.Instance.PlaySound("Success");
                                    }

                                    break;

                                case 3:
                                    FindObjectOfType <MinigameLogger>().WriteMinigameRound(1, finalScore[0], player.picoExpiratorio);
                                    RestauraVariaveis();
                                    displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir";
                                    break;

                                case 4:

                                    scc.StartSampling();
                                    scc.Recalibrate();

                                    displayHowTo.text = "";
                                    TextPanel.SetActive(false);
                                    while (player.sensorValueCinta <= Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        yield return(null);
                                    }

                                    StopCountdown();
                                    paraTempo = true;

                                    //saiu do 0
                                    while (player.sensorValueCinta > Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        FlowAction(player.picoExpiratorio, 2);
                                        yield return(null);
                                    }

                                    scc.StopSampling();

                                    //voltou pro 0
                                    finalScoreMenu.pikeString[1] = player.picoExpiratorio.ToString();
                                    TextPanel.SetActive(true);

                                    if (jogou)
                                    {
                                        displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                        SoundManager.Instance.PlaySound("Success");
                                    }

                                    break;

                                case 5:
                                    FindObjectOfType <MinigameLogger>().WriteMinigameRound(2, finalScore[1], player.picoExpiratorio);
                                    RestauraVariaveis();
                                    displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir";
                                    break;

                                case 6:

                                    scc.StartSampling();
                                    scc.Recalibrate();

                                    displayHowTo.text = "";
                                    TextPanel.SetActive(false);
                                    while (player.sensorValueCinta <= Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        yield return(null);
                                    }

                                    StopCountdown();
                                    paraTempo = true;

                                    //saiu do 0
                                    while (player.sensorValueCinta > Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        FlowAction(player.picoExpiratorio, 3);
                                        yield return(null);
                                    }

                                    scc.StopSampling();

                                    //voltou pro 0
                                    finalScoreMenu.pikeString[2] = player.picoExpiratorio.ToString();
                                    TextPanel.SetActive(true);

                                    if (jogou)
                                    {
                                        displayHowTo.text = "Parabéns!\nPressione [Enter] para ver a sua pontuação.";
                                        SoundManager.Instance.PlaySound("Success");
                                    }

                                    player.picoExpiratorio = 0;
                                    break;

                                case 7:
                                    FindObjectOfType <MinigameLogger>().WriteMinigameRound(3, finalScore[2], player.picoExpiratorio);

                                    TextPanel.SetActive(false);
                                    finalScoreMenu.DisplayFinalScore(finalScore[0], finalScore[1], finalScore[2]);
                                    finalScoreMenu.ToggleScoreMenu();

                                    Debug.Log("Saving minigame data...");
                                    GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(true);
                                    FindObjectOfType <MinigameLogger>().Save(GameDevice.Cinta, RespiratoryExercise.ExpiratoryPeak, Minigame.CakeGame);
                                    GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(false);
                                    Debug.Log("Minigame logs saved.");

                                    player.picoExpiratorio = 0;

                                    partidaCompleta = true;
                                    break;
                                }
                                ppasso = false;
                            }
                        }
                    }

                    #endregion
                }
                yield return(null);
            }
            sco.StopSampling();
        }
Exemple #2
0
        private IEnumerator PlayGame()
        {
            while (!partidaCompleta)
            {
                if (ppasso)
                {
                    CleanScene();

                    while (!scp.IsConnected && !scm.IsConnected && !scc.IsConnected)
                    {
                        passo = -1;
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Nenhum dispositivo de controle conectado! Conecte e volte ao menu principal.";
                        yield return(null);
                    }

                    // Se o Pitaco estiver conectado
                    if (scp.IsConnected)
                    {
                        switch (passo)
                        {
                        case 1:
                            displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir dentro do tempo.";
                            break;

                        case 2:

                            scp.StartSampling();
                            scp.Recalibrate();


                            displayHowTo.text = "";

                            TextPanel.SetActive(false);

                            while (player.sensorValue <= Pacient.Loaded.PitacoThreshold * 2 && jogou)
                            {
                                yield return(null);
                            }

                            StopCountdown();
                            paraTempo = true;

                            //saiu do 0
                            while (player.sensorValue > Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                FlowAction(player.picoExpiratorio);
                                yield return(null);
                            }

                            //voltou pro 0
                            finalScoreMenu.pikeString[0] = player.picoExpiratorio.ToString();
                            TextPanel.SetActive(true);

                            if (jogou)
                            {
                                displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                SoundManager.Instance.PlaySound("Success");
                            }

                            player.picoExpiratorio = 0;
                            break;

                        case 3:
                            RestauraVariaveis();
                            break;

                        case 4:
                            displayHowTo.text = "";
                            TextPanel.SetActive(false);
                            while (player.sensorValue <= Pacient.Loaded.PitacoThreshold * 2 && jogou)
                            {
                                yield return(null);
                            }

                            StopCountdown();
                            paraTempo = true;

                            //saiu do 0
                            while (player.sensorValue > Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                FlowAction(player.picoExpiratorio);
                                yield return(null);
                            }

                            //voltou pro 0
                            finalScoreMenu.pikeString[1] = player.picoExpiratorio.ToString();
                            TextPanel.SetActive(true);

                            if (jogou)
                            {
                                displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                SoundManager.Instance.PlaySound("Success");
                            }

                            player.picoExpiratorio = 0;
                            break;

                        case 5:
                            RestauraVariaveis();
                            break;

                        case 6:
                            displayHowTo.text = "";
                            TextPanel.SetActive(false);
                            while (player.sensorValue <= Pacient.Loaded.PitacoThreshold * 2 && jogou)
                            {
                                yield return(null);
                            }

                            StopCountdown();
                            paraTempo = true;

                            //saiu do 0
                            while (player.sensorValue > Pacient.Loaded.PitacoThreshold && jogou)
                            {
                                FlowAction(player.picoExpiratorio);
                                yield return(null);
                            }

                            //voltou pro 0
                            finalScoreMenu.pikeString[2] = player.picoExpiratorio.ToString();
                            TextPanel.SetActive(true);

                            if (jogou)
                            {
                                displayHowTo.text = "Parabéns!\nPressione [Enter] para ver a sua pontuação.";
                                SoundManager.Instance.PlaySound("Success");
                            }

                            player.picoExpiratorio = 0;
                            scp.StopSampling();
                            FindObjectOfType <PitacoLogger>().StopLogging();

                            break;
                        }
                        ppasso = false;
                    }
                    else     ////////////////////
                    // Se o Mano estiver conectado
                    {
                        if (scm.IsConnected)
                        {
                            switch (passo)
                            {
                            case 1:
                                displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir dentro do tempo.";
                                break;

                            case 2:

                                scm.StartSampling();
                                scm.Recalibrate();

                                displayHowTo.text = "";

                                TextPanel.SetActive(false);

                                while (player.sensorValue <= Pacient.Loaded.ManoThreshold * 2 && jogou)
                                {
                                    yield return(null);
                                }

                                StopCountdown();
                                paraTempo = true;

                                //saiu do 0
                                while (player.sensorValue > Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    FlowAction(player.picoExpiratorio);
                                    yield return(null);
                                }

                                //voltou pro 0
                                finalScoreMenu.pikeString[0] = player.picoExpiratorio.ToString();
                                TextPanel.SetActive(true);

                                if (jogou)
                                {
                                    displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                    SoundManager.Instance.PlaySound("Success");
                                }

                                player.picoExpiratorio = 0;
                                break;

                            case 3:
                                RestauraVariaveis();
                                break;

                            case 4:
                                displayHowTo.text = "";
                                TextPanel.SetActive(false);
                                while (player.sensorValue <= Pacient.Loaded.ManoThreshold * 2 && jogou)
                                {
                                    yield return(null);
                                }

                                StopCountdown();
                                paraTempo = true;

                                //saiu do 0
                                while (player.sensorValue > Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    FlowAction(player.picoExpiratorio);
                                    yield return(null);
                                }

                                //voltou pro 0
                                finalScoreMenu.pikeString[1] = player.picoExpiratorio.ToString();
                                TextPanel.SetActive(true);

                                if (jogou)
                                {
                                    displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                    SoundManager.Instance.PlaySound("Success");
                                }

                                player.picoExpiratorio = 0;
                                break;

                            case 5:
                                RestauraVariaveis();
                                break;

                            case 6:
                                displayHowTo.text = "";
                                TextPanel.SetActive(false);
                                while (player.sensorValue <= Pacient.Loaded.ManoThreshold * 2 && jogou)
                                {
                                    yield return(null);
                                }

                                StopCountdown();
                                paraTempo = true;

                                //saiu do 0
                                while (player.sensorValue > Pacient.Loaded.ManoThreshold && jogou)
                                {
                                    FlowAction(player.picoExpiratorio);
                                    yield return(null);
                                }

                                //voltou pro 0
                                finalScoreMenu.pikeString[2] = player.picoExpiratorio.ToString();
                                TextPanel.SetActive(true);

                                if (jogou)
                                {
                                    displayHowTo.text = "Parabéns!\nPressione [Enter] para ver a sua pontuação.";
                                    SoundManager.Instance.PlaySound("Success");
                                }

                                player.picoExpiratorio = 0;
                                scm.StopSampling();
                                FindObjectOfType <ManoLogger>().StopLogging();

                                break;
                            }
                            ppasso = false;
                        }
                        else
                        {
                            // Se a Cinta Extensora estiver conectada
                            if (scc.IsConnected)
                            {
                                switch (passo)
                                {
                                case 1:
                                    displayHowTo.text = "Pressione [Enter] e assopre o mais forte que conseguir dentro do tempo.";
                                    break;

                                case 2:

                                    scc.StartSampling();
                                    scc.Recalibrate();


                                    displayHowTo.text = "";

                                    TextPanel.SetActive(false);

                                    while (player.sensorValue <= Pacient.Loaded.CintaThreshold * 2 && jogou)
                                    {
                                        yield return(null);
                                    }

                                    StopCountdown();
                                    paraTempo = true;

                                    //saiu do 0
                                    while (player.sensorValue > Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        FlowAction(player.picoExpiratorio);
                                        yield return(null);
                                    }

                                    //voltou pro 0
                                    finalScoreMenu.pikeString[0] = player.picoExpiratorio.ToString();
                                    TextPanel.SetActive(true);

                                    if (jogou)
                                    {
                                        displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                        SoundManager.Instance.PlaySound("Success");
                                    }

                                    player.picoExpiratorio = 0;
                                    break;

                                case 3:
                                    RestauraVariaveis();
                                    break;

                                case 4:
                                    displayHowTo.text = "";
                                    TextPanel.SetActive(false);
                                    while (player.sensorValue <= Pacient.Loaded.CintaThreshold * 2 && jogou)
                                    {
                                        yield return(null);
                                    }

                                    StopCountdown();
                                    paraTempo = true;

                                    //saiu do 0
                                    while (player.sensorValue > Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        FlowAction(player.picoExpiratorio);
                                        yield return(null);
                                    }

                                    //voltou pro 0
                                    finalScoreMenu.pikeString[1] = player.picoExpiratorio.ToString();
                                    TextPanel.SetActive(true);

                                    if (jogou)
                                    {
                                        displayHowTo.text = "Parabéns!\nPressione [Enter] para ir para a proxima rodada.";
                                        SoundManager.Instance.PlaySound("Success");
                                    }

                                    player.picoExpiratorio = 0;
                                    break;

                                case 5:
                                    RestauraVariaveis();
                                    break;

                                case 6:
                                    displayHowTo.text = "";
                                    TextPanel.SetActive(false);
                                    while (player.sensorValue <= Pacient.Loaded.CintaThreshold * 2 && jogou)
                                    {
                                        yield return(null);
                                    }

                                    StopCountdown();
                                    paraTempo = true;

                                    //saiu do 0
                                    while (player.sensorValue > Pacient.Loaded.CintaThreshold && jogou)
                                    {
                                        FlowAction(player.picoExpiratorio);
                                        yield return(null);
                                    }

                                    //voltou pro 0
                                    finalScoreMenu.pikeString[2] = player.picoExpiratorio.ToString();
                                    TextPanel.SetActive(true);

                                    if (jogou)
                                    {
                                        displayHowTo.text = "Parabéns!\nPressione [Enter] para ver a sua pontuação.";
                                        SoundManager.Instance.PlaySound("Success");
                                    }

                                    player.picoExpiratorio = 0;
                                    scc.StopSampling();
                                    FindObjectOfType <CintaLogger>().StopLogging();

                                    break;
                                }
                                ppasso = false;
                            }
                        }
                    }   ////////////////////////////////////////
                }
                yield return(null);
            }
        }
Exemple #3
0
        //Incremental states(put them into the correct order)
        private IEnumerator PlayGame()
        {
            while (!finished)
            {
                sco.StartSampling();

                while (!scp.IsConnected && !scm.IsConnected && !scc.IsConnected)
                {
                    state = -1;
                    TextPanel.SetActive(true);
                    displayHowTo.text = "Nenhum dispositivo de controle conectado! Conecte e volte ao menu principal.";
                    yield return(null);
                }

                // Se o PITACO estiver conectado
                if (scp.IsConnected)
                {
                    switch (state)
                    {
                    case 1:     //Introduction
                        displayHowTo.text = "Bem-Vindo ao jogo do copo d'agua![ENTER]";

                        while (playable)
                        {
                            yield return(null);
                        }

                        playable = true;
                        break;

                    case 2:
                    case 4:
                    case 6:     //Pre-flow
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Pressione [Enter] e INSPIRE \n o mais forte que conseguir dentro do tempo.";
                        while (playable)
                        {
                            yield return(null);
                        }
                        CleanRound();
                        playable = true;
                        TextPanel.SetActive(false);
                        break;

                    case 3:
                    case 5:
                    case 7:     //Player's Flow
                        scp.StartSampling();
                        scp.Recalibrate();
                        displayHowTo.text = "";
                        EnablePlayerFlow(true, _roundNumber);
                        _roundNumber++;

                        while (playable)
                        {
                            StartCountdown();
                            yield return(null);
                        }
                        scp.StopSampling();
                        ResetCountDown();
                        playable = true;
                        break;

                    case 8:
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                        break;

                    case 9:
                        Debug.Log("Saving minigame data...");
                        GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(true);
                        FindObjectOfType <Core.MinigameLogger>().Save(GameDevice.Pitaco, RespiratoryExercise.InspiratoryPeak, Minigame.WaterGame);
                        GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(false);
                        Debug.Log("Minigame logs saved.");

                        NotPlayable();
                        break;

                    case 10:
                        TextPanel.SetActive(false);
                        ShowFinalScore();
                        break;

                    case 99:
                        TextPanel.SetActive(true);
                        while (playable)
                        {
                            yield return(null);
                        }
                        playable = true;
                        break;
                    }
                }
                else
                {
                    // Se o Mano estiver conectado
                    if (scm.IsConnected)
                    {
                        switch (state)
                        {
                        case 1:     //Introduction
                            displayHowTo.text = "Bem-Vindo ao jogo do copo d'agua![ENTER]";

                            while (playable)
                            {
                                yield return(null);
                            }

                            playable = true;
                            break;

                        case 2:
                        case 4:
                        case 6:     //Pre-flow
                            TextPanel.SetActive(true);
                            displayHowTo.text = "Pressione [Enter] e INSPIRE \n o mais forte que conseguir dentro do tempo.";
                            while (playable)
                            {
                                yield return(null);
                            }
                            CleanRound();
                            playable = true;
                            TextPanel.SetActive(false);
                            break;

                        case 3:
                        case 5:
                        case 7:     //Player's Flow
                            scm.StartSampling();
                            scm.Recalibrate();
                            displayHowTo.text = "";
                            EnablePlayerFlow(true, _roundNumber);
                            _roundNumber++;

                            while (playable)
                            {
                                StartCountdown();
                                yield return(null);
                            }
                            scm.StopSampling();
                            ResetCountDown();
                            playable = true;
                            break;

                        case 8:
                            TextPanel.SetActive(true);
                            displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                            break;

                        case 9:
                            Debug.Log("Saving minigame data...");
                            GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(true);
                            FindObjectOfType <Core.MinigameLogger>().Save(GameDevice.Mano, RespiratoryExercise.InspiratoryPeak, Minigame.WaterGame);
                            GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(false);
                            Debug.Log("Minigame logs saved.");

                            NotPlayable();
                            break;

                        case 10:
                            TextPanel.SetActive(false);
                            ShowFinalScore();
                            break;

                        case 99:
                            TextPanel.SetActive(true);
                            while (playable)
                            {
                                yield return(null);
                            }
                            playable = true;
                            break;
                        }
                    }
                    else
                    {
                        // Se a CINTA estiver conectada
                        if (scc.IsConnected)
                        {
                            switch (state)
                            {
                            case 1:     //Introduction
                                displayHowTo.text = "Bem-Vindo ao jogo do copo d'agua![ENTER]";

                                while (playable)
                                {
                                    yield return(null);
                                }

                                playable = true;
                                break;

                            case 2:
                            case 4:
                            case 6:     //Pre-flow
                                TextPanel.SetActive(true);
                                displayHowTo.text = "Pressione [Enter] e INSPIRE \n o mais forte que conseguir dentro do tempo.";
                                while (playable)
                                {
                                    yield return(null);
                                }
                                CleanRound();
                                playable = true;
                                TextPanel.SetActive(false);
                                break;

                            case 3:
                            case 5:
                            case 7:     //Player's Flow
                                scc.StartSampling();
                                scc.Recalibrate();
                                displayHowTo.text = "";
                                EnablePlayerFlow(true, _roundNumber);
                                _roundNumber++;

                                while (playable)
                                {
                                    StartCountdown();
                                    yield return(null);
                                }
                                scc.StopSampling();
                                ResetCountDown();
                                playable = true;
                                break;

                            case 8:
                                TextPanel.SetActive(true);
                                displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                                break;

                            case 9:
                                Debug.Log("Saving minigame data...");
                                GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(true);
                                FindObjectOfType <Core.MinigameLogger>().Save(GameDevice.Cinta, RespiratoryExercise.InspiratoryPeak, Minigame.WaterGame);
                                GameObject.Find("Canvas").transform.Find("SavingBgPanel").gameObject.SetActive(false);
                                Debug.Log("Minigame logs saved.");

                                NotPlayable();
                                break;

                            case 10:
                                TextPanel.SetActive(false);
                                ShowFinalScore();
                                break;

                            case 99:
                                TextPanel.SetActive(true);
                                while (playable)
                                {
                                    yield return(null);
                                }
                                playable = true;
                                break;
                            }
                        }
                    }
                }

                yield return(null);
            }
            sco.StopSampling();
        }
Exemple #4
0
        //Incremental states(put them into the correct order)
        private IEnumerator PlayGame()
        {
            while (!finished)
            {
                while (!scp.IsConnected && !scm.IsConnected && !scc.IsConnected)
                {
                    state = -1;
                    TextPanel.SetActive(true);
                    displayHowTo.text = "Nenhum dispositivo de controle conectado! Conecte e volte ao menu principal.";
                    yield return(null);
                }

                // Se o PITACO estiver conectado
                if (scp.IsConnected)
                {
                    switch (state)
                    {
                    case 1:    //Introduction
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Bem-Vindo ao jogo Coletando as Folhas! Pressione [ENTER] para continuar.";
                        while (playable)
                        {
                            yield return(null);
                        }

                        playable = true;
                        break;


                    case 2:
                    case 4:
                    case 6:    //Pre-flow
                        scp.Recalibrate();
                        scp.StartSamplingDelayed();
                        ResetCountDown();
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Pressione [Enter] e RESPIRE normalmente dentro do tempo para coletar as folhas.";
                        while (playable)
                        {
                            yield return(null);
                        }
                        CleanRound();
                        playable = true;
                        TextPanel.SetActive(false);
                        break;

                    case 3:
                    case 5:
                    case 7:    //Player's Flow
                        displayHowTo.text = "";

                        EnablePlayerFlow(true);
                        while (!timeOver && playable)
                        {
                            StartCountdown();
                            yield return(null);
                        }
                        Debug.Log("Terminei a jogada!");

                        _scorer.PutRoundScore(_roundNumber);
                        _roundNumber++;
                        ResetCountDown();
                        timeOver = false;
                        playable = true;
                        break;

                    case 8:
                        scp.StopSampling();
                        FindObjectOfType <Core.Util.PitacoLogger>().StopLogging();
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                        break;

                    case 9:
                        TextPanel.SetActive(false);
                        SoundManager.Instance.PlaySound("Finished");
                        ShowFinalScore();
                        break;

                    case 99:
                        TextPanel.SetActive(true);
                        while (playable)
                        {
                            yield return(null);
                        }
                        playable = true;
                        break;
                    }
                }
                else
                { ////////////////////
                    // Se o Mano estiver conectado
                    if (scm.IsConnected)
                    {
                        switch (state)
                        {
                        case 1:    //Introduction
                            TextPanel.SetActive(true);
                            displayHowTo.text = "Bem-Vindo ao jogo Coletando as Folhas! Pressione [ENTER] para continuar.";
                            while (playable)
                            {
                                yield return(null);
                            }

                            playable = true;
                            break;


                        case 2:
                        case 4:
                        case 6:    //Pre-flow
                            scm.Recalibrate();
                            scm.StartSamplingDelayed();
                            ResetCountDown();
                            TextPanel.SetActive(true);
                            displayHowTo.text = "Pressione [Enter] e RESPIRE normalmente dentro do tempo para coletar as folhas.";
                            while (playable)
                            {
                                yield return(null);
                            }
                            CleanRound();
                            playable = true;
                            TextPanel.SetActive(false);
                            break;

                        case 3:
                        case 5:
                        case 7:    //Player's Flow
                            displayHowTo.text = "";

                            EnablePlayerFlow(true);
                            while (!timeOver && playable)
                            {
                                StartCountdown();
                                yield return(null);
                            }
                            Debug.Log("Terminei a jogada!");

                            _scorer.PutRoundScore(_roundNumber);
                            _roundNumber++;
                            ResetCountDown();
                            timeOver = false;
                            playable = true;
                            break;

                        case 8:
                            scm.StopSampling();
                            FindObjectOfType <Core.Util.ManoLogger>().StopLogging();
                            TextPanel.SetActive(true);
                            displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                            break;

                        case 9:
                            TextPanel.SetActive(false);
                            SoundManager.Instance.PlaySound("Finished");
                            ShowFinalScore();
                            break;

                        case 99:
                            TextPanel.SetActive(true);
                            while (playable)
                            {
                                yield return(null);
                            }
                            playable = true;
                            break;
                        }
                    }
                    else
                    { ////////////////////
                        // Se a CINTA Extensora estiver conectada
                        if (scc.IsConnected)
                        {
                            switch (state)
                            {
                            case 1:    //Introduction
                                TextPanel.SetActive(true);
                                displayHowTo.text = "Bem-Vindo ao jogo Coletando as Folhas! Pressione [ENTER] para continuar.";
                                while (playable)
                                {
                                    yield return(null);
                                }

                                playable = true;
                                break;


                            case 2:
                            case 4:
                            case 6:    //Pre-flow
                                scc.Recalibrate();
                                scc.StartSamplingDelayed();
                                ResetCountDown();
                                TextPanel.SetActive(true);
                                displayHowTo.text = "Pressione [Enter] e RESPIRE normalmente dentro do tempo para coletar as folhas.";
                                while (playable)
                                {
                                    yield return(null);
                                }
                                CleanRound();
                                playable = true;
                                TextPanel.SetActive(false);
                                break;

                            case 3:
                            case 5:
                            case 7:    //Player's Flow
                                displayHowTo.text = "";

                                EnablePlayerFlow(true);
                                while (!timeOver && playable)
                                {
                                    StartCountdown();
                                    yield return(null);
                                }
                                Debug.Log("Terminei a jogada!");

                                _scorer.PutRoundScore(_roundNumber);
                                _roundNumber++;
                                ResetCountDown();
                                timeOver = false;
                                playable = true;
                                break;

                            case 8:
                                scc.StopSampling();
                                FindObjectOfType <Core.Util.CintaLogger>().StopLogging();
                                TextPanel.SetActive(true);
                                displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                                break;

                            case 9:
                                TextPanel.SetActive(false);
                                SoundManager.Instance.PlaySound("Finished");
                                ShowFinalScore();
                                break;

                            case 99:
                                TextPanel.SetActive(true);
                                while (playable)
                                {
                                    yield return(null);
                                }
                                playable = true;
                                break;
                            }
                        }
                    }
                }


                yield return(null);
            }
        }
Exemple #5
0
        //Incremental states(put them into the correct order)
        private IEnumerator PlayGame()
        {
            while (!finished)
            {
                while (!scp.IsConnected && !scm.IsConnected && !scc.IsConnected)
                {
                    state = -1;
                    TextPanel.SetActive(true);
                    displayHowTo.text = "Nenhum dispositivo de controle conectado! Conecte e volte ao menu principal.";
                    yield return(null);
                }


                // Se o Pitaco estiver conectado
                if (scp.IsConnected)
                {
                    switch (state)
                    {
                    case 1:     //Introduction
                        displayHowTo.text = "Bem-Vindo ao jogo do copo d'agua![ENTER]";

                        while (playable)
                        {
                            yield return(null);
                        }

                        playable = true;
                        break;

                    case 2:
                    case 4:
                    case 6:     //Pre-flow
                        scp.Recalibrate();
                        scp.StartSamplingDelayed();
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Pressione [Enter] e INSPIRE \n o mais forte que conseguir dentro do tempo.";
                        while (playable)
                        {
                            yield return(null);
                        }
                        CleanRound();
                        playable = true;
                        TextPanel.SetActive(false);
                        break;

                    case 3:
                    case 5:
                    case 7:     //Player's Flow
                        displayHowTo.text = "";
                        EnablePlayerFlow(true, _roundNumber);
                        _roundNumber++;

                        while (playable)
                        {
                            StartCountdown();
                            yield return(null);
                        }

                        ResetCountDown();
                        playable = true;
                        break;

                    case 8:
                        scp.StopSampling();
                        FindObjectOfType <Core.Util.PitacoLogger>().StopLogging();
                        TextPanel.SetActive(true);
                        displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                        Debug.Log("Saving minigame data...");
                        FindObjectOfType <Core.MinigameLogger>().Save();
                        break;

                    case 9:
                        TextPanel.SetActive(false);
                        ShowFinalScore();
                        break;

                    case 99:
                        TextPanel.SetActive(true);
                        while (playable)
                        {
                            yield return(null);
                        }
                        playable = true;
                        break;
                    }
                }
                else
                {
                    // Se o Mano estiver conectado
                    if (scm.IsConnected)
                    {
                        switch (state)
                        {
                        case 1: //Introduction
                            displayHowTo.text = "Bem-Vindo ao jogo do copo d'agua![ENTER]";

                            while (playable)
                            {
                                yield return(null);
                            }

                            playable = true;
                            break;

                        case 2:
                        case 4:
                        case 6: //Pre-flow
                            scm.Recalibrate();
                            scm.StartSamplingDelayed();
                            TextPanel.SetActive(true);
                            displayHowTo.text = "Pressione [Enter] e INSPIRE \n o mais forte que conseguir dentro do tempo.";
                            while (playable)
                            {
                                yield return(null);
                            }
                            CleanRound();
                            playable = true;
                            TextPanel.SetActive(false);
                            break;

                        case 3:
                        case 5:
                        case 7: //Player's Flow
                            displayHowTo.text = "";
                            EnablePlayerFlow(true, _roundNumber);
                            _roundNumber++;

                            while (playable)
                            {
                                StartCountdown();
                                yield return(null);
                            }

                            ResetCountDown();
                            playable = true;
                            break;

                        case 8:
                            scm.StopSampling();
                            FindObjectOfType <Core.Util.ManoLogger>().StopLogging();
                            TextPanel.SetActive(true);
                            displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                            Debug.Log("Saving minigame data...");
                            FindObjectOfType <Core.MinigameLogger>().Save();
                            break;

                        case 9:
                            TextPanel.SetActive(false);
                            ShowFinalScore();
                            break;

                        case 99:
                            TextPanel.SetActive(true);
                            while (playable)
                            {
                                yield return(null);
                            }
                            playable = true;
                            break;
                        }
                    }
                    else
                    {
                        // Se a Cinta estiver conectada
                        if (scc.IsConnected)
                        {
                            switch (state)
                            {
                            case 1: //Introduction
                                displayHowTo.text = "Bem-Vindo ao jogo do copo d'agua![ENTER]";

                                while (playable)
                                {
                                    yield return(null);
                                }

                                playable = true;
                                break;

                            case 2:
                            case 4:
                            case 6: //Pre-flow
                                scc.Recalibrate();
                                scc.StartSamplingDelayed();
                                TextPanel.SetActive(true);
                                displayHowTo.text = "Pressione [Enter] e INSPIRE \n o mais forte que conseguir dentro do tempo.";
                                while (playable)
                                {
                                    yield return(null);
                                }
                                CleanRound();
                                playable = true;
                                TextPanel.SetActive(false);
                                break;

                            case 3:
                            case 5:
                            case 7: //Player's Flow
                                displayHowTo.text = "";
                                EnablePlayerFlow(true, _roundNumber);
                                _roundNumber++;

                                while (playable)
                                {
                                    StartCountdown();
                                    yield return(null);
                                }

                                ResetCountDown();
                                playable = true;
                                break;

                            case 8:
                                scc.StopSampling();
                                FindObjectOfType <Core.Util.CintaLogger>().StopLogging();
                                TextPanel.SetActive(true);
                                displayHowTo.text = "Pressione [Enter] para visualizar sua pontuação.";
                                Debug.Log("Saving minigame data...");
                                FindObjectOfType <Core.MinigameLogger>().Save();
                                break;

                            case 9:
                                TextPanel.SetActive(false);
                                ShowFinalScore();
                                break;

                            case 99:
                                TextPanel.SetActive(true);
                                while (playable)
                                {
                                    yield return(null);
                                }
                                playable = true;
                                break;
                            }
                        }
                    }
                }   ////////////////////////////////////////



                yield return(null);
            }
        }