Example #1
0
    /*
    ============================================================================
    Blink functions
    ============================================================================
    */
    public IEnumerator Blink(bool fc, bool fa, float als, float ae, bool fr, float rs, float re,
			bool fg, float gs, float ge, bool fb, float bs, float be, EaseType et, float t)
    {
        this.Clear();

        this.fadeChildren = fc;
        this.fadeAlpha = fa;
        this.alphaStart = als;
        this.alphaEnd = ae;
        this.alphaDistance = ae - als;
        this.fadeRed = fr;
        this.redStart = rs;
        this.redEnd = re;
        this.redDistance = re - rs;
        this.fadeGreen = fg;
        this.greenStart = gs;
        this.greenEnd = ge;
        this.greenDistance = ge - gs;
        this.fadeBlue = fb;
        this.blueStart = bs;
        this.blueEnd = be;
        this.blueDistance = be - bs;
        this.interpolate = Interpolate.Ease(et);
        this.time = 0;
        this.time2 = t;

        yield return null;
        this.fading = true;
        this.flash = true;
        this.blink = true;
    }
Example #2
0
    public IEnumerator SetTargetData(CameraPosition cp, Transform c, Transform a, EaseType et, float t)
    {
        this.shaking = false;
        this.running = false;
        this.rotating = false;

        this.camPos = cp;
        this.cam = c;
        this.actor = a;
        this.interpolate = Interpolate.Ease(et);
        this.time = 0;
        this.time2 = t;

        Transform tmp = new GameObject().transform;
        this.camPos.Use(tmp, this.actor);
        yield return null;
        this.startPos = this.cam.position;
        this.distancePos = tmp.position - this.startPos;
        this.startRot = this.cam.rotation;
        this.endRot = tmp.rotation;
        this.startFoV = this.cam.camera.fieldOfView;
        this.distanceFov = this.camPos.fieldOfView - this.startFoV;
        GameObject.Destroy(tmp.gameObject);
        this.running = true;
    }
Example #3
0
 public static Function EaseFunction(EaseType type)
 {
     //Returns the static method that implements the given easing type for scalars.
     //Use this method to easily switch between easing interpolation types.
     //All easing methods clamp elapsedTime so that it is always less than duration.
     Function f = null;
     switch (type)
     {
         case EaseType.Linear: f = Easing.Linear; break;
         case EaseType.EaseInQuad: f = Easing.EaseInQuad; break;
         case EaseType.EaseOutQuad: f = Easing.EaseOutQuad; break;
         case EaseType.EaseInOutQuad: f = Easing.EaseInOutQuad; break;
         case EaseType.EaseInCubic: f = Easing.EaseInCubic; break;
         case EaseType.EaseOutCubic: f = Easing.EaseOutCubic; break;
         case EaseType.EaseInOutCubic: f = Easing.EaseInOutCubic; break;
         case EaseType.EaseInQuart: f = Easing.EaseInQuart; break;
         case EaseType.EaseOutQuart: f = Easing.EaseOutQuart; break;
         case EaseType.EaseInOutQuart: f = Easing.EaseInOutQuart; break;
         case EaseType.EaseInQuint: f = Easing.EaseInQuint; break;
         case EaseType.EaseOutQuint: f = Easing.EaseOutQuint; break;
         case EaseType.EaseInOutQuint: f = Easing.EaseInOutQuint; break;
         case EaseType.EaseInSine: f = Easing.EaseInSine; break;
         case EaseType.EaseOutSine: f = Easing.EaseOutSine; break;
         case EaseType.EaseInOutSine: f = Easing.EaseInOutSine; break;
         case EaseType.EaseInExpo: f = Easing.EaseInExpo; break;
         case EaseType.EaseOutExpo: f = Easing.EaseOutExpo; break;
         case EaseType.EaseInOutExpo: f = Easing.EaseInOutExpo; break;
         case EaseType.EaseInCirc: f = Easing.EaseInCirc; break;
         case EaseType.EaseOutCirc: f = Easing.EaseOutCirc; break;
         case EaseType.EaseInOutCirc: f = Easing.EaseInOutCirc; break;
     }
     return f;
 }
Example #4
0
    public IEnumerator BlinkCurrent(bool fc, bool fa, float ae, bool fr, float re,
			bool fg, float ge, bool fb, float be, EaseType et, float t)
    {
        this.Clear();

        this.fadeChildren = fc;
        this.fadeAlpha = fa;
        this.alphaEnd = ae;
        this.fadeRed = fr;
        this.redEnd = re;
        this.fadeGreen = fg;
        this.greenEnd = ge;
        this.fadeBlue = fb;
        this.blueEnd = be;
        this.interpolate = Interpolate.Ease(et);
        this.time = 0;
        this.time2 = t;

        this.Store();

        yield return null;
        this.useCurrent = true;
        this.fading = true;
        this.flash = true;
        this.blink = true;
    }
Example #5
0
    static void MoveTo(GameObject target, Vector3[] nodes, float time, EaseType easyType, bool firstNode, 
		string updateFuncName, string complateFuncName, GameObject funcTarget, object param)
    {
        if( null != target &&
            firstNode &&
            null != nodes &&
            nodes.Length > 0 )
        {
            target.transform.localPosition = nodes[0];
        }

        Hashtable args = iTween.Hash("path", nodes, "time", time, "easetype", easyType.ToString());
        if(null != updateFuncName)
        {
            args["onupdate"] = updateFuncName;
            if(null != param)
            {
                args["onupdateparams"] = param;
            }
            if(null != funcTarget) args["onupdatetarget"] = funcTarget;
        }
        if(null != complateFuncName)
        {
            args["oncomplete"] = complateFuncName;
            if(null != param)
            {
                args["oncompleteparams"] = param;
            }
            if(null != funcTarget) args["oncompletetarget"] = funcTarget;
        }

        iTween.MoveTo(target, args);
    }
 public static void Begin(GameObject target, Vector3 from, Vector3 to, float duration, EaseType easeType = EaseType.Linear)
 {
     var tweenScale = target.GetComponent<TweenScale>();
     if (tweenScale == null)
         tweenScale = target.AddComponent<TweenScale>();
     tweenScale.Begin(from, to, duration, easeType);
 }
