/// <summary>
        /// 当玩家加入一个游戏时,调用此方法通知
        /// </summary>
        /// <param name="player">游戏中的玩家对象</param>
        public virtual void OnJoinedGame(GamePlayerBase player)
        {
            lock ( SyncRoot )
            {
                if (Player != null)
                {
                    throw new InvalidOperationException("玩家当前已经在另一个游戏,无法加入游戏");
                }

                _player = player;
            }
        }
Exemple #2
0
 /// <summary>
 /// 当玩家退出游戏时,调用此方法通知游戏
 /// </summary>
 /// <param name="player">退出游戏的玩家</param>
 public virtual void OnPlayerQuitted(GamePlayerBase player)
 {
 }
 /// <summary>
 /// 创建 PlayerInfo 对象
 /// </summary>
 /// <param name="player"></param>
 public PlayerInfo(GamePlayerBase player)
 {
     PlayerName   = player.PlayerName;
     PlayerHostID = player.PlayerHost.ID;
 }
 /// <summary>
 /// 创建一条 GameChatMessage 对象
 /// </summary>
 /// <param name="player">发出消息的玩家</param>
 /// <param name="message">消息内容</param>
 public GameChatMessage(GamePlayerBase player, string message)
     : base(GameMessageType.Chat, message)
 {
     Player = new PlayerInfo(player);
 }