Пример #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;
    }
Пример #2
0
 void Ini()
 {
     if (monitorSet >= 0)
     {
         ECCommons.SetMonitorIndex(monitorSet, false, 800, 600);
     }
 }
Пример #3
0
 // Use this for initialization
 public virtual void Start()
 {
     motionNumbers    = new float[4];
     motionNumbers[0] = 0;
     motionNumbers[1] = 0;
     motionNumbers[2] = 1;
     motionNumbers[3] = 1;
     canvasGroup      = GetComponent <CanvasGroup>();
     rt     = ECCommons.SetComponent <RectTransform>(gameObject);
     events = ECCommons.SetComponent <ECUIEvent>(gameObject);
     if (childIndividual)
     {
         children.AddRange(GetComponentsInChildren <ECUIController>());
         children.RemoveAt(0);
         if (children.Count < 1)
         {
             childIndividual = false;
         }
     }
     if (colorMask)
     {
         graphics.AddRange(GetComponentsInChildren <Graphic>());
     }
     else if (GetComponent <Graphic>())
     {
         graphics.Add(GetComponent <Graphic>());
     }
     Invoke("Initialize", Time.deltaTime * iniDelay);
 }
Пример #4
0
 void Submit(uint index)
 {
     value[index]     = ECCommons.ListToString(separator, keys[index]) + separator;
     current[index]   = "";
     stateCode[index] = "";
     timer[index]     = 0;
     keys[index].Clear();
 }
Пример #5
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);
    }
Пример #6
0
 // Update is called once per frame
 void Update()
 {
     //if (Input.GetKeyDown(KeyCode.L))
     //{
     //StartCoroutine(FileIO.LoadWAV(a = gameObject.AddComponent<AudioSource>(), "Piano/A4.wav"));
     //a = ECCommons.SetComponent<AudioSource>(gameObject);
     //a.clip = FileIO.LoadAudio("Piano/A4.wav");
     //}
     //if (Input.GetKeyDown(KeyCode.Space)) a.Play();
     str.text = ECCommons.BaseConvert(value, oriDigit, tarDigit, ECConstant.B256);
     result   = str.text;
 }
Пример #7
0
    IEnumerator StartTranslating(MotionBase mBase, float factor, float accel, float decel, Vector3 position, Vector3 eulerAngles, Vector3 scale, float delay)
    {
        isPaused = false;
        isMoving = true;

        Vector3 originPos   = transform.position;
        Vector3 originAngle = transform.localEulerAngles;
        Vector3 originScale = transform.localScale;
        float   distance    = Vector3.Distance(originPos, position);
        float   angle3D     = ECCommons.Angle3D(originAngle, eulerAngles) * angularRatio;
        float   scale3D     = Vector3.Distance(originScale, scale) * scalingRatio;
        float   dist        = Mathf.Max(distance, angle3D, scale3D);

        GetMotionParatmers(mBase, factor, accel, decel, dist);
        if (dist > error && factor >= 0 && accel >= 0 && decel >= 0)
        {
            while (isMoving && rate != 1)
            {
                if (!isPaused)
                {
                    Rate();
                    transform.position         = Vector3.Lerp(originPos, position, rate);
                    transform.localEulerAngles = Vector3.Lerp(originAngle, eulerAngles, rate);
                    transform.localScale       = Vector3.Lerp(originScale, scale, rate);
                }
                yield return(0);
            }
        }
        switch (loop)
        {
        case Loop.RESTART:
            transform.position         = originPos;
            transform.localEulerAngles = originAngle;
            transform.localScale       = originScale;
            Transformation(Method.TO, mBase, factor, accel, decel, position, eulerAngles, scale, delay);
            break;

        case Loop.REVERSE:
            Transformation(Method.TO, mBase, factor, accel, decel, originPos, originAngle, originScale, delay);
            break;

        case Loop.CONTINUE:
            Transformation(Method.BY, mBase, factor, accel, decel, position, eulerAngles, scale, delay);
            break;

        default:
            transform.position         = position;
            transform.localEulerAngles = eulerAngles;
            transform.localScale       = scale;
            isMoving = false;
            break;
        }
    }