Example #7
0
    protected override void draw()
    {
        background(bgCol);

        fill(col);
        ellipse(pos.x, pos.y, 40, 40);

        fill(0, 255, 0);
        textSize(20);
        textAlign(LEFT, TOP);

        int fade = (int)fadeTween.Value;
        text("fade : " + fade, 20, 30);
        text("col  : " + col, 20, 60);

        text("ease : " + easeType, 20, 150);
        text("pos  : Vector3" + pos, 20, 180);

        if(button("Prev Ease", 20, 110, 150, 30)) {
            easeType = (EaseType)((int)easeType - 1);
            if((int)easeType < 0) { easeType = (EaseType)(EaseType.Max - 1); }
        } else if(button("Next Ease", 180, 110, 150, 30)) {
            easeType = (EaseType)( ((int)easeType + 1) % (int)EaseType.Max );
        } else if(mouseReleased) {
            removeTween(posTween);
            posTween = tween(this, "pos", pos, new Vector3(mouseX, mouseY, 0.0f), 0.25f, easeFuncs[(int)easeType]);
        }

        if(fade > 0) {
            beginNoRecycle();
            fill(0, 0, 60, fade);
            rect(0, 0, width, height);
            endRecycle();
        }
    }
Example #8
0
 protected AMPlugMaterial(Material mat, string prop, object end, EaseType p_easeType, bool p_isRelative)
     : base(end, p_easeType, p_isRelative)
 {
     ignoreAccessor = true;
     mMat = mat;
     mPropId = Shader.PropertyToID(prop);
 }
Example #9
0
 public void FadeOut(float t, EaseType type)
 {
     this.fadeIn = false;
     this.time = 0;
     this.time2 = t;
     this.interpolate = Interpolate.Ease(type);
     this.fadeOut = true;
 }
Example #10
0
		/// <summary>
		/// Provides an easing factor for the given animation progress.
		/// </summary>
		/// <param name="progress"> The fractional progress of the animation (from 0 to 1). </param>
		/// <param name="type"> The type of easing to perform. </param>
		/// <param name="direction"> The direction of the animation. </param>
		/// <returns> The factor to use in the animation. </returns>
		public static double Factor(double progress, EaseType type, EaseDirection direction)
		{
			if (direction == EaseDirection.In)
				return InFactor(progress, type);
			else if (direction == EaseDirection.Out)
				return OutFactor(progress, type);
			else
				return InOutFactor(progress, type);
		}
Example #11
0
	public static IEnumerator ColorFade(Renderer renderer, Color start, Color end, float duration, EaseType easeType) {

		float t = 0f;
		while (t < 1f) {
			t += Time.deltaTime * (1f / duration);
			renderer.material.color = Color.Lerp (start, end, Ease (t, easeType));
			yield return null;
		}
	}
Example #12
0
	public static IEnumerator AlphaFade (Renderer renderer, float start, float end, float duration, EaseType easeType) {

		float t = 0f;
		while (t < 1f) {
			t += Time.deltaTime * (1f / duration);
			float newAlpha = Mathf.Lerp (start, end, Ease(t, easeType));
			renderer.material.color = new Color (renderer.material.color.r, renderer.material.color.g, renderer.material.color.b, newAlpha);
			yield return null;
		}
	}
Example #13
0
    public static IEnumerator AlphaTo(this UIPanel v, EaseType easeType, float duration, float to)
    {
        float from = v.alpha;

        var ease = new EaseRunner(easeType, duration);
        while (ease.IsPlaying()) {
            v.alpha = Mathf.Lerp(from, to, ease.Run());
            yield return new WaitForEndOfFrame();
        }
    }
Example #14
0
    public static IEnumerator ColorTo(this UIWidget v, EaseType easeType, float duration, Color to)
    {
        Color from = v.color;

        var ease = new EaseRunner(easeType, duration);
        while (ease.IsPlaying()) {
            v.color = Color.Lerp(from, to, ease.Run());
            yield return new WaitForEndOfFrame();
        }
    }
Example #15
0
    public static IEnumerator MoveTo(this MonoBehaviour v, EaseType easeType, float duration, Vector3 to)
    {
        Vector3 from = v.transform.localPosition;

        var ease = new EaseRunner(easeType, duration);
        while (ease.IsPlaying()) {
            v.transform.localPosition = Vector3.Lerp(from, to, ease.Run());
            yield return new WaitForEndOfFrame();
        }
    }
Example #16
0
    public SimpleTweener(float startValue, float endValue, float time, EaseType ease)
    {
        StartValue = startValue;
        EndValue = endValue;
        Time = time;
        Ease = ease;

        invTime = 1/Time;
        CurrentValue = StartValue;

        getEasingFunction();
    }
Example #17
0
 public void LoadSaveGame(string sc, Hashtable ht, int sID)
 {
     this.sceneName = sc;
     this.spawnID = sID;
     this.saveGameData = ht;
     this.fadeOut = DataHolder.LoadSaveHUD().fadeOut;
     this.fadeOutTime = DataHolder.LoadSaveHUD().fadeOutTime;
     this.fadeOutInterpolate = DataHolder.LoadSaveHUD().fadeOutInterpolate;
     this.fadeIn = DataHolder.LoadSaveHUD().fadeIn;
     this.fadeInTime = DataHolder.LoadSaveHUD().fadeInTime;
     this.fadeInInterpolate = DataHolder.LoadSaveHUD().fadeInInterpolate;
 }
Example #18
0
 public void NewGameScene()
 {
     this.sceneName = DataHolder.MainMenu().newGameScene;
     this.spawnID = -1;
     this.fadeOut = DataHolder.MainMenu().fadeOut;
     this.fadeOutTime = DataHolder.MainMenu().fadeOutTime;
     this.fadeOutInterpolate = DataHolder.MainMenu().fadeOutInterpolate;
     this.fadeIn = DataHolder.MainMenu().fadeIn;
     this.fadeInTime = DataHolder.MainMenu().fadeInTime;
     this.fadeInInterpolate = DataHolder.MainMenu().fadeInInterpolate;
     this.newGame = true;
 }
