Example #1
0
    void init()
    {
        StartPos = Vector3.zero;
        EndPos   = Vector3.up * 10;
        Vector3 diffvector = EndPos - StartPos;
        Vector3 diff       = diffvector / MaxNodeNum;

        StripLength = diffvector.magnitude;
        //Debug.Log(StripLength);
        Vector3 lastpos = StartPos;

        nodes = new List <StripNode>();
        float l     = (EndPos - StartPos).magnitude;
        float diffl = l / (float)(MaxNodeNum - 1);

        for (int i = 0; i < MaxNodeNum; i++)//分10段,有11个节点
        {
            StripNode tempnode = new StripNode();
            tempnode.gameObject = StripUtils.CreatStripNode(i.ToString());
            tempnode.Pos        = lastpos;
            lastpos            += diff;
            tempnode.Width      = StripUtils.GetWidth(i * diffl, l);
            nodes.Add(tempnode);
        }
    }
Example #2
0
    //private Vector3 GetRealPos(Vector3 oriPos,Vector3 targetPos)
    //{
    //}

    private bool changeStatus(Vector3 targetPos)
    {
        int       length      = nodes.Count;
        StripNode lastnode    = nodes[length - 1];
        Vector3   endnodediff = targetPos - lastnode.OriPos;

        for (int i = 0; i < length; i++)
        {
            nodes[i].Pos = nodes[i].OriPos + ((float)i / length) * endnodediff * nodes[i].Width;
        }
        return(true);
    }