public StaticGrid(StaticGrid b) : base(b) { bool[][] 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; } } _mNodes = buildNodes(b.Width, b.Height, tMatrix); }
public StaticGrid(StaticGrid b) : base(b) { bool[][] 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; } } } _mNodes = buildNodes(b.Width, b.Height, tMatrix); }
public override BaseGrid Clone() { int tWidth = Width; int tHeight = Height; Node[][] tNodes = _mNodes; StaticGrid tNewGrid = new StaticGrid(tWidth, tHeight); Node[][] 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); }
public void LoadZone() { using (Stream stream = new MemoryStream(Data)) { int numBytesToRead = 1; int numBytesRead = 0; byte[] bytes = new byte[numBytesToRead]; byte[] xlength = new byte[2]; byte[] ylength = new byte[2]; stream.Read(bytes, numBytesRead, numBytesToRead); xlength[0] = bytes[0]; stream.Read(bytes, numBytesRead, numBytesToRead); xlength[1] = bytes[0]; stream.Read(bytes, numBytesRead, numBytesToRead); ylength[0] = bytes[0]; stream.Read(bytes, numBytesRead, numBytesToRead); ylength[1] = bytes[0]; YLength = BitConverter.ToInt16(ylength, 0); XLength = BitConverter.ToInt16(xlength, 0); Grid = new StaticGrid(XLength, YLength); for (int i = 0; i < YLength; ++i) { for (int t = 0; t < XLength; ++t) { stream.Read(bytes, numBytesRead, numBytesToRead); Grid.SetWalkableAt(new GridPos(t, i), bytes[0]); } } } }
public override BaseGrid Clone() { int tWidth = width; int tHeight = height; Node[][] tNodes = this.m_nodes; StaticGrid tNewGrid = new StaticGrid(tWidth, tHeight, null); Node[][] 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.m_nodes = tNewNodes; return tNewGrid; }