IEnumerator GetRandomObstacle() // find the obstacle to use { ObstacleToUse = new ObstacleKind(); int random = Random.Range(0, 5 + 1); switch (random) { case 0: ObstacleToUse = ObstacleKind.arrow; break; case 1: ObstacleToUse = ObstacleKind.square; break; case 2: ObstacleToUse = ObstacleKind.circle; break; case 3: ObstacleToUse = ObstacleKind.rotator; break; case 4: ObstacleToUse = ObstacleKind.stick; break; case 5: ObstacleToUse = ObstacleKind.longs; break; } yield return(null); }
internal List <Obstacle> GetObstacleList() { List <Obstacle> result = new List <Obstacle>(); for (int row = 0; row < _Obstacles.GetLength(0); row++) { for (int column = 0; column < _Obstacles.GetLength(1); column++) { ObstacleKind curObstacle = _Obstacles[row, column]; if (curObstacle != ObstacleKind.None) { result.Add(new Obstacle(column, row, curObstacle)); } } } return(result); }
public Board Generate() { int obstacleCount = _BoardSettings.ObstacleCount; Random rnd = new Random(); List <Obstacle> obstacleList = new List <Obstacle>(); for (int i = 0; i < obstacleCount; i++) { int column = 0; int row = 0; do { column = rnd.Next(_BoardSettings.Columns); row = rnd.Next(_BoardSettings.Rows); } while (obstacleList.Any(cur => cur.Column == column && cur.Row == row)); ObstacleKind kind = ObstacleKind.Wall; obstacleList.Add(new Obstacle(column, row, kind)); } ObstacleKind[,] obstacles = new ObstacleKind[_BoardSettings.Rows, _BoardSettings.Columns]; for (int row = 0; row < _BoardSettings.Rows; row++) { for (int column = 0; column < _BoardSettings.Columns; column++) { var obstacle = obstacleList.FirstOrDefault(cur => cur.Column == column && cur.Row == row); if (obstacle != null) { obstacles[row, column] = obstacle.Kind; } } } return(new Board(obstacles)); }
public Obstacle(int row, int column, ObstacleKind kind) { Column = column; Row = row; Kind = kind; }
public DamageCarriableEvent(ObstacleKind obstacleType) { this.obstacleType = obstacleType; }