本文整理汇总了C#中Microsoft.Xna.Framework.Net.NetworkSession类的典型用法代码示例。如果您正苦于以下问题:C# NetworkSession类的具体用法?C# NetworkSession怎么用?C# NetworkSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkSession类属于Microsoft.Xna.Framework.Net命名空间,在下文中一共展示了NetworkSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
}
示例2: ParticleManager
public ParticleManager(GameManager gameManager, Game game, Camera camera, NetworkSession networkSession)
{
this.game = game;
this.camera = camera;
this.networkSession = networkSession;
this.gameManager = gameManager;
}
示例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();
}
示例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;
}
示例5: CreateSession
private void CreateSession()
{
netSession = NetworkSession.Create(NetworkSessionType.SystemLink, maxNumPlayers, maxNumPlayers);
isHost = true;
isNetworked = true;
Game1.state = gameState.game;
}
示例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);
}
示例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);
}
示例8: MultiplayerManager
public MultiplayerManager(Game game, Camera camera, GameManager gameManager, NetworkSession networkSession)
{
_game = game;
_camera = camera;
_gameManager = gameManager;
_networkSession = networkSession;
}
示例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
}
示例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);
}
}
示例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;
}
示例12: LobbyScreen
public LobbyScreen(NetworkSession networkSession)
{
_networkSession = networkSession;
TransitionOnTime = TimeSpan.FromSeconds(0.5);
TransitionOffTime = TimeSpan.FromSeconds(0.5);
_packetReader = new PacketReader();
_packetWriter = new PacketWriter();
}
示例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());
}
示例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);
}
}
示例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();
}