Beispiel #1
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            if (m_Instance == null)
            {
                return;
            }
            if (m_revert)
            {
                if ((m_followType & FxFollowType.followPos) > 0 && m_EndTrans != null)
                {
                    m_EndWorldPos = ParticleCtrlUtilities.CalcNodeTransPos(m_EndRole, m_EndTrans, m_EndPosOffsetInWorld);
                }
                if (m_StartTrans != null)
                {
                    m_StartWorldPos = ParticleCtrlUtilities.CalcNodeTransPos(m_StartRole, m_StartTrans, m_StartPosOffsetInWorld);
                }
            }
            else
            {
                if ((m_followType & FxFollowType.followPos) > 0 && m_StartTrans != null)
                {
                    m_StartWorldPos = ParticleCtrlUtilities.CalcNodeTransPos(m_StartRole, m_StartTrans, m_StartPosOffsetInWorld);
                }
                if (m_EndTrans != null)
                {
                    m_EndWorldPos = ParticleCtrlUtilities.CalcNodeTransPos(m_EndRole, m_EndTrans, m_EndPosOffsetInWorld);
                }
            }

            var pct = GetPercent(playable);

            m_Instance.transform.position = Vector3.Lerp(m_StartWorldPos, m_EndWorldPos, pct);
        }
Beispiel #2
0
        // Token: 0x06000226 RID: 550 RVA: 0x0000AB69 File Offset: 0x00008D69
        public override void OnBehaviourPlay(Playable playable, FrameData info)
        {
            if (this.m_Instance != null)
            {
                this.m_Instance.SetActive(true);
                if (m_ParentTrans != null)
                {
                    m_Instance.transform.position =
                        ParticleCtrlUtilities.CalcNodeTransPos(
                            m_Instance.transform.parent, m_ParentTrans
                            , m_PosOffsetInWorld);
                    if (m_initResetRotate)
                    {
                        //try find CharactorRoot
                        var anim = ParticleCtrlUtilities.FindAnimInParent(m_ParentTrans);
                        if (anim != null)
                        {
                            m_Instance.transform.rotation = anim.transform.rotation;
                        }
                        else
                        {
                            m_Instance.transform.localRotation = Quaternion.identity;
                        }
                    }
                    else
                    {
                        m_Instance.transform.rotation = m_ParentTrans.rotation;
                    }
                    //m_Instance.transform.localScale = m_ParentTrans.lossyScale;
                }
                else
                {
                    m_Instance.transform.position = m_PosOffsetInWorld;
                    m_Instance.transform.rotation = Quaternion.identity;
                    //m_Instance.transform.localScale = Vector3.one;
                }
                initWorldPos    = m_Instance.transform.position;
                initWorldRotate = m_Instance.transform.rotation;

                var helper = m_Instance.GetComponent <TimelineFollowTranHelper>();
                if (helper == null)
                {
                    helper = m_Instance.AddComponent <TimelineFollowTranHelper>();
                }
                helper.m_ParentTrans      = m_ParentTrans;
                helper.m_followType       = m_followType;
                helper.m_PosOffsetInWorld = m_PosOffsetInWorld;
                helper.initWorldPos       = initWorldPos;
                helper.initWorldRotate    = initWorldRotate;
            }
        }
Beispiel #3
0
 // Called each frame while the state is set to Play
 public override void PrepareFrame(Playable playable, FrameData info)
 {
     if (m_ParentTrans == null || followType == FxFollowType.none)
     {
         return;
     }
     if ((followType & FxFollowType.followPos) > 0)
     {
         m_Instance.transform.position = ParticleCtrlUtilities.CalcNodeTransPos(m_Instance.transform.parent, m_ParentTrans, posOffset);
     }
     if ((followType & FxFollowType.followRotate) > 0)
     {
         m_Instance.transform.rotation = m_ParentTrans.rotation;
     }
 }
Beispiel #4
0
 private void LateUpdate()
 {
     if (m_ParentTrans == null || m_followType == FxFollowType.none)
     {
         transform.position = initWorldPos;
         transform.rotation = initWorldRotate;
         return;
     }
     if ((m_followType & FxFollowType.followPos) > 0)
     {
         transform.position = ParticleCtrlUtilities.CalcNodeTransPos(transform.parent, m_ParentTrans, m_PosOffsetInWorld);
     }
     if ((m_followType & FxFollowType.followRotate) > 0)
     {
         transform.rotation = m_ParentTrans.rotation;
     }
 }