Example #19
0
		/// <summary>
		/// Provides an ease-in factor for the given animation progress.
		/// </summary>
		/// <param name="progress"> The fractional progress of the animation (from 0 to 1). </param>
		/// <param name="type"> The type of easing to perform. </param>
		/// <returns> The factor to use in the animation. </returns>
		public static double InFactor(double progress, EaseType type)
		{
			switch (type)
			{
			case EaseType.Linear:
				return progress;
			case EaseType.Quadratic:
				return progress * progress;
			case EaseType.Cubic:
				return progress * progress * progress;
			}
			throw new NotImplementedException("Don't know how to ease in for " + type.ToString());
		}
Example #20
0
	public static float Ease (float t, EaseType easeType) {

		switch (easeType) {
			case EaseType.None:
				return t;
			case EaseType.In:
				return Mathf.Lerp(0f, 1f, 1f - Mathf.Cos(t * Mathf.PI * 0.5f));
			case EaseType.Out:
				return Mathf.Lerp(0f, 1f, Mathf.Sin(t * Mathf.PI * 0.5f));
			default:
				return Mathf.SmoothStep(0f, 1f, t);
		}
	}
Example #21
0
    public static IEnumerator UIColorFade(CanvasRenderer renderer, Color start, Color end, float duration, EaseType easeType, Action callback) {

		float t = 0f;
		while (t < 1f) {
			t += Time.deltaTime * (1f / duration);
			renderer.SetColor (Color.Lerp (start, end, Ease (t, easeType)));
			yield return null;
		}

        if (callback != null)
        {
            callback();
        }
	}
Example #22
0
	// ease function -----------------------------------------------------
	public static EasingFunction GetEasingFunction(EaseType easeType)
	{
		switch (easeType)
		{
			case EaseType.easeInQuad:		return new EasingFunction(easeInQuad);
			case EaseType.easeOutQuad:		return new EasingFunction(easeOutQuad);
			case EaseType.easeInOutQuad:	return new EasingFunction(easeInOutQuad);
			case EaseType.easeInCubic:		return new EasingFunction(easeInCubic);
			case EaseType.easeOutCubic:		return new EasingFunction(easeOutCubic);
			case EaseType.easeInOutCubic:	return new EasingFunction(easeInOutCubic);
			case EaseType.easeInQuart:		return new EasingFunction(easeInQuart);
			case EaseType.easeOutQuart:		return new EasingFunction(easeOutQuart);
			case EaseType.easeInOutQuart:	return new EasingFunction(easeInOutQuart);
			case EaseType.easeInQuint:		return new EasingFunction(easeInQuint);
			case EaseType.easeOutQuint:		return new EasingFunction(easeOutQuint);
			case EaseType.easeInOutQuint:	return new EasingFunction(easeInOutQuint);
			case EaseType.easeInSine:		return new EasingFunction(easeInSine);
			case EaseType.easeOutSine:		return new EasingFunction(easeOutSine);
			case EaseType.easeInOutSine:	return new EasingFunction(easeInOutSine);
			case EaseType.easeInExpo:		return new EasingFunction(easeInExpo);
			case EaseType.easeOutExpo:		return new EasingFunction(easeOutExpo);
			case EaseType.easeInOutExpo:	return new EasingFunction(easeInOutExpo);
			case EaseType.easeInCirc:		return new EasingFunction(easeInCirc);
			case EaseType.easeOutCirc:		return new EasingFunction(easeOutCirc);
			case EaseType.easeInOutCirc:	return new EasingFunction(easeInOutCirc);
			case EaseType.linear:			return new EasingFunction(linear);
			case EaseType.spring:			return new EasingFunction(spring);
			/* GFX47 MOD START */
			/*case EaseType.bounce:
				return new EasingFunction(bounce);
				break;*/
			case EaseType.easeInBounce:		return new EasingFunction(easeInBounce);
			case EaseType.easeOutBounce:	return new EasingFunction(easeOutBounce);
			case EaseType.easeInOutBounce:	return new EasingFunction(easeInOutBounce);
			/* GFX47 MOD END */
			case EaseType.easeInBack:		return new EasingFunction(easeInBack);
			case EaseType.easeOutBack:		return new EasingFunction(easeOutBack);
			case EaseType.easeInOutBack:	return new EasingFunction(easeInOutBack);
			/* GFX47 MOD START */
			/*case EaseType.elastic:
				return new EasingFunction(elastic);
				break;*/
			case EaseType.easeInElastic:	return new EasingFunction(easeInElastic);
			case EaseType.easeOutElastic:	return new EasingFunction(easeOutElastic);
			case EaseType.easeInOutElastic:	return new EasingFunction(easeInOutElastic);
			/* GFX47 MOD END */
		}
		return null;
	}
    void Begin(Vector3 from, Vector3 to, float duration, EaseType easeType)
    {
        this._from = from;
        this._distance = to - from;
        this._duration = duration;
        this._easeType = easeType;
        this._timePassed = 0f;

        if (duration == 0f) {
            transform.localScale = to;
        } else {
            transform.localScale = from;
            _timePassed = 0f;
        }
    }
Example #24
0
    public void FadeTo(MusicClip m, float time, EaseType type)
    {
        if(this.currentPlaying == 0)
        {
            this.FadeIn(m, time, type);
        }
        else if(this.CheckPlay(m))
        {
            if(this.currentPlaying == 3)
            {
                this.sourceA.Stop();
                this.currentPlaying = 2;
            }
            else if(this.currentPlaying == 4)
            {
                this.sourceB.Stop();
                this.currentPlaying = 1;
            }

            this.lastMusic = this.currentMusic;
            this.currentMusic = m;

            this.lastMusic.FadeOut(time, type);
            this.currentMusic.FadeIn(time, type);

            if(this.currentPlaying == 1)
            {
                this.sourceB.clip = this.currentMusic.GetClip();
                this.sourceB.volume = 0;
                this.sourceB.loop = this.currentMusic.loop;
                this.sourceB.Play();
                this.currentPlaying = 3;
            }
            else if(this.currentPlaying == 2)
            {
                this.sourceA.clip = this.currentMusic.GetClip();
                this.sourceA.volume = 0;
                this.sourceA.loop = this.currentMusic.loop;
                this.sourceA.Play();
                this.currentPlaying = 4;
            }
            if(this.currentMusic.HasLoops())
            {
                this.ticking = true;
                this.DoTick();
            }
        }
    }
