private void Awake()
        {
#if UNITY_EDITOR
            if (StageModel.Loaded == null)
            {
                StageModel.Loaded = testStage;
            }
            else
            {
                testStage = StageModel.Loaded;
            }
#endif

            spawner = FindObjectOfType <Spawner>();

            serialControllerPitaco = FindObjectOfType <SerialControllerPitaco>();
            serialControllerPitaco.OnSerialConnected += StartStage;

            serialControllerMano = FindObjectOfType <SerialControllerMano>();
            serialControllerMano.OnSerialConnected += StartStage;

            serialControllerCinta = FindObjectOfType <SerialControllerCinta>();
            serialControllerCinta.OnSerialConnected += StartStage;

#if !UNITY_EDITOR
            // Caso algum dispositivo de controle seja disconectado.
            serialControllerPitaco.OnSerialDisconnected += PauseOnDisconnect;
            serialControllerMano.OnSerialDisconnected   += PauseOnDisconnect;
            serialControllerCinta.OnSerialDisconnected  += PauseOnDisconnect;
#endif

            FindObjectOfType <Player>().OnPlayerDeath += GameOver;

            Time.timeScale = 1f;
        }
Exemple #2
0
        private void LoadParameters()
        {
            if (scp == null)
            {
                scp = FindObjectOfType <SerialControllerPitaco>();
            }

            if (scm == null)
            {
                scm = FindObjectOfType <SerialControllerMano>();
            }

            if (scc == null)
            {
                scc = FindObjectOfType <SerialControllerCinta>();
            }

            if (sco == null)
            {
                sco = FindObjectOfType <SerialControllerOximetro>();
            }

            if (scp.IsConnected || scm.IsConnected || scc.IsConnected || sco.IsConnected)
            {
                StartCoroutine(Load());
            }
        }
Exemple #3
0
 private void Awake()
 {
     scp = FindObjectOfType <SerialControllerPitaco>();
     scm = FindObjectOfType <SerialControllerMano>();
     scc = FindObjectOfType <SerialControllerCinta>();
     sco = FindObjectOfType <SerialControllerOximetro>();
 }
Exemple #4
0
        private void OnEnable()
        {
            parameters = null;
            id         = Pacient.Loaded.Id;

            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();

            Load();
        }
Exemple #5
0
        private void Awake()
        {
            if (serialController == null)
            {
                serialController = FindObjectOfType <SerialControllerMano>();
            }

            if (serialController == null)
            {
                Debug.LogWarning("Serial Controller instance not found!");
            }
        }
Exemple #6
0
        private void Start()
        {
            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();

            FindObjectOfType <Player>().HaveStarEvent             += ReceivedStars;
            FindObjectOfType <RoundManager>().ShowFinalScoreEvent += ShowFinalScore;
            FindObjectOfType <RoundManager>().CleanRoundEvent     += CleanScores;
            starsUI     = gameObject.GetComponentsInChildren <Image>();
            totalScores = new int[3];
        }
Exemple #7
0
        private void Awake()
        {
            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();
            sco = FindObjectOfType <SerialControllerOximetro>();


            _minigameOverviewSendDto = new MinigameOverviewSendDto {
                FlowDataRound = new List <FlowDataMinigame>()
            };
            _pitacoLogger   = FindObjectOfType <PitacoLogger>();
            _manoLogger     = FindObjectOfType <ManoLogger>();
            _cintaLogger    = FindObjectOfType <CintaLogger>();
            _oximetroLogger = FindObjectOfType <OximetroLogger>();
        }
