示例#1
0
        public void Reset()
        {
            Position     = Vector3.up * 9999;
            Velocity     = Vector3.zero;
            Acceleration = 0f;
            ElapsedTime  = 0f;

            LastWorldPos = CurWorldPos = Vector3.zero;

            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 = (Affector)AffectorList[i];
                aft.Reset();
            }

            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 * (ClientTrans.position + Owner.EmitPoint);
                }
                else
                {
                    headpos = ClientTrans.position + 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);
            }
        }
示例#2
0
        public void Init(Vector3 oriDir, float speed, float life, int oriRot, float oriScaleX, float oriScaleY, Color oriColor, Vector2 oriLowerUv, Vector2 oriUVDimension)
        {
            //OriDirection = ClientTrans.TransformDirection(oriDir);
            OriDirection   = oriDir;
            LifeTime       = life;
            OriRotateAngle = oriRot;
            OriScaleX      = oriScaleX;
            OriScaleY      = oriScaleY;
            Color          = oriColor;
            ElapsedTime    = 0f;
            // direction is synced to client rotation
            Velocity               = Owner.transform.rotation * OriDirection * speed;
            LowerLeftUV            = oriLowerUv;
            UVDimensions           = oriUVDimension;
            IsCollisionEventSended = false;

            if (Type == 1)
            {
                Sprite.SetUVCoord(LowerLeftUV, UVDimensions);
                Sprite.SetColor(oriColor);
                if (SimpleSprite)
                {
                    //Simple sprite 只更新一次。
                    Update(0f);
                    Sprite.Transform();
                }
            }

            else if (Type == 2)
            {
                Ribbon.SetUVCoord(LowerLeftUV, UVDimensions);
                Ribbon.SetColor(oriColor);
                Ribbon.SetHeadPosition(GetRealClientPos() + Position + OriDirection.normalized * Owner.TailDistance);
                Ribbon.ResetElementsPos();
            }
            else if (Type == 3)
            {
                Cone.SetUVCoord(LowerLeftUV, UVDimensions);
                Cone.SetColor(oriColor);
                Cone.SetRotation(oriRot);
            }

            //set  sprite direction
            if (Type == 1)
            {
                //direction is synced to client rotation
                Sprite.SetRotationTo(Owner.ClientTransform.rotation * OriDirection);
            }
        }