Esempio n. 1
0
        public object CreateSequence(NTweenSequence sequence)
        {
            Sequence hoTweenSequence = new Sequence ();

            foreach (var tween in sequence.GetTweens()) {

                // yuck
                if (tween is SequenceTweenHolder) {
                    var nTween = (SequenceTweenHolder)tween;

                    var tweenParms = SetAttributes (nTween.attribute);

                    tweenParms.Prop (nTween.builder.GetProperty (), nTween.builder.GetTweenValueTo ());

                    var hoTween = HOTween.To (nTween.builder.GetObject (), nTween.builder.GetDuration (), tweenParms);

                    hoTweenSequence.Append (hoTween);
                } else if (tween is SequenceCallBack) {
                    hoTweenSequence.AppendCallback (((SequenceCallBack)tween).Callback.Invoke);
                } else if (tween is SequenceInterval) {
                    hoTweenSequence.AppendInterval (((SequenceInterval)tween).Duration);
                }
            }

            return hoTweenSequence;
        }
Esempio n. 2
0
        public void Build(string goName, bool autoKill, UpdateType updateType)
        {
            if(mSequence != null) {
                HOTween.Kill(mSequence);
                mInsertActionTrack = null;
                mActionTween = null;
            }

            mSequence = new Sequence(
                new SequenceParms()
                .Id(string.Format("{0}:{1}", goName, mTake.name))
                .UpdateType(updateType)
                .AutoKill(autoKill)
                .Loops(mTake.numLoop, mTake.loopMode)
                .OnComplete(OnSequenceComplete));

            mTake.maintainCaches(mTarget);

            float minWaitTime = float.MaxValue;

            List<List<AMActionData>> trackValueSets = null;

            foreach(AMTrack track in mTake.trackValues) {
                Object tgt = null;
                if((tgt = track.GetTarget(mTarget)) != null) {
                    track.buildSequenceStart(this);

                    int keyMax = track.keys.Count;
                    if(keyMax > 0) {
                        for(int keyInd = 0; keyInd < keyMax; keyInd++) {
                            AMKey key = track.keys[keyInd];
                            key.build(this, track, keyInd, tgt);
                        }

                        float waitTime = track.keys[0].getWaitTime(mTake.frameRate, 0.0f);
                        if(waitTime < minWaitTime)
                            minWaitTime = waitTime;
                    }

                    //check to see if we have value sets for this track
                    if(mInsertActionTrack != null) {
                        if(trackValueSets == null)
                            trackValueSets = new List<List<AMActionData>>();
                        trackValueSets.Add(mInsertActionTrack);
                        mInsertActionTrack = null;
                    }
                }
            }

            //build the value track
            mInsertActionTrack = null;
            if(trackValueSets != null && trackValueSets.Count > 0) {
                mActionTween = new AMActionTween(trackValueSets);
                mSequence.Insert(mActionTween.startTime, HOTween.To(this, mActionTween.duration, new TweenParms().Prop("id", mActionTween)));

            }

            //prepend delay at the beginning
            if(minWaitTime > 0.0f)
                mSequence.PrependInterval(minWaitTime);
        }
Esempio n. 3
0
        // ***********************************************************************************
        // INIT
        // ***********************************************************************************

        /// <summary>
        /// Initializes the given <see cref="Sequence"/> with the stored parameters.
        /// </summary>
        /// <param name="p_sequence">
        /// The <see cref="Sequence"/> to initialize.
        /// </param>
        internal void InitializeSequence(Sequence p_sequence)
        {
            InitializeOwner(p_sequence);
        }
Esempio n. 4
0
 /// <summary>
 /// Pauses the given Sequence, and returns the total number of paused ones (1 if the Sequence existed, otherwise 0).
 /// </summary>
 /// <param name="p_sequence">
 /// The Sequence to pause.
 /// </param>
 /// <returns>
 /// The total number of paused Sequence (1 if the sequence existed, otherwise 0).
 /// </returns>
 public static int Pause(Sequence p_sequence)
 {
     return DoFilteredIteration(p_sequence, DoFilteredPause, false);
 }
Esempio n. 5
0
        /// <summary>
        /// Only call this during OnDestroy
        /// </summary>
        public void Destroy()
        {
            if(mSequence != null) {
                HOTween.Kill(mSequence);
                mSequence = null;
            }

            mActionTween = null;

            mTarget = null;
            mTake = null;
        }
