• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Net.NetworkSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Xna.Framework.Net.NetworkSession的典型用法代码示例。如果您正苦于以下问题:C# NetworkSession类的具体用法?C# NetworkSession怎么用?C# NetworkSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NetworkSession类属于Microsoft.Xna.Framework.Net命名空间,在下文中一共展示了NetworkSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadingScreen

		/// <summary>
		/// The constructor is private: loading screens should
		/// be activated via the static Load method instead.
		/// </summary>
		private LoadingScreen (ScreenManager screenManager,bool loadingIsSlow, 
				GameScreen[] screensToLoad)
			{
			this.loadingIsSlow = loadingIsSlow;
			this.screensToLoad = screensToLoad;

			TransitionOnTime = TimeSpan.FromSeconds (0.5);

			// If this is going to be a slow load operation, create a background
			// thread that will update the network session and draw the load screen
			// animation while the load is taking place.
			if (loadingIsSlow) {
				backgroundThread = new Thread (BackgroundWorkerThread);
				backgroundThreadExit = new ManualResetEvent (false);

				graphicsDevice = screenManager.GraphicsDevice;

				// Look up some services that will be used by the background thread.
				IServiceProvider services = screenManager.Game.Services;

				networkSession = (NetworkSession)services.GetService (
							typeof(NetworkSession));

				messageDisplay = (IMessageDisplay)services.GetService (
							typeof(IMessageDisplay));
			}
		}
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:31,代码来源:LoadingScreen.cs


示例2: ParticleManager

 public ParticleManager(GameManager gameManager, Game game, Camera camera, NetworkSession networkSession)
 {
     this.game = game;
     this.camera = camera;
     this.networkSession = networkSession;
     this.gameManager = gameManager;
 }
开发者ID:Nesokas,项目名称:hs,代码行数:7,代码来源:ParticleManager.cs


示例3: LocalNetworkGameMenu

        public LocalNetworkGameMenu(PlayerIndex enteringPlayer, NetworkSession nSession)
            : base("Local Network Game Lobby")
        {
            netSession = nSession;
            currentPlayerIndex = enteringPlayer;
            currentGamer = SignedInGamer.SignedInGamers[currentPlayerIndex];
            netSession.GameStarted += new EventHandler<GameStartedEventArgs>(loadNetworkGameScreen);

            // Create our menu entries.
            gameTypeOption = new MenuEntry("Game Type: " + GameType());
            highScoreOption = new MenuEntry("Score to Win: " + WinningScore());
            opt2 = new MenuEntry("Host: " + nSession.Host.ToString());
            opt3 = new MenuEntry("Ready?");
            opt4 = new MenuEntry("Waiting for opponent");
            opt5 = new MenuEntry("Go Back");

            netSession.GameStarted += new EventHandler<GameStartedEventArgs>(StartGame);

            gameTypeOption.Selected += changeGameType;
            highScoreOption.Selected += changeWinningScore;
            opt3.Selected += setReady;
            opt4.Selected += startGame;
            opt5.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(gameTypeOption);
            MenuEntries.Add(highScoreOption);
            MenuEntries.Add(opt2);
            MenuEntries.Add(opt3);
            MenuEntries.Add(opt4);
            MenuEntries.Add(opt5);

            SetMenuEntryText();
        }
开发者ID:nchoumitsky,项目名称:Meatieroids,代码行数:34,代码来源:LocalNetworkGameMenu.cs


示例4: CreateSession

        public bool CreateSession()
        {
            try
            {
                int maxLocalGamers = 1;
                int maxGamers = 10;
                int privateGamerSlots = 2;
                networkSession = NetworkSession.Create(NetworkSessionType.SystemLink, maxLocalGamers, maxGamers, privateGamerSlots, null);
                networkSession.AllowHostMigration = true;
                networkSession.AllowJoinInProgress = false;

                HookSessionEvents();
                networkDebug = "";
            }
            catch (NetworkNotAvailableException)
            {
                //networkEnabled = false;
                networkDebug = "Could not create session through Windows Live. Ensure you are on a network.";
                return false;
            }
            catch (InvalidOperationException)
            {
                disposeNetworkSession();
                networkDebug = "Old session still exists. Disposing. please try again.";
                return false;
            }

            return true;
        }
