Example #1
0
        /// <summary>
        /// Add a player to game
        /// </summary>
        public virtual void AddPlayer(Player player)
        {
            if (null == player)
                return;

            Players.Add(player.Name, player);
        }
Example #2
0
 public void RemovePlayer(Player player)
 {
     if (null == player || string.IsNullOrEmpty(player.Name))
         return;
     this.RemovePlayer(player.Name);
 }
Example #3
0
 //public override void Refresh() {
 //    base.Refresh();
 //    PlayPanel panel = null;
 //    InfoPanel info = null;
 //    int i = 0;
 //    foreach (Player player in this.Players.Values) {
 //        info = player.InfoPanel;
 //        if (null != info) {
 //            info.Show(i * (info.Width + 20) + 20, 40);
 //        }
 //        panel = player.PlayFiled;
 //        if (null != panel) {
 //            panel.Show(i * (panel.Width + 20) + 20, info.Bottom + 20);
 //        }
 //        i++;
 //    }
 //    // adjust form size depends on last panel.
 //    if (null != panel) {
 //        this.Container.Height = panel.Bottom + 60;
 //        this.Container.Width = panel.Right + 30;
 //    }
 //}
 public override void AddPlayer(Player player)
 {
     base.AddPlayer(player);
     this.Container.Controls.Add(player.PlayFiled);
 }
Example #4
0
        void OnClientConnected(object sender, NetworkEventArgs e)
        {
            RemoteInformation ri = e.RemoteInformation;
            if (null == ri)
                return;

            Player player = new Player();
            player.HostName = ri.Name;
            player.EndPoint = ri.EndPoint;
            this.AddPlayer(player);

            // tell new player how many players here
            foreach (Player p in this.Players.Values) {
                if (p != player) {
                    this.CallClient(player.HostName, p.HostName, "JOIN");
                    this.CallClient(player.HostName, p.HostName, "NAME," + p.Name);
                }
            }

            // tell all players the new player joined
            this.CallClients(player.HostName, "JOIN");
            // Get client player name
            this.CallClient(player.HostName, player.HostName, "NAME");
            // tell client the max players
            this.CallClient(player.HostName, player.HostName, "MAX," + this.MaxPlayers.ToString());

            if (null != this.PlayerJoined)
                this.PlayerJoined(this, new PlayerEventArgs(player));
        }
Example #5
0
 public PlayerEventArgs(Player player)
     : this()
 {
     this.Player = player;
 }