コード例 #1
0
    void Update()
    {
        if (!MenuController.username.Equals("nosave"))
        {
            double elapsedTime = Time.time - startTime;

            // only write the time if the game is paused
            if (ButtonManager.isPaused)
            {
                writer.WriteLine(elapsedTime + ",paused");
            }
            else
            {
                writer.Write(elapsedTime + ",");
                // string gazePos = gazePlotter.GetPos() + ",";
                // remove parentheses
                // writer.Write(gazePos.Replace("(","").Replace(")",""));
                string touchPos = touch.GetPos().ToString("F5") + ",";
                writer.Write(touchPos.Replace("(", "").Replace(")", ""));

                // get marked button position
                Vector3 bPos3 = bManager.GetButton().transform.position;
                Vector2 bPos  = new Vector2(bPos3.x, bPos3.y);
                writer.Write(bPos.ToString("F5").Replace("(", "").Replace(")", "") + ",");

                // write hand values if a hand exists
                if (lHand != null)
                {
                    string palmPos = lHand.GetPalmPosition().ToString("F5") + ",";
                    writer.Write(palmPos.Replace("(", "").Replace(")", ""));

                    foreach (FingerModel lFinger in lFingers)
                    {
                        //string type = lFinger.fingerType.ToString();
                        //type = "l" + type.Substring(4).ToLower();
                        string fingerPos = lFinger.GetTipPosition().ToString("F5") + ",";
                        writer.Write(fingerPos.Replace("(", "").Replace(")", ""));
                    }
                }
                else
                {
                    //writer.Write(",,,,,,,,,,,,,,,,,,");
                    for (int i = 0; i < 18; i++)
                    {
                        writer.Write(float.NaN + ",");
                    }
                }

                if (rHand != null)
                {
                    string palmPos = rHand.GetPalmPosition().ToString("F5") + ",";
                    writer.Write(palmPos.Replace("(", "").Replace(")", ""));

                    int i = 0;
                    foreach (FingerModel rFinger in rFingers)
                    {
                        //string type = rFinger.fingerType.ToString();
                        //type = "r" + type.Substring(4).ToLower();
                        // counter so that last entry doesn't have an extra comma
                        string fingerPos;
                        if (i == 4)
                        {
                            fingerPos = rFinger.GetTipPosition().ToString("F5");
                        }
                        else
                        {
                            fingerPos = rFinger.GetTipPosition().ToString("F5") + ",";
                        }
                        writer.Write(fingerPos.Replace("(", "").Replace(")", ""));
                        i++;
                    }
                }
                else
                {
                    //writer.Write(",,,,,,,,,,,,,,,,,");
                    for (int i = 0; i < 17; i++)
                    {
                        writer.Write(float.NaN + ",");
                    }
                    writer.Write(float.NaN);
                }
                writer.WriteLine();
            }
        }
    }