Example #25
0
	public static IEnumerator UIAlphaFade (CanvasGroup canvasGroup, float start, float end, float duration, EaseType easeType, Action callback) {

		float t = 0f;
		while (t < 1f) {
			t += Time.deltaTime * (1f / duration);
			float newAlpha = Mathf.Lerp (start, end, Ease(t, easeType));
			// renderer.SetColor ( new Color (renderer.GetColor().r, renderer.GetColor().g, renderer.GetColor().b, newAlpha));
            canvasGroup.alpha = newAlpha;
			yield return null;
		}

        if (callback != null)
        {
            callback();
        }
	}
		/// <summary>
		/// animates the letterbox in
		/// </summary>
		/// <returns>The in.</returns>
		/// <param name="letterboxSize">Letterbox size.</param>
		/// <param name="duration">Duration.</param>
		/// <param name="easeType">Ease type.</param>
		public IEnumerator animateIn( float letterboxSize, float duration = 2, EaseType easeType = EaseType.ExpoOut )
		{
			// wait for any current animations to complete
			while( _isAnimating )
				yield return null;
			
			_isAnimating = true;
			var elapsedTime = 0f;
			while( elapsedTime < duration )
			{
				elapsedTime += Time.deltaTime;
				this.letterboxSize = Lerps.ease( easeType, 0, letterboxSize, elapsedTime, duration );
				yield return null;
			}
			_isAnimating = false;
		}
Example #27
0
    /// <summary>
    /// initializes a new instance and sets up the details according to the config parameter
    /// </summary>
    public Tween( object target, float duration, TweenConfig config, Action<AbstractTween> onComplete = null )
    {
        // default to removing on complete
        autoRemoveOnComplete = true;

        this.target = target;
        this.duration = duration;

        // copy the TweenConfig info over
        id = config.id;
        delay = config.delay;
        loopType = config.loopType;
        iterations = config.iterations;
        _easeType = config.easeType;
        updateType = config.propertyUpdateType;
        isFrom = config.isFrom;
        timeScale = config.timeScale;
        _onComplete = config.onCompleteHandler;
        _onStart = config.onStartHandler;

        if( config.isPaused )
            state = TweenState.Paused;

        // if onComplete is passed to the constructor it wins. it is left as the final param to allow an inline Action to be
        // set and maintain clean code (Actions always try to be the last param of a method)
        if( onComplete != null )
            _onComplete = onComplete;

        // add all our properties
        for( var i = 0; i < config.tweenProperties.Count; i++ )
        {
            var tweenProp = config.tweenProperties[i];

            // if the tween property is initialized already it means it is being reused so we need to clone it
            if( tweenProp.isInitialized )
                tweenProp = tweenProp.clone();

            addTweenProperty( tweenProp );
        }

        // calculate total duration
        if( iterations < 0 )
            totalDuration = float.PositiveInfinity;
        else
            totalDuration = iterations * duration;
    }
Example #28
0
        public static float EaseFromTo(float start, float end, float value, EaseType type = EaseType.EaseInOut)
        {
            switch (type)
            {
                case EaseType.EaseInOut:
                    return Mathf.Lerp(start, end, value * value * (3.0f - 2.0f * value));

                case EaseType.EaseOut:
                    return Mathf.Lerp(start, end, Mathf.Sin(value * Mathf.PI * 0.5f));

                case EaseType.EaseIn:
                    return Mathf.Lerp(start, end, 1.0f - Mathf.Cos(value * Mathf.PI * 0.5f));

                default:
                    return Mathf.Lerp(start, end, value);
            }
        }
Example #29
0
    public IEnumerator MoveToPosition(Transform a, bool ic, bool g, bool fd, Vector3 wp, EaseType et, float t)
    {
        this.StopMoving();

        this.actor = a;
        if(ic) this.controller = (CharacterController)this.actor.GetComponent(typeof(CharacterController));
        this.applyGravity = g;
        this.waypoint = wp;
        this.interpolate = Interpolate.Ease(et);
        this.time = 0;
        this.time2 = t;

        yield return null;
        if(fd) this.actor.LookAt(new Vector3(this.waypoint.x, this.actor.position.y, this.waypoint.z));
        this.startPos = this.actor.position;
        this.distancePos = this.waypoint - this.startPos;
        this.moveToWP = true;
    }
Example #30
0
    private IEnumerator FadeScreen2(bool fa, float als, float ae, bool fr, float rs, float re,
			bool fg, float gs, float ge, bool fb, float bs, float be, EaseType et, float t)
    {
        this.fadingScreen = false;
        this.flash = false;
        yield return null;

        this.fadeAlpha = fa;
        this.alphaStart = als;
        this.alphaEnd = ae;
        this.alphaDistance = ae - als;
        this.fadeRed = fr;
        this.redStart = rs;
        this.redEnd = re;
        this.redDistance = re - rs;
        this.fadeGreen = fg;
        this.greenStart = gs;
        this.greenEnd = ge;
        this.greenDistance = ge - gs;
        this.fadeBlue = fb;
        this.blueStart = bs;
        this.blueEnd = be;
        this.blueDistance = be - bs;
        this.interpolate = Interpolate.Ease(et);
        this.time = 0;
        this.time2 = t;

        this.currentColor = new Color(0, 0, 0, 0);
        if(this.fadeAlpha) this.currentColor.a = Interpolate.Ease(this.interpolate, this.alphaStart, this.alphaDistance, this.time, this.time2);
        if(this.fadeRed) this.currentColor.r = Interpolate.Ease(this.interpolate, this.redStart, this.redDistance, this.time, this.time2);
        if(this.fadeGreen) this.currentColor.g = Interpolate.Ease(this.interpolate, this.greenStart, this.greenDistance, this.time, this.time2);
        if(this.fadeBlue) this.currentColor.b = Interpolate.Ease(this.interpolate, this.blueStart, this.blueDistance, this.time, this.time2);
        this.tex = new Texture2D(1, 1);
        this.tex.SetPixel(0, 0, this.currentColor);
        this.tex.Apply();
        DontDestroyOnLoad(this.tex);
        if(GUISystemType.ORK.Equals(DataHolder.GameSettings().guiSystemType))
        {
            GameHandler.GUIHandler().AddScreenFadeSprite(this);
        }
        this.fadingScreen = true;
    }
