コード例 #1
0
 public Task Handle(ShipHit message)
 {
     _gameDisplay.DisplayHit(message.ShipName);
     _store.AddHit(message.Target.X, message.Target.Y);
     _gameDisplay.DisplayBoard(_store.ShotsTaken, _store.BoardSize);
     return(Task.CompletedTask);
 }
コード例 #2
0
        private void Apply(ShipHit e)
        {
            this._shotsTaken.Add(e.Target);
            var shipId = _board.GetObjectIdOnBoard(e.Target.X, e.Target.Y);

            _ships[shipId.Value].Shoot();
        }
コード例 #3
0
        private void CheckShot(int rowIndex, int columnIndex)
        {
            var ship = GetShipByGridPoint(rowIndex, columnIndex);

            if (ship.IsDead)
            {
                ShipSunk?.Invoke(this, ship);
            }
            else
            {
                ShipHit?.Invoke(this, ship);
            }
        }