private void PlaceShips(Event ev) { while (!ShipList.AreShipsPlaced(Player.Ships)) { ShipList.PlaceShip(Player.Ships, RandomCoordinates(), RandomShipOrientation()); } }
private void HandlePlayerAdd(Event ev) { MatchAddPlayerEvent evCasted = (MatchAddPlayerEvent)ev; Player plr = evCasted.Player; HookPlayerEvents(plr); oldController.Registers.Add(plr.ID, new Register(plr.ID, plr.Name)); }
private void CreateShots(Event ev) { shotsRemain = new List<Shot>(); foreach (Player opponent in Player.Match.Players) { if (opponent == Player) continue; QueueShotsPlayer(opponent); } }
private void HandlePlayerLose(Event ev) { Player plr = ((PlayerLostEvent)ev).Player; if (plr == myPlayer) { oldController.RoundLost(); } else { oldController.OpponentDestroyed(plr.ID); } }
private void shipHit(Event ev) { ShipHitEvent shipHitEvent = (ShipHitEvent)ev; Player owner = shipHitEvent.Ship.Owner; if (owner != Player) { bool sink = shipHitEvent.Ship.IsSunk(); Coordinates coords = shipHitEvent.HitCoords; bot.shipHit(coords, sink); } else { //other player has made a hit } }
private void HandlePlayerShot(Event ev) { PlayerShotEvent evCasted = (PlayerShotEvent)ev; Player plr = evCasted.Player; Shot shot = evCasted.Shot; if (plr == myPlayer) { Ship shipHit = ShipList.GetShipAt(shot); if (shipHit == null) { oldController.ShotMiss(shot); } else { oldController.ShotHit(shot, shipHit.IsSunk()); } } else { oldController.OpponentShot(shot); } }
private void Shoot(Event ev) { int shotIdx = rand.Next(shotsRemain.Count); Shot randShot = shotsRemain[shotIdx]; shotsRemain.RemoveAt(shotIdx); Player.Shoot(randShot); }
private void roundBeginEvent(Event ev) { RoundBeginEvent matchBeginEvent = (RoundBeginEvent)ev; this.newRound(); }
public void UpdateWinner(Event ev) { var playerWon = (PlayerWonEvent)ev; MessageBox.Show("The winner is " + playerWon.Player.Name + " in " + playerWon.Player.ShotsMade.Count + " shots!"); if (playerWon.Player == user) { userScore++; } else { compScore++; } showStats(); }
private void matchBeginEvent(Event ev) { this.newMatch(); }
private void matchBeginEvent(Event ev) { MatchBeginEvent matchBeginEvent = (MatchBeginEvent)ev; this.newMatch(); }
private void HandleTurnBegin(Event ev) { Shot shotMade = oldController.MakeShot(); shotMade.ReceiverPlr = myPlayer.Match.Players.Where(plr => plr.ID == shotMade.Receiver).First(); myPlayer.Shoot(shotMade); }
private void playerTurnBeginEvent(Event ev) { this.turnStart(); }
private void HandleTeamAdd(Event ev) { Team team = ((MatchTeamAddEvent)ev).Team; oldController.Teams.Add(team.ID, team); }
private void HandleTeamRemove(Event ev) { Team team = ((MatchTeamRemoveEvent)ev).Team; oldController.Teams.Remove(team.ID); }
private void HandleRoundBegin(Event ev) { oldController.NewRound(); foreach (Ship ship in oldController.PlaceShips().ToList()) { Ship existingShip = myPlayer.Ships.Where(x => x.Length == ship.Length && !x.IsPlaced).First(); if (existingShip != null) { existingShip.Place(ship.Location, ship.Orientation); } } }
private void HandlePlayerWin(Event ev) { oldController.RoundWon(); }
public static void EventGenerated(Event ev) { Console.WriteLine(ev.GetType().Name); }
public void UpdateShipDestroyed(Event ev) { ShipDestroyedEvent des = (ShipDestroyedEvent) ev; if (des.Ship.Owner == user) { gridAI.SetCellState(lastHit, CellState.Sunk); } else { gridUser.SetCellState(lastHit, CellState.Sunk); } }
private void HandleMatchBegin(Event ev) { oldController.NewMatch(); }
public void RoundEnd(Event ev) { reset_Board(); }
private void HandleMatchEnd(Event ev) { oldController.MatchOver(); }
private void roundBeginEvent(Event ev) { this.newRound(); }
public NetIncomingEvent(NetCom communicator, Event incomingEvent) : base(communicator) { ReceivedEvent = incomingEvent; }
public InvalidEventException(Event ev, string message) : base(message) { InvalidEvent = ev; }
public void UpdateShot(Event ev) { var playerShot = (PlayerShotEvent)ev; if (playerShot.Player == user) { gridUser.SetCellState(playerShot.Shot.Coordinates, CellState.Miss); gridUser.Invalidate(); } else { gridAI.SetCellState(playerShot.Shot.Coordinates, CellState.Miss); gridAI.Invalidate(); } }
private void playerTurnBeginEvent(Event ev) { PlayerTurnBeginEvent playerTurnBeginEvent = (PlayerTurnBeginEvent)ev; this.turnStart(); }
private void HandlePlayerRemove(Event ev) { Player plr = ((MatchRemovePlayerEvent)ev).Player; UnhookPlayerEvents(plr); oldController.Registers.Remove(((MatchRemovePlayerEvent)ev).Player.ID); }
private void shipHitEvent(Event ev) { ShipHitEvent shipHitEvent = (ShipHitEvent)ev; Player owner = shipHitEvent.Ship.Owner; //who owns the hit ship // We only care about hits on enemy ships if (owner != Player) { // An opponent's ship has been hit this.hit(shipHitEvent.HitCoords, shipHitEvent.Ship.IsSunk()); } }
public void UpdateShotHit(Event ev) { var shipHit = (ShipHitEvent)ev; if (shipHit.Ship.Owner == user) { gridAI.SetCellState(shipHit.HitCoords, CellState.Hit); gridAI.Invalidate(); } else { gridUser.SetCellState(shipHit.HitCoords, CellState.Hit); gridUser.Invalidate(); } lastHit = shipHit.HitCoords; }