Inheritance: System.Entity
Exemplo n.º 1
0
 /// <summary>
 /// Populates the shotRemain list with all possible shots against a Player opponent
 /// </summary>
 /// <param name="opponent"></param>
 private void QueueShotsPlayer(Player opponent)
 {
     for (int x = 0; x < Player.Match.FieldSize.X; x++)
     {
         for (int y = 0; y < Player.Match.FieldSize.Y; y++)
         {
             shotsRemain.Add(new Shot(opponent, new Coordinates(x, y)));
         }
     }
 }
Exemplo n.º 2
0
        public void NewMatch()
        {
            this.player = this.controller.Player;
            this.match = this.player.Match;
            ShotHelper.MatchX = match.FieldSize.X - 1;
            ShotHelper.MatchY = match.FieldSize.Y - 1;

            this.shipLengths = this.match.StartingShips.Select(ship => ship.Length).ToArray();

            cellStateMap = new CellStateMap(match.FieldSize.X);

            historyMap = new HistoryMap(match.FieldSize.X, this.shipLengths, cellStateMap);
            placementMap = new PlacementMap(match.FieldSize.X, this.shipLengths, cellStateMap);
            huntingMap = new HuntingMap(match.FieldSize.X, this.shipLengths, cellStateMap);
        }
Exemplo n.º 3
0
 private void HookPlayerEvents(Player plr)
 {
     plr.OnEvent += HandlePlayerShot;
     plr.OnEvent += HandlePlayerLose;
     if (plr == myPlayer)
     {
         plr.OnEvent += HandleTurnBegin;
         plr.OnEvent += HandlePlayerWin;
     }
 }
Exemplo n.º 4
0
 public virtual void PlayerRemove(Player plr)
 {
     InvokeEvent(new TeamRemovePlayerEvent(this, plr));
 }
Exemplo n.º 5
0
 public virtual void PlayerAdd(Player plr)
 {
     InvokeEvent(new TeamAddPlayerEvent(this, plr));
 }
Exemplo n.º 6
0
        private void HandleAddPlayer(Event ev)
        {
            MatchAddPlayerEvent evCasted = (MatchAddPlayerEvent)ev;
            Player plr = evCasted.Player;
            if (plr != User)
                computer = plr;

            plr.OnEvent += HandleShot;
            foreach (Ship ship in plr.Ships)
            {
                ship.OnEvent += HandleShipMove;
                ship.OnEvent += HandleShipDestroyed;
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Shoots against a player opponent at the specified X and Y coordinates.
 /// </summary>
 /// <param name="opponent"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public virtual void Shoot(Player opponent, int x, int y)
 {
     Shoot(new Shot(opponent, new Coordinates(x, y)));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates a MatchRemovePlayerEvent from within the match and returns it. Invokes any event
 /// subscriptions to OnPlayerRemove.
 /// </summary>
 /// <param name="player"></param>
 /// <returns>The generated event</returns>
 /// <exception cref="InvalidEventException">Thrown when the event being created is not valid for the
 /// current state of the match.</exception>
 protected internal virtual void PlayerRemove(Player player)
 {
     InvokeEvent(new MatchRemovePlayerEvent(this, player));
 }
 /// <summary>
 /// Constructs the event with the player that lost.
 /// </summary>
 /// <param name="loser"></param>
 public PlayerDisqualifiedEvent(Player loser, string reason)
     : base(loser)
 {
     Reason = reason;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructs the event with the player that won.
 /// </summary>
 /// <param name="player"></param>
 public PlayerWonEvent(Player player)
     : base(player)
 {
 }
Exemplo n.º 11
0
        /// <summary>
        /// This creates a new match.
        /// </summary>
        public void NewMatch()
        {
            match = new UserMatch(configuration);
            user = new Player(match, NAME);
            match.AddUser(user);

            var bots = ControllerSkeleton.LoadControllerFolder(Environment.CurrentDirectory + "\\..\\bots");
            foreach (ControllerSkeleton bot in bots)
                if (bot.Controller.Name == BOTNAME)
                {
                    computer = match.PlayerCreate(bot);
                    break;
                }

            match.OnEvent += UpdateShot;
            match.OnEvent += UpdateShotHit;
            match.OnEvent += UpdateWinner;
            match.OnEvent += RoundEnd;
            match.OnEvent += UpdateShipDestroyed;

            match.Play();
        }
Exemplo n.º 12
0
 /// <summary>
 /// Constructs this event with the given player.
 /// </summary>
 /// <param name="player"></param>
 public PlayerEvent(Player player)
     : base(player)
 {
     Player = player;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Constructs this event with the given player.
 /// </summary>
 /// <param name="player"></param>
 public MatchAddPlayerEvent(Match match, Player player)
     : base(match)
 {
     Player = player;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Constructs the event with the player that lost.
 /// </summary>
 /// <param name="loser"></param>
 public PlayerLostEvent(Player loser)
     : base(loser)
 {
 }
Exemplo n.º 15
0
 /// <summary>
 /// To set the User as a player of the match.
 /// </summary>
 /// <param name="user">User controller</param>
 public void AddUser(Player user)
 {
     User = user;
     PlayerAdd(user);
 }
Exemplo n.º 16
0
 private void UnhookPlayerEvents(Player plr)
 {
     plr.OnEvent -= HandlePlayerLose;
     plr.OnEvent -= HandlePlayerShot;
     plr.OnEvent -= HandlePlayerWin;
     plr.OnEvent -= HandleTurnBegin;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Creates a MatchAddPlayerEvent from within the match and returns it. Invokes any event
 /// subscriptions to OnPlayerAdd.
 /// </summary>
 /// <param name="player"></param>
 /// <returns>The generated event</returns>
 /// <exception cref="InvalidEventException">Thrown when the event being created is not valid for the
 /// current state of the match.</exception>
 protected internal virtual void PlayerAdd(Player player)
 {
     InvokeEvent(new MatchAddPlayerEvent(this, player));
 }
Exemplo n.º 18
0
 public TeamAddPlayerEvent(Team team, Player plr)
     : base(team)
 {
     Player = plr;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Constructs this event with the player and message it created.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="message"></param>
 public PlayerMessageEvent(Player player, string message)
     : base(player)
 {
     Message = message;
 }
 public PlayerTurnBeginEvent(Player player)
     : base(player)
 {
 }
 public TeamRemovePlayerEvent(Team team, Player plr)
     : base(team)
 {
 }
Exemplo n.º 22
0
 /// <summary>
 /// Constructs the event with the player who made the shot. No ship hit.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="shot"></param>
 public PlayerShotEvent(Player player, Shot shot)
     : base(player)
 {
     Shot = shot;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Constructs the event with the player that switched their turn.
 /// </summary>
 public PlayerTurnEndEvent(Player player)
     : base(player)
 {
 }
 /// <summary>
 /// Constructs this event with the player being removed.
 /// </summary>
 /// <param name="player"></param>
 public MatchRemovePlayerEvent(Match match, Player player)
     : base(match)
 {
     Player = player;
 }