public EnemyShip(IGridSquare seedSquare, EnemyBoard enemyBoard) { maxSize = enemyBoard.GetActiveShipMaxSize(); sizeDetected = 1; seed = Utils.ConvertGridSquareToPoint(seedSquare); bool addDown = true; bool addRight = true; bool addUp = true; bool addLeft = true; possibleTilesAroundSeed = new List <Point>(); for (int dist = 1; dist <= 4; dist++) { Point down = seed.Plus(new Point(0, dist)); if (IsPointOnGrid(down) && enemyBoard.IsTestedSquare(down)) { addDown = false; } if (addDown && IsPointOnGrid(down)) { possibleTilesAroundSeed.Add(down); } Point right = seed.Plus(new Point(dist, 0)); if (IsPointOnGrid(right) && enemyBoard.IsTestedSquare(right)) { addRight = false; } if (addRight && IsPointOnGrid(right)) { possibleTilesAroundSeed.Add(right); } Point up = seed.Plus(new Point(0, -dist)); if (IsPointOnGrid(up) && enemyBoard.IsTestedSquare(up)) { addUp = false; } if (addUp && IsPointOnGrid(up)) { possibleTilesAroundSeed.Add(up); } Point left = seed.Plus(new Point(-dist, 0)); if (IsPointOnGrid(left) && enemyBoard.IsTestedSquare(left)) { addLeft = false; } if (addLeft && IsPointOnGrid(left)) { possibleTilesAroundSeed.Add(left); } } }
public AdmiralAckbot() { state = BotStates.Searching; ourBoard = new GameBoard(); enemyBoard = new EnemyBoard(); rng = new Random(); }
// Use this for initialization void Start() { gameManager = FindObjectOfType <GameManager>(); gameBoard = FindObjectOfType <GameBoard>(); enemyBoard = FindObjectOfType <EnemyBoard>(); text = GetComponent <Text>(); ships = gameBoard.GetComponentsInChildren <Ship>(); enemyShips = enemyBoard.GetComponentsInChildren <EnemyShip>(); }
private void StartGame() { Game = new Game(); PlayerBoard.UpdateBoard(Game.Player1.GameBoard); EnemyBoard.UpdateBoard(Game.Player1.EnemyBoard); Game.RoundCompleted.Subscribe(UpdateBoards); Game.GameFinished.Subscribe(GameFinished); EndMessage = string.Empty; EnemyBoard.IsActive = true; }
// Use this for initialization void Start() { enemyBoard = FindObjectOfType <EnemyBoard>(); enemyBoard2 = FindObjectOfType <EnemyBoard2>(); gameProgress = FindObjectOfType <GameProgress>(); gameManager = FindObjectOfType <GameManager>(); enemyShips = FindObjectsOfType <EnemyShip>(); levelManager = FindObjectOfType <LevelManager>(); CPUMode = levelManager.SetOpponent(); hardMode = levelManager.SetDifficulty(); }
public void GetNeighbors_should_return_neighbours_of_the_field() { EnemyBoard board = new EnemyBoard(); var result = board.GetNeighbors(new Coordinates(5, 5)); Assert.AreEqual(4, result.Count()); Assert.AreEqual(1, result.Where(x => x.Coordinates.Column == 5 && x.Coordinates.Row == 6).Count()); Assert.AreEqual(1, result.Where(x => x.Coordinates.Column == 5 && x.Coordinates.Row == 4).Count()); Assert.AreEqual(1, result.Where(x => x.Coordinates.Column == 4 && x.Coordinates.Row == 5).Count()); Assert.AreEqual(1, result.Where(x => x.Coordinates.Column == 6 && x.Coordinates.Row == 5).Count()); }
public void GetHitNeighbors_should_return_neighbours_of_hit_field() { EnemyBoard board = new EnemyBoard(); board.Fields.Where(x => x.Coordinates.Column == 5 && x.Coordinates.Row == 3).First().FieldType = FieldType.Hit; var result = board.GetHitNeighbors(); Assert.AreEqual(1, result.Where(x => x.Column == 5 && x.Row == 2).Count()); Assert.AreEqual(1, result.Where(x => x.Column == 5 && x.Row == 4).Count()); Assert.AreEqual(1, result.Where(x => x.Column == 4 && x.Row == 3).Count()); Assert.AreEqual(1, result.Where(x => x.Column == 6 && x.Row == 3).Count()); }
private void UpdateBoards(Unit unit) { EnemyBoard.UpdateBoard(Game.Player1.EnemyBoard); PlayerBoard.UpdateBoard(Game.Player1.GameBoard); }