Ejemplo n.º 1
0
        public StaticGrid(StaticGrid b)
            : base(b)
        {
            var tMatrix = new bool[b.Width][];

            for (int widthTrav = 0; widthTrav < b.Width; widthTrav++)
            {
                tMatrix[widthTrav] = new bool[b.Height];
                for (int heightTrav = 0; heightTrav < b.Height; heightTrav++)
                {
                    if (b.IsWalkableAt(widthTrav, heightTrav))
                    {
                        tMatrix[widthTrav][heightTrav] = true;
                    }
                    else
                    {
                        tMatrix[widthTrav][heightTrav] = false;
                    }
                }
            }
            this.mNodes = BuildNodes(b.Width, b.Height, tMatrix);
        }
Ejemplo n.º 2
0
        public override BaseGrid Clone()
        {
            int tWidth  = Width;
            int tHeight = Height;

            Node[][] tNodes = this.mNodes;

            var tNewGrid = new StaticGrid(tWidth, tHeight, null);

            var tNewNodes = new Node[tWidth][];

            for (int widthTrav = 0; widthTrav < tWidth; widthTrav++)
            {
                tNewNodes[widthTrav] = new Node[tHeight];
                for (int heightTrav = 0; heightTrav < tHeight; heightTrav++)
                {
                    tNewNodes[widthTrav][heightTrav] = new Node(widthTrav, heightTrav, tNodes[widthTrav][heightTrav].Walkable);
                }
            }
            tNewGrid.mNodes = tNewNodes;

            return(tNewGrid);
        }