コード例 #1
0
ファイル: NcTrailTexture.cs プロジェクト: wly2/BaiLaoHui
    void Update()
    {
        if (GetComponent <Renderer>() == null || GetComponent <Renderer>().sharedMaterial == 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 =
                                NgInterpolate.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 =
                                NgInterpolate.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>();

        for (int i = 0; i < m_Points.Count; ++i)
        {
            // cull old points first
            if (GetEngineTime() - m_Points[i].timeCreated > m_fLifeTime)
            {
                remove.Add(m_Points[i]);
            }
        }

        for (int i = 0; i < remove.Count; ++i)
        {
            m_Points.Remove(remove[i]);
        }

        if (m_bInterpolation)
        {
            remove = new List <Point>();
            for (int i = 0; i < m_SmoothedPoints.Count; ++i)
            {
                // cull old points first
                if (GetEngineTime() - m_SmoothedPoints[i].timeCreated > m_fLifeTime)
                {
                    remove.Add(m_SmoothedPoints[i]);
                }
            }

            for (int i = 0; i < remove.Count; ++i)
            {
                m_SmoothedPoints.Remove(remove[i]);
            }
        }

        List <Point> pointsToUse;

        pointsToUse = m_bInterpolation ? m_SmoothedPoints : 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 / nFadeTailCount;
                }
                if (0 < nFadeHeadCount && pointsToUse.Count - (n + 1) <= nFadeHeadCount)
                {
                    color.a = color.a * (pointsToUse.Count - (n + 1)) / 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.renderer == null || base.renderer.sharedMaterial == null)
        {
            base.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.Count == 0 && this.m_bAutoDestruct)
        {
            UnityEngine.Object.Destroy(this.m_TrialObject);
            UnityEngine.Object.Destroy(base.gameObject);
        }
        float magnitude = (this.m_LastPosition - base.transform.position).magnitude;

        if (this.m_bEmit)
        {
            if (magnitude > this.m_fMinVertexDistance)
            {
                bool flag = false;
                if (this.m_Points.Count < 3)
                {
                    flag = true;
                }
                else
                {
                    Vector3 from = this.m_Points[this.m_Points.Count - 2].basePosition - this.m_Points[this.m_Points.Count - 3].basePosition;
                    Vector3 to   = this.m_Points[this.m_Points.Count - 1].basePosition - this.m_Points[this.m_Points.Count - 2].basePosition;
                    if (Vector3.Angle(from, to) > this.m_fMaxAngle || magnitude > this.m_fMaxVertexDistance)
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    NcTrailTexture.Point point = new NcTrailTexture.Point();
                    point.basePosition = this.m_base.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.transform.position;
                    if (this.m_bInterpolation)
                    {
                        if (this.m_Points.Count == 1)
                        {
                            this.m_SmoothedPoints.Add(point);
                        }
                        else if (1 < this.m_Points.Count)
                        {
                            for (int i = 0; i < 1 + this.m_nSubdivisions; i++)
                            {
                                this.m_SmoothedPoints.Add(point);
                            }
                        }
                        int num = 2;
                        if (num <= this.m_Points.Count)
                        {
                            int       num2  = Mathf.Min(this.m_nMaxSmoothCount, this.m_Points.Count);
                            Vector3[] array = new Vector3[num2];
                            for (int j = 0; j < num2; j++)
                            {
                                array[j] = this.m_Points[this.m_Points.Count - (num2 - j)].basePosition;
                            }
                            IEnumerable <Vector3> collection = NgInterpolate.NewCatmullRom(array, this.m_nSubdivisions, false);
                            Vector3[]             array2     = new Vector3[num2];
                            for (int k = 0; k < num2; k++)
                            {
                                array2[k] = this.m_Points[this.m_Points.Count - (num2 - k)].tipPosition;
                            }
                            IEnumerable <Vector3> collection2 = NgInterpolate.NewCatmullRom(array2, this.m_nSubdivisions, false);
                            List <Vector3>        list        = new List <Vector3>(collection);
                            List <Vector3>        list2       = new List <Vector3>(collection2);
                            float timeCreated  = this.m_Points[this.m_Points.Count - num2].timeCreated;
                            float timeCreated2 = this.m_Points[this.m_Points.Count - 1].timeCreated;
                            for (int l = 0; l < list.Count; l++)
                            {
                                int num3 = this.m_SmoothedPoints.Count - (list.Count - l);
                                if (-1 < num3 && num3 < this.m_SmoothedPoints.Count)
                                {
                                    NcTrailTexture.Point point2 = new NcTrailTexture.Point();
                                    point2.tipPosition          = list2[l];
                                    point2.basePosition         = list[l];
                                    point2.timeCreated          = Mathf.Lerp(timeCreated, timeCreated2, (float)l / (float)list.Count);
                                    this.m_SmoothedPoints[num3] = point2;
                                }
                            }
                        }
                    }
                }
                else
                {
                    this.m_Points[this.m_Points.Count - 1].tipPosition  = this.GetTipPoint();
                    this.m_Points[this.m_Points.Count - 1].basePosition = this.m_base.position;
                    if (this.m_bInterpolation)
                    {
                        this.m_SmoothedPoints[this.m_SmoothedPoints.Count - 1].tipPosition  = this.GetTipPoint();
                        this.m_SmoothedPoints[this.m_SmoothedPoints.Count - 1].basePosition = this.m_base.position;
                    }
                }
            }
            else
            {
                if (this.m_Points.Count > 0)
                {
                    this.m_Points[this.m_Points.Count - 1].tipPosition  = this.GetTipPoint();
                    this.m_Points[this.m_Points.Count - 1].basePosition = this.m_base.position;
                }
                if (this.m_bInterpolation && this.m_SmoothedPoints.Count > 0)
                {
                    this.m_SmoothedPoints[this.m_SmoothedPoints.Count - 1].tipPosition  = this.GetTipPoint();
                    this.m_SmoothedPoints[this.m_SmoothedPoints.Count - 1].basePosition = this.m_base.position;
                }
            }
        }
        if (!this.m_bEmit && this.m_bLastFrameEmit && this.m_Points.Count > 0)
        {
            this.m_Points[this.m_Points.Count - 1].lineBreak = true;
        }
        this.m_bLastFrameEmit = this.m_bEmit;
        List <NcTrailTexture.Point> list3 = new List <NcTrailTexture.Point>();

        foreach (NcTrailTexture.Point current in this.m_Points)
        {
            if (NcEffectBehaviour.GetEngineTime() - current.timeCreated > this.m_fLifeTime)
            {
                list3.Add(current);
            }
        }
        foreach (NcTrailTexture.Point current2 in list3)
        {
            this.m_Points.Remove(current2);
        }
        if (this.m_bInterpolation)
        {
            list3 = new List <NcTrailTexture.Point>();
            foreach (NcTrailTexture.Point current3 in this.m_SmoothedPoints)
            {
                if (NcEffectBehaviour.GetEngineTime() - current3.timeCreated > this.m_fLifeTime)
                {
                    list3.Add(current3);
                }
            }
            foreach (NcTrailTexture.Point current4 in list3)
            {
                this.m_SmoothedPoints.Remove(current4);
            }
        }
        List <NcTrailTexture.Point> list4;

        if (this.m_bInterpolation)
        {
            list4 = this.m_SmoothedPoints;
        }
        else
        {
            list4 = this.m_Points;
        }
        if (list4.Count > 1)
        {
            Vector3[] array3 = new Vector3[list4.Count * 2];
            Vector2[] array4 = new Vector2[list4.Count * 2];
            int[]     array5 = new int[(list4.Count - 1) * 6];
            Color[]   array6 = new Color[list4.Count * 2];
            for (int m = 0; m < list4.Count; m++)
            {
                NcTrailTexture.Point point3 = list4[m];
                float num4  = (NcEffectBehaviour.GetEngineTime() - point3.timeCreated) / this.m_fLifeTime;
                Color color = Color.Lerp(Color.white, Color.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 t    = 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], t);
                }
                Vector3 a    = point3.basePosition - point3.tipPosition;
                float   num8 = this.m_fTipSize;
                if (this.m_SizeRates != null && this.m_SizeRates.Length > 0)
                {
                    float num9  = num4 * (float)(this.m_SizeRates.Length - 1);
                    float num10 = Mathf.Floor(num9);
                    float num11 = Mathf.Clamp(Mathf.Ceil(num9), 1f, (float)(this.m_SizeRates.Length - 1));
                    float t2    = Mathf.InverseLerp(num10, num11, num9);
                    if (num10 >= (float)this.m_SizeRates.Length)
                    {
                        num10 = (float)(this.m_SizeRates.Length - 1);
                    }
                    if (num10 < 0f)
                    {
                        num10 = 0f;
                    }
                    if (num11 >= (float)this.m_SizeRates.Length)
                    {
                        num11 = (float)(this.m_SizeRates.Length - 1);
                    }
                    if (num11 < 0f)
                    {
                        num11 = 0f;
                    }
                    num8 *= Mathf.Lerp(this.m_SizeRates[(int)num10], this.m_SizeRates[(int)num11], t2);
                }
                if (this.m_bCenterAlign)
                {
                    array3[m * 2]     = point3.basePosition - a * (num8 * 0.5f);
                    array3[m * 2 + 1] = point3.basePosition + a * (num8 * 0.5f);
                }
                else
                {
                    array3[m * 2]     = point3.basePosition - a * num8;
                    array3[m * 2 + 1] = point3.basePosition;
                }
                int num12 = (!this.m_bInterpolation) ? this.m_nFadeTailCount : (this.m_nFadeTailCount * this.m_nSubdivisions);
                int num13 = (!this.m_bInterpolation) ? this.m_nFadeHeadCount : (this.m_nFadeHeadCount * this.m_nSubdivisions);
                if (0 < num12 && m <= num12)
                {
                    color.a = color.a * (float)m / (float)num12;
                }
                if (0 < num13 && list4.Count - (m + 1) <= num13)
                {
                    color.a = color.a * (float)(list4.Count - (m + 1)) / (float)num13;
                }
                array6[m * 2] = (array6[m * 2 + 1] = color);
                float num14 = (float)m / (float)list4.Count;
                array4[m * 2]     = new Vector2((!this.m_UvFlipHorizontal) ? num14 : (1f - num14), (float)((!this.m_UvFlipVirtical) ? 0 : 1));
                array4[m * 2 + 1] = new Vector2((!this.m_UvFlipHorizontal) ? num14 : (1f - num14), (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.vertices  = array3;
            this.m_TrailMesh.colors    = array6;
            this.m_TrailMesh.uv        = array4;
            this.m_TrailMesh.triangles = array5;
        }
        else
        {
            this.m_TrailMesh.Clear();
        }
    }
コード例 #3
0
ファイル: NgInterpolate.cs プロジェクト: linbozhang/ThrowCoin
    /**
     * 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 = NgInterpolate.NewCounter(0, slices + 1, 1);

        return(NewEase(ease, start, end, slices + 1, counter));
    }
コード例 #4
0
ファイル: NgInterpolate.cs プロジェクト: linbozhang/ThrowCoin
    /**
     * 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 = NgInterpolate.NewTimer(duration);

        return(NewBezier <Transform>(ease, nodes, TransformDotPosition, duration, timer));
    }
コード例 #5
0
ファイル: NgInterpolate.cs プロジェクト: linbozhang/ThrowCoin
    /**
     * 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 = NgInterpolate.NewTimer(duration);

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