public void TestTCODLineDrawing() { TCODLineDrawing.InitLine(2, 2, 5, 5); int x = 2, y = 2; for (int i = 0; i < 4; ++i) { Assert.IsTrue((2 + i == x) && (2 + i == y)); TCODLineDrawing.StepLine(ref x, ref y); } }
private void ConnectPoints(Point upStairsPoint, Point downStairsPoint) { //First check if the stairs are connected... if (ArePointsConnected(upStaircase, downStaircase)) { return; } //If not, open a path between the staircases TCODLineDrawing.InitLine(upStairsPoint.x, upStairsPoint.y, downStairsPoint.x, downStairsPoint.y); int nextX = upStairsPoint.x; int nextY = upStairsPoint.y; Random rand = Game.Random; do { SetSquareOpen(nextX, nextY); //Chance surrounding squares also get done if (nextX - 1 > 0 && nextY - 1 > 0) { if (rand.Next(100) < MineChance) { SetSquareOpen(nextX - 1, nextY - 1); } } if (nextY - 1 > 0) { if (rand.Next(100) < MineChance) { SetSquareOpen(nextX, nextY - 1); } } if (nextX + 1 < Width && nextY - 1 > 0) { if (rand.Next(100) < MineChance) { SetSquareOpen(nextX + 1, nextY - 1); } } if (nextX - 1 > 0) { if (rand.Next(100) < MineChance) { SetSquareOpen(nextX - 1, nextY); } } if (nextX + 1 < Width) { if (rand.Next(100) < MineChance) { SetSquareOpen(nextX + 1, nextY); } } if (nextX - 1 > 0 && nextY + 1 < Height) { if (rand.Next(100) < MineChance) { SetSquareOpen(nextX - 1, nextY + 1); } } if (nextY + 1 < Height) { if (rand.Next(100) < MineChance) { SetSquareOpen(nextX, nextY + 1); } } if (nextX + 1 < Width && nextY + 1 < Height) { if (rand.Next(100) < MineChance) { SetSquareOpen(nextX + 1, nextY + 1); } } } while (!TCODLineDrawing.StepLine(ref nextX, ref nextY)); }