Exemple #8
0
        private IEnumerator Flow()
        {
            while (!stop)
            {
                var peak = 0f;
                scp = FindObjectOfType <SerialControllerPitaco>();
                scm = FindObjectOfType <SerialControllerMano>();
                scc = FindObjectOfType <SerialControllerCinta>();


                if (scp.IsConnected) // Se PITACO conectado
                {
                    sensorValue = sensorValue <-Pacient.Loaded.PitacoThreshold || sensorValue> Pacient.Loaded.PitacoThreshold ? sensorValue : 0f;
                    peak        = sensorValue > 0 ? (Pacient.Loaded.CapacitiesPitaco.ExpPeakFlow * GameManager.CapacityMultiplierMinigames) * 0.5f : (-Pacient.Loaded.CapacitiesPitaco.InsPeakFlow * GameManager.CapacityMultiplierMinigames);
                }
                else
                {
                    if (scm.IsConnected) // Se Mano conectado
                    {
                        sensorValue = sensorValue <-Pacient.Loaded.ManoThreshold || sensorValue> Pacient.Loaded.ManoThreshold ? sensorValue : 0f;
                        peak        = sensorValue > 0 ? (Pacient.Loaded.CapacitiesMano.ExpPeakFlow * GameManager.CapacityMultiplierMinigames) * 0.5f : (-Pacient.Loaded.CapacitiesMano.InsPeakFlow * GameManager.CapacityMultiplierMinigames);
                    }
                    else
                    {
                        if (scc.IsConnected) // Se CINTA conectada
                        {
                            sensorValue = sensorValue <-Pacient.Loaded.CintaThreshold || sensorValue> Pacient.Loaded.CintaThreshold ? sensorValue : 0f;
                            peak        = sensorValue > 0 ? (Pacient.Loaded.CapacitiesCinta.ExpPeakFlow * GameManager.CapacityMultiplierMinigames) * 0.5f : (-Pacient.Loaded.CapacitiesCinta.InsPeakFlow * GameManager.CapacityMultiplierMinigames);
                        }
                    }
                }


                var nextPosition = sensorValue * CameraLimits.Boundary / peak;

                nextPosition = Mathf.Clamp(nextPosition, -CameraLimits.Boundary, CameraLimits.Boundary);

                var from = this.transform.position;
                var to   = new Vector3(this.transform.position.x, -nextPosition);

                this.transform.position = Vector3.Lerp(from, to, Time.deltaTime * 15f);

                playerRespiratoryInfo.Add(Time.time, sensorValue);

                yield return(null);
            }
        }
        private void OnEnable()
        {
            if (serialControllerMano == null)
            {
                serialControllerMano = FindObjectOfType <SerialControllerMano>();
            }


            if (serialControllerMano.IsConnected)
            {
                ManoConnected = true;
            }



            this.GetComponent <Button>().interactable = Pacient.Loaded != null && (ManoConnected == true);
        }
        private void Awake()
        {
            _serialController = FindObjectOfType <SerialControllerMano>();
            _serialController.OnSerialMessageReceived += OnSerialMessageReceived;
            _tmpCapacities     = new Capacities();
            _flowWatch         = new Stopwatch();
            _timerWatch        = new Stopwatch();
            _capturedSamples   = new Dictionary <float, float>();
            _calibrationLogger = new CalibrationLoggerMano();

            _dudeObject.transform.Translate(-Camera.main.orthographicSize * Camera.main.aspect + (_dudeObject.transform.localScale.x / 2f), 0f, 0f);

            if (CalibrationToLoad > 0)
            {
                _currentExercise = CalibrationToLoad;
            }
        }
Exemple #11
0
        protected override void Awake()
        {
            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();
            sco = FindObjectOfType <SerialControllerOximetro>();


            sb.AppendLine("time;tag;instanceId;posX;posY");
            plr             = FindObjectOfType <Player>();
            spwn            = FindObjectOfType <Spawner>();
            scr             = FindObjectOfType <Scorer>();
            _pitacoLogger   = FindObjectOfType <PitacoLogger>();
            _manoLogger     = FindObjectOfType <ManoLogger>();
            _cintaLogger    = FindObjectOfType <CintaLogger>();
            _oximetroLogger = FindObjectOfType <OximetroLogger>();
            FindObjectOfType <StageManager>().OnStageEnd += StopLogging;
        }
