Example #1
0
        //protected virtual void OnAttackedAndHit(AttackedAndHitEventArgs e)
        //{
        //    EventHandler<AttackedAndHitEventArgs> handler = this.AttackedAndHit;
        //    if (handler != null)
        //    {
        //        handler(this, e);
        //    }
        //}
        protected virtual void OnPlayerConnected(PlayerConnectedEventArgs e)
        {
            EventHandler<PlayerConnectedEventArgs> handler = this.PlayerConnected;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Example #2
0
 private void HandlePlayerConnected(object sender, PlayerConnectedEventArgs e)
 {
     //message written to the server console window when the player connects
     Console.WriteLine(e.Name + " has connected.");
 }
Example #3
0
        private void HandlePlayerConnected(object sender, PlayerConnectedEventArgs e)
        {
            //write to the client to let them know someone else has connected
            this.writeToClient(e.Name + " has connected.\r\n");

            lock (playerlock)
            {
                //subscribe to all the other player's events the player will need to know about
                if (this.players.Contains((Player)sender))
                {
                    this.players[this.players.IndexOf((Player)sender)].PlayerMoved += this.HandlePlayerMoved;
                    this.players[this.players.IndexOf((Player)sender)].PlayerDisconnected += this.HandlePlayerDisconnected;
                }
            }
        }