示例#1
0
    void Update()
    {
        if (GetComponent <Renderer>() == null || GetComponent <Renderer>().material == null)
        {
            enabled = false;
            return;
        }

        if (0 < m_fDelayTime)
        {
            if (GetEngineTime() < m_fStartTime + m_fDelayTime)
            {
                return;
            }
            m_fDelayTime = 0;
            m_fStartTime = 0;
            InitTrailObject();
        }

        if (m_bEmit && 0 < m_fEmitTime && m_fStopTime == 0)
        {
            if (m_fStartTime + m_fEmitTime < GetEngineTime())
            {
                if (m_bSmoothHide)
                {
                    m_fStopTime = GetEngineTime();
                }
                else
                {
                    m_bEmit = false;
                }
            }
        }
        if (0 < m_fStopTime && m_fLifeTime < (GetEngineTime() - m_fStopTime))
        {
            m_bEmit = false;
        }

        if (!m_bEmit && m_Points.Count == 0 && m_bAutoDestruct)
        {
            Destroy(m_TrialObject);
            Destroy(gameObject);
        }

//      // early out if there is no camera
//      if (!Camera.main) return;

        // if we have moved enough, create a new vertex and make sure we rebuild the mesh
        float theDistance = (m_LastPosition - transform.position).magnitude;

        if (m_bEmit)
        {
            if (theDistance > m_fMinVertexDistance)
            {
                bool make = false;
                if (m_Points.Count < 3)
                {
                    make = true;
                }
                else
                {
                    //Vector3 l1 = m_Points[m_Points.Count - 2].basePosition - m_Points[m_Points.Count - 3].basePosition;
                    //Vector3 l2 = m_Points[m_Points.Count - 1].basePosition - m_Points[m_Points.Count - 2].basePosition;
                    Vector3 l1 = m_Points[m_Points.Count - 2].basePosition - m_Points[m_Points.Count - 3].basePosition;
                    Vector3 l2 = m_Points[m_Points.Count - 1].basePosition - m_Points[m_Points.Count - 2].basePosition;
                    if (Vector3.Angle(l1, l2) > m_fMaxAngle || theDistance > m_fMaxVertexDistance)
                    {
                        make = true;
                    }
                }

                if (make)
                {
                    Point p = new Point();
                    p.basePosition = m_base.position;
                    p.tipPosition  = GetTipPoint();
                    if (0 < m_fStopTime)
                    {
                        p.timeCreated = GetEngineTime() - (GetEngineTime() - m_fStopTime);
                    }
                    else
                    {
                        p.timeCreated = GetEngineTime();
                    }
                    m_Points.Add(p);
                    m_LastPosition = transform.position;


                    if (m_bInterpolation)
                    {
                        if (m_Points.Count == 1)
                        {
                            m_SmoothedPoints.Add(p);
                        }
                        else if (1 < m_Points.Count)
                        {
                            // add 1+m_nSubdivisions for every possible pair in the m_Points
                            for (int n = 0; n < 1 + m_nSubdivisions; ++n)
                            {
                                m_SmoothedPoints.Add(p);
                            }
                        }

                        // we use 4 control points for the smoothing
                        int nMinSmoothCount = 2;
                        if (nMinSmoothCount <= m_Points.Count)
                        {
                            int       nSampleCount = Mathf.Min(m_nMaxSmoothCount, m_Points.Count);
                            Vector3[] tipPoints    = new Vector3[nSampleCount];
                            for (int n = 0; n < nSampleCount; n++)
                            {
                                tipPoints[n] = m_Points[m_Points.Count - (nSampleCount - n)].basePosition;
                            }

                            //						IEnumerable<Vector3> smoothTip = NcInterpolate.NewBezier(NcInterpolate.Ease(NcInterpolate.EaseType.Linear), tipPoints, m_nSubdivisions);
                            IEnumerable <Vector3> smoothTip = NcInterpolate.NewCatmullRom(tipPoints, m_nSubdivisions, false);

                            Vector3[] basePoints = new Vector3[nSampleCount];
                            for (int n = 0; n < nSampleCount; n++)
                            {
                                basePoints[n] = m_Points[m_Points.Count - (nSampleCount - n)].tipPosition;
                            }

                            //						IEnumerable<Vector3> smoothBase = NcInterpolate.NewBezier(NcInterpolate.Ease(NcInterpolate.EaseType.Linear), basePoints, m_nSubdivisions);
                            IEnumerable <Vector3> smoothBase = NcInterpolate.NewCatmullRom(basePoints, m_nSubdivisions, false);

                            List <Vector3> smoothTipList  = new List <Vector3>(smoothTip);
                            List <Vector3> smoothBaseList = new List <Vector3>(smoothBase);

                            float firstTime  = m_Points[m_Points.Count - nSampleCount].timeCreated;
                            float secondTime = m_Points[m_Points.Count - 1].timeCreated;

                            //Debug.Log(" smoothTipList.Count: " + smoothTipList.Count);

                            for (int n = 0; n < smoothTipList.Count; ++n)
                            {
                                int idx = m_SmoothedPoints.Count - (smoothTipList.Count - n);
                                // there are moments when the m_SmoothedPoints are lesser
                                // than what is required, when elements from it are removed
                                if (-1 < idx && idx < m_SmoothedPoints.Count)
                                {
                                    Point sp = new Point();
                                    sp.tipPosition        = smoothBaseList[n];
                                    sp.basePosition       = smoothTipList[n];
                                    sp.timeCreated        = Mathf.Lerp(firstTime, secondTime, n / (float)(smoothTipList.Count));
                                    m_SmoothedPoints[idx] = sp;
                                }
                                //else
                                //{
                                //	Debug.LogError(idx + "/" + m_SmoothedPoints.Count);
                                //}
                            }
                        }
                    }
                }
                else
                {
                    m_Points[m_Points.Count - 1].tipPosition  = GetTipPoint();
                    m_Points[m_Points.Count - 1].basePosition = m_base.position;
                    //m_Points[m_Points.Count - 1].timeCreated = GetEngineTime();

                    if (m_bInterpolation)
                    {
                        m_SmoothedPoints[m_SmoothedPoints.Count - 1].tipPosition  = GetTipPoint();
                        m_SmoothedPoints[m_SmoothedPoints.Count - 1].basePosition = m_base.position;
                    }
                }
            }
            else
            {
                if (m_Points.Count > 0)
                {
                    m_Points[m_Points.Count - 1].tipPosition  = GetTipPoint();
                    m_Points[m_Points.Count - 1].basePosition = m_base.position;
                    //m_Points[m_Points.Count - 1].timeCreated = GetEngineTime();
                }

                if (m_bInterpolation)
                {
                    if (m_SmoothedPoints.Count > 0)
                    {
                        m_SmoothedPoints[m_SmoothedPoints.Count - 1].tipPosition  = GetTipPoint();
                        m_SmoothedPoints[m_SmoothedPoints.Count - 1].basePosition = m_base.position;
                    }
                }
            }
        }

        if (!m_bEmit && m_bLastFrameEmit && m_Points.Count > 0)
        {
            m_Points[m_Points.Count - 1].lineBreak = true;
        }

        m_bLastFrameEmit = m_bEmit;



        List <Point> remove = new List <Point>();

        foreach (Point p in m_Points)
        {
            // cull old points first
            if (GetEngineTime() - p.timeCreated > m_fLifeTime)
            {
                remove.Add(p);
            }
        }
        foreach (Point p in remove)
        {
            m_Points.Remove(p);
        }

        if (m_bInterpolation)
        {
            remove = new List <Point>();
            foreach (Point p in m_SmoothedPoints)
            {
                // cull old points first
                if (GetEngineTime() - p.timeCreated > m_fLifeTime)
                {
                    remove.Add(p);
                }
            }
            foreach (Point p in remove)
            {
                m_SmoothedPoints.Remove(p);
            }
        }

        List <Point> pointsToUse;

        if (m_bInterpolation)
        {
            pointsToUse = m_SmoothedPoints;
        }
        else
        {
            pointsToUse = m_Points;
        }

        if (pointsToUse.Count > 1)
        {
            Vector3[] newVertices  = new Vector3[pointsToUse.Count * 2];
            Vector2[] newUV        = new Vector2[pointsToUse.Count * 2];
            int[]     newTriangles = new int[(pointsToUse.Count - 1) * 6];
            Color[]   newColors    = new Color[pointsToUse.Count * 2];

            for (int n = 0; n < pointsToUse.Count; ++n)
            {
                Point p    = pointsToUse[n];
                float time = (GetEngineTime() - p.timeCreated) / m_fLifeTime;

                Color color = Color.Lerp(Color.white, Color.clear, time);
                if (m_Colors != null && m_Colors.Length > 0)
                {
                    float colorTime = time * (m_Colors.Length - 1);
                    float min       = Mathf.Floor(colorTime);
                    float max       = Mathf.Clamp(Mathf.Ceil(colorTime), 1, m_Colors.Length - 1);
                    float lerp      = Mathf.InverseLerp(min, max, colorTime);
                    if (min >= m_Colors.Length)
                    {
                        min = m_Colors.Length - 1;
                    }
                    if (min < 0)
                    {
                        min = 0;
                    }
                    if (max >= m_Colors.Length)
                    {
                        max = m_Colors.Length - 1;
                    }
                    if (max < 0)
                    {
                        max = 0;
                    }
                    color = Color.Lerp(m_Colors[(int)min], m_Colors[(int)max], lerp);
                }

                Vector3 lineDirection = p.basePosition - p.tipPosition;
                float   size          = m_fTipSize;

                if (m_SizeRates != null && m_SizeRates.Length > 0)
                {
                    float sizeTime = time * (m_SizeRates.Length - 1);
                    float min      = Mathf.Floor(sizeTime);
                    float max      = Mathf.Clamp(Mathf.Ceil(sizeTime), 1, m_SizeRates.Length - 1);
                    float lerp     = Mathf.InverseLerp(min, max, sizeTime);
                    if (min >= m_SizeRates.Length)
                    {
                        min = m_SizeRates.Length - 1;
                    }
                    if (min < 0)
                    {
                        min = 0;
                    }
                    if (max >= m_SizeRates.Length)
                    {
                        max = m_SizeRates.Length - 1;
                    }
                    if (max < 0)
                    {
                        max = 0;
                    }
                    size *= Mathf.Lerp(m_SizeRates[(int)min], m_SizeRates[(int)max], lerp);
                }

                if (m_bCenterAlign)
                {
                    newVertices[n * 2]       = p.basePosition - (lineDirection * (size * 0.5f));
                    newVertices[(n * 2) + 1] = p.basePosition + (lineDirection * (size * 0.5f));
                }
                else
                {
                    newVertices[n * 2]       = p.basePosition - (lineDirection * size);
                    newVertices[(n * 2) + 1] = p.basePosition;
                }

                // FadeInOut
                int nFadeTailCount = (m_bInterpolation ? m_nFadeTailCount * m_nSubdivisions : m_nFadeTailCount);
                int nFadeHeadCount = (m_bInterpolation ? m_nFadeHeadCount * m_nSubdivisions : m_nFadeHeadCount);
                if (0 < nFadeTailCount && n <= nFadeTailCount)
                {
                    color.a = color.a * n / (float)nFadeTailCount;
                }
                if (0 < nFadeHeadCount && pointsToUse.Count - (n + 1) <= nFadeHeadCount)
                {
                    color.a = color.a * (pointsToUse.Count - (n + 1)) / (float)nFadeHeadCount;
                }

                newColors[n * 2] = newColors[(n * 2) + 1] = color;

                float uvRatio = (float)n / pointsToUse.Count;

                newUV[n * 2]       = new Vector2((m_UvFlipHorizontal ? 1 - uvRatio : uvRatio), (m_UvFlipVirtical ? 1 : 0));
                newUV[(n * 2) + 1] = new Vector2((m_UvFlipHorizontal ? 1 - uvRatio : uvRatio), (m_UvFlipVirtical ? 0 : 1));

                if (n > 0 /*&& !pointsToUse[n - 1].lineBreak*/)
                {
                    newTriangles[(n - 1) * 6]       = (n * 2) - 2;
                    newTriangles[((n - 1) * 6) + 1] = (n * 2) - 1;
                    newTriangles[((n - 1) * 6) + 2] = n * 2;

                    newTriangles[((n - 1) * 6) + 3] = (n * 2) + 1;
                    newTriangles[((n - 1) * 6) + 4] = n * 2;
                    newTriangles[((n - 1) * 6) + 5] = (n * 2) - 1;
                }
            }

            m_TrailMesh.Clear();
            m_TrailMesh.vertices  = newVertices;
            m_TrailMesh.colors    = newColors;
            m_TrailMesh.uv        = newUV;
            m_TrailMesh.triangles = newTriangles;
        }
        else
        {
            m_TrailMesh.Clear();
        }
    }
