Example #1
0
        public void Init(XftEventComponent client)
        {
            m_client = client;
            if (m_DownsampleMaterial == null)
            {
                downsampleShader               = client.GlowDownSampleShader;
                m_DownsampleMaterial           = new Material(downsampleShader);
                m_DownsampleMaterial.hideFlags = HideFlags.HideAndDontSave;
            }

            if (m_CompositeMaterial == null)
            {
                compositeShader               = client.GlowCompositeShader;
                m_CompositeMaterial           = new Material(compositeShader);
                m_CompositeMaterial.hideFlags = HideFlags.HideAndDontSave;
            }

            if (m_BlurMaterial == null)
            {
                blurShader               = client.GlowBlurShader;
                m_BlurMaterial           = new Material(blurShader);
                m_BlurMaterial.hideFlags = HideFlags.HideAndDontSave;
            }
            SetClientParam();
        }
Example #2
0
 public GlitchEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.Glitch, owner)
 {
     m_random     = new WaveRandom();
     Mask         = owner.GlitchMask;
     GlitchShader = owner.GlitchShader;
 }
Example #3
0
 public GlowEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.Glow, owner)
 {
     downsampleShader = owner.GlowDownSampleShader;
     compositeShader  = owner.GlowCompositeShader;
     blurShader       = owner.GlowBlurShader;
 }
Example #4
0
        public GlowEvent(XftEventComponent owner)
            : base(CameraEffectEvent.EType.Glow, owner)
        {

            downsampleShader = owner.GlowDownSampleShader;
            compositeShader = owner.GlowCompositeShader;
            blurShader = owner.GlowBlurShader;
        }
Example #5
0
 public void ResetEditorEvents()
 {
     for (int i = 0; i < EventList.Count; i++)
     {
         XftEventComponent e = EventList[i];
         e.ResetCustom();
     }
 }
Example #6
0
 public GlowPerObjEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.GlowPerObj, owner)
 {
     ReplacementShader = owner.GlowPerObjReplacementShader;
     blendShader       = owner.GlowPerObjBlendShader;
     downsampleShader  = owner.GlowDownSampleShader;
     compositeShader   = owner.GlowCompositeShader;
     blurShader        = owner.GlowBlurShader;
 }
Example #7
0
        //[System.Obsolete("DeActive() is deprecated, please use Stop() instead.")]
        public void DeActive()
        {
            for (int i = 0; i < EventList.Count; i++)
            {
                XftEventComponent e = EventList[i];
                e.ResetCustom();
            }


            //foreach (Transform child in transform)
            //{
            //    SetActive(child.gameObject, false);
            //}
            //SetActive(gameObject, false);


            gameObject.SetActive(false);
        }
Example #8
0
        public void Init(XftEventComponent client)
        {
            //Note: In forward lightning path, the depth texture is not automatically generated.
            if (Camera.main.depthTextureMode == DepthTextureMode.None)
            {
                Camera.main.depthTextureMode = DepthTextureMode.Depth;
            }

            m_client = client;

            ReplacementShader = client.GlowPerObjReplacementShader;


            blendShader = client.GlowPerObjBlendShader;

            if (m_blendMaterial == null)
            {
                m_blendMaterial           = new Material(blendShader);
                m_blendMaterial.hideFlags = HideFlags.HideAndDontSave;
            }

            if (m_DownsampleMaterial == null)
            {
                downsampleShader               = client.GlowDownSampleShader;
                m_DownsampleMaterial           = new Material(downsampleShader);
                m_DownsampleMaterial.hideFlags = HideFlags.HideAndDontSave;
            }

            if (m_CompositeMaterial == null)
            {
                compositeShader               = client.GlowCompositeShader;
                m_CompositeMaterial           = new Material(compositeShader);
                m_CompositeMaterial.hideFlags = HideFlags.HideAndDontSave;
            }

            if (m_BlurMaterial == null)
            {
                blurShader               = client.GlowBlurShader;
                m_BlurMaterial           = new Material(blurShader);
                m_BlurMaterial.hideFlags = HideFlags.HideAndDontSave;
            }
            SetClientParam();
        }
Example #9
0
        public void Reset()
        {
            mIsActive   = true;
            ElapsedTime = 0f;

            //reset times
            Start();

            for (int i = 0; i < EflList.Count; i++)
            {
                EffectLayer el = EflList[i];
                el.Reset();
            }


            for (int i = 0; i < EventList.Count; i++)
            {
                XftEventComponent e = EventList[i];
                e.ResetCustom();
            }
        }