Exemple #12
0
        private void OnEnable()
        {
            PitacoPrecisaCalib = false;
            ManoPrecisaCalib   = false;
            CintaPrecisaCalib  = false;

            if (serialControllerPitaco == null)
            {
                serialControllerPitaco = FindObjectOfType <SerialControllerPitaco>();
            }

            if (serialControllerMano == null)
            {
                serialControllerMano = FindObjectOfType <SerialControllerMano>();
            }

            if (serialControllerCinta == null)
            {
                serialControllerCinta = FindObjectOfType <SerialControllerCinta>();
            }

            if (Pacient.Loaded.Name != null)
            {
                if (serialControllerPitaco.IsConnected && !Pacient.Loaded.IsCalibrationPitacoDone)
                {
                    PitacoPrecisaCalib = true;
                }

                if (serialControllerMano.IsConnected && !Pacient.Loaded.IsCalibrationManoDone)
                {
                    ManoPrecisaCalib = true;
                }

                if (serialControllerCinta.IsConnected && !Pacient.Loaded.IsCalibrationCintaDone)
                {
                    CintaPrecisaCalib = true;
                }

                if (PitacoPrecisaCalib == true || ManoPrecisaCalib == true || CintaPrecisaCalib == true)
                {
                    SysMessage.Info("Para começar a jogar, você precisa \ncalibrar todos os dispositivos conectados!");
                }
            }
        }
        private void OnEnable()
        {
            if (serialControllerPitaco == null)
            {
                serialControllerPitaco = FindObjectOfType <SerialControllerPitaco>();
            }

            if (serialControllerMano == null)
            {
                serialControllerMano = FindObjectOfType <SerialControllerMano>();
            }

            if (serialControllerCinta == null)
            {
                serialControllerCinta = FindObjectOfType <SerialControllerCinta>();
            }

            if (serialControllerPitaco.IsConnected && !Pacient.Loaded.IsCalibrationPitacoDone)
            {
                PitacoPrecisaCalib = true;
            }

            if (serialControllerMano.IsConnected && !Pacient.Loaded.IsCalibrationManoDone)
            {
                ManoPrecisaCalib = true;
            }

            if (serialControllerCinta.IsConnected && !Pacient.Loaded.IsCalibrationCintaDone)
            {
                CintaPrecisaCalib = true;
            }


            // if (PitacoPrecisaCalib == true || ManoPrecisaCalib == true || CintaPrecisaCalib == true)
            // {
            //     SysMessage.Info("Para começar a jogar, você precisa \ncalibrar todos os dispositivos conectados!");
            // }



            this.GetComponent <Button>().interactable = Pacient.Loaded != null && (PitacoPrecisaCalib == false && ManoPrecisaCalib == false && CintaPrecisaCalib == false);
        }
    // Start é chamado no início do primeiro frame
    private void OnEnable()
    {
        if (serialControllerPitaco == null)
        {
            serialControllerPitaco = FindObjectOfType <SerialControllerPitaco>();
        }

        if (serialControllerMano == null)
        {
            serialControllerMano = FindObjectOfType <SerialControllerMano>();
        }

        if (serialControllerCinta == null)
        {
            serialControllerCinta = FindObjectOfType <SerialControllerCinta>();
        }


        if (serialControllerPitaco.IsConnected)
        {
            PitacoConnected = true;
        }

        if (serialControllerMano.IsConnected)
        {
            ManoConnected = true;
        }

        if (serialControllerCinta.IsConnected)
        {
            CintaConnected = true;
        }


        if (Pacient.Loaded != null)
        {
            if ((PitacoConnected && !Pacient.Loaded.CalibrationPitacoDone) || (ManoConnected && !Pacient.Loaded.CalibrationManoDone) || (CintaConnected && !Pacient.Loaded.CalibrationCintaDone))
            {
                StartCoroutine(ExampleCoroutine());
            }
        }
    }
Exemple #15
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;
            }
        }
Exemple #16
0
        void Start()
        {
            if (scp == null)
            {
                scp = FindObjectOfType <SerialControllerPitaco>();
            }

            if (scm == null)
            {
                scm = FindObjectOfType <SerialControllerMano>();
            }

            if (scc == null)
            {
                scc = FindObjectOfType <SerialControllerCinta>();
            }

            if (sco == null)
            {
                sco = FindObjectOfType <SerialControllerOximetro>();
            }
        }
