コード例 #1
0
    void connectTwoSide(bool isLeftRight, List <QuadTreeConnectedNode> firstSideNodes, List <QuadTreeConnectedNode> secondSideNodes)
    {
        // Debug.Log(firstSideNodes.Count + "," + secondSideNodes.Count);
        var compareHelper = new ConnectHelper(isLeftRight, firstSideNodes, secondSideNodes);

        compareHelper.AddFirstSide();
        compareHelper.AddSecondSide();
        while (true)
        {
            // 當2個buffer的sum值相等,就可以ConnectNode
            if (compareHelper.IsEqual())
            {
                // Debug.Log("IsEqual");
                compareHelper.ConnectNode(); // 實際做connect的地方
                compareHelper.ClearBuffer();

                if (compareHelper.IsFinish())
                {
                    return;
                }
                else
                {
                    compareHelper.AddFirstSide();
                    compareHelper.AddSecondSide();
                }
            }
            else if (compareHelper.FirstSideIsBigger())
            {
                // Debug.Log("FirstSideIsBigger");
                compareHelper.AddSecondSide();
            }
            else
            {
                // Debug.Log("SecondSideIsBigger");
                compareHelper.AddFirstSide();
            }
        }
    }