Пример #1
0
        public void BinaryTreeText(Node node)
        {
            chuoi.Add(node.XuatChuoi());

            if (node.nodeL != null) BinaryTreeText(node.nodeL);
            if (node.nodeR != null) BinaryTreeText(node.nodeR);
        }
Пример #2
0
        public void Build(Node node)
        {
            //check if node is large enough
            if (node.width <= widthOfCamera) return;

            //check if node has object
            if (node.listObject.Count == 0) return;

            node.nodeL = new Node(node.id + "00", node.positionX, node.positionY, node.width / 2, node.height);
            node.nodeR = new Node(node.id + "01", node.positionX + node.width / 2, node.positionY, node.width / 2, node.height);

            foreach (GameObject gameObject in node.listObject)
            {
                if (node.nodeL.KiemTraThuoc(gameObject))
                {
                    node.nodeL.listObject.Add(gameObject);
                }

                if (node.nodeR.KiemTraThuoc(gameObject))
                {
                    node.nodeR.listObject.Add(gameObject);
                }
            }

            node.listObject.Clear();

            Build(node.nodeL);
            Build(node.nodeR);
        }
Пример #3
0
        public Node(string id, float positionX, float positionY, float width, float height)
        {
            this.id = id;
            this.positionX = positionX;
            this.positionY = positionY;
            this.width = width;
            this.height = height;

            nodeL = null;
            nodeR = null;

            listObject = new List<GameObject>();
        }
Пример #4
0
        public Node()
        {
            id = "";
            positionX = 0;
            positionY = 0;
            width = 0;
            height = 0;

            nodeL = null;
            nodeR = null;

            listObject = new List<GameObject>();
        }
Пример #5
0
 public BinaryTree(float PositionX, float PositionY, float Width, float Height, float WidthCamera)
 {
     rootNode = new Node("00", PositionX, PositionY, Width, Height);
     widthOfCamera = WidthCamera;
 }