Example #1
0
 private void connect_Click(object sender, EventArgs e)
 {
     if (port.IsOpen)
     {
         port.Close();
         connect.Text = "Connect";
     }
     else
     {
         try
         {
             int    baudRate = Convert.ToInt32(this.baudBox.Text);
             string portName = comboBox1.Text;
             port.Open(portName, baudRate);
             connect.Text = "Disconnect";
         }
         catch (NullReferenceException)
         {
             MessageBox.Show("Error Opening Com Port: No Port Name Selected!");
         }
         catch (FormatException)
         {
             MessageBox.Show("Error Opening Com Port: Invalid Baud Rate!");
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error Opening Com Port: " + ex.Message);
         }
     }
 }
Example #2
0
 private void stopi()
 {
     sp.Close();
     CancelInvoke("Resolocation");
     source.clip = audioo[4];
     source.Play();
     girl.GetComponent <Animator>().Play("speak 6");
 }
Example #3
0
    private void stopi()
    {
        gg1[0].SetActive(false);
        gg1[1].SetActive(true);
        gg1[2].SetActive(true);
        gg1[3].SetActive(false);
        gg1[4].SetActive(true);
        sp.Close();
        CancelInvoke("Resolocation");

        girl.GetComponent <Animator>().Play("next" + k.ToString());
        k++;
    }
Example #4
0
 public static void Close()
 {
     SerialPortWrapper.Close();
 }
Example #5
0
    private void Resolocation()
    {
        {
            string s = sp.ReadLine();

            s = s.Substring(s.IndexOf("t") + 1, s.IndexOf(";") - s.IndexOf("t") - 1);
            f = (float.Parse(s) / 100);
            shkala.transform.position   = Vector3.Lerp(shkala.transform.position, new Vector3(shkala.transform.position.x, (-2.68f + (f * 0.05f) / 2), shkala.transform.position.z), 0.1f);
            shkala.transform.localScale = new Vector3(shkala.transform.localScale.x, 4.6737f + (f * 0.09096f) / 2, shkala.transform.localScale.z);
            text.text = (Mathf.Round(f)).ToString();
            if ((f < 20.5) && (f > 19.5) && (k == 1))
            {
                CancelInvoke("Resolocation");
                sp.Close();
                girl.GetComponent <Animator>().Play("speak 5");
                if (!source.isPlaying)
                {
                    source.clip = audioo[3];
                    source.Play();
                    sound_3 = false;
                }
            }
            if ((f < 15.5) && (f > 14.5) && (k == 2))
            {
                CancelInvoke("Resolocation");
                sp.Close();
                girl.GetComponent <Animator>().Play("speak 9");
                if (!source.isPlaying)
                {
                    source.clip = audioo[4];
                    source.Play();
                    sound_4 = false;
                }
            }
            if ((f < 30.5) && (f > 29.5) && (k == 3))
            {
                CancelInvoke("Resolocation");
                sp.Close();
                girl.GetComponent <Animator>().Play("speak 9");
                if (!source.isPlaying)
                {
                    source.clip = audioo[5];
                    source.Play();
                    sound_5 = false;
                }
            }
            if ((f > 13.5) && (f < 14.5) && (k == 4))
            {
                CancelInvoke("Resolocation");
                sp.Close();
                girl.GetComponent <Animator>().Play("speak 8");
                if (!source.isPlaying)
                {
                    source.clip = audioo[6];
                    source.Play();
                    sound_6 = false;
                }
            }
            if ((f < 30.5) && (f > 29.5) && (k == 5))
            {
                CancelInvoke("Resolocation");
                sp.Close();
                girl.GetComponent <Animator>().Play("speak 15");
                Fish.GetComponent <Animator>().Play("hot");
                if (!source.isPlaying)
                {
                    source.clip = audioo[8];
                    source.Play();
                }
            }
            if ((f < 25.5) && (f > 21.5) && (k == 6))
            {
                CancelInvoke("Resolocation");
                sp.Close();
                girl.GetComponent <Animator>().Play("speak 19");
                Fish.GetComponent <Animator>().Play("happy");
                if (!source.isPlaying)
                {
                    source.clip = audioo[11];
                    source.Play();
                }
            }
            if ((k == 7) || (k == 8) || (k == 9))
            {
                if (f - chea1 <= 0.2f)
                {
                    CancelInvoke("Resolocation");
                    sp.Close();
                    p++;
                    if (!source.isPlaying)
                    {
                        source.clip = audioo[13 + p];
                        source.Play();
                    }
                    girl.GetComponent <Animator>().Play("speak 33");
                    FishAnim(f);
                }
                else
                {
                    Invoke("chea", 0.7f);
                }
            }
        }
    }