Ejemplo n.º 1
0
        public void Reset()
        {
            //activate on death subemitter.
            if (Owner.UseSubEmitters && !string.IsNullOrEmpty(Owner.DeathSubEmitter))
            {
                XffectComponent sub = Owner.SpawnCache.GetEffect(Owner.DeathSubEmitter);
                if (sub == null)
                {
                    return;
                }

                sub.transform.position = CurWorldPos;
                sub.Active();
            }

            //Position = Vector3.up * -9999;
            Position    = Owner.ClientTransform.position;
            Velocity    = Vector3.zero;
            ElapsedTime = 0f;


            CurWorldPos = Owner.transform.position;

            LastWorldPos = CurWorldPos;

            IsCollisionEventSended = false;

            if (Owner.IsRandomStartColor)
            {
                //StartColor = Owner.RandomColorParam.GetGradientColor(UnityEngine.Random.Range(0f, 1f));
                StartColor = Owner.RandomColorGradient.Evaluate(UnityEngine.Random.Range(0f, 1f));
            }

            //do not use foreach in script!
            for (int i = 0; i < AffectorList.Count; i++)
            {
                Affector aft = AffectorList[i];
                aft.Reset();
            }

            Scale = Vector3.one;


            mIsFade = false;


            RenderObj.Reset();

            if (Owner.UseSubEmitters &&
                SubEmitter != null && XffectComponent.IsActive(SubEmitter.gameObject) &&
                Owner.SubEmitterAutoStop)
            {
                SubEmitter.StopEmit();
            }
        }
Ejemplo n.º 2
0
        //deactive the effect smoothly.
        public void StopEffect(string eftName)
        {
            List <XffectComponent> cache = EffectDic[eftName];

            if (cache == null)
            {
                Debug.LogError(name + ": cache doesnt exist!");
                return;
            }
            if (cache.Count > 1)
            {
                Debug.LogWarning("DeActive() only support one Xffect cache!");
            }
            XffectComponent xft = cache[0];

            if (!XffectComponent.IsActive(xft.gameObject))
            {
                return;
            }
            xft.StopEmit();
        }
Ejemplo n.º 3
0
        public void Reset()
        {
            isCollision = false;
            isBounce    = false;

            //activate on death subemitter.
            if (Owner.UseSubEmitters && !string.IsNullOrEmpty(Owner.DeathSubEmitter))
            {
                XffectComponent sub = Owner.SpawnCache.GetEffect(Owner.DeathSubEmitter);
                if (sub == null)
                {
                    return;
                }
                sub.Active();
                sub.transform.position = CurWorldPos;
            }

            //Position = Vector3.up * -9999;
            //if (Owner.SpriteType == (int)STYPE.BILLBOARD_UP) {
            //	Position = Quaternion.Euler (new Vector3 (0, Owner.transform.rotation.eulerAngles.y, 0)) * Owner.EmitPoint + Owner.transform.position;
            //} else {
            Position = Owner.EmitPoint + Owner.transform.position;
            //}

            Velocity    = Vector3.zero;
            ElapsedTime = 0f;


            CurWorldPos = Owner.transform.position;

            LastWorldPos = CurWorldPos;

            IsCollisionEventSended = false;

            //foreach (Affector aft in AffectorList)
            //{
            //    aft.Reset();
            //}V

            //do not use foreach in your script!
            for (int i = 0; i < AffectorList.Count; i++)
            {
                Affector aft = AffectorList[i];
                aft.Reset();
            }

            Scale = Vector3.one;

            if (Type == 1)
            {
                Sprite.SetRotation(OriRotateAngle);
                Sprite.SetPosition(Position);
                Sprite.SetColor(Color.clear);
                Sprite.Update(true, 0f);
                //TODO:should reset in ScaleAffector.
                Scale = Vector3.one;
            }
            else if (Type == 2)
            {
                Vector3 headpos;
                if (Owner.AlwaysSyncRotation)
                {
                    headpos = ClientTrans.rotation * (GetRealClientPos() + Owner.EmitPoint);
                }
                else
                {
                    headpos = GetRealClientPos() + Owner.EmitPoint;
                }
                Ribbon.SetHeadPosition(headpos /*+ OriDirection.normalized * Owner.TailDistance*/);
                Ribbon.Reset();
                Ribbon.SetColor(Color.clear);
                Ribbon.UpdateVertices(Vector3.zero);
            }
            else if (Type == 3)
            {
                Cone.SetRotation(OriRotateAngle);
                Cone.SetColor(Color.clear);
                Cone.SetPosition(Position);
                Scale = Vector3.one;
                Cone.ResetAngle();
                Cone.Update(true, 0f);
            }
            else if (Type == 4)
            {
                CusMesh.SetColor(Color.clear);
                CusMesh.SetRotation(OriRotateAngle);
                CusMesh.Update(true, 0f);
            }


            if (Owner.UseSubEmitters && SubEmitter != null && XffectComponent.IsActive(SubEmitter.gameObject))
            {
                SubEmitter.StopEmit();
            }
        }