Beispiel #5
0
        public static void InitPrticle(GameObject particle, GameObject root)
        {
            if (particle == null)
            {
                //Debug.LogError("特效资源为空");
                return;
            }
            var pTrans = (root == null) ? null : root.transform;

            if (pTrans != null)
            {
                var roleAnim = ParticleCtrlUtilities.FindAnimInParent(pTrans);
                if (roleAnim != null)
                {
                    particle.transform.SetParent(roleAnim.transform.parent);
                }
            }
        }
Beispiel #6
0
 Vector3 CalcDirection()
 {
     if (startRoot == null && m_StartTrans != null)
     {
         var anim = ParticleCtrlUtilities.FindAnimInParent(m_StartTrans);
         if (anim != null)
         {
             startRoot = anim.transform;
         }
     }
     if (endRoot == null && m_EndTrans != null)
     {
         var anim = ParticleCtrlUtilities.FindAnimInParent(m_EndTrans);
         if (anim != null)
         {
             endRoot = anim.transform;
         }
     }
     if (m_revert)
     {
         if (startRoot != null && endRoot != null)
         {
             return(startRoot.position - endRoot.position);
         }
         else
         {
             return(endRoot.forward);
         }
     }
     else
     {
         if (startRoot != null && endRoot != null)
         {
             return(endRoot.position - startRoot.position);
         }
         else
         {
             return(startRoot.forward);
         }
     }
 }
Beispiel #7
0
        // Token: 0x06000226 RID: 550 RVA: 0x0000AB69 File Offset: 0x00008D69
        public override void OnBehaviourPlay(Playable playable, FrameData info)
        {
            if (this.m_Instance != null)
            {
                this.m_Instance.SetActive(true);
                if (m_StartTrans != null)
                {
                    //m_Instance.transform.localScale = m_StartTrans.lossyScale;
                    m_StartWorldPos = ParticleCtrlUtilities.CalcNodeTransPos(m_StartRole, m_StartTrans, m_StartPosOffsetInWorld);
                }
                else
                {
                    m_StartWorldPos = m_StartPosOffsetInWorld;
                    m_Instance.transform.position = m_StartPosOffsetInWorld;
                    m_Instance.transform.rotation = Quaternion.identity;
                    //m_Instance.transform.localScale = Vector3.one;
                }

                if (m_EndTrans != null)
                {
                    m_EndWorldPos = ParticleCtrlUtilities.CalcNodeTransPos(m_EndRole, m_EndTrans, m_EndPosOffsetInWorld);
                }
                else
                {
                    m_EndWorldPos = m_EndPosOffsetInWorld;
                }

                if (m_revert)
                {
                    m_Instance.transform.position = m_EndWorldPos;
                }
                else
                {
                    m_Instance.transform.position = m_StartWorldPos;
                }
                m_Instance.transform.forward = CalcDirection();
            }
        }
Beispiel #8
0
 // Update is called once per frame
 void LateUpdate()
 {
     CalcPct();
     if (lifePct > 1f)
     {
         if (destory)
         {
             GameObject.Destroy(gameObject);
         }
         else
         {
             gameObject.SetActive(false);
         }
     }
     else if (TargetTrans != null)
     {
         transform.position = Vector3.Lerp(startPos, TargetTrans.position, flyPct);
     }
     else
     {
         if (followTrans == null || followType == FxFollowType.none)
         {
             transform.position = posOffset;
             transform.rotation = rotateOffset;
             return;
         }
         if ((followType & FxFollowType.followPos) > 0)
         {
             transform.position = ParticleCtrlUtilities.CalcNodeTransPos(transform.parent, followTrans, posOffset);
         }
         if ((followType & FxFollowType.followRotate) > 0)
         {
             transform.rotation = followTrans.rotation;
         }
     }
 }