示例#2
0
    private void Update()
    {
        if (base.GetComponent <Renderer>() == null || base.GetComponent <Renderer>().get_material() == null)
        {
            base.set_enabled(false);
            return;
        }
        if (0f < this.m_fDelayTime)
        {
            if (NcEffectBehaviour.GetEngineTime() < this.m_fStartTime + this.m_fDelayTime)
            {
                return;
            }
            this.m_fDelayTime = 0f;
            this.m_fStartTime = 0f;
            this.InitTrailObject();
        }
        if (this.m_bEmit && 0f < this.m_fEmitTime && this.m_fStopTime == 0f && this.m_fStartTime + this.m_fEmitTime < NcEffectBehaviour.GetEngineTime())
        {
            if (this.m_bSmoothHide)
            {
                this.m_fStopTime = NcEffectBehaviour.GetEngineTime();
            }
            else
            {
                this.m_bEmit = false;
            }
        }
        if (0f < this.m_fStopTime && this.m_fLifeTime < NcEffectBehaviour.GetEngineTime() - this.m_fStopTime)
        {
            this.m_bEmit = false;
        }
        if (!this.m_bEmit && this.m_Points.get_Count() == 0 && this.m_bAutoDestruct)
        {
            Object.Destroy(this.m_TrialObject);
            Object.Destroy(base.get_gameObject());
        }
        float magnitude = (this.m_LastPosition - base.get_transform().get_position()).get_magnitude();

        if (this.m_bEmit)
        {
            if (magnitude > this.m_fMinVertexDistance)
            {
                bool flag = false;
                if (this.m_Points.get_Count() < 3)
                {
                    flag = true;
                }
                else
                {
                    Vector3 vector  = this.m_Points.get_Item(this.m_Points.get_Count() - 2).basePosition - this.m_Points.get_Item(this.m_Points.get_Count() - 3).basePosition;
                    Vector3 vector2 = this.m_Points.get_Item(this.m_Points.get_Count() - 1).basePosition - this.m_Points.get_Item(this.m_Points.get_Count() - 2).basePosition;
                    if (Vector3.Angle(vector, vector2) > this.m_fMaxAngle || magnitude > this.m_fMaxVertexDistance)
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    NcTrailTexture.Point point = new NcTrailTexture.Point();
                    point.basePosition = this.m_base.get_position();
                    point.tipPosition  = this.GetTipPoint();
                    if (0f < this.m_fStopTime)
                    {
                        point.timeCreated = NcEffectBehaviour.GetEngineTime() - (NcEffectBehaviour.GetEngineTime() - this.m_fStopTime);
                    }
                    else
                    {
                        point.timeCreated = NcEffectBehaviour.GetEngineTime();
                    }
                    this.m_Points.Add(point);
                    this.m_LastPosition = base.get_transform().get_position();
                    if (this.m_bInterpolation)
                    {
                        if (this.m_Points.get_Count() == 1)
                        {
                            this.m_SmoothedPoints.Add(point);
                        }
                        else if (1 < this.m_Points.get_Count())
                        {
                            for (int i = 0; i < 1 + this.m_nSubdivisions; i++)
                            {
                                this.m_SmoothedPoints.Add(point);
                            }
                        }
                        int num = 2;
                        if (num <= this.m_Points.get_Count())
                        {
                            int       num2  = Mathf.Min(this.m_nMaxSmoothCount, this.m_Points.get_Count());
                            Vector3[] array = new Vector3[num2];
                            for (int j = 0; j < num2; j++)
                            {
                                array[j] = this.m_Points.get_Item(this.m_Points.get_Count() - (num2 - j)).basePosition;
                            }
                            IEnumerable <Vector3> enumerable = NcInterpolate.NewCatmullRom(array, this.m_nSubdivisions, false);
                            Vector3[]             array2     = new Vector3[num2];
                            for (int k = 0; k < num2; k++)
                            {
                                array2[k] = this.m_Points.get_Item(this.m_Points.get_Count() - (num2 - k)).tipPosition;
                            }
                            IEnumerable <Vector3> enumerable2 = NcInterpolate.NewCatmullRom(array2, this.m_nSubdivisions, false);
                            List <Vector3>        list        = new List <Vector3>(enumerable);
                            List <Vector3>        list2       = new List <Vector3>(enumerable2);
                            float timeCreated  = this.m_Points.get_Item(this.m_Points.get_Count() - num2).timeCreated;
                            float timeCreated2 = this.m_Points.get_Item(this.m_Points.get_Count() - 1).timeCreated;
                            for (int l = 0; l < list.get_Count(); l++)
                            {
                                int num3 = this.m_SmoothedPoints.get_Count() - (list.get_Count() - l);
                                if (-1 < num3 && num3 < this.m_SmoothedPoints.get_Count())
                                {
                                    NcTrailTexture.Point point2 = new NcTrailTexture.Point();
                                    point2.tipPosition  = list2.get_Item(l);
                                    point2.basePosition = list.get_Item(l);
                                    point2.timeCreated  = Mathf.Lerp(timeCreated, timeCreated2, (float)l / (float)list.get_Count());
                                    this.m_SmoothedPoints.set_Item(num3, point2);
                                }
                            }
                        }
                    }
                }
                else
                {
                    this.m_Points.get_Item(this.m_Points.get_Count() - 1).tipPosition  = this.GetTipPoint();
                    this.m_Points.get_Item(this.m_Points.get_Count() - 1).basePosition = this.m_base.get_position();
                    if (this.m_bInterpolation)
                    {
                        this.m_SmoothedPoints.get_Item(this.m_SmoothedPoints.get_Count() - 1).tipPosition  = this.GetTipPoint();
                        this.m_SmoothedPoints.get_Item(this.m_SmoothedPoints.get_Count() - 1).basePosition = this.m_base.get_position();
                    }
                }
            }
            else
            {
                if (this.m_Points.get_Count() > 0)
                {
                    this.m_Points.get_Item(this.m_Points.get_Count() - 1).tipPosition  = this.GetTipPoint();
                    this.m_Points.get_Item(this.m_Points.get_Count() - 1).basePosition = this.m_base.get_position();
                }
                if (this.m_bInterpolation && this.m_SmoothedPoints.get_Count() > 0)
                {
                    this.m_SmoothedPoints.get_Item(this.m_SmoothedPoints.get_Count() - 1).tipPosition  = this.GetTipPoint();
                    this.m_SmoothedPoints.get_Item(this.m_SmoothedPoints.get_Count() - 1).basePosition = this.m_base.get_position();
                }
            }
        }
        if (!this.m_bEmit && this.m_bLastFrameEmit && this.m_Points.get_Count() > 0)
        {
            this.m_Points.get_Item(this.m_Points.get_Count() - 1).lineBreak = true;
        }
        this.m_bLastFrameEmit = this.m_bEmit;
        List <NcTrailTexture.Point> list3 = new List <NcTrailTexture.Point>();

        using (List <NcTrailTexture.Point> .Enumerator enumerator = this.m_Points.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                NcTrailTexture.Point current = enumerator.get_Current();
                if (NcEffectBehaviour.GetEngineTime() - current.timeCreated > this.m_fLifeTime)
                {
                    list3.Add(current);
                }
            }
        }
        using (List <NcTrailTexture.Point> .Enumerator enumerator2 = list3.GetEnumerator())
        {
            while (enumerator2.MoveNext())
            {
                NcTrailTexture.Point current2 = enumerator2.get_Current();
                this.m_Points.Remove(current2);
            }
        }
        if (this.m_bInterpolation)
        {
            list3 = new List <NcTrailTexture.Point>();
            using (List <NcTrailTexture.Point> .Enumerator enumerator3 = this.m_SmoothedPoints.GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    NcTrailTexture.Point current3 = enumerator3.get_Current();
                    if (NcEffectBehaviour.GetEngineTime() - current3.timeCreated > this.m_fLifeTime)
                    {
                        list3.Add(current3);
                    }
                }
            }
            using (List <NcTrailTexture.Point> .Enumerator enumerator4 = list3.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    NcTrailTexture.Point current4 = enumerator4.get_Current();
                    this.m_SmoothedPoints.Remove(current4);
                }
            }
        }
        List <NcTrailTexture.Point> list4;

        if (this.m_bInterpolation)
        {
            list4 = this.m_SmoothedPoints;
        }
        else
        {
            list4 = this.m_Points;
        }
        if (list4.get_Count() > 1)
        {
            Vector3[] array3 = new Vector3[list4.get_Count() * 2];
            Vector2[] array4 = new Vector2[list4.get_Count() * 2];
            int[]     array5 = new int[(list4.get_Count() - 1) * 6];
            Color[]   array6 = new Color[list4.get_Count() * 2];
            for (int m = 0; m < list4.get_Count(); m++)
            {
                NcTrailTexture.Point point3 = list4.get_Item(m);
                float num4  = (NcEffectBehaviour.GetEngineTime() - point3.timeCreated) / this.m_fLifeTime;
                Color color = Color.Lerp(Color.get_white(), Color.get_clear(), num4);
                if (this.m_Colors != null && this.m_Colors.Length > 0)
                {
                    float num5 = num4 * (float)(this.m_Colors.Length - 1);
                    float num6 = Mathf.Floor(num5);
                    float num7 = Mathf.Clamp(Mathf.Ceil(num5), 1f, (float)(this.m_Colors.Length - 1));
                    float num8 = Mathf.InverseLerp(num6, num7, num5);
                    if (num6 >= (float)this.m_Colors.Length)
                    {
                        num6 = (float)(this.m_Colors.Length - 1);
                    }
                    if (num6 < 0f)
                    {
                        num6 = 0f;
                    }
                    if (num7 >= (float)this.m_Colors.Length)
                    {
                        num7 = (float)(this.m_Colors.Length - 1);
                    }
                    if (num7 < 0f)
                    {
                        num7 = 0f;
                    }
                    color = Color.Lerp(this.m_Colors[(int)num6], this.m_Colors[(int)num7], num8);
                }
                Vector3 vector3 = point3.basePosition - point3.tipPosition;
                float   num9    = this.m_fTipSize;
                if (this.m_SizeRates != null && this.m_SizeRates.Length > 0)
                {
                    float num10 = num4 * (float)(this.m_SizeRates.Length - 1);
                    float num11 = Mathf.Floor(num10);
                    float num12 = Mathf.Clamp(Mathf.Ceil(num10), 1f, (float)(this.m_SizeRates.Length - 1));
                    float num13 = Mathf.InverseLerp(num11, num12, num10);
                    if (num11 >= (float)this.m_SizeRates.Length)
                    {
                        num11 = (float)(this.m_SizeRates.Length - 1);
                    }
                    if (num11 < 0f)
                    {
                        num11 = 0f;
                    }
                    if (num12 >= (float)this.m_SizeRates.Length)
                    {
                        num12 = (float)(this.m_SizeRates.Length - 1);
                    }
                    if (num12 < 0f)
                    {
                        num12 = 0f;
                    }
                    num9 *= Mathf.Lerp(this.m_SizeRates[(int)num11], this.m_SizeRates[(int)num12], num13);
                }
                if (this.m_bCenterAlign)
                {
                    array3[m * 2]     = point3.basePosition - vector3 * (num9 * 0.5f);
                    array3[m * 2 + 1] = point3.basePosition + vector3 * (num9 * 0.5f);
                }
                else
                {
                    array3[m * 2]     = point3.basePosition - vector3 * num9;
                    array3[m * 2 + 1] = point3.basePosition;
                }
                int num14 = (!this.m_bInterpolation) ? this.m_nFadeTailCount : (this.m_nFadeTailCount * this.m_nSubdivisions);
                int num15 = (!this.m_bInterpolation) ? this.m_nFadeHeadCount : (this.m_nFadeHeadCount * this.m_nSubdivisions);
                if (0 < num14 && m <= num14)
                {
                    color.a = color.a * (float)m / (float)num14;
                }
                if (0 < num15 && list4.get_Count() - (m + 1) <= num15)
                {
                    color.a = color.a * (float)(list4.get_Count() - (m + 1)) / (float)num15;
                }
                array6[m * 2] = (array6[m * 2 + 1] = color);
                float num16 = (float)m / (float)list4.get_Count();
                array4[m * 2]     = new Vector2((!this.m_UvFlipHorizontal) ? num16 : (1f - num16), (float)((!this.m_UvFlipVirtical) ? 0 : 1));
                array4[m * 2 + 1] = new Vector2((!this.m_UvFlipHorizontal) ? num16 : (1f - num16), (float)((!this.m_UvFlipVirtical) ? 1 : 0));
                if (m > 0)
                {
                    array5[(m - 1) * 6]     = m * 2 - 2;
                    array5[(m - 1) * 6 + 1] = m * 2 - 1;
                    array5[(m - 1) * 6 + 2] = m * 2;
                    array5[(m - 1) * 6 + 3] = m * 2 + 1;
                    array5[(m - 1) * 6 + 4] = m * 2;
                    array5[(m - 1) * 6 + 5] = m * 2 - 1;
                }
            }
            this.m_TrailMesh.Clear();
            this.m_TrailMesh.set_vertices(array3);
            this.m_TrailMesh.set_colors(array6);
            this.m_TrailMesh.set_uv(array4);
            this.m_TrailMesh.set_triangles(array5);
        }
        else
        {
            this.m_TrailMesh.Clear();
        }
    }
