Ejemplo n.º 1
0
 internal SplineIterator(XSpline spline, bool reverse, int startidx, int endidx)
 {
     mSpline   = spline;
     mReverse  = reverse;
     mStartidx = Mathf.Min(startidx, endidx);
     mEndidx   = Mathf.Max(startidx, endidx);
     Reset();
 }
Ejemplo n.º 2
0
        public void Update(float deltaTime)
        {
            ElapsedTime += deltaTime;
            for (int i = 0; i < AffectorList.Count; i++)
            {
                Affector aft = AffectorList[i];
                aft.Update(deltaTime);
            }


            if (Owner.EmitType == (int)EMITTYPE.Spline && Owner.DirType == DIRECTION_TYPE.Spline)
            {
                XSpline spline = Owner.EmitSpline.Spline;

                if (Owner.SplineEaseType == XEase.Easing.Linear)
                {
                    mSplineIterator.Iterate(mOriSpeed * deltaTime);
                }
                else
                {
                    mSplineOffset += mOriSpeed * deltaTime;
                    float t = mSplineOffset / spline.Length;
                    t = Mathf.Clamp(t, 0, 1);
                    mSplineIterator.SetOffset(XEase.EaseByType(Owner.SplineEaseType, 0, spline.Length, t));
                }

                Position = mSplineIterator.GetPosition();
            }
            else
            {
                Position += Velocity * deltaTime;
            }



            //if (Mathf.Abs(Acceleration) > 1e-04)
            //{
            //Velocity += Velocity.normalized * Acceleration * deltaTime;
            //}

            if (SyncClient)
            {
                //NOTICE: only sync position.
                CurWorldPos = Position + GetRealClientPos();
            }
            else
            {
                CurWorldPos = Position;
            }


            CollisionDetection();

            //sync subemitters position.
            if (Owner.UseSubEmitters && SubEmitter != null && XffectComponent.IsActive(SubEmitter.gameObject))
            {
                SubEmitter.transform.position = CurWorldPos;
            }


            RenderObj.Update(deltaTime);

            if (Owner.UseShaderCurve2 || Owner.UseShaderCurve1)
            {
                float x = Owner.UseShaderCurve1 ? Owner.ShaderCurveX1.Evaluate(GetElapsedTime(), this) : 1f;

                float y = Owner.UseShaderCurve2 ? Owner.ShaderCurveX2.Evaluate(GetElapsedTime(), this) : 0f;

                RenderObj.ApplyShaderParam(x, y);
            }
            else if (Owner.UseFlowControl)
            {
                float x = Owner.FlowSpeed * GetElapsedTime();
                float y = Owner.FlowStretchLength;

                //float d = x % y;

                //float p = x / y;

                //float px = x;

                //if (Mathf.FloorToInt(p) % 2 == 0)
                //{
                //    //first circle.
                //    px = d;
                //}
                //else
                //{
                //    px = y - d;
                //}


                RenderObj.ApplyShaderParam(x, y);
            }


            LastWorldPos = CurWorldPos;

            if (ElapsedTime > LifeTime && LifeTime > 0)
            {
                Reset();
                Remove();
            }
        }
Ejemplo n.º 3
0
 internal SplineEditorHelper(XSpline spline)
 {
     mSpline = spline;
 }