예제 #1
0
    public static void Set(GameObject subject, object targetPosition, object targetScale, object targetRotation, float speed, bool endless, System.Action callback)
    {
        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].subject == subject)
            {
                list.RemoveAt(i);
            }
        }
        TransformationTarget tt = new TransformationTarget(subject, targetPosition, targetScale, targetRotation, speed, endless);

        tt.OnTransformationEnd += callback;
        list.Add(tt);
    }
예제 #2
0
 void FixedUpdate()
 {
     for (int i = 0; i < list.Count; i++)
     {
         bool end = true;
         TransformationTarget t = list[i];
         if (t.targetPosition != null)
         {
             t.subject.transform.position = Vector3.Lerp(t.subject.transform.position, (Vector3)t.targetPosition, Time.deltaTime * t.speed);
             if (Vector3.Distance(t.subject.transform.position, (Vector3)t.targetPosition) > tolerance)
             {
                 end = false;
             }
         }
         if (t.targetScale != null)
         {
             t.subject.transform.localScale = Vector3.Lerp(t.subject.transform.localScale, (Vector3)t.targetScale, Time.deltaTime * t.speed);
             if (Vector3.Distance(t.subject.transform.localScale, (Vector3)t.targetScale) > tolerance)
             {
                 end = false;
             }
         }
         if (t.targetScale != null)
         {
             float x = t.subject.transform.rotation.x;
             float y = t.subject.transform.rotation.y;
             float z = t.subject.transform.rotation.z;
             t.subject.transform.rotation = Quaternion.Lerp(t.subject.transform.rotation, (Quaternion)t.targetRotation, Time.deltaTime * t.speed);
             if (x - ((Quaternion)t.targetRotation).x > tolerance || y - ((Quaternion)t.targetRotation).y > tolerance || z - ((Quaternion)t.targetRotation).z > tolerance)
             {
                 end = false;
             }
         }
         if (end)
         {
             if (!t.endless)
             {
                 t.TransfomationEnded();
                 list.RemoveAt(i);
             }
             Debug.Log("Transformation ended!");
         }
     }
 }
예제 #3
0
        public void OnManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
        {
            m_begin_shift      = m_offset;
            m_begin_position   = e.Position.X;
            m_current_position = m_begin_position;
            m_begin_width      = Template.ActualWidth;

            if (m_fixed)
            {
                m_target = TransformationTarget.Center;
            }
            else
            {
                m_target = e.Position.X < 20 ?
                           TransformationTarget.LeftEdge :
                           (
                    e.Position.X > Template.ActualWidth - 20 ?
                    TransformationTarget.RightEdge :
                    TransformationTarget.Center
                           );
            }

            Template.Width = Template.ActualWidth;
        }