Ejemplo n.º 1
0
    public void GetFile()
    {
        if (textFile && textFile.FileExists())
        {
            textFile.GetData();
            for (int i = 0; i < textFile.value.Length; i++)
            {
                if (textFile.value[i].Length > 0)
                {
                    string[] data = ECCommons.Separate(textFile.separator, textFile.value[i]);
                    switch (i)
                    {
                    case 0: portName = data[1]; break;

                    case 1: timeout = int.Parse(data[1]); break;

                    case 2: buffer = int.Parse(data[1]); break;

                    case 3: readLength = int.Parse(data[1]); break;
                    }
                }
            }
        }
        storeName = portName;
        tmpBuffer = buffer;
        state     = ConnectionState.DISCONNECTED;
    }
Ejemplo n.º 2
0
    public static bool KeyCount(uint index, string key, int target)
    {
        int c = value[index].Contains(key) ? ECCommons.Separate(key, value[index]).Length : 0;

        if (c < target)
        {
            return(false);
        }
        return(true);
    }
Ejemplo n.º 3
0
 public void GetData()
 {
     string[] tmp = ReadLines();
     if (tmp.Length > 0)
     {
         bool renew = false;
         if (NullData() || data.Length < tmp.Length && data.Length <= 1 && value[0].Equals("DataName"))
         {
             dataLength = tmp.Length;
             data       = new string[tmp.Length];
             value      = new string[tmp.Length];
             for (byte i = 0; i < tmp.Length; i++)
             {
                 value[i] = tmp[i];
                 string[] strs = ECCommons.Separate(separator, tmp[i]);
                 data[i] = strs[0];
             }
             return;
         }
         if (tmp.Length >= value.Length)
         {
             dataLength = value.Length;
             for (byte i = 0; i < value.Length; i++)
             {
                 if (tmp[i].Length > data[i].Length)
                 {
                     value[i] = tmp[i];
                     string[] strs = ECCommons.Separate(separator, tmp[i]);
                     data[i] = strs[0];
                 }
                 else
                 {
                     renew = true;
                 }
             }
         }
         if (tmp.Length < value.Length || renew)
         {
             SetData();
         }
     }
 }
Ejemplo n.º 4
0
    public void GetFile()
    {
        if (textFile && textFile.FileExists())
        {
            textFile.GetData();
            for (int i = 0; i < textFile.value.Length; i++)
            {
                string[] data = ECCommons.Separate(textFile.separator, textFile.value[i]);
                if (data.Length > 1)
                {
                    switch (i)
                    {
                    case 0: connectName = data[1]; break;

                    case 1: appName = data[1]; break;

                    case 2: useUnityServer = data[1].Contains("T"); break;

                    case 3: serverIP = data[1]; break;

                    case 4: serverPort = int.Parse(data[1]); break;

                    case 5: facilitatorIP = data[1]; break;

                    case 6: facilitatorPort = int.Parse(data[1]); break;
                    }
                }
            }
        }
        if (!useUnityServer)
        {
            MasterServer.ipAddress     = serverIP;
            MasterServer.port          = serverPort;
            Network.natFacilitatorIP   = facilitatorIP;
            Network.natFacilitatorPort = facilitatorPort;
        }
        state = ConnectionState.DISCONNECTED;
    }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (connection.type != ECNetwork.Type.CLIENT)
        {
            if (Input.GetKey(KeyCode.UpArrow))
            {
                movingObject.transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
            }

            if (Input.GetKey(KeyCode.DownArrow))
            {
                movingObject.transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
            }

            if (Input.GetKey(KeyCode.LeftArrow))
            {
                movingObject.transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
            }

            if (Input.GetKey(KeyCode.RightArrow))
            {
                movingObject.transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
            }

            if (connection.state == ConnectionState.CONNECTED)
            {
                if (connection.receivedData.Length == 1)
                {
                    System.IO.File.WriteAllBytes("ScreenCap.png", ECCommons.RenderTexTo2D(cameras[1].GetComponent <Camera>().targetTexture).EncodeToPNG());
                }
                connection.DataTransfer(ECCommons.Combine(", ",
                                                          movingObject.transform.position.x,
                                                          movingObject.transform.position.y,
                                                          movingObject.transform.position.z,
                                                          movingObject.transform.eulerAngles.x,
                                                          movingObject.transform.eulerAngles.y,
                                                          movingObject.transform.eulerAngles.z));
            }

            /*
             * if (Input.GetKey(KeyCode.W))
             *  vrWand.transform.Translate(Vector3.up * Time.deltaTime);
             *
             * if (Input.GetKey(KeyCode.S))
             *  vrWand.transform.Translate(-Vector3.up * Time.deltaTime);
             *
             * if (Input.GetKey(KeyCode.A))
             *  vrWand.transform.Translate(Vector3.left * Time.deltaTime);
             *
             * if (Input.GetKey(KeyCode.D))
             *  vrWand.transform.Translate(-Vector3.left * Time.deltaTime);
             */
            if (Input.GetAxis("6th") != 0)
            {
                vrWand.transform.Translate(-Vector3.left * Time.deltaTime * Input.GetAxis("6th"));
            }
            if (Input.GetAxis("7th") != 0)
            {
                vrWand.transform.Translate(Vector3.up * Time.deltaTime * Input.GetAxis("7th"));
            }
        }
        else
        {
            if (connection.state == ConnectionState.CONNECTED && connection.receivedData.Length == 6)
            {
                string[] data = ECCommons.Separate(", ", connection.receivedData);
                Vector3  pos  = new Vector3(float.Parse(data[0]), float.Parse(data[1]), float.Parse(data[2]));
                Vector3  rot  = new Vector3(float.Parse(data[3]), float.Parse(data[4]), float.Parse(data[5]));
                movingObject.transform.position    = pos;
                movingObject.transform.eulerAngles = rot;
            }
            else if (connection.state != ConnectionState.CONNECTED)
            {
                connection.autoConnect = true;
                connection.Disconnect();
            }
        }
    }