Esempio n. 6
0
 /// <summary>
 /// Kills the given Sequence, and returns the total number of killed ones (1 if the Sequence existed, otherwise 0).
 /// </summary>
 /// <param name="p_sequence">
 /// The Sequence to kill.
 /// </param>
 /// <returns>
 /// The total number of killed Sequences (1 if the Sequence existed, otherwise 0).
 /// </returns>
 public static int Kill(Sequence p_sequence)
 {
     return DoFilteredIteration(p_sequence, DoFilteredKill, true);
 }
Esempio n. 7
0
        // ===================================================================================
        // TWEEN METHODS ---------------------------------------------------------------------

        /// <summary>
        /// Called internally each time a new <see cref="Sequence"/> is created.
        /// Adds the given Sequence to the tween list.
        /// </summary>
        /// <param name="p_sequence">
        /// The <see cref="Sequence"/> to add.
        /// </param>
        internal static void AddSequence(Sequence p_sequence)
        {
            if (!initialized) {
                Init();
            }

            AddTween(p_sequence);
        }
Esempio n. 8
0
 /// <summary>
 /// Completes the given Sequence, and returns the total number of completed ones (1 if the Sequence existed, otherwise 0).
 /// Where a loop was involved and not infinite, the relative Sequence completes at the position where it would actually be after the set number of loops.
 /// If there were infinite loops, this method will have no effect.
 /// </summary>
 /// <param name="p_sequence">
 /// The Sequence to complete.
 /// </param>
 /// <returns>
 /// The total number of completed Sequences (1 if the Sequence existed, otherwise 0).
 /// </returns>
 public static int Complete(Sequence p_sequence)
 {
     return DoFilteredIteration(p_sequence, DoFilteredComplete, true);
 }
Esempio n. 9
0
 /// <summary>
 /// Reverses the given Sequence, and returns the total number of reversed ones (1 if the Sequence existed, otherwise 0).
 /// </summary>
 /// <param name="p_sequence">
 /// The Sequence to reverse.
 /// </param>
 /// <param name="p_forcePlay">
 /// If TRUE, the tween will also start playing in case it was paused,
 /// otherwise it will maintain its current play/pause state (default).
 /// </param>
 /// <returns>
 /// The total number of reversed Sequences (1 if the Sequence existed, otherwise 0).
 /// </returns>
 public static int Reverse(Sequence p_sequence, bool p_forcePlay = false)
 {
     return DoFilteredIteration(p_sequence, DoFilteredReverse, p_forcePlay);
 }
Esempio n. 10
0
 /// <summary>
 /// Restarts the given Sequence, and returns the total number of restarted ones (1 if the Sequence existed, otherwise 0).
 /// </summary>
 /// <param name="p_sequence">
 /// The Sequence to restart.
 /// </param>
 /// <returns>
 /// The total number of restarted Sequences (1 if the Sequence existed, otherwise 0).
 /// </returns>
 public static int Restart(Sequence p_sequence)
 {
     return DoFilteredIteration(p_sequence, DoFilteredRestart, false);
 }
Esempio n. 11
0
 /// <summary>
 /// Resumes the given Sequence,
 /// sets it so that it moves backwards instead than forward,
 /// and returns the total number of resumed ones (1 if the Sequence existed, otherwise 0).
 /// </summary>
 /// <param name="p_sequence">
 /// The Sequence to resume.
 /// </param>
 /// <returns>
 /// The total number of resumed Sequences (1 if the Sequence existed, otherwise 0).
 /// </returns>
 public static int PlayBackwards(Sequence p_sequence)
 {
     return DoFilteredIteration(p_sequence, DoFilteredPlayBackwards, false);
 }
Esempio n. 12
0
 /// <summary>
 /// Resumes the given Sequence,
 /// sets it so that it moves forward and not backwards,
 /// and returns the total number of resumed ones (1 if the Sequence existed, otherwise 0).
 /// </summary>
 /// <param name="p_sequence">
 /// The Sequence to resume.
 /// </param>
 /// <returns>
 /// The total number of resumed Sequences (1 if the Sequence existed, otherwise 0).
 /// </returns>
 public static int PlayForward(Sequence p_sequence)
 {
     return DoFilteredIteration(p_sequence, DoFilteredPlayForward, false);
 }