Exemple #17
0
        private void OnEnable()
        {
            PitacoPrecisaCalib = false;
            ManoPrecisaCalib   = false;
            CintaPrecisaCalib  = false;

            if (serialControllerPitaco == null)
            {
                serialControllerPitaco = FindObjectOfType <SerialControllerPitaco>();
            }

            if (serialControllerMano == null)
            {
                serialControllerMano = FindObjectOfType <SerialControllerMano>();
            }

            if (serialControllerCinta == null)
            {
                serialControllerCinta = FindObjectOfType <SerialControllerCinta>();
            }

            if (serialControllerPitaco.IsConnected && !Pacient.Loaded.IsCalibrationPitacoDone)
            {
                PitacoPrecisaCalib = true;
            }

            if (serialControllerMano.IsConnected && !Pacient.Loaded.IsCalibrationManoDone)
            {
                ManoPrecisaCalib = true;
            }

            if (serialControllerCinta.IsConnected && !Pacient.Loaded.IsCalibrationCintaDone)
            {
                CintaPrecisaCalib = true;
            }


            this.GetComponent <Button>().interactable = Pacient.Loaded != null && (PitacoPrecisaCalib == false && ManoPrecisaCalib == false && CintaPrecisaCalib == false);
        }
Exemple #18
0
        public void DisplayFinalScore(int score1, int score2, int score3)
        {
            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();

            finalScore[0].FillStarsFinal(score1);
            finalScore[1].FillStarsFinal(score2);
            finalScore[2].FillStarsFinal(score3);

            // Se o Pitaco estiver conectado
            if (scp.IsConnected)
            {
                peakText[0].text = "   Pico: " + PitacoFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[0])) + " L/min";
                peakText[1].text = "   Pico: " + PitacoFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[1])) + " L/min";
                peakText[2].text = "   Pico: " + PitacoFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[2])) + " L/min";
            }
            else
            {
                // Se o Mano estiver conectado
                if (scm.IsConnected)
                {
                    peakText[0].text = "   Pico: " + ManoFlowMath.ToCentimetersofWater(Parsers.Float(pikeString[0])) + " CmH2O";
                    peakText[1].text = "   Pico: " + ManoFlowMath.ToCentimetersofWater(Parsers.Float(pikeString[1])) + " CmH2O";
                    peakText[2].text = "   Pico: " + ManoFlowMath.ToCentimetersofWater(Parsers.Float(pikeString[2])) + " CmH2O";
                }
                else
                {
                    // Se a Cinta Extensora estiver conectada
                    if (scc.IsConnected)
                    {
                        peakText[0].text = "   Pico: " + CintaFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[0])) + " L/min";
                        peakText[1].text = "   Pico: " + CintaFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[1])) + " L/min";
                        peakText[2].text = "   Pico: " + CintaFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[2])) + " L/min";
                    }
                }
            }   ////////////////////////////////////////
        }
Exemple #19
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();
                    }
                }
            }
        }
