private void HandleCheckHit(CheckHit x) { player.MyTurn = true; //tell attacker if its hit var isHit = IsShipHitted(x.X, x.Y); var hitResponse = new HitResponse(x, isHit); if (isHit) { rtxBox2.Text += $"I have been attacked on {x.X},{x.Y}; HIT.\n"; var isOver = IsGameOver(player.ShipSet); if (isOver == true) { rtxBox2.Text += $"GAME OVER"; opponent.Tell(new GameOver(player.PlayerNumber, username)); } else { opponent.Tell(hitResponse); } } else { rtxBox2.Text += $"I have been attacked on {x.X},{x.Y}; MISS.\n"; opponent.Tell(hitResponse); } }
private void HandleTryingToHit(TryingToHit x) { rtxBox2.Text += $"{username} targeting coordinates {x.X},{x.Y}.\n"; player.MyTurn = false; var for_checkHit = new CheckHit(x.X, x.Y); opponent.Tell(for_checkHit); //for draw hit or miss image on opponent grid player.IsOpponentHit[x.X, x.Y] = true; }
public HitResponse(CheckHit checkHit, bool isHit) { CheckHit = checkHit; this.isHit = isHit; }