Пример #1
0
 private void touchesBeganHandler(object sender, TouchEventArgs e)
 {
     foreach (var touch in e.Touches)
     {
         if (homeTouches.ContainsKey(touch.Id)) return;
         var newFtlTouch = new ftlTouch();
         newFtlTouch.TouchObject = box;
         newFtlTouch.Add (touch, Time.realtimeSinceStartup);
         newFtlTouch.TouchObject.GetComponent<TouchObjectScript>().Id = touch.Id;
         homeTouches.Add (touch.Id, newFtlTouch);
     }
 }
Пример #2
0
 private void touchesMovedHandler(object sender, TouchEventArgs e)
 {
     foreach (var touch in e.Touches)
     {
         if (!homeTouches.ContainsKey(touch.Id))
         {
             var newFtlTouch = new ftlTouch();
             newFtlTouch.TouchObject = box;
             newFtlTouch.Add (touch, Time.realtimeSinceStartup);
             newFtlTouch.TouchObject.GetComponent<TouchObjectScript>().Id = touch.Id;
             homeTouches.Add (touch.Id, newFtlTouch);
             newFtlTouch.Active = true;
         }
         homeTouches[touch.Id].Add (touch, Time.realtimeSinceStartup);
     }
 }
 private void touchesMovedHandler(object sender, TouchEventArgs e)
 {
     foreach (var touch in e.Touches)
     {
         if (!ftlTouches.ContainsKey(touch.Id))
         {
             var newFtlTouch = new ftlTouch();
             newFtlTouch.TouchObject = box;
             newFtlTouch.Add (touch, Time.realtimeSinceStartup);
             newFtlTouch.TouchObject.GetComponent<TouchObjectScript>().Id = touch.Id;
             ftlTouches.Add (touch.Id, newFtlTouch);
             newFtlTouch.Active = true;
         }
         ftlTouches[touch.Id].Add (touch, Time.realtimeSinceStartup);
         if (SAVING)
         {
             var index = ftlTouches[touch.Id].ElementList.Count - 1;
             var element = ftlTouches[touch.Id].ElementList[index];
             tw.WriteLine(touch.Id.ToString() 	// Writes out data for touch
                          + "," + GameTimeElapsed.ToString("f4")
                          + "," + (Time.realtimeSinceStartup - StartTime).ToString("f4")
                          + "," + element.WorldPosition.x.ToString("f4")
                          + "," + element.WorldPosition.y.ToString("f4")
                          + "," + TargetPosition.x.ToString("f4")
                          + "," + TargetPosition.y.ToString("f4")
                          + "," + CurrentLevel.ToString("f4"));
         }
     }
 }
 private void touchesBeganHandler(object sender, TouchEventArgs e)
 {
     foreach (var touch in e.Touches)
     {
         if (ftlTouches.ContainsKey(touch.Id)) return;
         var newFtlTouch = new ftlTouch();
         newFtlTouch.TouchObject = box;
         newFtlTouch.Add (touch, Time.realtimeSinceStartup);
         newFtlTouch.TouchObject.GetComponent<TouchObjectScript>().Id = touch.Id;
         ftlTouches.Add (touch.Id, newFtlTouch);
         var position = Camera.main.ScreenToWorldPoint(touch.Position);
         if (SAVING)
         {
             tw.WriteLine(touch.Id.ToString() 	// Writes out data for touch
                          + "," + GameTimeElapsed.ToString("f4")
                          + "," + (Time.realtimeSinceStartup - StartTime).ToString("f4")
                          + "," + position.x.ToString("f4")
                          + "," + position.y.ToString("f4")
                          + "," + TargetPosition.x.ToString("f4")
                          + "," + TargetPosition.y.ToString("f4")
                          + "," + CurrentLevel.ToString("f4"));
         }
     }
 }
