using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/**
* Internal Representation of a Sequence
*
*
Example:
* var seq = LeanTween.sequence();
* seq.append(1f); // delay everything one second
* seq.append( () => { // fire an event before start
* Debug.Log("I have started");
* });
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
* seq.append( (object obj) => { // fire event after tween
* var dict = obj as Dictionary;
* Debug.Log("We are done now obj value:"+dict["hi"]);
* }, new Dictionary(){ {"hi","sup"} } );
* @class LTSeq
* @constructor
*/
public class LTSeq {
public LTSeq previous;
public LTSeq current;
public LTDescr tween;
public float totalDelay;
public float timeScale;
private int debugIter;
public uint counter;
public bool toggle = false;
private uint _id;
public int id{
get{
uint toId = _id | counter << 16;
/*uint backId = toId & 0xFFFF;
uint backCounter = toId >> 16;
if(_id!=backId || backCounter!=counter){
Debug.LogError("BAD CONVERSION toId:"+_id);
}*/
return (int)toId;
}
}
public void reset(){
previous = null;
tween = null;
totalDelay = 0f;
}
public void init(uint id, uint global_counter){
reset();
_id = id;
counter = global_counter;
this.current = this;
}
private LTSeq addOn(){
this.current.toggle = true;
LTSeq lastCurrent = this.current;
this.current = LeanTween.sequence(true);
// Debug.Log("this.current:" + this.current.id + " lastCurrent:" + lastCurrent.id);
this.current.previous = lastCurrent;
lastCurrent.toggle = false;
this.current.totalDelay = lastCurrent.totalDelay;
this.current.debugIter = lastCurrent.debugIter + 1;
return current;
}
private float addPreviousDelays(){
// Debug.Log("delay:"+delay+" count:"+this.current.count+" this.current.totalDelay:"+this.current.totalDelay);
LTSeq prev = this.current.previous;
if (prev != null && prev.tween!=null) {
return this.current.totalDelay + prev.tween.time;
}
return this.current.totalDelay;
}
/**
* Add a time delay to the sequence
* @method append (delay)
* @param {float} delay:float amount of time to add to the sequence
* @return {LTSeq} LTDescr an object that distinguishes the tween
* var seq = LeanTween.sequence();
* seq.append(1f); // delay everything one second
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
*/
public LTSeq append( float delay ){
this.current.totalDelay += delay;
return this.current;
}
/**
* Add a time delay to the sequence
* @method append (method)
* @param {System.Action} callback:System.Action method you want to be called
* @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to
* @example
* var seq = LeanTween.sequence();
* seq.append( () => { // fire an event before start
* Debug.Log("I have started");
* });
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
* seq.append( () => { // fire event after tween
* Debug.Log("We are done now");
* });;
*/
public LTSeq append( System.Action callback ){
LTDescr newTween = LeanTween.delayedCall(0f, callback);
// Debug.Log("newTween:" + newTween);
return append(newTween);
}
/**
* Add a time delay to the sequence
* @method add (method(object))
* @param {System.Action} callback:System.Action method you want to be called
* @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to
* @example
* var seq = LeanTween.sequence();
* seq.append( () => { // fire an event before start
* Debug.Log("I have started");
* });
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
* seq.append((object obj) => { // fire event after tween
* var dict = obj as Dictionary;
* Debug.Log("We are done now obj value:"+dict["hi"]);
* }, new Dictionary(){ {"hi","sup"} } );
*/
public LTSeq append( System.Action