Example #10
0
        public void Reset(XftEventComponent client)
        {
            if (m_client != null && !CheckDone())
            {
                //Debug.LogWarning("can't reset CameraShake Component, may be the last shake is not finished?");
                //return;
            }

            m_client = client;
            PositionSpring.Stiffness = new Vector3(m_client.PositionStifness, m_client.PositionStifness, m_client.PositionStifness);
            PositionSpring.Damping   = Vector3.one - new Vector3(m_client.PositionDamping, m_client.PositionDamping, m_client.PositionDamping);

            RotationSpring.Stiffness = new Vector3(m_client.RotationStiffness, m_client.RotationStiffness, m_client.RotationStiffness);
            RotationSpring.Damping   = Vector3.one - new Vector3(m_client.RotationDamping, m_client.RotationDamping, m_client.RotationDamping);
            m_elapsedTime            = 0f;

            PositionSpring.RefreshTransformType();
            RotationSpring.RefreshTransformType();

            m_earthQuakeTimeTemp = m_client.EarthQuakeTime;
        }
Example #11
0
        public void Reset(XftEventComponent client)
        {
            m_client = client;
            if (m_client.CameraShakeType == XCameraShakeType.Spring)
            {
                if (PositionSpring != null && !CheckDone())
                {
                    //last event shake has not finished, so set the client pos to original pos.
                    transform.localPosition = mOriPosition;
                    transform.localRotation = Quaternion.Euler(mOriRotation);
                }

                //reset spring
                PositionSpring = new Spring(client.transform, Spring.TransformType.Position);
                PositionSpring.MinVelocity = 0.00001f;
                RotationSpring = new Spring(client.transform, Spring.TransformType.Rotation);
                RotationSpring.MinVelocity = 0.00001f;
                PositionSpring.Stiffness = new Vector3(m_client.PositionStifness, m_client.PositionStifness, m_client.PositionStifness);
                PositionSpring.Damping = Vector3.one - new Vector3(m_client.PositionDamping, m_client.PositionDamping, m_client.PositionDamping);
                RotationSpring.Stiffness = new Vector3(m_client.RotationStiffness, m_client.RotationStiffness, m_client.RotationStiffness);
                RotationSpring.Damping = Vector3.one - new Vector3(m_client.RotationDamping, m_client.RotationDamping, m_client.RotationDamping);

                m_client.transform.localPosition = transform.localPosition;
                m_client.transform.localRotation = transform.localRotation;
                PositionSpring.RefreshTransformType();
                RotationSpring.RefreshTransformType();
                m_earthQuakeTimeTemp = m_client.EarthQuakeTime;


                mLastPosition = transform.localPosition;
                mLastRotation = transform.localRotation.eulerAngles;
                mOriPosition = transform.localPosition;
                mOriRotation = transform.localRotation.eulerAngles;
            }


            //NOTE: NEED TO APPLY THE M_CLIENT'S elapsedTime = 0 first.
            Update();

        }
Example #12
0
        public void Reset(XftEventComponent client)
        {
            m_client = client;
            if (m_client.CameraShakeType == XCameraShakeType.Spring)
            {
                if (PositionSpring != null && !CheckDone())
                {
                    //last event shake has not finished, so set the client pos to original pos.
                    transform.localPosition = mOriPosition;
                    transform.localRotation = Quaternion.Euler(mOriRotation);
                }

                //reset spring
                PositionSpring             = new Spring(client.transform, Spring.TransformType.Position);
                PositionSpring.MinVelocity = 0.00001f;
                RotationSpring             = new Spring(client.transform, Spring.TransformType.Rotation);
                RotationSpring.MinVelocity = 0.00001f;
                PositionSpring.Stiffness   = new Vector3(m_client.PositionStifness, m_client.PositionStifness, m_client.PositionStifness);
                PositionSpring.Damping     = Vector3.one - new Vector3(m_client.PositionDamping, m_client.PositionDamping, m_client.PositionDamping);
                RotationSpring.Stiffness   = new Vector3(m_client.RotationStiffness, m_client.RotationStiffness, m_client.RotationStiffness);
                RotationSpring.Damping     = Vector3.one - new Vector3(m_client.RotationDamping, m_client.RotationDamping, m_client.RotationDamping);

                m_client.transform.localPosition = transform.localPosition;
                m_client.transform.localRotation = transform.localRotation;
                PositionSpring.RefreshTransformType();
                RotationSpring.RefreshTransformType();
                m_earthQuakeTimeTemp = m_client.EarthQuakeTime;


                mLastPosition = transform.localPosition;
                mLastRotation = transform.localRotation.eulerAngles;
                mOriPosition  = transform.localPosition;
                mOriRotation  = transform.localRotation.eulerAngles;
            }


            //NOTE: NEED TO APPLY THE M_CLIENT'S elapsedTime = 0 first.
            Update();
        }