Example #31
0
 protected override void ScaleY(float _duration, Action _onPlayCallback, EaseType _easeType)
 {
     transform.ScaleInY(_duration, _easeType, _onPlayCallback);
 }
Example #32
0
    /**
     * Returns the static method that implements the given easing type for scalars.
     * Use this method to easily switch between easing interpolation types.
     *
     * All easing methods clamp elapsedTime so that it is always <= duration.
     *
     * var ease = Interpolate.Ease(EaseType.EaseInQuad);
     * i = ease(start, distance, elapsedTime, duration);
     */
    public static Function Ease(EaseType type)
    {
        // Source Flash easing functions:
        // http://gizma.com/easing/
        // http://www.robertpenner.com/easing/easing_demo.html
        //
        // Changed to use more friendly variable names, that follow my Lerp
        // conventions:
        // start = b (start value)
        // distance = c (change in value)
        // elapsedTime = t (current time)
        // duration = d (time duration)

        Function f = null;

        switch (type)
        {
        case EaseType.Linear: f = Interpolate.Linear; break;

        case EaseType.EaseInQuad: f = Interpolate.EaseInQuad; break;

        case EaseType.EaseOutQuad: f = Interpolate.EaseOutQuad; break;

        case EaseType.EaseInOutQuad: f = Interpolate.EaseInOutQuad; break;

        case EaseType.EaseInCubic: f = Interpolate.EaseInCubic; break;

        case EaseType.EaseOutCubic: f = Interpolate.EaseOutCubic; break;

        case EaseType.EaseInOutCubic: f = Interpolate.EaseInOutCubic; break;

        case EaseType.EaseInQuart: f = Interpolate.EaseInQuart; break;

        case EaseType.EaseOutQuart: f = Interpolate.EaseOutQuart; break;

        case EaseType.EaseInOutQuart: f = Interpolate.EaseInOutQuart; break;

        case EaseType.EaseInQuint: f = Interpolate.EaseInQuint; break;

        case EaseType.EaseOutQuint: f = Interpolate.EaseOutQuint; break;

        case EaseType.EaseInOutQuint: f = Interpolate.EaseInOutQuint; break;

        case EaseType.EaseInSine: f = Interpolate.EaseInSine; break;

        case EaseType.EaseOutSine: f = Interpolate.EaseOutSine; break;

        case EaseType.EaseInOutSine: f = Interpolate.EaseInOutSine; break;

        case EaseType.EaseInExpo: f = Interpolate.EaseInExpo; break;

        case EaseType.EaseOutExpo: f = Interpolate.EaseOutExpo; break;

        case EaseType.EaseInOutExpo: f = Interpolate.EaseInOutExpo; break;

        case EaseType.EaseInCirc: f = Interpolate.EaseInCirc; break;

        case EaseType.EaseOutCirc: f = Interpolate.EaseOutCirc; break;

        case EaseType.EaseInOutCirc: f = Interpolate.EaseInOutCirc; break;
        }
        return(f);
    }
Example #33
0
        public static float Ease(EaseType ease, float t, float duration)
        {
            switch (ease)
            {
            case EaseType.Linear:
                return(EasingFunctions.Linear.Ease(t, duration));

            case EaseType.SineIn:
                return(EasingFunctions.Sine.EaseIn(t, duration));

            case EaseType.SineOut:
                return(EasingFunctions.Sine.EaseOut(t, duration));

            case EaseType.SineInOut:
                return(EasingFunctions.Sine.EaseInOut(t, duration));

            case EaseType.QuadIn:
                return(EasingFunctions.Quad.EaseIn(t, duration));

            case EaseType.QuadOut:
                return(EasingFunctions.Quad.EaseOut(t, duration));

            case EaseType.QuadInOut:
                return(EasingFunctions.Quad.EaseInOut(t, duration));

            case EaseType.CubicIn:
                return(EasingFunctions.Cubic.EaseIn(t, duration));

            case EaseType.CubicOut:
                return(EasingFunctions.Cubic.EaseOut(t, duration));

            case EaseType.CubicInOut:
                return(EasingFunctions.Cubic.EaseInOut(t, duration));

            case EaseType.QuintIn:
                return(EasingFunctions.Quint.EaseIn(t, duration));

            case EaseType.QuintOut:
                return(EasingFunctions.Quint.EaseOut(t, duration));

            case EaseType.QuintInOut:
                return(EasingFunctions.Quint.EaseInOut(t, duration));

            case EaseType.ExpoIn:
                return(EasingFunctions.Expo.EaseIn(t, duration));

            case EaseType.ExpoOut:
                return(EasingFunctions.Expo.EaseOut(t, duration));

            case EaseType.ExpoInOut:
                return(EasingFunctions.Expo.EaseInOut(t, duration));

            case EaseType.CircIn:
                return(EasingFunctions.Circ.EaseIn(t, duration));

            case EaseType.CircOut:
                return(EasingFunctions.Circ.EaseOut(t, duration));

            case EaseType.CircInOut:
                return(EasingFunctions.Circ.EaseInOut(t, duration));

            case EaseType.BackIn:
                return(EasingFunctions.Back.EaseIn(t, duration));

            case EaseType.BackOut:
                return(EasingFunctions.Back.EaseOut(t, duration));

            case EaseType.BackInOut:
                return(EasingFunctions.Back.EaseInOut(t, duration));

            case EaseType.ElasticIn:
                return(EasingFunctions.Elastic.EaseIn(t, duration));

            case EaseType.ElasticOut:
                return(EasingFunctions.Elastic.EaseOut(t, duration));

            case EaseType.ElasticInOut:
                return(EasingFunctions.Elastic.EaseInOut(t, duration));

            case EaseType.BounceIn:
                return(EasingFunctions.Bounce.EaseIn(t, duration));

            case EaseType.BounceOut:
                return(EasingFunctions.Bounce.EaseOut(t, duration));

            case EaseType.BounceInOut:
                return(EasingFunctions.Bounce.EaseInOut(t, duration));

            default:
                return(EasingFunctions.Linear.Ease(t, duration));
            }
        }
