Example #1
0
    /*
     * public class LList {
     *  public List<Image>[] llist;
     * }
     */

    public List <Image> Dline(GameObject btnStart, GameObject btnEnd, int segmentNum)
    {
        Vector3 startPos   = btnStart.transform.localPosition;
        Vector3 endPos     = btnEnd.transform.localPosition;
        Vector3 controlPos = new Vector3(0, 0, 0);

        if (endPos.y != 0)
        {
            controlPos = new Vector3(startPos.x, endPos.y, 0);
        }
        //if(startPos.y != 0)
        //controlPos = new Vector3(endPos.x, startPos.y, 0);
        else
        {
            controlPos = new Vector3(endPos.x, endPos.y, 0);
        }
        //      GameObject.Find("BezierUtils").SendMessage("GetBeizerList");
        Vector3[] path = BezierUtils.GetBeizerList(startPos, controlPos, endPos, segmentNum);

        //      drawline(startPos, path[1]);
        for (int i = 1; i < segmentNum; i++)
        {
            Image lineObjImg = Drawline(path[i], path[i + 1]);
            LineList.Add(lineObjImg);
        }

        return(LineList);
    }
    void Awake()
    {
        var controlPoint = BezierUtils.GetControlPoint(targe1.position, targe2.position, hight);

        targe3.position = controlPoint;
        path            = BezierUtils.GetBeizerList(targe1.position, controlPoint, targe2.position);
    }
Example #3
0
    /// <summary>
    /// 贝赛尔曲线初始化
    /// </summary>
    /// <param name="startPoint"></param>
    /// <param name="endPoint"></param>
    public virtual void Init(Transform startPoint, Transform endPoint)
    {
        // _EndPos = endPoint.position;
        var controlPoint = BezierUtils.GetControlPoint(startPoint.position, endPoint.position, hight);

        path   = BezierUtils.GetBeizerList(startPoint.position, controlPoint, endPoint.position);
        isMove = true;
    }
Example #4
0
    /// <summary>
    /// 绘制曲线.
    /// </summary>
    private Vector3[] DrawWire(Vector3 controlPos, int segments)
    {
        Vector3[] bezierPoses = BezierUtils.GetBeizerList(startPos.position, controlPos, endPos.position, segments);

        lr.positionCount = bezierPoses.Length;
        for (int i = 0; i <= bezierPoses.Length - 1; i++)
        {
            lr.SetPosition(i, bezierPoses[i]);
        }
        return(bezierPoses);
    }
Example #5
0
    IEnumerator ShowQiqiu()
    {
        qiqiu.gameObject.SetActive(true);
        Vector3 endPosition       = new Vector3(qiqiu.GetComponent <RectTransform>().position.x, 1300, qiqiu.GetComponent <RectTransform>().position.x);
        Vector3 controlerPosition = qiqiu.GetComponent <RectTransform>().position + (endPosition - qiqiu.GetComponent <RectTransform>().position) * 0.5f + new Vector3(500, 0, 0);

        Vector3[] positionArr = BezierUtils.GetBeizerList(qiqiu.GetComponent <RectTransform>().position, controlerPosition, endPosition, 80);
        for (int i = 0; i < positionArr.Length; i++)
        {
            qiqiu.GetComponent <RectTransform>().position = positionArr[i] - new Vector3(0, 0, positionArr[i].z);
            yield return(new WaitForSeconds(playSecond));
        }
        qiqiu.gameObject.SetActive(false);
        IsStand = true;
        yield return(null);
    }
Example #6
0
        /// <summary>
        /// 初始化警告公告牌下方的流动线路、以及模拟机柜、机柜节点线路
        /// </summary>
        private void InitLine()
        {
            //警告公告牌下方的流动线路
            Transform triangleLabel = transform.Find("TriangleLabel");
            Line      line          = triangleLabel.Find("Line").GetComponent <Line>();

            //确定坐标,并重新初始化Line
            Vector3 triangleLabelPosition = triangleLabel.position;

            triangleLabelPosition.y = 0.1F;
            List <Vector3> linePoints = new List <Vector3>();

            linePoints.Add(new Vector3(triangleLabelPosition.x + 1, triangleLabelPosition.y, triangleLabelPosition.z + 1));
            linePoints.Add(new Vector3(triangleLabelPosition.x + 1, triangleLabelPosition.y, triangleLabelPosition.z - 1));
            linePoints.Add(new Vector3(triangleLabelPosition.x - 1, triangleLabelPosition.y, triangleLabelPosition.z - 1));
            linePoints.Add(new Vector3(triangleLabelPosition.x - 1, triangleLabelPosition.y, triangleLabelPosition.z + 1));
            linePoints.Add(new Vector3(triangleLabelPosition.x + 1, triangleLabelPosition.y, triangleLabelPosition.z + 1));

            line.points = linePoints.ToArray();
            line.InitLine();


            //模拟机柜、机柜节点线路
            Vector3 rackPosition = transform.Find("Rack").position;

            //第一条
            Vector3[]  rackNode1Pos    = BezierUtils.GetBeizerList(transform.Find("RackNode1").position, rackPosition, 20, 2);
            GameObject lineGameObject1 = GameObject.Instantiate(linePrefab, transform, true);
            Line       line1           = lineGameObject1.GetComponent <Line>();

            line1.points = rackNode1Pos;
            line1.InitLine();

            //第二条
            Vector3[]  rackNode2Pos    = BezierUtils.GetBeizerList(transform.Find("RackNode2").position, rackPosition, 20, 2);
            GameObject lineGameObject2 = GameObject.Instantiate(linePrefab, transform, true);
            Line       line2           = lineGameObject2.GetComponent <Line>();

            line2.points = rackNode2Pos;
            line2.InitLine();
        }