示例#3
0
    /**
     * Instead of easing based on time, generate n interpolated points (slices)
     * between the start and end positions.
     */
    public static IEnumerator NewEase(Function ease, Vector3 start, Vector3 end, int slices)
    {
        IEnumerable <float> counter = NcInterpolate.NewCounter(0, slices + 1, 1);

        return(NewEase(ease, start, end, slices + 1, counter));
    }
示例#4
0
    /**
     * Returns sequence generator from the first node to the last node over
     * duration time using the points in-between the first and last node
     * as control points of a bezier curve used to generate the interpolated points
     * in the sequence. If there are no control points (ie. only two nodes, first
     * and last) then this behaves exactly the same as NewEase(). In other words
     * a zero-degree bezier spline curve is just the easing method. The sequence
     * is generated as it is accessed using the Time.deltaTime to calculate the
     * portion of duration that has elapsed.
     */
    public static IEnumerable <Vector3> NewBezier(Function ease, Transform[] nodes, float duration)
    {
        IEnumerable <float> timer = NcInterpolate.NewTimer(duration);

        return(NewBezier <Transform>(ease, nodes, TransformDotPosition, duration, timer));
    }
示例#5
0
    /**
     * Returns sequence generator from start to end over duration using the
     * given easing function. The sequence is generated as it is accessed
     * using the Time.deltaTime to calculate the portion of duration that has
     * elapsed.
     */
    public static IEnumerator NewEase(Function ease, Vector3 start, Vector3 end, float duration)
    {
        IEnumerable <float> timer = NcInterpolate.NewTimer(duration);

        return(NewEase(ease, start, end, duration, timer));
    }