Exemplo n.º 1
0
        private void StartStage()
        {
            if (IsRunning)
            {
                if (GameManager.GameIsPaused)
                {
                    GameManager.UnPauseGame();
                }
                // else
                //     return;
            }


            // Conectando/reconectando dispositivos "OnTheFly", ou seja, em tempo de execução.
            Debug.Log("CONECTANDO/RECONECTANDO DISPOSITIVOS...");

            serialControllerPitaco.Connect();
            serialControllerMano.Connect();
            serialControllerCinta.Connect();

            serialControllerPitaco.StartSamplingDelayed();
            serialControllerMano.StartSamplingDelayed();
            serialControllerCinta.StartSamplingDelayed();

            IsRunning = true;
            OnStageStart?.Invoke();
        }
Exemplo n.º 2
0
        private void StartStage()
        {
            if (IsRunning)
            {
                if (GameManager.GameIsPaused)
                {
                    GameManager.UnPauseGame();
                }
            }


            serialControllerPitaco.StartSamplingDelayed();
            serialControllerMano.StartSamplingDelayed();
            serialControllerCinta.StartSamplingDelayed();
            serialControllerOximetro.StartSamplingDelayed();

            IsRunning = true;
            OnStageStart?.Invoke();
        }
Exemplo n.º 3
0
        private void Start()
        {
            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();
            sco = FindObjectOfType <SerialControllerOximetro>();

            stop          = false;
            waitSignal    = false;
            x             = 0;
            lastCoroutine = null;
            FindObjectOfType <RoundManager>().AuthorizePlayerFlowEvent += ReceivedMessage;


            if (scp.IsConnected) // Se PITACO conectado
            {
                scp.OnSerialMessageReceived += OnMessageReceivedPitaco;
                scp.StartSamplingDelayed();
            }
            else
            {
                if (scm.IsConnected) // Se MANO conectado
                {
                    scm.OnSerialMessageReceived += OnMessageReceivedMano;
                    scm.StartSamplingDelayed();
                }
                else
                {
                    if (scc.IsConnected) // Se CINTA conectada
                    {
                        scc.OnSerialMessageReceived += OnMessageReceivedCinta;
                        scc.StartSamplingDelayed();
                    }
                }
            }

            if (sco.IsConnected) // Se OXÍMETRO conectado
            {
                sco.OnSerialMessageReceived += OnMessageReceivedOximetro;
            }
        }
Exemplo n.º 4
0
        void Start()
        {
            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();


            _spawner      = FindObjectOfType <Spawner>();
            _scorer       = FindObjectOfType <Scorer>();
            stop          = false;
            waitSignal    = true;
            x             = 0;
            lastCoroutine = null;
            FindObjectOfType <RoundManager>().AuthorizePlayerFlowEvent += ReceivedMessage;

            if (scp.IsConnected) // Se PITACO conectado
            {
                scp.OnSerialMessageReceived += OnMessageReceived;
                scp.StartSamplingDelayed();
            }
            else
            {
                if (scm.IsConnected) // Se Mano conectado
                {
                    scm.OnSerialMessageReceived += OnMessageReceived;
                    scm.StartSamplingDelayed();
                }
                else
                {
                    if (scc.IsConnected) // Se CINTA conectada
                    {
                        scc.OnSerialMessageReceived += OnMessageReceived;
                        scc.StartSamplingDelayed();
                    }
                }
            }
        }
Exemplo n.º 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
                        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);
            }
        }
Exemplo n.º 6
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);
            }
        }