示例#1
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();
            }
        }
示例#2
0
        public void Reset()
        {
            //Position = Vector3.up * -9999;
            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();
            //}

            //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 = Vector2.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 = Vector2.one;
                Cone.ResetAngle();
                Cone.Update(true, 0f);
            }
            else if (Type == 4)
            {
                CusMesh.SetColor(Color.clear);
                CusMesh.SetRotation(OriRotateAngle);

                CusMesh.Update(true, 0f);
            }
        }