Ejemplo n.º 1
0
		void Update()
		{
			if (m_scene != null)
			{
				if (!m_initialized)
				{
					m_scene.Init();
					m_initialized = true;
					m_delay = 0.5f;
				}

				if (m_scene.IsLoaded() && m_moveLoader == null)
				{
					m_delay -= Time.deltaTime;
					if (m_delay > 0)
						return;

					GameManager.Instance.OnSceneLoaded();

					if (m_move != SceneMove.None)
					{
						m_moveLoader = HOTween.To(Root, 1,
							new TweenParms()
								.Prop("localPosition", m_startPos)
								.Ease(EaseType.Linear)
								.OnComplete(OnLoaderMoveDone));
					}
					else
					{
						OnLoaderMoveDone();
					}
				}
			}
		}
Ejemplo n.º 2
0
    IEnumerator DoDeath()
    {
        WaitForFixedUpdate wait = new WaitForFixedUpdate();

        mEyeLock = false;

        Holoville.HOTween.Tweener[] shakeTweens;

        deathSfx.Play();

        //shake
        shakeTweens = new Holoville.HOTween.Tweener[deathGOs.Length];
        for (int i = 0; i < deathGOs.Length; i++)
        {
            shakeTweens[i] = Holoville.HOTween.HOTween.Shake(deathGOs[i].transform, deathShakeDuration,
                                                             "localPosition", new Vector3(deathShakeAmount, 0, 0),
                                                             true, deathShakeAmp, deathShakePeriod);
            shakeTweens[i].loops = -1;
            shakeTweens[i].Play();
        }

        //wait
        yield return(new WaitForSeconds(deathFallStartDelay));

        //fade
        deathFader.gameObject.SetActive(true);
        deathFader.Play("fadeout");

        //fall down while fading
        float curFallVel = 0;

        while (deathFader.isPlaying)
        {
            for (int i = 0; i < deathGOs.Length; i++)
            {
                Vector3 pos = deathGOs[i].transform.position;
                pos.y -= curFallVel * Time.fixedDeltaTime;
            }

            curFallVel += deathFallAccel * Time.fixedDeltaTime;

            yield return(wait);
        }

        for (int i = 0; i < shakeTweens.Length; i++)
        {
            Holoville.HOTween.HOTween.Kill(shakeTweens[i]);
        }

        //deactivate self, go to next boss
        gameObject.SetActive(false);
        shieldGO.SetActive(false);
        armGO.SetActive(false);
        damageGO.SetActive(false);

        nextBossGO.SetActive(true);
    }
Ejemplo n.º 3
0
		void OnLoaderMoveDone()
		{
			gameObject.SetActive(false);

			if (m_moveLoader != null)
			{
				m_moveLoader.Kill();
				m_moveLoader = null;
			}
		}