Example #34
0
 public Base Ease(EaseType easeType)
 {
     this.ease = GetEaseFunction(easeType);
     return(this);
 }
        /// <summary>Goes to the next cinematic target</summary>
        /// <param name="targetTransform">The Transform component of the target</param>
        /// <param name="easeInDuration">The time it takes for the camera to reach the target</param>
        /// <param name="holdDuration">The time the camera follows the target. If below 0, you’ll have to manually move to the next target by using the GoToNextTarget method</param>
        /// <param name="zoom">The zoom the camera should make while following the target. Use 1 for no zoom</param>
        /// <param name="easeType">The animation type of the camera movement to reach the target</param>
        /// <param name="sendMessageName">The method name that will be called when the target is reached</param>
        /// <param name="sendMessageParam">The parameter that will be sent when the above method is called</param>
        /// <param name="index">The position in the targets list. Use -1 to put in last and 0 for first</param>
        public void AddCinematicTarget(Transform targetTransform, float easeInDuration = 1f, float holdDuration = 1f, float zoom = 1f, EaseType easeType = EaseType.EaseOut, string sendMessageName = "", string sendMessageParam = "", int index = -1)
        {
            var newCinematicTarget = new CinematicTarget()
            {
                TargetTransform  = targetTransform,
                EaseInDuration   = easeInDuration,
                HoldDuration     = holdDuration,
                Zoom             = zoom,
                EaseType         = easeType,
                SendMessageName  = sendMessageName,
                SendMessageParam = sendMessageParam
            };

            if (index == -1 || index > CinematicTargets.Count)
            {
                CinematicTargets.Add(newCinematicTarget);
            }
            else
            {
                CinematicTargets.Insert(index, newCinematicTarget);
            }
        }
Example #36
0
 /// Sets the ease for this tween to Quad In Out.
 public Tween <DriverValueType> SetEaseQuadInOut()
 {
     this.ease = EaseType.QuadInOut;
     return(this);
 }
Example #37
0
 /// <summary>
 /// Creates a new instance of this plugin.
 /// </summary>
 /// <param name="p_endVal">
 /// The <see cref="float"/> value to tween to.
 /// </param>
 /// <param name="p_easeType">
 /// The <see cref="EaseType"/> to use.
 /// </param>
 /// <param name="p_isRelative">
 /// If <c>true</c>, the given end value is considered relative instead than absolute.
 /// </param>
 public PlugInt(float p_endVal, EaseType p_easeType, bool p_isRelative)
     : base(p_endVal, p_easeType, p_isRelative)
 {
 }
