示例#1
0
        private IEnumerator ProcessData()
        {
            while (true)
            {
                yield return(new WaitForEndOfFrame());

                try
                {
                    string result = serialPort.ReadLine();

                    // Tests
                    //string result = SimulateReadLine();

                    string[] resultData = result.Split(';');

                    ArdKeyCode[] keyCodes = (ArdKeyCode[])Enum.GetValues(typeof(ArdKeyCode));
                    for (int i = 0; i < keyCodes.Length; i++)
                    {
                        ArdKeyCode keyCode = keyCodes[i];
                        ArdButton  button  = buttons[keyCode];
                        int        data    = int.Parse(resultData[i]);

                        button.ProcessData(data);
                    }

                    string leituraSensor = resultData[resultData.Length - 1];
                    Debug.Log("Leitura Sensor: " + leituraSensor);
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
            }
        }
示例#2
0
        private IEnumerator ProcessData()
        {
            while (true)
            {
                yield return(new WaitForEndOfFrame());

                try
                {
                    string result = serialPort.ReadLine();

                    // Tests
                    //string result = SimulateReadLine();

                    string[] resultData = result.Split(';');

                    ArdKeyCode[] keyCodes = (ArdKeyCode[])Enum.GetValues(typeof(ArdKeyCode));
                    for (int i = 0; i < keyCodes.Length; i++)
                    {
                        ArdKeyCode keyCode = keyCodes[i];
                        ArdButton  button  = buttons[keyCode];
                        data = int.Parse(resultData[i]);

                        button.ProcessData(data);
                    }

                    data = int.Parse(resultData[keyCodes.Length - 1]);

                    if (data != null)
                    {
                        //print("Data: " + data);
                        if (data <= 256)
                        {
                            PlayerPrefs.SetInt("Dificuldade", 1);
                        }
                        else if (data > 256 && data <= 512)
                        {
                            PlayerPrefs.SetInt("Dificuldade", 2);
                        }
                        else if (data > 512 && data <= 768)
                        {
                            PlayerPrefs.SetInt("Dificuldade", 3);
                        }
                        else if (data > 768)
                        {
                            PlayerPrefs.SetInt("Dificuldade", 4);
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
            }
        }
示例#3
0
        private IEnumerator ProcessData()
        {
            while (true)
            {
                yield return(new WaitForEndOfFrame());

                try
                {
                    string result = serialPort.ReadLine();

                    // Tests
                    // string result = SimulateReadLine(); // funcionou com o teste teclado

                    Debug.Log(result);
                    Debug.Log("teste");

                    string[] resultData = result.Split(';');

                    ArdKeyCode[] keyCodes = (ArdKeyCode[])Enum.GetValues(typeof(ArdKeyCode));
                    Debug.Log("Tamanho vetor: " + keyCodes.Length);
                    for (int i = 0; i < keyCodes.Length; i++)
                    {
                        ArdKeyCode keyCode = keyCodes[i];
                        ArdButton  button  = buttons[keyCode];
                        data = int.Parse(resultData[i]);

                        button.ProcessData(data);
                    }


                    PlayerStats.forcaLuz = data;
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
            }
        }