Пример #5
0
    private void OnTouchesMoved(object sender, TouchEventArgs e)
    {
        if (!enabled) return;
        foreach (var touch in e.Touches)
        {
            if (!RealTime)
            {
                if (touch.Hit != null && touch.Hit.Transform != null && touch.Hit.Transform.GetComponent<ftlSpeedGraph>() != null)
                        panGraph -= (touch.Position.x - touch.PreviousPosition.x);
                if (analysisTouches.ContainsKey(touch.Id))
                {
                    var position = Camera.main.ScreenToWorldPoint (touch.Position);
                    position.z = 0;
                    analysisTouches[touch.Id].TouchObject.transform.position = position;
                }

                if (GameObject.Find ("Min_" + touch.Id.ToString()))
                {
                    if (!SliderSound.isPlaying)
                        SliderSound.Play ();
                    SliderSound.volume = sliderSoundVolume;
                    var touchPosition = Camera.main.ScreenToWorldPoint (touch.Position);
                    var min = GameObject.Find ("Min_" + touch.Id.ToString());
                    var sliderPosition = min.transform.position;
                    sliderPosition.x = touchPosition.x;
                    var maxPos = GameObject.FindGameObjectWithTag("SliderMax");
                    if (touchPosition.x >= -4.121f && touchPosition.x < (maxPos.transform.position.x - 0.2f))
                    {
                        var timeSpan = MAX_TIME_HARD - MIN_TIME_HARD;
                        var fullSpaceBetween = 9.991f;
                        var minSliderNormalized = (touchPosition.x + 4.121f) / fullSpaceBetween;
                        MIN_TIME = MIN_TIME_HARD + minSliderNormalized * timeSpan;
                        min.transform.position = sliderPosition;
                    }
                }
                if (GameObject.Find ("Max_" + touch.Id.ToString()))
                {
                    if (!SliderSound.isPlaying)
                        SliderSound.Play ();
                    SliderSound.volume = sliderSoundVolume;
                    var touchPosition = Camera.main.ScreenToWorldPoint (touch.Position);
                    var max = GameObject.Find ("Max_" + touch.Id.ToString());
                    var sliderPosition = max.transform.position;
                    sliderPosition.x = touchPosition.x;
                    var minPos = GameObject.FindGameObjectWithTag("SliderMin");
                    if (touchPosition.x <= 5.87f && touchPosition.x > (minPos.transform.position.x + 0.2f))
                    {
                        var timeSpan = MAX_TIME_HARD - MIN_TIME_HARD;
                        var fullSpaceBetween = 9.991f;
                        var maxSliderNormalized = (touchPosition.x + 4.121f) / fullSpaceBetween;
                        MAX_TIME = MIN_TIME_HARD + maxSliderNormalized * timeSpan;
                        max.transform.position = sliderPosition;
                    }
                }
            }
            else if (RealTime)
            {
                if (!separateMouse || (separateMouse && touch.Tags.HasTag("Touch")))
                {
                    var newFtlTouch = new ftlTouch();
                    newFtlTouch.EventTime = Time.realtimeSinceStartup -START_TIME;
                    newFtlTouch.iTouch = touch;
                    newFtlTouch.SetDictionary = ftlTouches;
                    if (ftlTouches.ContainsKey (touch.Id - 1))
                    {
                        var lastFtlTouch = ftlTouches[touch.Id - 1][ftlTouches[touch.Id - 1].Count - 1];
                        if (lastFtlTouch.iTouch.Position.x == touch.Position.x)
                        {
                            if (lastFtlTouch.iTouch.Position.y < touch.Position.y && lastFtlTouch.iTouch.Position.y < 50f)
                                lastFtlTouch.Discard = true;
                            else if (touch.Position.y < lastFtlTouch.iTouch.Position.y && newFtlTouch.iTouch.Position.y < 50f)
                                newFtlTouch.Discard = true;
                        }
                    }
                    newFtlTouch.CamObject = gameObject;
                    newFtlTouch.Add (BezelTV);
                }
            }
        }
    }
Пример #6
0
 private void OnTouchesEnded(object sender, TouchEventArgs e)
 {
     if (!enabled) return;
     foreach (var touch in e.Touches)
     {
         if (analysisTouches.ContainsKey(touch.Id))
         {
             Destroy (analysisTouches[touch.Id].TouchObject);
             analysisTouches.Remove(touch.Id);
         }
         if (touch.Hit != null)
         {
             if (touch.Hit.Transform.tag.Contains("Slider"))
             {
                 SliderSound.volume = 0;
                 SliderSound.Stop ();
             }
         }
         if (ftlTouches.ContainsKey(touch.Id) && RealTime)
         {
             var newFtlTouch = new ftlTouch();
             newFtlTouch.EventTime = CURRENT_TIME;
             newFtlTouch.iTouch = touch;
             newFtlTouch.SetDictionary = ftlTouches;
             newFtlTouch.CamObject = gameObject;
             newFtlTouch.Add (BezelTV);
         }
     }
 }