开发者ID:bjorfoss,项目名称:XNAX1,代码行数:29,代码来源:NetworkObject.cs


示例5: CreateSession

 private void CreateSession()
 {
     netSession = NetworkSession.Create(NetworkSessionType.SystemLink, maxNumPlayers, maxNumPlayers);
     isHost = true;
     isNetworked = true;
     Game1.state = gameState.game;
 }
开发者ID:frobro98,项目名称:School-Projects,代码行数:7,代码来源:NetworkController.cs


示例6: LobbyScreen

        /// <summary>
        /// Constructs a new lobby screen.
        /// </summary>
        public LobbyScreen(NetworkSession networkSession)
        {
            this.networkSession = networkSession;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:10,代码来源:LobbyScreen.cs


示例7: CreateSession

 public void CreateSession()
 {
     if (session == null)
     {
         session = NetworkSession.Create(NetworkSessionType.SystemLink,
         maximumLocalPlayers,
         maximumGamers);
     }
     // If the host goes out, another machine will assume as a new host
     session.AllowHostMigration = true;
     // Allow players to join a game in progress
     session.AllowJoinInProgress = true;
     session.GamerJoined +=
     new EventHandler<GamerJoinedEventArgs>(session_GamerJoined);
     session.GamerLeft +=
     new EventHandler<GamerLeftEventArgs>(session_GamerLeft);
     session.GameStarted +=
     new EventHandler<GameStartedEventArgs>(session_GameStarted);
     session.GameEnded +=
     new EventHandler<GameEndedEventArgs>(session_GameEnded);
     session.SessionEnded +=
     new EventHandler<NetworkSessionEndedEventArgs>(session_SessionEnded);
     session.HostChanged +=
     new EventHandler<HostChangedEventArgs>(session_HostChanged);
 }
开发者ID:SeaHarg,项目名称:Snake,代码行数:25,代码来源:networker.cs


示例8: MultiplayerManager

 public MultiplayerManager(Game game, Camera camera, GameManager gameManager, NetworkSession networkSession)
 {
     _game = game;
     _camera = camera;
     _gameManager = gameManager;
     _networkSession = networkSession;
 }
开发者ID:shadowpt,项目名称:hs,代码行数:7,代码来源:MultiplayerManager.cs


示例9: LobbyScreen

        /// <summary>
        /// Constructs a new LobbyScreen object.
        /// </summary>
        public LobbyScreen(NetworkSession networkSession)
            : base()
        {
            // safety-check the parameter
            if (networkSession == null)
            {
                throw new ArgumentNullException("networkSession");
            }

            // apply the parameters
            this.networkSession = networkSession;

            // add the single menu entry
            MenuEntries.Add("");

            // set the transition time
            TransitionOnTime = TimeSpan.FromSeconds(1.0);
            TransitionOffTime = TimeSpan.FromSeconds(0.0);

            gamerJoinedHandler = new EventHandler<GamerJoinedEventArgs>(
                networkSession_GamerJoined);
            gameStartedHandler = new EventHandler<GameStartedEventArgs>(
                networkSession_GameStarted);
            sessionEndedHandler = new EventHandler<NetworkSessionEndedEventArgs>(
                networkSession_SessionEnded);

            networkSession.LocalGamers[0].IsReady = true; //DRD
        }
开发者ID:robotButler,项目名称:battlelines,代码行数:31,代码来源:LobbyScreen.cs


示例10: PauseMenuScreen

		/// <summary>
		/// Constructor.
		/// </summary>
		public PauseMenuScreen (NetworkSession networkSession)
		: base(Resources.Paused)
			{
			this.networkSession = networkSession;

			// Add the Resume Game menu entry.
			MenuEntry resumeGameMenuEntry = new MenuEntry (Resources.ResumeGame);
			resumeGameMenuEntry.Selected += OnCancel;
			MenuEntries.Add (resumeGameMenuEntry);

			if (networkSession == null) {
				// If this is a single player game, add the Quit menu entry.
				MenuEntry quitGameMenuEntry = new MenuEntry (Resources.QuitGame);
				quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;
				MenuEntries.Add (quitGameMenuEntry);
			} else {
				// If we are hosting a network game, add the Return to Lobby menu entry.
				if (networkSession.IsHost) {
					MenuEntry lobbyMenuEntry = new MenuEntry (Resources.ReturnToLobby);
					lobbyMenuEntry.Selected += ReturnToLobbyMenuEntrySelected;
					MenuEntries.Add (lobbyMenuEntry);
				}

				// Add the End/Leave Session menu entry.
				string leaveEntryText = networkSession.IsHost ? Resources.EndSession : 
								Resources.LeaveSession;

				MenuEntry leaveSessionMenuEntry = new MenuEntry (leaveEntryText);
				leaveSessionMenuEntry.Selected += LeaveSessionMenuEntrySelected;
				MenuEntries.Add (leaveSessionMenuEntry);
			}
		}
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:35,代码来源:PauseMenuScreen.cs


示例11: LiveSession

 /// <summary>
 /// Creates a new instance
 /// </summary>
 /// <param name="networkSession">the newly created or joined NetworkSession instance</param>
 internal LiveSession(NetworkSession networkSession)
 {
     _networkSession = networkSession;
     _networkSession.GamerLeft += OnLivePlayerLeft;
     _networkSession.GamerJoined += OnLivePlayerJoined;
     _networkSession.GameStarted += OnLiveSessionStarted;
     _networkSession.GameEnded += OnLiveSessionEnded;
 }
开发者ID:rc183,项目名称:igf,代码行数:12,代码来源:LiveSession.cs


示例12: LobbyScreen

 public LobbyScreen(NetworkSession networkSession)
 {
     _networkSession = networkSession;
     TransitionOnTime = TimeSpan.FromSeconds(0.5);
     TransitionOffTime = TimeSpan.FromSeconds(0.5);
     _packetReader = new PacketReader();
     _packetWriter = new PacketWriter();
 }
开发者ID:Nesokas,项目名称:hs,代码行数:8,代码来源:LobbyScreen.cs


示例13: connectToGame

 /** Takes a RemoteGame and connects to it. */
 public void connectToGame(RemoteGame game)
 {
     session = NetworkSession.Join(game.getSession());
     session.GameStarted += new EventHandler<GameStartedEventArgs>(GameStarted);
     session.GameEnded += new EventHandler<GameEndedEventArgs>(GameEnded);
     session.SessionEnded += new EventHandler<NetworkSessionEndedEventArgs>(NetworkSessionEnded);
     session.GamerJoined += new EventHandler<GamerJoinedEventArgs>(GamerJoined);
     session.GamerLeft += new EventHandler<GamerLeftEventArgs>(GamerLeft);
     //Console.WriteLine("Connected to game: " + game.getDescription());
 }
开发者ID:kiniry-teaching,项目名称:UCD,代码行数:11,代码来源:NetworkManager.cs


示例14: CriaSessao

 protected void CriaSessao()
 {
     estado_atual = EstadoDeJogo.Loading;
     try {
         rede = NetworkSession.Create (NetworkSessionType.SystemLink, 2, 2);
         estado_atual = EstadoDeJogo.Lobby;
         ManipulaEventos ();
     } catch (Exception ex) {
         Console.WriteLine ("Erro: " + ex.Message);
     }
 }
开发者ID:thiagoabreu,项目名称:XnaGameDevDimap2012,代码行数:11,代码来源:HideSeek.cs


示例15: MonoGamerPeer

 public MonoGamerPeer(NetworkSession session, AvailableNetworkSession availableSession)
 {
   this.session = session;
   this.online = this.session.SessionType == NetworkSessionType.PlayerMatch;
   this.availableSession = availableSession;
   this.MGServerWorker.WorkerSupportsCancellation = true;
   this.MGServerWorker.DoWork += new DoWorkEventHandler(this.MGServer_DoWork);
   this.MGServerWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.MGServer_RunWorkerCompleted);
   this.MGServerWorker.RunWorkerAsync();
   this.HookEvents();
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:11,代码来源:MonoGamerPeer.cs


示例16: Create

		/// <summary>
		/// Creates a new NetworkSessionComponent.
		/// </summary>
		public static void Create (ScreenManager screenManager,
				NetworkSession networkSession)
		{
			Game game = screenManager.Game;

			// Register this network session as a service.
			game.Services.AddService (typeof(NetworkSession), networkSession);

			// Create a NetworkSessionComponent, and add it to the Game.
			game.Components.Add (new NetworkSessionComponent (screenManager,
							networkSession));
		}
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:15,代码来源:NetworkSessionComponent.cs


示例17: NetworkSessionComponent

        /// <summary>
        /// The constructor is private: external callers should use the Create method.
        /// </summary>
        NetworkSessionComponent(ScreenManager screenManager,
                                NetworkSession networkSession)
            : base(screenManager.Game)
        {
            this.screenManager = screenManager;
            this.networkSession = networkSession;

            // Hook up our session event handlers.
            networkSession.GamerJoined += GamerJoined;
            networkSession.GamerLeft += GamerLeft;
            networkSession.SessionEnded += NetworkSessionEnded;
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:15,代码来源:NetworkSessionComponent.cs


示例18: RespawnScreen

        /// <summary>
        /// Constructor.
        /// </summary>
        public RespawnScreen(NetworkSession networkSession)
            : base(Resources.Respawn, true)
        {
            this.networkSession = networkSession;

            // Flag that there is no need for the game to transition
            // off when the pause menu is on top of it.
            IsPopup = true;

            // Add the Resume Game menu entry.
            MenuEntry resumeGameMenuEntry = new MenuEntry(Resources.ResumeGame);
            resumeGameMenuEntry.Selected += OnCancel;
        }
开发者ID:bradleat,项目名称:trafps,代码行数:16,代码来源:RespawnScreen.cs


示例19: CreateSession

 public void CreateSession()
 {
     if (session == null)
     {
         session = NetworkSession.Create(NetworkSessionType.SystemLink, maximumLocalPlayers, maximumGamers);
         session.AllowHostMigration = true;  // Switch hosts if the original goes out
         session.AllowJoinInProgress = true; // Allow players to join a game in progress
         session.GamerJoined += new EventHandler<GamerJoinedEventArgs>(session_GamerJoined);
         session.GamerLeft += new EventHandler<GamerLeftEventArgs>(session_GamerLeft);
         session.GameStarted += new EventHandler<GameStartedEventArgs>(session_GameStarted);
         session.GameEnded += new EventHandler<GameEndedEventArgs>(session_GameEnded);
         session.HostChanged += new EventHandler<HostChangedEventArgs>(session_HostChanged);
     }
 }
开发者ID:hatRiot,项目名称:XNA,代码行数:14,代码来源:NetworkHelper.cs


示例20: CreateGame

 public void CreateGame()
 {
     try
     {
         ShutDown();
         Session = NetworkSession.Create(NetworkSessionType.SystemLink, 1, MaxPlayers);
         Session.AllowHostMigration = true;
         Session.AllowJoinInProgress = true;
         Session.GamerJoined += new EventHandler<GamerJoinedEventArgs>(Session_GamerJoined);
         Session.StartGame();
     }
     catch (Exception e)
     {
         e.ToString();
     }
 }
开发者ID:narfman0,项目名称:ERMotA,代码行数:16,代码来源:Network.cs



注:本文中的Microsoft.Xna.Framework.Net.NetworkSession类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Net.NetworkSessionProperties类代码示例发布时间:2022-05-26
下一篇:
C# Net.NetworkGamer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap