コード例 #1
0
ファイル: GameBase.cs プロジェクト: samuelchen/SharpTetris
        /// <summary>
        /// Add a player to game
        /// </summary>
        public virtual void AddPlayer(Player player)
        {
            if (null == player)
                return;

            Players.Add(player.Name, player);
        }
コード例 #2
0
ファイル: GameBase.cs プロジェクト: samuelchen/SharpTetris
 public void RemovePlayer(Player player)
 {
     if (null == player || string.IsNullOrEmpty(player.Name))
         return;
     this.RemovePlayer(player.Name);
 }
コード例 #3
0
ファイル: LocalGame.cs プロジェクト: samuelchen/SharpTetris
 //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);
 }
コード例 #4
0
ファイル: ServerGame.cs プロジェクト: samuelchen/SharpTetris
        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));
        }
コード例 #5
0
ファイル: GameEvents.cs プロジェクト: samuelchen/SharpTetris
 public PlayerEventArgs(Player player)
     : this()
 {
     this.Player = player;
 }