Example #13
0
		public SoundEvent(XftEventComponent owner)
			: base(XEventType.Sound, owner)
		{
			
		}
Example #14
0
 public RadialBlurTexAddEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.RadialBlurMask, owner)
 {
 }
 public GlitchEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.Glitch, owner)
 {
     m_random = new WaveRandom();
 }
 public ColorInverseEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.ColorInverse, owner)
 {
 }
Example #17
0
 public XftEvent(XEventType type, XftEventComponent owner)
 {
     m_type  = type;
     m_owner = owner;
 }
Example #18
0
 public GlitchEvent (XftEventComponent owner)
     : base(CameraEffectEvent.EType.Glitch, owner)
 {
     m_random = new WaveRandom();
     Mask = owner.GlitchMask;
     GlitchShader = owner.GlitchShader;
 }
Example #19
0
 public GlowPerObjEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.GlowPerObj, owner)
 {
     ReplacementShader = owner.GlowPerObjReplacementShader;
     blendShader = owner.GlowPerObjBlendShader;
     downsampleShader = owner.GlowDownSampleShader;
     compositeShader = owner.GlowCompositeShader;
     blurShader = owner.GlowBlurShader;
 }
Example #20
0
 public RadialBlurEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.RadialBlur, owner)
 {
 }
Example #21
0
 public CameraShakeEvent(XftEventComponent owner)
     : base(XEventType.CameraShake, owner)
 {
 }
Example #22
0
 public CameraEffectEvent(EType etype, XftEventComponent owner)
     : base(XEventType.CameraEffect, owner)
 {
     m_effectType = etype;
 }
Example #23
0
 public ColorInverseEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.ColorInverse, owner)
 {
 }
Example #24
0
 public XftEvent(XEventType type, XftEventComponent owner)
 {
     m_type = type;
     m_owner = owner;
 }
Example #25
0
 public TimeScaleEvent(XftEventComponent owner)
     : base(XEventType.TimeScale, owner)
 {
 }
 public RadialBlurTexAddEvent (XftEventComponent owner)
     : base(CameraEffectEvent.EType.RadialBlurMask, owner)
 {
     RadialBlurShader = owner.RadialBlurTexAddShader;
     Mask = owner.RadialBlurMask;
 }
Example #27
0
 public LightEvent(XftEventComponent owner)
     : base(XEventType.Light, owner)
 {
 }
Example #28
0
        public void Initialize()
        {
            if (CheckEditModeInited())
            {//already inited.
                return;
            }

            List <GameObject> tobeDeleted = new List <GameObject>();


            //if it's instantiated, delete all the old meshes.
            foreach (Transform child in transform)
            {
                if (child.gameObject.name.Contains("xftmesh"))
                {
                    tobeDeleted.Add(child.gameObject);
                }
            }


            foreach (Transform child in transform)
            {
                EffectLayer el = (EffectLayer)child.GetComponent(typeof(EffectLayer));
                if (el == null)
                {
                    continue;
                }

                if (el.Material == null)
                {
                    Debug.LogWarning("effect layer: " + el.gameObject.name + " has no material, please assign a material first!");
                    continue;
                }

                Material mat = el.Material;
                //ver 1.2.1
                mat.renderQueue  = mat.shader.renderQueue;
                mat.renderQueue += el.Depth;
                EflList.Add(el);

                if (MergeSameMaterialMesh)
                {
                    if (!MatDic.ContainsKey(mat.name))
                    {
                        MeshFilter mf = CreateMeshObj(mat);
                        MatDic[mat.name] = new VertexPool(mf.sharedMesh, mat);
                    }
                }
                else
                {
                    MeshFilter mf = CreateMeshObj(mat);
                    MatList.Add(new VertexPool(mf.sharedMesh, mat));
                }
            }


            foreach (GameObject obj in tobeDeleted)
            {
                DestoryMeshObject(obj);
            }

            //now set each gameobject's parent.
            foreach (GameObject obj in MeshList)
            {
                //after the editor reimported scripts, the MeshList in memory will be cleared.
                if (obj == null)
                {
                    continue;
                }
                obj.transform.parent = this.transform;

                //fixed 2012.6.25,
                obj.transform.position = Vector3.zero;
                obj.transform.rotation = Quaternion.identity;

                //fixed 2012.7.11, avoid the lossy scale influence the mesh object.
                Vector3 realLocalScale = Vector3.zero;
                realLocalScale.x = 1 / obj.transform.parent.lossyScale.x;
                realLocalScale.y = 1 / obj.transform.parent.lossyScale.y;
                realLocalScale.z = 1 / obj.transform.parent.lossyScale.z;

                obj.transform.localScale = realLocalScale * Scale;
            }


            //assign vertex pool.
            for (int i = 0; i < EflList.Count; i++)
            {
                EffectLayer efl = EflList[i];

                if (MergeSameMaterialMesh)
                {
                    efl.Vertexpool = MatDic[efl.Material.name];
                }
                else
                {
                    if (EflList.Count != MatList.Count)
                    {
                        Debug.LogError("something wrong with the no merge mesh mat list!");
                        efl.Vertexpool = MatList[0];
                        continue;
                    }
                    efl.Vertexpool = MatList[i];
                }
            }


            //start each effect layer.


            this.transform.localScale = Vector3.one;

            foreach (EffectLayer el in EflList)
            {
                el.StartCustom();
            }

            //add events
            EventList.Clear();
            foreach (Transform child in transform)
            {
                XftEventComponent xftevent = child.GetComponent <XftEventComponent>();
                if (xftevent == null)
                {
                    continue;
                }
                EventList.Add(xftevent);
                xftevent.Initialize(this);
            }
            Initialized = true;
        }
