예제 #1
0
        /// <summary>
        /// Animate Selector Between items
        /// </summary>
        protected IEnumerator IAnimateSelection()
        {
            IsChangingItem = true;              //Set that is Changing  an item.


            yield return(null);


            float elapsedTime = 0;
            float normalized  = 0;

            DeltaTransform CurrentT = new DeltaTransform();

            CurrentT.StoreTransform(transform);

            Vector3 NextPosition =
                InitialTransform.LocalPosition - transform.InverseTransformDirection(transform.TransformDirection(CurrentItem.transform.localPosition));

            Vector3 RotationVector = RadialVector * S_Editor.Angle * IndexSelected;

            Quaternion NextRotation = Quaternion.Euler(RotationVector) * InitialTransform.LocalRotation;


            if (SelectionTime > 0)
            {
                while (elapsedTime <= SelectionTime)
                {
                    normalized = SelectionCurve.Evaluate(elapsedTime / SelectionTime);

                    if (S_Editor.SelectorType != SelectorType.Radial)
                    {
                        transform.localPosition = Vector3.LerpUnclamped(CurrentT.LocalPosition, NextPosition, normalized);
                    }

                    if (S_Editor.SelectorType == SelectorType.Radial)
                    {
                        transform.localRotation = Quaternion.SlerpUnclamped(CurrentT.LocalRotation, NextRotation, normalized);

                        CheckForWorldRotation();
                    }

                    elapsedTime += Time.deltaTime;
                    yield return(null);
                }
            }

            if (S_Editor.SelectorType == SelectorType.Radial)
            {
                transform.localRotation = NextRotation;
                CheckForWorldRotation();
            }
            else
            {
                transform.localPosition = NextPosition;
            }
            IsChangingItem = false;
            IdleTimeMove   = IdleTimeScale = 0;         //Make sure to reset the Idle counting animations to zero when finishing dismounting
        }
예제 #2
0
        IEnumerator FrameCameraAnim()
        {
            Vector3 currentcampos = S_Camera.transform.localPosition;
            Vector3 FixPos        = InitialPosCam + (S_Camera.transform.forward * (Items[0].BoundingBox.magnitude - CurrentItem.BoundingBox.magnitude) * frame_Multiplier);
            float   elapsedTime   = 0;
            float   normalized    = 0;

            while (elapsedTime <= SelectionTime && SelectionTime > 0)
            {
                normalized = SelectionCurve.Evaluate(elapsedTime / SelectionTime);
                S_Camera.transform.localPosition = Vector3.Lerp(currentcampos, FixPos, normalized);
                elapsedTime += Time.deltaTime;
                yield return(null);
            }
            S_Camera.transform.localPosition = FixPos;
            yield return(null);
        }
        /// <summary>
        /// Animate Selector Between items
        /// </summary>
        protected IEnumerator IAnimateSelection()
        {
            IsChangingItem = true;              //Set that is Changing  an item.

            yield return(null);

            if (CurrentItem != null)
            {
                float elapsedTime = 0;
                float normalized  = 0;

                DeltaTransform CurrentT = new DeltaTransform();

                CurrentT.StoreTransform(transform);

                Vector3 NextPosition =
                    InitialTransform.LocalPosition - transform.InverseTransformDirection(transform.TransformDirection(CurrentItem.transform.localPosition));

                Debug.Log(transform.localPosition.x);
                // TODO : not have this be a magic number ( based on the number of columns ...)
                NextPosition.x = -2f;

                Vector3 RotationVector = RadialVector * S_Editor.Angle * IndexSelected;

                Quaternion NextRotation = Quaternion.Euler(RotationVector) * InitialTransform.LocalRotation;

                float fraction = 1;

                if (S_Editor.SelectorType == SelectorType.Radial)
                {
                    fraction = Quaternion.Angle(transform.rotation, NextRotation) / S_Editor.Angle;
                }


                if (SelectionTime > 0)
                {
                    float RemainingSelectionTime = SelectionTime * fraction;

                    while (elapsedTime <= RemainingSelectionTime && CurrentItem != null && RemainingSelectionTime > 0)
                    {
                        normalized = SelectionCurve.Evaluate(elapsedTime / RemainingSelectionTime);

                        if (S_Editor.SelectorType != SelectorType.Radial)
                        {
                            transform.localPosition = Vector3.LerpUnclamped(CurrentT.LocalPosition, NextPosition, normalized);
                        }

                        if (S_Editor.SelectorType == SelectorType.Radial)
                        {
                            transform.localRotation = Quaternion.SlerpUnclamped(CurrentT.LocalRotation, NextRotation, normalized);

                            CheckForWorldRotation();
                        }

                        elapsedTime += Time.deltaTime;
                        yield return(null);
                    }
                }

                if (S_Editor.SelectorType == SelectorType.Radial)
                {
                    transform.localRotation = NextRotation;
                    CheckForWorldRotation();
                }
                else
                {
                    transform.localPosition = NextPosition;
                }
            }
            IsChangingItem = false;
            IdleTimeMove   = IdleTimeScale = 0;         //Make sure to reset the Idle counting animations to zero when finishing dismounting
        }