using UnityEngine; using System; using System.Collections; public abstract class AbstractTweenProperty { protected bool _isInitialized; public bool isInitialized { get { return _isInitialized; } } protected bool _isRelative; protected GoTween _ownerTween; protected Func _easeFunction; public AbstractTweenProperty( bool isRelative = false ) { _isRelative = isRelative; } public override int GetHashCode() { return base.GetHashCode(); } /// /// checks to see if a TweenProperty matches another. checks propertyNames of IGenericPropertys first then /// resorts to direct type checking /// public override bool Equals( object obj ) { // null check first if( obj == null ) return false; // handle IGenericProperty comparisons which just have the property name checked if( this is IGenericProperty && obj is IGenericProperty ) return ((IGenericProperty)this).propertyName == ((IGenericProperty)obj).propertyName; // check for the same types if( obj.GetType() == this.GetType() ) return true; return base.Equals( obj ); } /// /// called by a Tween just after this property is validated and added to the Tweens property list /// public virtual void init( GoTween owner ) { _isInitialized = true; _ownerTween = owner; // if we dont have an easeFunction use the owners type if( _easeFunction == null ) setEaseType( owner.easeType ); } /// /// clones the instance /// public AbstractTweenProperty clone() { var clone = MemberwiseClone() as AbstractTweenProperty; clone._ownerTween = null; clone._isInitialized = false; clone._easeFunction = null; return clone; } /// /// sets the ease type for this tween property /// technically, this should be an internal method /// public void setEaseType( GoEaseType easeType ) { _easeFunction = GoTweenUtils.easeFunctionForType( easeType ); } /// /// each TweenProperty should override this to ensure the object is the correct type /// public virtual bool validateTarget( object target ) { return true; } /// /// subclasses should get the eased time then set the new value on the object /// public abstract void tick( float totalElapsedTime ); /// /// called when a Tween is initially started. /// subclasses should strongly type the start/end/target and handle isFrom with /// regard to setting the proper start/end values /// public abstract void prepareForUse(); }