Пример #7
0
 private void OnTouchesBegan(object sender, TouchEventArgs e)
 {
     if (!enabled) return;
     foreach (var touch in e.Touches)
     {
         if (!RealTime &&
             (touch.Hit == null || (touch.Hit != null && touch.Hit.Transform.tag == "Line")))// && (!separateMouse) || (separateMouse && touch.Tags.HasTag("Mouse")))
         {
             var newAnalysisTouch = new AnalysisTouch();
             newAnalysisTouch.iTouch = touch;
             newAnalysisTouch.SetDictionary  = analysisTouches;
             var position = Camera.main.ScreenToWorldPoint (touch.Position);
             position.z = 0;
             newAnalysisTouch.TouchObject = Instantiate (analysisTouchObject, position, Quaternion.identity) as GameObject;
             newAnalysisTouch.TouchObject.name = "TouchObject";
             newAnalysisTouch.Add ();
         }
         else if (touch.Hit != null)// && (!separateMouse || (separateMouse && touch.Tags.HasTag("Mouse"))))
         {
             if (touch.Hit.Transform.tag == "SliderMin")
             {
                 if (GameObject.Find ("Save"))
                 {
                     GameObject.Find ("Save").GetComponent<ButtonSliders>().SlideIn();
                 }
                 touch.Hit.Transform.name = "Min_" + touch.Id.ToString();
                 var touchPosition = Camera.main.ScreenToWorldPoint (touch.Position);
                 var sliderPosition = touch.Hit.Transform.transform.position;
                 sliderPosition.x = touchPosition.x;
                 if (touchPosition.x >= -4.121f) // Should be -4.3187 ??
                 {
                     var timeSpan = MAX_TIME_HARD - MIN_TIME_HARD;
                     var fullSpaceBetween = 9.991f;
                     var minSliderNormalized = (touchPosition.x + 4.121f) / fullSpaceBetween;
                     MIN_TIME = MIN_TIME_HARD + minSliderNormalized * timeSpan;
                     touch.Hit.Transform.transform.position = sliderPosition;
                 }
             }
             else if (touch.Hit.Transform.tag == "SliderMax")
             {
                 if (GameObject.Find ("Save"))
                     GameObject.Find ("Save").GetComponent<ButtonSliders>().SlideIn();
                 touch.Hit.Transform.name = "Max_" + touch.Id.ToString();
                 var touchPosition = Camera.main.ScreenToWorldPoint (touch.Position);
                 var sliderPosition = touch.Hit.Transform.transform.position;
                 sliderPosition.x = touchPosition.x;
                 if (touchPosition.x <= 4.121f)
                 {
                     var timeSpan = MAX_TIME_HARD - MIN_TIME_HARD;
                     var fullSpaceBetween = 9.991f;
                     var maxSliderNormalized = (touchPosition.x + 4.121f) / fullSpaceBetween;
                     MAX_TIME = MIN_TIME_HARD + maxSliderNormalized * timeSpan;
                     touch.Hit.Transform.transform.position = sliderPosition;
                 }
             }
             else if (touch.Hit.Transform.tag == "ReadoutButton")
             {
                 touch.Hit.Transform.GetComponent<ReadoutButton>().DestroyReadout();
                 var gpId = touch.Hit.Transform.GetComponent<ReadoutButton>().SetDataDisplay.GraphPointId;
                 graphPoints.Remove(gpId);
                 Destroy(touch.Hit.Transform.gameObject);
             }
         }
         else if (RealTime)
         {
             var clip = firstTouchSound.clip;
             firstTouchSound.PlayOneShot(clip);
             USER_MESSAGE = "Experiment Mode";
             USER_WARNING = "";
             if (ftlTouches.Count == 0)
             {
                 START_TIME = Time.realtimeSinceStartup;
                 CURRENT_TIME = 0;
                 MIN_TIME_HARD = CURRENT_TIME;
                 MIN_TIME = MIN_TIME_HARD;
             }
             if (!separateMouse || (separateMouse && touch.Tags.HasTag("Touch")))
             {
                 if (ftlTouches.Count == 0)
                 {
                     GameObject.Find ("Save").GetComponent<ButtonSliders>().SlideIn();
                     GameObject.Find ("Clear").GetComponent<ButtonSliders>().SlideIn();
                     GameObject.Find ("Analysis").GetComponent<SpriteRenderer> ().color = ButtonNormal;
                 }
                 var newFtlTouch = new ftlTouch();
                 newFtlTouch.EventTime = CURRENT_TIME;
                 newFtlTouch.iTouch = touch;
                 newFtlTouch.SetDictionary = ftlTouches;
                 if (ftlTouches.ContainsKey (touch.Id - 1))
                 {
                     var lastFtlTouch = ftlTouches[touch.Id - 1][ftlTouches[touch.Id - 1].Count - 1];
                     if (lastFtlTouch.iTouch.Position.x == touch.Position.x)
                     {
                         if (lastFtlTouch.iTouch.Position.y < touch.Position.y && lastFtlTouch.iTouch.Position.y < 50f)
                             lastFtlTouch.Discard = true;
                         else if (touch.Position.y < lastFtlTouch.iTouch.Position.y && newFtlTouch.iTouch.Position.y < 50f)
                             newFtlTouch.Discard = true;
                     }
                 }
                 newFtlTouch.CamObject = gameObject;
                 newFtlTouch.Add (BezelTV);
             }
         }
     }
 }