Пример #1
0
        /// <summary>
        /// <para>Add a child at the specified position and enable its flag.</para>
        /// </summary>
        /// <param name="position"></param>
        /// <param name="flag"></param>
        private void AddChild(NodeChild position, NodeContent flag)
        {
            this.EnableVertex(flag);
            QuadNode node = new QuadNode(this, position);
            this.Childs[(int)position] = node;
            float size = node.GetNodeSize();

            switch (position)
            {
                case NodeChild.NorthWest:
                    node.Location = this.Location + new Vector2(0, size);
                    break;
                case NodeChild.NorthEast:
                    node.Location = this.Location + new Vector2(size, size);
                    break;
                case NodeChild.SouthWest:
                    node.Location = this.Location + new Vector2(0, 0);
                    break;
                default:
                    node.Location = this.Location + new Vector2(size, 0);
                    break;
            }
            node.InitializeNeighbors();
            this.InitializeNeighbors();
            node.Initialize();

            switch (position)
            {
                case NodeChild.NorthWest:
                    this.EnableVertex(NodeContent.NorthVertex, NodeVertex.North);
                    this.EnableVertex(NodeContent.WestVertex, NodeVertex.West);
                    break;
                case NodeChild.NorthEast:
                    this.EnableVertex(NodeContent.NorthVertex, NodeVertex.North);
                    this.EnableVertex(NodeContent.EastVertex, NodeVertex.East);
                    break;
                case NodeChild.SouthWest:
                    this.EnableVertex(NodeContent.SouthVertex, NodeVertex.South);
                    this.EnableVertex(NodeContent.WestVertex, NodeVertex.West);
                    break;
                default:
                    this.EnableVertex(NodeContent.SouthVertex, NodeVertex.South);
                    this.EnableVertex(NodeContent.EastVertex, NodeVertex.East);
                    break;
            }
        }