void FixedUpdate() { if (m_kShapeArc == null) { return; } m_fAccumAnimOffset += -m_fspeed * Time.deltaTime; //if (m_fAccumAnimOffset >= m_kShapeArc.GetCurveLength (0)-(m_fArrowHeadLenth*0.02f)/2 - 0.382f) if (m_fAccumAnimOffset <= (m_fArrowHeadLenth * 0.04f) / 2 + 0.764f) { //m_fAccumAnimOffset = 0.0f; this.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0); m_kShapeArc.GetComponent <LoopPathAnim>().moveToTail(m_kMWPD); } m_kMWPD.Offset.z = m_fAccumAnimOffset; // float linelenth = (m_kShapeArc.GetCurveLength (0) - (m_fArrowHeadLenth*0.04f)/2 + 0.764f)/5; // float lineMax = m_kShapeArc.GetCurveLength (0); // if(m_fAccumAnimOffset<lineMax && m_fAccumAnimOffset>=lineMax - linelenth) // { // this.gameObject.renderer.material.SetFloat("_Alpha",m_fAccumAnimOffset - /linelenth); // } // else if(m_fAccumAnimOffset>linelenth && m_fAccumAnimOffset<=linelenth*3) // { // this.gameObject.renderer.material.SetFloat("_Alpha",1); // } // else if(m_fAccumAnimOffset>linelenth*3&& m_fAccumAnimOffset<=linelenth*5) // { // this.gameObject.renderer.material.SetFloat("_Alpha",1-((m_fAccumAnimOffset-linelenth*3.0f)/linelenth)); // } // else // { // this.gameObject.renderer.material.SetFloat("_Alpha",0); // } float fnowoffset = m_kShapeArc.GetCurveLength(0) - m_fAccumAnimOffset; float linelenth = (m_fArrowHeadLenth * 0.04f) / 2 + 0.764f; if (fnowoffset > 0 && fnowoffset <= m_fHigh) { this.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", fnowoffset / m_fHigh); } else if (fnowoffset > m_fHigh && fnowoffset <= m_kShapeArc.GetCurveLength(0) - m_fHigh - linelenth) { this.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.7f); } else if (fnowoffset > m_kShapeArc.GetCurveLength(0) - m_fHigh - linelenth && fnowoffset <= m_kShapeArc.GetCurveLength(0)) { float f = (1 - ((fnowoffset - m_kShapeArc.GetCurveLength(0) + m_fHigh + linelenth) / m_fHigh)) * 0.7f; //if (f > 0.05f) //{ // f = 1; //} this.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", f); } else { this.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0); } //float linelenth = m_kShapeArc.GetCurveLength (0)/5; //设置alpha // if(fnowoffset>0&&fnowoffset<= linelenth) // { // this.gameObject.renderer.material.SetFloat("_Alpha",fnowoffset/linelenth); // } // else if(fnowoffset>linelenth && fnowoffset<=linelenth*3) // { // this.gameObject.renderer.material.SetFloat("_Alpha",1); // } // else if(fnowoffset>linelenth*3&& fnowoffset<=linelenth*4) // { // this.gameObject.renderer.material.SetFloat("_Alpha",1-((fnowoffset-linelenth*3.0f)/linelenth)); // } // else // { // this.gameObject.renderer.material.SetFloat("_Alpha",0); // } }
//得到曲线路径长度 --CardGame public float getShapeLen() { return(m_kShapeArc.GetCurveLength(0)); }