Exemple #1
0
 /// <summary>
 /// Fires the ship positions received event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="ShipPositionsReceivedEventArgs"/> instance containing the event data.</param>
 protected virtual void FireShipPositionsReceived(object sender, ShipPositionsReceivedEventArgs args)
 {
     if (this.ShipPositionsReceived != null)
     {
         this.ShipPositionsReceived(sender, args);
     }
 }
Exemple #2
0
        /// <summary>
        /// Handles the received ship positions. Initiates shooting if positions of both players are received.
        /// </summary>
        /// <param name="sender">The sender of the ShipPositionsReceived event.</param>
        /// <param name="args">The event arguments.</param>
        private void Competitor_ShipPositionsReceived(object sender, ShipPositionsReceivedEventArgs args)
        {
            Competitor competitor = (Competitor)sender;

            competitor.BattleField.Ships      = args.Ships;
            competitor.ShipPositionsReceived -= this.Competitor_ShipPositionsReceived;
            competitor.PositionsReady         = true;

            if (this.CompetitorB.PositionsReady && this.CompetitorA.PositionsReady)
            {
                this.InitiateShooting();
            }
        }