예제 #1
0
    public void touchesEndedHandler(object sender, TouchEventArgs e)
    {
        foreach (var touch in e.Touches)
        {
            bool madeAMove =  StickyScript.theresNewTextOnStickies;
            string moveLog = "";
            if (StickyScript.theresNewTextOnStickies)
            {
                StickyScript.theresNewTextOnStickies = false;
                moveLog += " StickyScript.theresNewTextOnStickies";
            }
            ViewControl.dragging = false;
            if (activeNote != null && ActiveNotes != null)
            {
                for (int i = 0; i < ActiveNotes.Count; i++)
                {
                    GridSnapper.Snap(ActiveNotes[i]);
                }
            }
            madeAMove = draggedSomeStickies || madeAMove;
            if (draggedSomeStickies)
            {
                moveLog += " draggedSomeStickies";
                draggedSomeStickies = false;
            }
            draggingHandles = null;
            activeNote = null;
            if (stickyScaler != null)
            {
                ViewControl.calculateMaxMin = 2;
                stickyScaler.mouseOver = false;
                stickyScaler = null;
                madeAMove = true;
            }

            if (madeAMove)
            {
                SaveLoadManager.MakeAMove("ftlGatherer" + moveLog);
            }
            ITouch _touch;
            if (!ftlTouches.TryGetValue(touch.Id, out _touch)) return;
            ftlTouches.Remove(touch.Id);
        }
    }
예제 #2
0
 public void touchesBeganHandler(object sender, TouchEventArgs e)
 {
     foreach (var touch in e.Touches)
     {
         if (ftlTouches.ContainsKey(touch.Id)) return;
         ftlTouches.Add (touch.Id, touch);
         var pos = Camera.main.ScreenToWorldPoint (new Vector3 (touch.Position.x, touch.Position.y, 10));
         if (pressedEditorButton)
         {
             pressedEditorButton = false;
         }
         else if (MainPanelGatherer)
         {
             var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             RaycastHit hit;
             if (Physics.Raycast(ray, out hit) && hit.transform.tag == "ProjectionSurface")
             {
                 stickyScaler = null;
                 draggingHandles = null;
                 List<GameObject> lastActiveNotes = ActiveNotes;
                 ActiveNotes = null;
                 ray = GetComponent<Camera>().ViewportPointToRay(hit.textureCoord);
                 pos.z = 10;
                 //pos = GetComponent<StickySender>().TransformToMainPanel(new Vector3 (touch.Position.x, touch.Position.y, 10));
                 pos = TransformToMainPanel(pos);
                 mousePosLast = pos;
                 mousePosLast.z = 0f;
                 if (Physics.Raycast(ray, out hit))
                 {
                     var hitObject = hit.transform.gameObject;
                     if (Input.GetKey(KeyCode.LeftControl))
                     {
                         Debug.Log(hit.transform.name);
                     }
                     switch (hitObject.tag)
                     {
                         case "StickyNote":
                             //delete handles and lines in ActiveNotes
                             if (lastActiveNotes != null)
                             {
                                 for (int i = 0; i < lastActiveNotes.Count; i++)
                                 {
                                     if (lastActiveNotes[i] != null && (lastActiveNotes[i].tag == "Handle" || lastActiveNotes[i].tag == "Line"))
                                     {
                                         lastActiveNotes[i] = null;
                                     }
                                 }
                             }
                             //add/remove the sticky
                             activeNote = hitObject;
                             if (isAnActiveNote(hitObject, lastActiveNotes))
                             {
                                 ActiveNotes = lastActiveNotes;
                                 if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                                 {
                                     ActiveNotes.Remove(activeNote);
                                 }
                             }
                             else
                             {
                                 if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                                 {
                                     if (lastActiveNotes == null)
                                     {
                                         ActiveNotes = new List<GameObject>();
                                     }
                                     else
                                     {
                                         ActiveNotes = lastActiveNotes;
                                     }
                                     ActiveNotes.Add(hitObject);
                                 }
                                 else
                                 {
                                     ActiveNotes = new List<GameObject>();
                                     ActiveNotes.Add(hitObject);
                                 }
                             }
                             hit.transform.gameObject.GetComponent<StickyScript>().press();
                             offset = pos - hit.transform.gameObject.transform.position;
                             offset.z = 0;
                             break;
                         case "Line":
                             activeNote = hitObject;
                             ActiveNotes = new List<GameObject>();
                             ActiveNotes.Add(hitObject);
                             break;
                         case "Handle":
                             activeNote = hitObject;
                             if (isAnActiveNote(hitObject, lastActiveNotes))
                             {
                                 ActiveNotes = lastActiveNotes;
                             }
                             else
                             {
                                 ActiveNotes = new List<GameObject>();
                                 ActiveNotes.Add(hitObject);
                             }
                             offset = pos - hit.transform.gameObject.transform.position;
                             offset.z = 0;
                             break;
                         case "StickyScaler":
                             stickyScaler = hit.transform.GetComponent<StickyScaler>();
                             stickyScaler.dragStartPos = pos;
                             offset = pos - hit.transform.gameObject.transform.position;
                             offset.z = 0;
                             ActiveNotes = lastActiveNotes;
                             break;
                         default:
                             activeNote = null;
                             break;
                     }
                     ViewControl.dragging = false;
                 }
                 else
                 {
                     ViewControl.dragging = true;
                 }
             }
         }
     }
 }