Example #38
0
        public static Func <float, float, float, float> Function(EaseType type)
        {
            switch (type)
            {
            case EaseType.Linear:
                return(EaseFunctions[(int)EaseType.Linear]);

            case EaseType.QuadraticIn:
                return(EaseFunctions[(int)EaseType.QuadraticIn]);

            case EaseType.QuadraticOut:
                return(EaseFunctions[(int)EaseType.QuadraticOut]);

            case EaseType.QuadraticInOut:
                return(EaseFunctions[(int)EaseType.QuadraticInOut]);

            case EaseType.QuarticIn:
                return(EaseFunctions[(int)EaseType.QuarticIn]);

            case EaseType.QuarticOut:
                return(EaseFunctions[(int)EaseType.QuarticOut]);

            case EaseType.QuarticInOut:
                return(EaseFunctions[(int)EaseType.QuarticInOut]);

            case EaseType.QuinticIn:
                return(EaseFunctions[(int)EaseType.QuinticIn]);

            case EaseType.QuinticOut:
                return(EaseFunctions[(int)EaseType.QuinticOut]);

            case EaseType.QuinticInOut:
                return(EaseFunctions[(int)EaseType.QuinticInOut]);

            case EaseType.CubicIn:
                return(EaseFunctions[(int)EaseType.CubicIn]);

            case EaseType.CubicOut:
                return(EaseFunctions[(int)EaseType.CubicOut]);

            case EaseType.CubicInOut:
                return(EaseFunctions[(int)EaseType.CubicInOut]);

            case EaseType.ExponentialIn:
                return(EaseFunctions[(int)EaseType.ExponentialIn]);

            case EaseType.ExponentialOut:
                return(EaseFunctions[(int)EaseType.ExponentialOut]);

            case EaseType.ExponentialInOut:
                return(EaseFunctions[(int)EaseType.ExponentialInOut]);

            case EaseType.CircularIn:
                return(EaseFunctions[(int)EaseType.CircularIn]);

            case EaseType.CircularOut:
                return(EaseFunctions[(int)EaseType.CircularOut]);

            case EaseType.CircularInOut:
                return(EaseFunctions[(int)EaseType.CircularInOut]);

            case EaseType.SinusoidalIn:
                return(EaseFunctions[(int)EaseType.SinusoidalIn]);

            case EaseType.SinusoidalOut:
                return(EaseFunctions[(int)EaseType.SinusoidalOut]);

            case EaseType.SinusoidalInOut:
                return(EaseFunctions[(int)EaseType.SinusoidalInOut]);

            case EaseType.ElasticIn:
                return(EaseFunctions[(int)EaseType.ElasticIn]);

            case EaseType.ElasticOut:
                return(EaseFunctions[(int)EaseType.ElasticOut]);

            case EaseType.ElasticInOut:
                return(EaseFunctions[(int)EaseType.ElasticInOut]);

            case EaseType.BounceIn:
                return(EaseFunctions[(int)EaseType.BounceIn]);

            case EaseType.BounceOut:
                return(EaseFunctions[(int)EaseType.BounceOut]);

            case EaseType.BounceInOut:
                return(EaseFunctions[(int)EaseType.BounceInOut]);

            case EaseType.BackIn:
                return(EaseFunctions[(int)EaseType.BackIn]);

            case EaseType.BackOut:
                return(EaseFunctions[(int)EaseType.BackOut]);

            case EaseType.BackInOut:
                return(EaseFunctions[(int)EaseType.BackInOut]);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #39
0
 /// Sets the ease for this tween to Cubic In Out.
 public Tween <DriverValueType> SetEaseCubicInOut()
 {
     this.ease = EaseType.CubicInOut;
     return(this);
 }
 public TweenScaleToScenarioItem(List <GameObject> targets, Vector3 endScale, float duration, EaseType ease)
     : this(targets, endScale, duration, ease, true)
 {
 }
Example #41
0
        /// <summary>
        /// Interpolate using the specified function.
        /// </summary>
        static public float Interpolate(float p, EaseType function)
        {
            switch (function)
            {
            default: return(Linear(p));

            case EaseType.Linear: return(Linear(p));

            case EaseType.QuadraticEaseOut: return(QuadraticEaseOut(p));

            case EaseType.QuadraticEaseIn: return(QuadraticEaseIn(p));

            case EaseType.QuadraticEaseInOut: return(QuadraticEaseInOut(p));

            case EaseType.CubicEaseIn: return(CubicEaseIn(p));

            case EaseType.CubicEaseOut: return(CubicEaseOut(p));

            case EaseType.CubicEaseInOut: return(CubicEaseInOut(p));

            case EaseType.QuarticEaseIn: return(QuarticEaseIn(p));

            case EaseType.QuarticEaseOut: return(QuarticEaseOut(p));

            case EaseType.QuarticEaseInOut: return(QuarticEaseInOut(p));

            case EaseType.QuinticEaseIn: return(QuinticEaseIn(p));

            case EaseType.QuinticEaseOut: return(QuinticEaseOut(p));

            case EaseType.QuinticEaseInOut: return(QuinticEaseInOut(p));

            case EaseType.SineEaseIn: return(SineEaseIn(p));

            case EaseType.SineEaseOut: return(SineEaseOut(p));

            case EaseType.SineEaseInOut: return(SineEaseInOut(p));

            case EaseType.CircularEaseIn: return(CircularEaseIn(p));

            case EaseType.CircularEaseOut: return(CircularEaseOut(p));

            case EaseType.CircularEaseInOut: return(CircularEaseInOut(p));

            case EaseType.ExponentialEaseIn: return(ExponentialEaseIn(p));

            case EaseType.ExponentialEaseOut: return(ExponentialEaseOut(p));

            case EaseType.ExponentialEaseInOut: return(ExponentialEaseInOut(p));

            case EaseType.ElasticEaseIn: return(ElasticEaseIn(p));

            case EaseType.ElasticEaseOut: return(ElasticEaseOut(p));

            case EaseType.ElasticEaseInOut: return(ElasticEaseInOut(p));

            case EaseType.BackEaseIn: return(BackEaseIn(p));

            case EaseType.BackEaseOut: return(BackEaseOut(p));

            case EaseType.BackEaseInOut: return(BackEaseInOut(p));

            case EaseType.BounceEaseIn: return(BounceEaseIn(p));

            case EaseType.BounceEaseOut: return(BounceEaseOut(p));

            case EaseType.BounceEaseInOut: return(BounceEaseInOut(p));
            }
        }
Example #42
0
 public static IEnumerator CurveFrom(this Transform transform, Vector3 control, Vector3 start, float duration, EaseType ease)
 {
     return(CurveFrom(transform, control, start, duration, Ease.FromType(ease)));
 }
Example #43
0
 /// Sets the ease for this tween to Sine Out.
 public Tween <DriverValueType> SetEaseSineOut()
 {
     this.ease = EaseType.SineOut;
     return(this);
 }
Example #44
0
 /// <summary>
 /// Creates a new instance of this plugin.
 /// </summary>
 /// <param name="p_endVal">
 /// The <see cref="Vector3"/> euler angles to tween to.
 /// </param>
 /// <param name="p_easeType">
 /// The <see cref="EaseType"/> to use.
 /// </param>
 /// <param name="p_isRelative">
 /// If <c>true</c>, the given end value is considered relative instead than absolute.
 /// </param>
 public PlugQuaternion(Vector3 p_endVal, EaseType p_easeType, bool p_isRelative)
     : base(p_endVal, p_easeType, p_isRelative)
 {
 }
Example #45
0
 /// Sets the ease for this tween to Linear.
 public Tween <DriverValueType> SetEaseLinear()
 {
     this.ease = EaseType.Linear;
     return(this);
 }
Example #46
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public GTweener SetEase(EaseType value)
 {
     _easeType = value;
     return(this);
 }
Example #47
0
 /// Sets the ease for this tween.
 public Tween <DriverValueType> SetEase(EaseType ease)
 {
     this.ease = ease;
     return(this);
 }
Example #48
0
 protected override void Fade(float _duration, Action _onPlayCallback, EaseType _easeType)
 {
     transform.FadeIn(_duration, _easeType, _onPlayCallback);
 }
Example #49
0
    public static System.Func <float, float> GetEaseFunction(EaseType easeType)
    {
        switch (easeType)
        {
        case EaseType.linear: return(Tween.Ease.linear);

        case EaseType.clerp: return(Tween.Ease.clerp);

        case EaseType.spring: return(Tween.Ease.spring);

        case EaseType.easeInQuad: return(Tween.Ease.easeInQuad);

        case EaseType.easeOutQuad: return(Tween.Ease.easeOutQuad);

        case EaseType.easeInOutQuad: return(Tween.Ease.easeInOutQuad);

        case EaseType.easeInCubic: return(Tween.Ease.easeInCubic);

        case EaseType.easeOutCubic: return(Tween.Ease.easeOutCubic);

        case EaseType.easeInOutCubic: return(Tween.Ease.easeInOutCubic);

        case EaseType.easeInQuart: return(Tween.Ease.easeInQuart);

        case EaseType.easeOutQuart: return(Tween.Ease.easeOutQuart);

        case EaseType.easeInOutQuart: return(Tween.Ease.easeInOutQuart);

        case EaseType.easeInQuint: return(Tween.Ease.easeInQuint);

        case EaseType.easeOutQuint: return(Tween.Ease.easeOutQuint);

        case EaseType.easeInOutQuint: return(Tween.Ease.easeInOutQuint);

        case EaseType.easeInSine: return(Tween.Ease.easeInSine);

        case EaseType.easeOutSine: return(Tween.Ease.easeOutSine);

        case EaseType.easeInOutSine: return(Tween.Ease.easeInOutSine);

        case EaseType.easeInExpo: return(Tween.Ease.easeInExpo);

        case EaseType.easeOutExpo: return(Tween.Ease.easeOutExpo);

        case EaseType.easeInOutExpo: return(Tween.Ease.easeInOutExpo);

        case EaseType.easeInCirc: return(Tween.Ease.easeInCirc);

        case EaseType.easeOutCirc: return(Tween.Ease.easeOutCirc);

        case EaseType.easeInOutCirc: return(Tween.Ease.easeInOutCirc);

        case EaseType.easeInBounce: return(Tween.Ease.easeInBounce);

        case EaseType.easeOutBounce: return(Tween.Ease.easeOutBounce);

        case EaseType.easeInOutBounce: return(Tween.Ease.easeInOutBounce);

        case EaseType.easeInBack: return(Tween.Ease.easeInBack);

        case EaseType.easeOutBack: return(Tween.Ease.easeOutBack);

        case EaseType.easeInOutBack: return(Tween.Ease.easeInOutBack);

        case EaseType.easeInElastic: return(Tween.Ease.easeInElastic);

        case EaseType.easeOutElastic: return(Tween.Ease.easeOutElastic);

        case EaseType.easeInOutElastic: return(Tween.Ease.easeInOutElastic);
        }
        return(Tween.Ease.easeInOutQuad);
    }
Example #50
0
 internal override void Slide(float _duration, Action _onPlayCallback, EaseType _easeType, slideDirection _direction)
 {
     transform.SlideIn(_duration, _easeType, _onPlayCallback, false, false, _direction);
 }
Example #51
0
 public static IEnumerator ScaleFrom(this Transform transform, Vector3 target, float duration, EaseType ease)
 {
     return(ScaleFrom(transform, target, duration, Ease.FromType(ease)));
 }
Example #52
0
 /// Sets the ease for this tween to Quart In.
 public Tween <DriverValueType> SetEaseQuartIn()
 {
     this.ease = EaseType.QuartIn;
     return(this);
 }
 public TweenScaleToScenarioItem(List <GameObject> targets, Vector3 endScale, float duration, EaseType ease, bool isInterruptable)
     : base(isInterruptable)
 {
     this.targets  = targets;
     this.endScale = endScale;
     this.duration = duration;
     this.ease     = ease;
 }
Example #54
0
 /// <summary>
 /// Creates a new instance of this plugin.
 /// </summary>
 /// <param name="p_endVal">
 /// The <see cref="Vector3"/> euler angles to tween to.
 /// </param>
 /// <param name="p_easeType">
 /// The <see cref="EaseType"/> to use.
 /// </param>
 public PlugQuaternion(Vector3 p_endVal, EaseType p_easeType)
     : base(p_endVal, p_easeType, false)
 {
 }
Example #55
0
 public static IEnumerator RotateFrom(this Transform transform, Quaternion target, float duration, EaseType ease)
 {
     return(RotateFrom(transform, target, duration, Ease.FromType(ease)));
 }
Example #56
0
 /// <summary>
 /// Creates a new instance of this plugin.
 /// </summary>
 /// <param name="p_endVal">
 /// The <see cref="float"/> value to tween to.
 /// </param>
 /// <param name="p_easeType">
 /// The <see cref="EaseType"/> to use.
 /// </param>
 public PlugInt(float p_endVal, EaseType p_easeType)
     : base(p_endVal, p_easeType, false)
 {
 }
 public TweenScaleToScenarioItem(GameObject target, Vector3 endScale, float duration, EaseType ease, bool isInterruptable)
     : this(new List <GameObject>() { target }, endScale, duration, ease, isInterruptable)
 {
 }
        public GButtonColorAnimationPlayer(MonoBehaviour monoBehaviour, Image image,
                                           bool useColorAnimationOnHover, Color colorOnHover, float colorDurationOnHover, EaseType colorEaseTypeOnHover, ColorSpaceType colorSpaceTypeOnHover,
                                           bool useColorAnimationOnClick, Color colorOnClick, float colorDurationOnClick, EaseType colorEaseTypeOnClick, ColorSpaceType colorSpaceTypeOnClick)
        {
            this.monoBehaviour            = monoBehaviour;
            this.image                    = image;
            this.colorEaseTypeOnClick     = colorEaseTypeOnClick;
            this.colorSpaceTypeOnClick    = colorSpaceTypeOnClick;
            this.colorEaseTypeOnHover     = colorEaseTypeOnHover;
            this.colorSpaceTypeOnHover    = colorSpaceTypeOnHover;
            this.useColorAnimationOnHover = useColorAnimationOnHover;
            this.colorOnHover             = colorOnHover;
            this.colorDurationOnHover     = colorDurationOnHover;
            this.useColorAnimationOnClick = useColorAnimationOnClick;
            this.colorOnClick             = colorOnClick;
            this.colorDurationOnClick     = colorDurationOnClick;

            _defaultColor = image.color;
        }