Example #1
0
        public static MapBlock Combine( MapBlock bottomright, MapBlock bottomleft, MapBlock topright, MapBlock topleft )
        {
            // Merge 4 trees
            Node root = new Node( false, bottomright.Tree.Level+1 );
            root.BottomRightChild = bottomright.Tree.Clone();
            root.BottomLeftChild = bottomleft.Tree.Clone();
            root.TopRightChild = topright.Tree.Clone();
            root.TopLeftChild = topleft.Tree.Clone();

            // Use for new block
            MapBlock result = new MapBlock( root );

            // Clip the tree
            result.WalkTree( new MapBlockHandling.TreeClipper() );
            result.tree.Level = 5;

            // Optimise the tee
            result.WalkTree( new MapBlockHandling.TreeOptimiser( true ) );

            return result;
        }
Example #2
0
        public static MapBlock Combine( MapBlock[,] matrix )
        {
            Node root = new Node( false );

            // Create 4 children
            root.BottomRightChild = new Node( false );
            root.BottomLeftChild = new Node( false );
            root.TopRightChild = new Node( false );
            root.TopLeftChild  = new Node( false );

            // Add items to children
            root.BottomRightChild.BottomRightChild = matrix[3,3].Tree.Clone();
            root.BottomRightChild.BottomLeftChild = matrix[2,3].Tree.Clone();
            root.BottomRightChild.TopRightChild = matrix[3,2].Tree.Clone();
            root.BottomRightChild.TopLeftChild = matrix[2,2].Tree.Clone();

            root.BottomLeftChild.BottomRightChild = matrix[1,3].Tree.Clone();
            root.BottomLeftChild.BottomLeftChild = matrix[0,3].Tree.Clone();
            root.BottomLeftChild.TopRightChild = matrix[1,2].Tree.Clone();
            root.BottomLeftChild.TopLeftChild = matrix[0,2].Tree.Clone();

            root.TopRightChild.BottomRightChild = matrix[3,1].Tree.Clone();
            root.TopRightChild.BottomLeftChild = matrix[2,1].Tree.Clone();
            root.TopRightChild.TopRightChild = matrix[3,0].Tree.Clone();
            root.TopRightChild.TopLeftChild = matrix[2,0].Tree.Clone();

            root.TopLeftChild.BottomRightChild = matrix[1,1].Tree.Clone();
            root.TopLeftChild.BottomLeftChild = matrix[0,1].Tree.Clone();
            root.TopLeftChild.TopRightChild = matrix[1,0].Tree.Clone();
            root.TopLeftChild.TopLeftChild = matrix[0,0].Tree.Clone();

            root.Level = matrix[3,3].Tree.Level+2;

            // Use for new block
            MapBlock result = new MapBlock( root );

            // Clip the tree
            result.WalkTree( new MapBlockHandling.TreeClipperDeep( ) );
            result.tree.Level = 5;

            // Optimise the tee
            result.WalkTree( new MapBlockHandling.TreeOptimiser( true ) );

            return result;
        }
Example #3
0
 protected virtual void Draw( MapBlock block, int x, int y )
 {
     sx = x; sy = y;
     block.WalkTree( new DelegateWalker.VisitDelegate( DrawWalker ) );
 }
Example #4
0
 private void PrepareBottomRight( MapBlock block )
 {
     sx = 0; sy = 0;
     //block.WalkTree( MapBlock.WalkMode.TopLeftOnly, new MapBlock.Walker( BottomRightWalker ), 0, 0 );
     block.WalkTree( new DelegateWalker.VisitDelegate( BottomRightWalker ), TreeWalkerMode.TopLeftOnly );
 }
Example #5
0
 protected virtual void PrepareRight( MapBlock block )
 {
     sx = 0; sy = 0;
     block.WalkTree( new DelegateWalker.VisitDelegate( RightWalker ), TreeWalkerMode.LeftOnly );
 }
Example #6
0
 protected virtual void PrepareBottom( MapBlock block )
 {
     sx = 0; sy = 0;
     //block.WalkTree( MapBlock.WalkMode.TopOnly, new MapBlock.Walker( BottomWalker ), 0, 0 );
     block.WalkTree( new DelegateWalker.VisitDelegate( BottomWalker ), TreeWalkerMode.TopOnly );
 }