Exemple #20
0
        private IEnumerator Flow(int round)
        {
            scp = FindObjectOfType <SerialControllerPitaco>();
            scm = FindObjectOfType <SerialControllerMano>();
            scc = FindObjectOfType <SerialControllerCinta>();

            if (scp.IsConnected) // Se PITACO conectado
            {
                //While player does not blow.
                while (sensorValuePitaco >= -Pacient.Loaded.PitacoThreshold * 2f)
                {
                    //Debug.Log($"Wait: {sensorValue}");
                    yield return(null);
                }

                //Player is blowing, take the highest value.
                while (sensorValuePitaco < -Pacient.Loaded.PitacoThreshold)
                {
                    //Debug.Log($"Blow: {sensorValue}");

                    if (sensorValuePitaco < maximumPeak)
                    {
                        maximumPeak = sensorValuePitaco;
                        //Debug.Log("Novo pico máximo: " + maximumPeak);
                    }

                    //calculate the percentage of the pike.
                    yield return(null);
                }
            }
            else
            {
                if (scm.IsConnected) // Se Mano conectado
                {
                    //While player does not blow.
                    while (sensorValueMano >= -Pacient.Loaded.ManoThreshold * 2f)
                    {
                        //Debug.Log($"Wait: {sensorValue}");
                        yield return(null);
                    }

                    //Player is blowing, take the highest value.
                    while (sensorValueMano < -Pacient.Loaded.ManoThreshold)
                    {
                        //Debug.Log($"Blow: {sensorValue}");

                        if (sensorValueMano < maximumPeak)
                        {
                            maximumPeak = sensorValueMano;
                            //Debug.Log("Novo pico máximo: " + maximumPeak);
                        }

                        //calculate the percentage of the pike.
                        yield return(null);
                    }
                }
                else
                {
                    if (scc.IsConnected) // Se CINTA conectada
                    {
                        //While player does not blow.
                        while (sensorValueCinta >= -Pacient.Loaded.CintaThreshold * 2f)
                        {
                            //Debug.Log($"Wait: {sensorValue}");
                            yield return(null);
                        }

                        //Player is blowing, take the highest value.
                        while (sensorValueCinta < -Pacient.Loaded.CintaThreshold)
                        {
                            //Debug.Log($"Blow: {sensorValue}");

                            if (sensorValueCinta < maximumPeak)
                            {
                                maximumPeak = sensorValueCinta;
                                //Debug.Log("Novo pico máximo: " + maximumPeak);
                            }

                            //calculate the percentage of the pike.
                            yield return(null);
                        }
                    }
                }
            }

            SoundManager.Instance.PlaySound("Success");

            var roundScore = CalculateFlowPike(maximumPeak);

            WriteMinigameLog(round, roundScore, PitacoFlowMath.ToLitresPerMinute(maximumPeak));
            waitSignal  = false;
            maximumPeak = 0f;
            OnAuthorize();
        }
Exemple #21
0
        private void OnStageSelected()
        {
            //Olhando se o Pitaco está conectado

            if (serialControllerPitaco == null)
            {
                serialControllerPitaco = FindObjectOfType <SerialControllerPitaco>();
            }

            if (serialControllerPitaco.IsConnected)
            {
                PitacoConnected = true;
            }

            //Olhando se o Mano está conectado
            if (serialControllerMano == null)
            {
                serialControllerMano = FindObjectOfType <SerialControllerMano>();
            }

            if (serialControllerMano.IsConnected)
            {
                ManoConnected = true;
            }

            //Olhando se a Cinta está conectada
            if (serialControllerCinta == null)
            {
                serialControllerCinta = FindObjectOfType <SerialControllerCinta>();
            }

            if (serialControllerCinta.IsConnected)
            {
                CintaConnected = true;
            }



            if (PitacoConnected == false && ManoConnected == false && CintaConnected == false)
            {
                SysMessage.Warning("Nenhum dispositivo de controle conectado! Conecte antes de jogar!");
                return;
            }



            if (!Pacient.Loaded.CalibrationPitacoDone && PitacoConnected == true)
            {
                SysMessage.Warning("Calibração não foi feita: PITACO!");
                return;
            }

            if (!Pacient.Loaded.CalibrationManoDone && ManoConnected == true)
            {
                SysMessage.Warning("Calibração não foi feita: MANO!");
                return;
            }

            if (!Pacient.Loaded.CalibrationCintaDone && CintaConnected == true)
            {
                SysMessage.Warning("Calibração não foi feita: CINTA!");
                return;
            }

#if !UNITY_EDITOR
            // Retirar esta parte, acredito que não seja necessaria
            // if (!FindObjectOfType<Ibit.Core.Serial.SerialController>().IsConnected)
            // {
            //     SysMessage.Warning("Pitaco não está conectado! Conecte antes de jogar!");
            //     return;
            // }
#endif

            StageModel.Loaded = stage;
            FindObjectOfType <SceneLoader>().LoadScene(1);
            Debug.Log($"Stage {stage.Id} loaded.");
        }