Ejemplo n.º 4
0
 protected virtual void OnLoop()
 {
     if (this.item.loopAnimation)
     {
         this.isLooping = true;
         if (this.mLoop == null)
         {
             this.cachedTransform.localScale = Vector3.one * 1.5f;
             this.mLoop = HOTween.To(this.cachedTransform, 0.5f, new TweenParms().Prop("localScale", Vector3.one).Ease(EaseType.Linear).Loops(-1, LoopType.Yoyo).IntId(999));
         }
         else if (this.mLoop.isPaused)
         {
             this.mLoop.Play();
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Resumes the given Tweener (delays included), and returns the total number of resumed ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to resume.
 /// </param>
 /// <returns>
 /// The total number of resumed Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int Play(Tweener p_tweener)
 {
     return Play(p_tweener, false);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Resumes the given Tweener,
 /// sets it so that it moves forward and not backwards,
 /// and returns the total number of resumed ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to resume.
 /// </param>
 /// <param name="p_skipDelay">
 /// If <c>true</c> skips any initial delay.
 /// </param>
 /// <returns>
 /// The total number of resumed Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int PlayForward(Tweener p_tweener, bool p_skipDelay)
 {
     return DoFilteredIteration(p_tweener, DoFilteredPlayForward, false, p_skipDelay);
 }
Ejemplo n.º 7
0
        // ***********************************************************************************
        // INIT
        // ***********************************************************************************

        /// <summary>
        /// Initializes the given <see cref="Tweener"/> with the stored parameters.
        /// </summary>
        /// <param name="p_tweenObj">
        /// The <see cref="Tweener"/> to initialize.
        /// </param>
        /// <param name="p_target">
        /// The <see cref="Tweener"/> target.
        /// </param>
        internal void InitializeObject(Tweener p_tweenObj, object p_target)
        {
            InitializeOwner(p_tweenObj);

            if (speedBased && !easeSet)
            {
                easeType = EaseType.Linear;
            }
            p_tweenObj._pixelPerfect             = pixelPerfect;
            p_tweenObj._speedBased               = speedBased;
            p_tweenObj._easeType                 = easeType;
            p_tweenObj._easeAnimationCurve       = easeAnimCurve;
            p_tweenObj._easeOvershootOrAmplitude = easeOvershootOrAmplitude;
            p_tweenObj._easePeriod               = easePeriod;
            p_tweenObj._delay = p_tweenObj.delayCount = delay;
            p_tweenObj.isFrom = isFrom;
            p_tweenObj.onPluginOverwritten       = onPluginOverwritten;
            p_tweenObj.onPluginOverwrittenWParms = onPluginOverwrittenWParms;
            p_tweenObj.onPluginOverwrittenParms  = onPluginOverwrittenParms;

            // Parse properties and create/set plugins.
            p_tweenObj.plugins = new List <ABSTweenPlugin>();
            Type      targetType     = p_target.GetType();
            FieldInfo fieldInfo      = null;
            int       propDatasCount = propDatas.Count;

            for (int i = 0; i < propDatasCount; ++i)
            {
                HOTPropData data = propDatas[i];
                // Store propInfo and fieldInfo to see if they exist, and then pass them to plugin init.
                PropertyInfo propInfo = targetType.GetProperty(data.propName);
                if (propInfo == null)
                {
                    fieldInfo = targetType.GetField(data.propName);
                    if (fieldInfo == null)
                    {
                        TweenWarning.Log("\"" + p_target + "." + data.propName + "\" is missing, static, or not public. The tween for this property will not be created.");
                        continue;
                    }
                }
                // Store correct plugin.
                ABSTweenPlugin plug;
                ABSTweenPlugin absTweenPlugin = data.endValOrPlugin as ABSTweenPlugin;
                if (absTweenPlugin != null)
                {
                    // Use existing plugin.
                    plug = absTweenPlugin;
                    if (plug.ValidateTarget(p_target))
                    {
                        if (plug.initialized)
                        {
                            // This plugin was already initialized with another Tweener. Clone it.
                            plug = plug.CloneBasic(); // OPTIMIZE Uses Activator, which is slow.
                        }
                    }
                    else
                    {
                        // Invalid target.
                        TweenWarning.Log(Utils.SimpleClassName(plug.GetType()) + " : Invalid target (" + p_target + "). The tween for this property will not be created.");
                        continue;
                    }
                }
                else
                {
                    // Parse value to find correct plugin to use.
                    plug = null;
//                    string propType = (propInfo != null ? propInfo.PropertyType.ToString() : fieldInfo.FieldType.ToString());
//                    string shortPropType = propType.Substring(propType.IndexOf(".") + 1);
                    string shortPropType = propInfo != null
                        ? _TypeToShortString.ContainsKey(propInfo.PropertyType) ? _TypeToShortString[propInfo.PropertyType] : ""
                        : _TypeToShortString.ContainsKey(fieldInfo.FieldType) ? _TypeToShortString[fieldInfo.FieldType] : "";

                    switch (shortPropType)
                    {
                    case "Vector2":
                        if (!ValidateValue(data.endValOrPlugin, PlugVector2.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugVector2((Vector2)data.endValOrPlugin, data.isRelative);
                        break;

                    case "Vector3":
                        if (!ValidateValue(data.endValOrPlugin, PlugVector3.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugVector3((Vector3)data.endValOrPlugin, data.isRelative);
                        break;

                    case "Vector4":
                        if (!ValidateValue(data.endValOrPlugin, PlugVector4.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugVector4((Vector4)data.endValOrPlugin, data.isRelative);
                        break;

                    case "Quaternion":
                        if (!ValidateValue(data.endValOrPlugin, PlugQuaternion.validValueTypes))
                        {
                            break;
                        }
                        if (data.endValOrPlugin is Vector3)
                        {
                            plug = new PlugQuaternion((Vector3)data.endValOrPlugin, data.isRelative);
                        }
                        else
                        {
                            plug = new PlugQuaternion((Quaternion)data.endValOrPlugin, data.isRelative);
                        }
                        break;

                    case "Color":
                        if (!ValidateValue(data.endValOrPlugin, PlugColor.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugColor((Color)data.endValOrPlugin, data.isRelative);
                        break;

                    case "Color32":
                        if (!ValidateValue(data.endValOrPlugin, PlugColor32.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugColor32((Color32)data.endValOrPlugin, data.isRelative);
                        break;

                    case "Rect":
                        if (!ValidateValue(data.endValOrPlugin, PlugRect.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugRect((Rect)data.endValOrPlugin, data.isRelative);
                        break;

                    case "String":
                        if (!ValidateValue(data.endValOrPlugin, PlugString.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugString(data.endValOrPlugin.ToString(), data.isRelative);
                        break;

                    case "Int32":
                        if (!ValidateValue(data.endValOrPlugin, PlugInt.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugInt((int)data.endValOrPlugin, data.isRelative);
                        break;

                    case "UInt32":
                        if (!ValidateValue(data.endValOrPlugin, PlugUInt.validValueTypes))
                        {
                            break;
                        }
                        plug = new PlugUInt(Convert.ToUInt32(data.endValOrPlugin), data.isRelative);
                        break;

                    default:
                        if (data.endValOrPlugin.GetType() != typeof(Boolean))
                        {
                            try {
                                plug = new PlugFloat(Convert.ToSingle(data.endValOrPlugin), data.isRelative);
                            } catch (Exception) {
                                TweenWarning.Log("No valid plugin for animating \"" + p_target + "." + data.propName + "\" (of type " + (propInfo != null ? propInfo.PropertyType : fieldInfo.FieldType) + "). The tween for this property will not be created.");
                                continue;
                            }
                        }
                        break;
                    }
                    if (plug == null)
                    {
                        TweenWarning.Log("The end value set for \"" + p_target + "." + data.propName + "\" tween is invalid. The tween for this property will not be created.");
                        continue;
                    }
                }
                plug.Init(p_tweenObj, data.propName, easeType, targetType, propInfo, fieldInfo);
                p_tweenObj.plugins.Add(plug);
            }
        }
Ejemplo n.º 8
0
 public void takeDamage(float d)
 {
     if (overcharged)
         damageTakenWhileOvercharged += d;
     lastHit = Time.time;
     //Make Shield more Opaque After getting hit
     if (hitAnim != null)
     {
         hitAnim.Kill();
     }
     if (sprite != null)
     {
         sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, 1);
         hitAnim = HOTween.To(sprite, .5f, new TweenParms().Prop("color", (new Color(sprite.color.r, sprite.color.g, sprite.color.b, .1f))).UpdateType(UpdateType.Update).Ease(EaseType.EaseOutSine));
     }
     float dif = d - shields;
     if (shields == 0)
     {
         return;
     }
     if (shields != 0)
     {
         if (shields < d)
         {
             shields = 0;
             sBar.setValue();
             //NEED TO PLAY EFFECT SHOWING SHIELD FAILING
             return;
         }
         if (shields >= d)
         {
             shields -= d;
             sBar.setValue();
         }
         if (shields < 0)
         {
             shields = 0;
         }
     }
 }
Ejemplo n.º 9
0
 public void Insert(AMKey key, Tweener tween)
 {
     mSequence.Insert(key.getWaitTime(mTake.frameRate, 0.0f), tween);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Completes the given Tweener, and returns the total number of completed ones (1 if the Tweener existed, otherwise 0).
 /// Where a loop was involved and not infinite, the relative Tweener 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_tweener">
 /// The Tweener to complete.
 /// </param>
 /// <returns>
 /// The total number of completed Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int Complete(Tweener p_tweener)
 {
     return DoFilteredIteration(p_tweener, DoFilteredComplete, true);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Reverses the given Tweener,
 /// animating it from its current value back to the starting one,
 /// and returns the total number of reversed Tweeners (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener 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 Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int Reverse(Tweener p_tweener, bool p_forcePlay = false)
 {
     return DoFilteredIteration(p_tweener, DoFilteredReverse, p_forcePlay);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Restarts the given Tweener from position 0, but recalculating them by taking their current targets values as start values,
 /// and the currently changed value to determine the end values.
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to restart.
 /// </param>
 /// <returns>
 /// The total number of restarted Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int RestartIncremental(Tweener p_tweener)
 {
     return DoFilteredIteration(p_tweener, DoFilteredRestartIncremental, false);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Restarts the given Tweener, and returns the total number of restarted ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to restart.
 /// </param>
 /// <param name="p_skipDelay">
 /// If <c>true</c> skips any initial delay.
 /// </param>
 /// <returns>
 /// The total number of restarted Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int Restart(Tweener p_tweener, bool p_skipDelay)
 {
     return DoFilteredIteration(p_tweener, DoFilteredRestart, false, p_skipDelay);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Restarts the given Tweener (delays included), and returns the total number of restarted ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to restart.
 /// </param>
 /// <returns>
 /// The total number of restarted Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int Restart(Tweener p_tweener)
 {
     return Restart(p_tweener, false);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Rewinds the given Tweener (delays included), and returns the total number of rewinded ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to rewind.
 /// </param>
 /// <returns>
 /// The total number of rewinded Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int Rewind(Tweener p_tweener)
 {
     return Rewind(p_tweener, false);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Resumes the given Tweener,
 /// sets it so that it moves backwards instead than forward,
 /// and returns the total number of resumed ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to resume.
 /// </param>
 /// <returns>
 /// The total number of resumed Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int PlayBackwards(Tweener p_tweener)
 {
     return DoFilteredIteration(p_tweener, DoFilteredPlayBackwards, false);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Kills the given Tweener, and returns the total number of killed ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to kill.
 /// </param>
 /// <returns>
 /// The total number of killed Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int Kill(Tweener p_tweener)
 {
     return DoFilteredIteration(p_tweener, DoFilteredKill, true);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates a new tween and returns the <see cref="Tweener"/> representing it,
        /// or <c>null</c> if the tween was invalid (no valid property to tween was given).
        /// </summary>
        /// <param name="p_target">
        /// The tweening target (must be the object containing the properties or fields to tween).
        /// </param>
        /// <param name="p_duration">
        /// The duration in seconds of the tween.
        /// </param>
        /// <param name="p_parms">
        /// A <see cref="TweenParms"/> representing the tween parameters.
        /// You can pass an existing one, or create a new one inline via method chaining,
        /// like <c>new TweenParms().Prop("x",10).Loops(2).OnComplete(myFunction)</c>
        /// </param>
        /// <returns>
        /// The newly created <see cref="Tweener"/>,
        /// or <c>null</c> if the parameters were invalid.
        /// </returns>
        public static Tweener To(object p_target, float p_duration, TweenParms p_parms)
        {
            if (!initialized) Init();

            Tweener tw = new Tweener(p_target, p_duration, p_parms);

            // Check if tween is valid.
            if (tw.isEmpty) {
                return null;
            }

            AddTween(tw);
            return tw;
        }
Ejemplo n.º 19
0
        private void takeDamage(float d, Collision2D col)
        {
            if (overcharged)
                damageTakenWhileOvercharged += d;
            lastHit = Time.time;
            controller.hullRef.lastHit = lastHit;//set hull last hit to same time
            //Make Shield more Opaque After getting hit
            if (hitAnim != null)
            {
                hitAnim.Kill();
            }
            sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, 1);
            hitAnim = HOTween.To(sprite, .5f, new TweenParms().Prop("color", (new Color(sprite.color.r, sprite.color.g, sprite.color.b, .1f))).UpdateType(UpdateType.Update).Ease(EaseType.EaseOutSine));
            float dif = d - shields;
            if (shields == 0)
            {
                return;
            }
            if (shields != 0)
            {
                if (shields < d)
                {
                    shields = 0;
                    sBar.setValue();
                    //NEED TO PLAY EFFECT SHOWING SHIELD FAILING
                }
                if (shields >= d)
                {
                    shields -= d;
                    sBar.setValue();
                    //NEED TO UPDATE FOR OBJECT POOLING SO IT DEACTIVATES INSTEAD OF DESTROYS
                    //NEED TO PLAY EFFECT FOR SHIELD HIT
                }
                if (shields < 0)
                {
                    shields = 0;               
                }
                col.gameObject.layer = LayerMask.NameToLayer("Default");
                TrashMan.despawn(col.gameObject);

            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Creates a new FROM tween and returns the <see cref="Tweener"/> representing it,
        /// or <c>null</c> if the tween was invalid (no valid property to tween was given).
        /// </summary>
        /// <param name="p_target">
        /// The tweening target (must be the object containing the properties or fields to tween).
        /// </param>
        /// <param name="p_duration">
        /// The duration in seconds of the tween.
        /// </param>
        /// <param name="p_parms">
        /// A <see cref="TweenParms"/> representing the tween parameters.
        /// You can pass an existing one, or create a new one inline via method chaining,
        /// like <c>new TweenParms().Prop("x",10).Loops(2).OnComplete(myFunction)</c>
        /// </param>
        /// <returns>
        /// The newly created <see cref="Tweener"/>,
        /// or <c>null</c> if the parameters were invalid.
        /// </returns>
        public static Tweener From(object p_target, float p_duration, TweenParms p_parms)
        {
            if (!initialized) Init();

            p_parms = p_parms.IsFrom();
            Tweener tw = new Tweener(p_target, p_duration, p_parms);

            // Check if tween is valid.
            if (tw.isEmpty) {
                return null;
            }

            AddTween(tw);
            // Immediately jump to position 0 to avoid flickering of objects before they're punched to FROM position.
            // p_isStartupIteration is set to FALSE to ignore callbacks.
            if (!tw._isPaused) {
                tw.Update(0, true, true, false, true);
            }
            return tw;
        }
Ejemplo n.º 21
0
 protected override void affectEnemy()
 {
     if (!charging)
     {
         if (chargingAnim != null)
         {
             chargingAnim.Kill();
             resetBeam();
         }
         chargingAnim = HOTween.To(this, effectiveChargeTime, new TweenParms().Prop("width1", .1f).Prop("color1", new Color(1,.4f,0,1)).Prop("effectiveDamage",damage).UpdateType(UpdateType.Update).Ease(EaseType.EaseInSine).OnComplete(Charged).OnUpdate(chargeBeam));
     }
     charging = true;
     hasBeenReset = false;
     if(tController!=null)
         tController.takeBeamDamage(((1/effectiveFireRate) * effectiveDamage)*Time.deltaTime);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates a new SHAKE tween and returns the <see cref="Tweener"/> representing it,
        /// or <c>null</c> if the tween was invalid (no valid property to tween was given).
        /// Any ease type passed won't be considered, since shake uses its own one.
        /// </summary>
        /// <param name="p_target">
        /// The tweening target (must be the object containing the properties or fields to tween).
        /// </param>
        /// <param name="p_duration">The duration in seconds of the tween.</param>
        /// <param name="p_parms">
        /// A <see cref="TweenParms"/> representing the tween parameters.
        /// You can pass an existing one, or create a new one inline via method chaining,
        /// like <c>new TweenParms().Prop("x",10).Loops(2).OnComplete(myFunction)</c>
        /// </param>
        /// <param name="p_shakeAmplitude">Default: 0.1f - amplitude of the shake effect</param>
        /// <param name="p_shakePeriod">Default: 0.12f - oscillation period of shake effect</param>
        /// <returns>
        /// The newly created <see cref="Tweener"/>,
        /// or <c>null</c> if the parameters were invalid.
        /// </returns>
        public static Tweener Shake(object p_target, float p_duration, TweenParms p_parms, float p_shakeAmplitude = 0.1f, float p_shakePeriod = 0.12f)
        {
            if (!initialized) Init();

            p_parms
                .Ease(EaseType.EaseOutElastic, p_shakeAmplitude, p_shakePeriod)
                .IsFrom();
            Tweener tw = new Tweener(p_target, p_duration, p_parms);

            // Check if tween is valid.
            if (tw.isEmpty) return null;

            AddTween(tw);
            return tw;
        }
Ejemplo n.º 23
0
 protected override void affectEnemy()
 {
     if (!charging)
     {
         chargingAnim = HOTween.To(this, 2, new TweenParms().Prop("width1", .1f).Prop("color1", new Color(0, 0, 1, 1)).UpdateType(UpdateType.Update).Ease(EaseType.EaseInSine).OnUpdate(chargeBeam));
     }
     charging = true;
     hasBeenReset = false;
     tController.takeBeamDamage(((1 / effectiveFireRate) * effectiveDamage) * Time.deltaTime);
     tController.snare();
     tController.reduceShield();
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Pauses the given Tweener, and returns the total number of paused ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to pause.
 /// </param>
 /// <returns>
 /// The total number of paused Tweener (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int Pause(Tweener p_tweener)
 {
     return DoFilteredIteration(p_tweener, DoFilteredPause, false);
 }
Ejemplo n.º 25
0
        // ***********************************************************************************
        // INIT
        // ***********************************************************************************

        /// <summary>
        /// Initializes the given <see cref="Tweener"/> with the stored parameters.
        /// </summary>
        /// <param name="p_tweenObj">
        /// The <see cref="Tweener"/> to initialize.
        /// </param>
        /// <param name="p_target">
        /// The <see cref="Tweener"/> target.
        /// </param>
        internal void InitializeObject(Tweener p_tweenObj, object p_target)
        {
            InitializeOwner(p_tweenObj);

            if (speedBased && !easeSet) easeType = EaseType.Linear;
            p_tweenObj._pixelPerfect = pixelPerfect;
            p_tweenObj._speedBased = speedBased;
            p_tweenObj._easeType = easeType;
            p_tweenObj._easeAnimationCurve = easeAnimCurve;
            p_tweenObj._easeOvershootOrAmplitude = easeOvershootOrAmplitude;
            p_tweenObj._easePeriod = easePeriod;
            p_tweenObj._delay = p_tweenObj.delayCount = delay;
            p_tweenObj.isFrom = isFrom;
            p_tweenObj.onPluginOverwritten = onPluginOverwritten;
            p_tweenObj.onPluginOverwrittenWParms = onPluginOverwrittenWParms;
            p_tweenObj.onPluginOverwrittenParms = onPluginOverwrittenParms;

            // Parse properties and create/set plugins.
            p_tweenObj.plugins = new List<ABSTweenPlugin>();
            Type targetType = p_target.GetType();
            FieldInfo fieldInfo = null;
            int propDatasCount = propDatas.Count;
            for (int i = 0; i < propDatasCount; ++i) {
                HOTPropData data = propDatas[i];
                // Store propInfo and fieldInfo to see if they exist, and then pass them to plugin init.
                PropertyInfo propInfo = targetType.GetProperty(data.propName);
                if (propInfo == null) {
                    fieldInfo = targetType.GetField(data.propName);
                    if (fieldInfo == null)
                    {
                        TweenWarning.Log("\"" + p_target + "." + data.propName + "\" is missing, static, or not public. The tween for this property will not be created.");
                        continue;
                    }
                }
                // Store correct plugin.
                ABSTweenPlugin plug;
                ABSTweenPlugin absTweenPlugin = data.endValOrPlugin as ABSTweenPlugin;
                if (absTweenPlugin != null) {
                    // Use existing plugin.
                    plug = absTweenPlugin;
                    if (plug.ValidateTarget(p_target)) {
                        if (plug.initialized) {
                            // This plugin was already initialized with another Tweener. Clone it.
                            plug = plug.CloneBasic(); // OPTIMIZE Uses Activator, which is slow.
                        }
                    } else {
                        // Invalid target.
                        TweenWarning.Log(Utils.SimpleClassName(plug.GetType()) + " : Invalid target (" + p_target + "). The tween for this property will not be created.");
                        continue;
                    }
                } else {
                    // Parse value to find correct plugin to use.
                    plug = null;
//                    string propType = (propInfo != null ? propInfo.PropertyType.ToString() : fieldInfo.FieldType.ToString());
//                    string shortPropType = propType.Substring(propType.IndexOf(".") + 1);
                    string shortPropType = propInfo != null
                        ? _TypeToShortString.ContainsKey(propInfo.PropertyType) ? _TypeToShortString[propInfo.PropertyType] : ""
                        : _TypeToShortString.ContainsKey(fieldInfo.FieldType) ? _TypeToShortString[fieldInfo.FieldType] : "";
                    switch (shortPropType) {
                        case "Vector2":
                            if (!ValidateValue(data.endValOrPlugin, PlugVector2.validValueTypes)) break;
                            plug = new PlugVector2((Vector2)data.endValOrPlugin, data.isRelative);
                            break;
                        case "Vector3":
                            if (!ValidateValue(data.endValOrPlugin, PlugVector3.validValueTypes)) break;
                            plug = new PlugVector3((Vector3)data.endValOrPlugin, data.isRelative);
                            break;
                        case "Vector4":
                            if (!ValidateValue(data.endValOrPlugin, PlugVector4.validValueTypes)) break;
                            plug = new PlugVector4((Vector4)data.endValOrPlugin, data.isRelative);
                            break;
                        case "Quaternion":
                            if (!ValidateValue(data.endValOrPlugin, PlugQuaternion.validValueTypes)) break;
                            if (data.endValOrPlugin is Vector3) {
                                plug = new PlugQuaternion((Vector3)data.endValOrPlugin, data.isRelative);
                            } else {
                                plug = new PlugQuaternion((Quaternion)data.endValOrPlugin, data.isRelative);
                            }
                            break;
                        case "Color":
                            if (!ValidateValue(data.endValOrPlugin, PlugColor.validValueTypes)) break;
                            plug = new PlugColor((Color)data.endValOrPlugin, data.isRelative);
                            break;
                        case "Color32":
                            if (!ValidateValue(data.endValOrPlugin, PlugColor32.validValueTypes)) break;
                            plug = new PlugColor32((Color32)data.endValOrPlugin, data.isRelative);
                            break;
                        case "Rect":
                            if (!ValidateValue(data.endValOrPlugin, PlugRect.validValueTypes)) break;
                            plug = new PlugRect((Rect)data.endValOrPlugin, data.isRelative);
                            break;
                        case "String":
                            if (!ValidateValue(data.endValOrPlugin, PlugString.validValueTypes)) break;
                            plug = new PlugString(data.endValOrPlugin.ToString(), data.isRelative);
                            break;
                        case "Int32":
                            if (!ValidateValue(data.endValOrPlugin, PlugInt.validValueTypes)) break;
                            plug = new PlugInt((int)data.endValOrPlugin, data.isRelative);
                            break;
                        case "UInt32":
                            if (!ValidateValue(data.endValOrPlugin, PlugUInt.validValueTypes)) break;
                            plug = new PlugUInt(Convert.ToUInt32(data.endValOrPlugin), data.isRelative);
                            break;
                        default:
                            if (data.endValOrPlugin.GetType() != typeof(Boolean)) {
                                try {
                                    plug = new PlugFloat(Convert.ToSingle(data.endValOrPlugin), data.isRelative);
                                } catch (Exception) {
                                    TweenWarning.Log("No valid plugin for animating \"" + p_target + "." + data.propName + "\" (of type " + (propInfo != null ? propInfo.PropertyType : fieldInfo.FieldType) + "). The tween for this property will not be created.");
                                    continue;
                                }
                            }
                            break;
                    }
                    if (plug == null) {
                        TweenWarning.Log("The end value set for \"" + p_target + "." + data.propName + "\" tween is invalid. The tween for this property will not be created.");
                        continue;
                    }
                }
                plug.Init(p_tweenObj, data.propName, easeType, targetType, propInfo, fieldInfo);
                p_tweenObj.plugins.Add(plug);
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Resumes the given Tweener (delays included),
 /// sets it so that it moves forward and not backwards,
 /// and returns the total number of resumed ones (1 if the Tweener existed, otherwise 0).
 /// </summary>
 /// <param name="p_tweener">
 /// The Tweener to resume.
 /// </param>
 /// <returns>
 /// The total number of resumed Tweeners (1 if the Tweener existed, otherwise 0).
 /// </returns>
 public static int PlayForward(Tweener p_tweener)
 {
     return PlayForward(p_tweener, false);
 }