Пример #8
0
 string AddList(string data)
 {
     if (orderLength > 0)
     {
         data = ECCommons.FixLength(current, 0, orderLength - 1) + "." + data;
         current++;
         if (current >= Mathf.Pow(10, orderLength - 1))
         {
             current = 0;
         }
     }
     return(data);
 }
Пример #9
0
    public void Save(string path)
    {
        ECFile store = new ECFile(path);

        if (!store.DirectoryExists())
        {
            store.CreateDirectory();
        }
        path = store.directory + "/" + store.file + "_";
        totalPaint++;
        while (ECFile.FileExists(path + ECCommons.FixLength(totalPaint, 0, 3) + "." + store.extension))
        {
            totalPaint++;
        }
        paint.SaveTexture(path + ECCommons.FixLength(totalPaint, 0, 3) + "." + store.extension);
    }
Пример #10
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();
         }
     }
 }
Пример #11
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;
    }
Пример #12
0
    // Use this for initialization
    void Start()
    {
        if (orderLength > 0)
        {
            orderLength++;
        }
        receiverFolder    = directory + "/" + receiverFolder;
        transmitterFolder = directory + "/" + transmitterFolder;

        if (startUpClear)
        {
            if (ReceiverFound())
            {
                Directory.Delete(receiverFolder, true);
            }
            if (TransmitterFound())
            {
                Directory.Delete(transmitterFolder, true);
            }
        }

        transferedData = ECCommons.FixLength(0, 0, orderLength);
    }
Пример #13
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();
            }
        }
    }
Пример #14
0
    public static  Vector2[] VerticalPoints(Vector2 point, Vector2 center, float width, float height)
    {
        Vector2[] points = new Vector2[4];
        float     h      = center.x;
        float     k      = center.y;
        float     p      = point.x - h;
        float     q      = point.y - k;
        float     a      = width;
        float     b      = height;
        //if (point.x == center.x || point.y == center.y)
        //{
        //    points[0] = new Vector2(h, k + b);
        //    points[1] = new Vector2(h + a, k);
        //    points[2] = new Vector2(h - a, k);
        //    points[3] = new Vector2(h, k - b);
        //}
        //else
        //{
        float a2 = a * a;
        float b2 = b * b;
        float b4 = b2 * b2;
        float q2 = q * q;
        float d  = a2 - b2;
        float d2 = d * d;
        float B  = 2 * b2 * q / d;
        float C  = b2 * ((a2 * p * p + b2 * q2) / d2 - 1);
        float D  = -2 * b4 * q / d;
        float E  = -b4 * b2 * q2 / d2;

        Complex[] ys = ECCommons.QuarticRoots(1, B, C, D, E);
        Complex[] xs = new Complex[ys.Length];
        for (int i = 0; i < xs.Length; i++)
        {
            if (ys[i].i == 0)
            {
                if (ys[i].r > b)
                {
                    ys[i].r = b;
                }
                else if (ys[i].r < -b)
                {
                    ys[i].r = -b;
                }
                //xs[i].r = a2 * p * ys[i].r / (d * ys[i].r + b2 * q);
                xs[i].r = a * System.Math.Sqrt(1 - ys[i].r * ys[i].r / b2);
                if (p < 0)
                {
                    xs[i].r *= -1;
                }
                points[i] = new Vector2((float)xs[i].r + h, (float)ys[i].r + k);
            }
            else if (i > 0)
            {
                points[i] = points[0];
            }
            else if (a > b)
            {
                points[i] = new Vector2(h, k + b);
            }
            else
            {
                points[i] = new Vector2(h + a, k);
            }
        }
        //}
        return(points);
    }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     GetFile();
     view = ECCommons.SetComponent <NetworkView>(gameObject);
 }