Beispiel #1
0
        ///<summary>Try create a new Player instance if it hasn't being created before</summary>
        public static PTweenPlayerInstance TryCreateNewPlayerInstance(PTweenPlayerComponent playerComponent, PTweenAnimationDirection animationDirection)
        {
            PTweenPlayerInstance instance = null;

            for (int i = 0; i < m_AllPlayerInstances.Count; i++)
            {
                var curPlayer = m_AllPlayerInstances[i];
                if (curPlayer.PlayerTarget == playerComponent)
                {
                    instance = curPlayer;
                    break;
                }
            }

            if (instance == null)
            {
                instance = new PTweenPlayerInstance();
                instance.PlayerTarget = playerComponent;
                m_AllPlayerInstances.Add(instance);
            }

            instance.AnimationDirection = animationDirection;

            instance.PtweenInstances = new PTweenInstance[playerComponent.Targets.Length];

            for (int i = 0; i < instance.PtweenInstances.Length; i++)
            {
                instance.PtweenInstances[i] = PlayTweenComponent(instance.PlayerTarget.Targets[i], animationDirection);
            }

            return(instance);
        }
Beispiel #2
0
        ///<summary>Returns the first PlayerInstance with his player target equal than PlayerComponent parameter</summary>
        public static PTweenPlayerInstance GetPlayerInstanceByOriginalComponent(PTweenPlayerComponent originalComponent)
        {
            for (int i = 0; i < AllPlayerInstances.Count; i++)
            {
                PTweenPlayerInstance curInstance = AllPlayerInstances[i];
                if (curInstance.PlayerTarget == originalComponent)
                {
                    return(curInstance);
                }
            }

            return(null);
        }
Beispiel #3
0
        ///<summary>Updates player instance PtweensInstances' position, Rotation and Scale</summary>
        public static void UpdatePlayerInstance(PTweenPlayerInstance instance)
        {
            instance.IsPlayerFinished = true;

            for (int i = 0; i < instance.PtweenInstances.Length; i++)
            {
                var curPtweenInstance = instance.PtweenInstances[i];

                if (!IsPTweenInstanceFinished(curPtweenInstance))
                {
                    instance.IsPlayerFinished = false;
                }
                else
                {
                    continue;
                }

                if (curPtweenInstance.Position.Animate)
                {
                    curPtweenInstance.Target.transform.localPosition = UpdatePTweenClipVector(curPtweenInstance.Position, curPtweenInstance.AnimationDirection);
                }

                if (curPtweenInstance.Rotation.Animate)
                {
                    curPtweenInstance.Target.transform.rotation = Quaternion.Euler(UpdatePTweenClipVector(curPtweenInstance.Rotation, curPtweenInstance.AnimationDirection));
                }

                if (curPtweenInstance.Scale.Animate)
                {
                    curPtweenInstance.Target.transform.localScale = UpdatePTweenClipVector(curPtweenInstance.Scale, curPtweenInstance.AnimationDirection);
                }

                if (curPtweenInstance.Alpha.Animate)
                {
                    curPtweenInstance.Alpha.CanvasGroup.alpha = UpdatePTweenClipAlpha(curPtweenInstance.Alpha, curPtweenInstance.AnimationDirection);
                }
            }
        }
Beispiel #4
0
        ///<summary>Returns player instance that will be playing</summary>
        public static PTweenPlayerInstance StartPTweenPlayerComponent(PTweenPlayerComponent playerComponent, PTweenAnimationDirection animationDirection)
        {
            PTweenPlayerInstance instance = TryCreateNewPlayerInstance(playerComponent, animationDirection);

            return(instance);
        }