Example #29
0
 public GlowEvent(XftEventComponent owner)
     : base(XftEventType.CameraGlow, owner)
 {
 }
 public RadialBlurTexAddEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.RadialBlurMask, owner)
 {
     RadialBlurShader = owner.RadialBlurTexAddShader;
     Mask             = owner.RadialBlurMask;
 }
 public RadialBlurTexAddEvent(XftEventComponent owner)
     : base(XftEventType.CameraRadialBlurMask, owner)
 {
 }
Example #32
0
        public void Update()
        {
            CurTime = Time.realtimeSinceStartup;

            float deltaTime = (float)(CurTime - LastTime);


#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                if (!EditView || EditorUtility.IsPersistent(gameObject))
                {
                    return;
                }
                CurTime = EditorApplication.timeSinceStartup;
                if (!CheckEditModeInited())
                {
                    ResetEditScene();
                }
                deltaTime  = (float)(CurTime - LastTime);
                deltaTime *= PlaybackTime;
            }
#endif
            ElapsedTime += deltaTime;


            //simple method to check game delay: the game must run above 10 FPS.
            if (deltaTime > 0.1f)
            {
                deltaTime = 0.0333f;
            }

            if (Paused)
            {
                LastTime = CurTime;
                return;
            }

            if (!UpdateWhenOffScreen && !IsInCameraView() && !EditView)
            {
                LastTime = CurTime;
                return;
            }

            if (!IgnoreTimeScale)
            {
                deltaTime *= Time.timeScale;
            }



            for (int i = 0; i < EflList.Count; i++)
            {
                if (EflList[i] == null)//be destroyed?
                {
                    return;
                }
                EffectLayer el = EflList[i];
                if (ElapsedTime > el.StartTime && IsActive(el.gameObject))
                {
                    el.FixedUpdateCustom(deltaTime);
                }
            }


            for (int i = 0; i < EventList.Count; i++)
            {
                XftEventComponent e = EventList[i];
                if (IsActive(e.gameObject))
                {
                    e.UpdateCustom(deltaTime);
                }
            }

            LastTime = CurTime;

#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                LateUpdate();
            }
#endif
        }
 public RadialBlurEvent(XftEventComponent owner)
     : base(XftEventType.RadialBlur, owner)
 {
 }
Example #34
0
 public CameraEffectEvent(EType etype, XftEventComponent owner)
     : base(XEventType.CameraEffect, owner)
 {
     m_effectType = etype;
 }
Example #35
0
 public GlowEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.Glow, owner)
 {
 }
Example #36
0
 public RadialBlurTexAddEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.RadialBlurMask, owner)
 {
 }
Example #37
0
 public RadialBlurEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.RadialBlur, owner)
 {
 }
        public CameraShakeEvent(XftEventComponent owner)
            : base(XEventType.CameraShake, owner)
        {

        }
Example #39
0
 public GlowPerObjEvent(XftEventComponent owner)
     : base(CameraEffectEvent.EType.GlowPerObj, owner)
 {
 }
Example #40
0
 public SoundEvent(XftEventComponent owner)
     : base(XftEventType.Sound, owner)
 {
 }
Example #41
0
 public TimeScaleEvent(XftEventComponent owner)
     : base(XEventType.TimeScale, owner)
 {
 }
Example #42
0
		public LightEvent (XftEventComponent owner)
            : base(XEventType.Light, owner)
		{

		}
Example #43
0
 public ColorInverseEvent(XftEventComponent owner)
     : base(XftEventType.CameraColorInverse, owner)
 {
 }