Beispiel #9
0
        // Token: 0x06000224 RID: 548 RVA: 0x0000AA7C File Offset: 0x00008C7C
        void Initialize(GameObject prefabGameObject
                        , Transform startTransform
                        , Transform endTransform
                        , Vector3 startOffsetInWorld
                        , Vector3 endOffsetInWorld
                        , FxFollowType followType
                        , bool initResetRotate
                        , float realLife
                        , float duration
                        , bool revert
                        , float scaleFactor
                        )
        {
            if (startTransform == null || endTransform == null)
            {
                return;
            }
            if (prefabGameObject == null)
            {
                throw new System.ArgumentNullException("Prefab cannot be null");
            }
            if (this.m_Instance != null)
            {
                Debug.LogWarningFormat("Prefab Control Playable ({0}) has already been initialized with a Prefab ({1}).", new object[]
                {
                    prefabGameObject.name,
                    this.m_Instance.name
                });
            }
            else
            {
                this.m_Instance      = Object.Instantiate <GameObject>(prefabGameObject);
                this.m_Instance.name = prefabGameObject.name + " [Timeline]";
                this.m_Instance.SetActive(false);
                ParticleScaleUtility.ScaleEffectNode(this.m_Instance, scaleFactor);
                this.m_StartTrans = startTransform;
                if (this.m_StartTrans != null)
                {
                    var anim = ParticleCtrlUtilities.FindAnimInParent(m_StartTrans);
                    if (anim != null)
                    {
                        this.m_StartRole = anim.transform;
                    }
                }
                this.m_EndTrans = endTransform;
                if (this.m_EndTrans != null)
                {
                    var anim = ParticleCtrlUtilities.FindAnimInParent(m_EndTrans);
                    if (anim != null)
                    {
                        this.m_EndRole = anim.transform;
                    }
                }
                this.m_StartPosOffsetInWorld = startOffsetInWorld;
                this.m_EndPosOffsetInWorld   = endOffsetInWorld;
                this.m_followType            = followType;
                this.m_initResetRotate       = initResetRotate;
                this.m_realLife = realLife;
                this.m_duration = duration;
                this.m_revert   = revert;
                //float roleScale = 1f;
                if (startTransform != null)
                {
                    var roleAnim = ParticleCtrlUtilities.FindAnimInParent(startTransform);
                    if (roleAnim != null)
                    {
                        this.m_Instance.transform.SetParent(roleAnim.transform.parent);
                        //roleScale = roleAnim.transform.lossyScale.x;
                    }
                }
                //ParticleScaleUtility.ScaleEffectNode(this.m_Instance, scaleFactor * roleScale);
                //if (m_ParentTrans != null)
                //{
                //    m_Instance.transform.position = m_ParentTrans.position + m_PosOffsetInWorld;
                //    if( initResetRotate)
                //        m_Instance.transform.rotation = Quaternion.identity;
                //    else
                //        m_Instance.transform.rotation = m_ParentTrans.rotation;
                //    m_Instance.transform.localScale = m_ParentTrans.lossyScale;
                //} else
                //{
                //    m_Instance.transform.position = m_PosOffsetInWorld;
                //    m_Instance.transform.rotation = Quaternion.identity;
                //    m_Instance.transform.localScale = Vector3.one;
                //}

                ParticlePrefabControl.SetHideFlagsRecursive(this.m_Instance);
            }
        }
Beispiel #10
0
        // Called when the state of the playable is set to Play
        public override void OnBehaviourPlay(Playable playable, FrameData info)
        {
            if (m_Instance == null)
            {
                this.m_Instance = fxGo;
                //if (!this.m_Instance.activeInHierarchy)
                //{
                //    this.m_Instance.SetActive(true);
                //}
                //this.m_Instance.name = prefabGameObject.name + " [Timeline]";
                //this.m_Instance.SetActive(false);
                //float roleScale = 1f;
                m_ParentTrans = (sourceGameObject == null) ? null : sourceGameObject.transform;
                //if (m_ParentTrans != null)
                //{
                //    var roleAnim = ParticleCtrlUtilities.FindAnimInParent(m_ParentTrans);

                //    //if (roleAnim != null)
                //    //{
                //    //    roleScale = roleAnim.transform.lossyScale.x;
                //    //}
                //}
                //ParticleScaleUtility.ScaleEffectNode(this.m_Instance, scaleFactor * roleScale);
            }

            if (this.m_Instance != null)
            {
                this.m_Instance.SetActive(true);
                if (m_ParentTrans != null)
                {
                    m_Instance.transform.position = ParticleCtrlUtilities.CalcNodeTransPos(m_Instance.transform.parent, m_ParentTrans, posOffset);
                    if (initResetRotate)
                    {
                        var anim = ParticleCtrlUtilities.FindAnimInParent(m_ParentTrans);
                        if (anim != null)
                        {
                            m_Instance.transform.rotation = anim.transform.rotation;
                        }
                        else
                        {
                            m_Instance.transform.localRotation = Quaternion.identity;
                        }
                    }
                    else
                    {
                        m_Instance.transform.rotation = m_ParentTrans.rotation;
                    }
                }
                else
                {
                    m_Instance.transform.position = posOffset;
                    m_Instance.transform.rotation = Quaternion.identity;
                }
                var particles = m_Instance.GetComponentsInChildren <ParticleSystem>(true);
                if (particles != null && particles.Length > 0)
                {
                    foreach (var p in particles)
                    {
                        p.Simulate(clipIn, false, true);
                        p.Play(false);
                    }
                }

                var matAnims = m_Instance.GetComponentsInChildren <FxHelper.FxHelper_MatAnim>(true);
                if (matAnims != null && matAnims.Length > 0)
                {
                    foreach (var a in matAnims)
                    {
                        a.SetTime(clipIn);
                    }
                }
            }
        }