本文整理汇总了C#中Microsoft.Xna.Framework.Net.NetworkGamer类的典型用法代码示例。如果您正苦于以下问题:C# NetworkGamer类的具体用法?C# NetworkGamer怎么用?C# NetworkGamer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkGamer类属于Microsoft.Xna.Framework.Net命名空间,在下文中一共展示了NetworkGamer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EnableSendVoice
public void EnableSendVoice (
NetworkGamer remoteGamer,
bool enable
)
{
throw new NotImplementedException();
}
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:7,代码来源:LocalNetworkGamer.cs
示例2: EnableSendVoice
/*
public void EnableSendVoice (
NetworkGamer remoteGamer,
bool enable)
{
throw new NotImplementedException ();
}
*/
public int ReceiveData (
byte[] data,
int offset,
out NetworkGamer sender)
{
if (data == null)
throw new ArgumentNullException("data");
if (receivedData.Count <= 0) {
sender = null;
return 0;
}
lock (receivedData) {
CommandReceiveData crd;
// we will peek at the value first to see if we can process it
crd = (CommandReceiveData)receivedData.Peek();
if (offset + crd.data.Length > data.Length)
throw new ArgumentOutOfRangeException("data","The length + offset is greater than parameter can hold.");
// no exception thrown yet so let's process it
// take it off the queue
receivedData.Dequeue();
Array.Copy(crd.data, offset, data, 0, data.Length);
sender = crd.gamer;
return data.Length;
}
}
开发者ID:GhostTap,项目名称:MonoGame,代码行数:42,代码来源:LocalNetworkGamer.cs
示例3: ReceiveData
public int ReceiveData (
byte[] data,
out NetworkGamer sender
)
{
throw new NotImplementedException();
}
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:7,代码来源:LocalNetworkGamer.cs
示例4: CommandSendData
public CommandSendData(byte[] data, int offset, int count, SendDataOptions options, NetworkGamer gamer)
{
if (gamer != null)
gamerInternalIndex = gamer.Id;
this.data = new byte[count];
Array.Copy(data, offset, this.data, 0, count);
this.offset = offset;
this.count = count;
this.options = options;
this.gamer = gamer;
}
开发者ID:Clancey,项目名称:MonoGame,代码行数:11,代码来源:CommandSendData.cs
示例5: Player
public Player(Game game, NetworkGamer gamer)
: base(game)
{
Gamer = gamer;
DrawOrder = 100;
Width = Storage.Sprite("DefenseClass").Width;
Height = Storage.Sprite("DefenseClass").Height;
Texture = new Color[(int)(Width * Height)];
Class = Class.None;
_previousPositions = new Queue<Tuple<Vector2, float>>(MaxPreviousPositions);
}
开发者ID:hortont424,项目名称:sand,代码行数:13,代码来源:Player.cs
示例6: ReceiveData
public int ReceiveData(byte[] data, int offset, out NetworkGamer sender)
{
if (data == null)
throw new ArgumentNullException("data");
if (this.receivedData.Count <= 0)
{
sender = (NetworkGamer) null;
return 0;
}
else
{
lock (this.receivedData)
{
CommandReceiveData local_0 = this.receivedData.Peek();
if (offset + local_0.data.Length > data.Length)
throw new ArgumentOutOfRangeException("data", "The length + offset is greater than parameter can hold.");
this.receivedData.Dequeue();
Array.Copy((Array) local_0.data, offset, (Array) data, 0, data.Length);
sender = local_0.gamer;
return data.Length;
}
}
}
开发者ID:Zeludon,项目名称:FEZ,代码行数:23,代码来源:LocalNetworkGamer.cs
示例7: SendData
public void SendData (
byte[] data,
SendDataOptions options,
NetworkGamer recipient)
{
CommandEvent cme = new CommandEvent(new CommandSendData(data, 0, data.Length, options, recipient, this ));
Session.commandQueue.Enqueue(cme);
}
开发者ID:GhostTap,项目名称:MonoGame,代码行数:8,代码来源:LocalNetworkGamer.cs
示例8: ReceiveData
public int ReceiveData (
PacketReader data,
out NetworkGamer sender)
{
lock (receivedData) {
if (receivedData.Count >= 0) {
data.Reset(0);
// take it off the queue
CommandReceiveData crd = (CommandReceiveData)receivedData.Dequeue();
// lets make sure that we can handle the data
if (data.Length < crd.data.Length) {
data.Reset(crd.data.Length);
}
Array.Copy(crd.data, data.Data, data.Length);
sender = crd.gamer;
return data.Length;
}
else {
sender = null;
return 0;
}
}
}
开发者ID:GhostTap,项目名称:MonoGame,代码行数:28,代码来源:LocalNetworkGamer.cs
示例9: UpdateShipData
/// <summary>
/// Update ship state based on the data in the packet.
/// </summary>
/// <param name="sender">The sender of the packet.</param>
private void UpdateShipData(NetworkGamer sender)
{
if (sender != null)
{
PlayerData playerData = sender.Tag as PlayerData;
//if ((playerData != null) && (playerData.Ship != null))
//{
// playerData.Ship.Position = packetReader.ReadVector2();
// playerData.Ship.Velocity = packetReader.ReadVector2();
// playerData.Ship.Rotation = packetReader.ReadSingle();
// playerData.Ship.Life = packetReader.ReadSingle();
// playerData.Ship.Shield = packetReader.ReadSingle();
// playerData.Ship.Score = packetReader.ReadInt32();
//}
}
}
开发者ID:robotButler,项目名称:battlelines,代码行数:20,代码来源:World.cs
示例10: HostChangedEventArgs
public HostChangedEventArgs(NetworkGamer aNewHost, NetworkGamer aOldHost)
{
this.newHost = aNewHost;
this.oldHost = aOldHost;
}
开发者ID:Zeludon,项目名称:FEZ,代码行数:5,代码来源:HostChangedEventArgs.cs
示例11: ConnectNetworkGamer
internal void ConnectNetworkGamer(NetworkGamer gamer)
{
if (LocalNetworkGamer == null && IsNetworkGamer(gamer))
{
LocalNetworkGamer = gamer as LocalNetworkGamer;
LocalNetworkGamer.Tag = this;
Flags = Calc.BitSet(0, (int)GamerFlags.Lobby);
flagsIsDirty = true;
#if DEBUG
Log.Trace(String.Format("{0} connected to the session", GamerTag), 2.0f);
#endif
}
}
开发者ID:BeauPrime,项目名称:Networking,代码行数:14,代码来源:LocalGamer.cs
示例12: SendData
public void SendData (
PacketWriter data,
SendDataOptions options,
NetworkGamer recipient
)
{
throw new NotImplementedException();
}
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:8,代码来源:LocalNetworkGamer.cs
示例13: clientWritePackets
/// <summary>
/// Write requests to the host.
/// </summary>
/// <param name="gamers">Clients</param>
/// <param name="host">Host</param>
public void clientWritePackets(GamerCollection<LocalNetworkGamer> gamers, NetworkGamer host)
{
Command cmd;
foreach (LocalNetworkGamer gamer in gamers)
{
// TODO: Reimpliment.
if(_writer.Length > 0)
gamer.SendData(_writer, SendDataOptions.ReliableInOrder, host);
}
}
开发者ID:rdgoetz,项目名称:LessThanOk,代码行数:15,代码来源:NetworkManager.cs
示例14: KillShip
/// <summary>
/// Kill the sender's ship based on data in the packet.
/// </summary>
/// <param name="sender">The sender of the packet.</param>
private void KillShip(NetworkGamer sender)
{
if (sender != null)
{
PlayerData playerData = sender.Tag as PlayerData;
if ((playerData != null))
{
//GameplayObject source = null;
//// read the index of the source of the last damage taken
//int sourcePlayerIndex = packetReader.ReadInt32();
//if ((sourcePlayerIndex >= 0) &&
// (sourcePlayerIndex < networkSession.AllGamers.Count))
//{
// PlayerData sourcePlayerData =
// networkSession.AllGamers[sourcePlayerIndex].Tag
// as PlayerData;
// source = sourcePlayerData != null ? sourcePlayerData.Ship :
// null;
//}
//// kill the ship
//playerData.Ship.Die(source, false);
}
}
}
开发者ID:robotButler,项目名称:battlelines,代码行数:28,代码来源:World.cs
示例15: DrawPlayerData
/// <summary>
/// Draw the specified player's data in the screen - gamertag, etc.
/// </summary>
/// <param name="totalTime">The total time spent in the game.</param>
/// <param name="networkGamer">The player to be drawn.</param>
/// <param name="position">The center of the desired location.</param>
/// <param name="spriteBatch">The SpriteBatch object used to draw.</param>
/// <param name="lobby">If true, drawn "lobby style"</param>
public void DrawPlayerData(float totalTime, NetworkGamer networkGamer,
Vector2 position, SpriteBatch spriteBatch, bool lobby)
{
// safety-check the parameters, as they must be valid
if (networkGamer == null)
{
throw new ArgumentNullException("networkGamer");
}
if (spriteBatch == null)
{
throw new ArgumentNullException("spriteBatch");
}
// get the player data
PlayerData playerData = networkGamer.Tag as PlayerData;
if (playerData == null)
{
return;
}
// draw the gamertag
float playerStringScale = 1.0f;
if (networkGamer.IsLocal)
{
// pulse the scale of local gamers
playerStringScale = 1f + 0.08f * (1f + (float)Math.Sin(totalTime * 4f));
}
string playerString = networkGamer.Gamertag;
//TODO divide colors
Color playerColor = Color.Green;
Vector2 playerStringSize = playerFont.MeasureString(playerString);
Vector2 playerStringPosition = position;
spriteBatch.DrawString(playerFont, playerString, playerStringPosition,
playerColor, 0f,
new Vector2(playerStringSize.X / 2f, playerStringSize.Y / 2f),
playerStringScale, SpriteEffects.None, 0f);
// draw the chat texture
Texture2D chatTexture = null;
if (networkGamer.IsMutedByLocalUser)
{
chatTexture = chatMuteTexture;
}
else if (networkGamer.IsTalking)
{
chatTexture = chatTalkingTexture;
}
else if (networkGamer.HasVoice)
{
chatTexture = chatAbleTexture;
}
if (chatTexture != null)
{
float chatTextureScale = 0.9f * playerStringSize.Y /
(float)chatTexture.Height;
Vector2 chatTexturePosition = new Vector2(playerStringPosition.X -
1.2f * playerStringSize.X / 2f -
1.1f * chatTextureScale * (float)chatTexture.Width / 2f,
playerStringPosition.Y);
spriteBatch.Draw(chatTexture, chatTexturePosition, null,
Color.White, 0f, new Vector2((float)chatTexture.Width / 2f,
(float)chatTexture.Height / 2f), chatTextureScale,
SpriteEffects.None, 0f);
}
// if we're in "lobby mode", draw a sample version of the ship,
// and the ready texture
if (lobby)
{
// draw the ship
// draw the ready texture
if ((readyTexture != null) && networkGamer.IsReady)
{
float readyTextureScale = 0.9f * playerStringSize.Y /
(float)readyTexture.Height;
Vector2 readyTexturePosition = new Vector2(playerStringPosition.X +
1.2f * playerStringSize.X / 2f +
2.2f +
1.1f * readyTextureScale * (float)readyTexture.Width / 2f,
playerStringPosition.Y);
spriteBatch.Draw(readyTexture, readyTexturePosition, null,
Color.White, 0f, new Vector2((float)readyTexture.Width / 2f,
(float)readyTexture.Height / 2f), readyTextureScale,
SpriteEffects.None, 0f);
}
}
else
{
}
//.........这里部分代码省略.........
开发者ID:robotButler,项目名称:battlelines,代码行数:101,代码来源:World.cs
示例16: SendGamerStateChange
internal void SendGamerStateChange (NetworkGamer gamer)
{
#if !WINDOWS_PHONE
Game.Instance.Log("SendGamerStateChange " + gamer.RemoteUniqueIdentifier);
#endif
NetOutgoingMessage om = peer.CreateMessage ();
om.Write ((byte)NetworkMessageType.GamerStateChange);
om.Write ((int)gamer.State);
SendMessage (om, SendDataOptions.Reliable, gamer);
}
开发者ID:ValXp,项目名称:MonoGame,代码行数:11,代码来源:MonoGamerPeer.cs
示例17: GetGamerFromNetworkGamer
internal static Gamer GetGamerFromNetworkGamer(NetworkGamer gamer)
{
foreach( LocalGamer local in SignedInGamers )
{
if (local.IsNetworkGamer(gamer))
{
local.ConnectNetworkGamer(gamer);
return local;
}
}
return new RemoteGamer(gamer);
}
开发者ID:BeauPrime,项目名称:Networking,代码行数:12,代码来源:Network.cs
示例18: SendMessage
private void SendMessage (NetworkMessageType messageType, byte[] data, SendDataOptions options, NetworkGamer gamer)
{
NetOutgoingMessage om = peer.CreateMessage ();
om.Write ((byte)messageType);
om.Write (data);
SendMessage (om, options, gamer);
}
开发者ID:ValXp,项目名称:MonoGame,代码行数:11,代码来源:MonoGamerPeer.cs
示例19: IsNetworkGamer
internal bool IsNetworkGamer(NetworkGamer gamer)
{
LocalNetworkGamer local = gamer as LocalNetworkGamer;
return LocalNetworkGamer == null && local != null && local.SignedInGamer == SignedInGamer;
}
开发者ID:BeauPrime,项目名称:Networking,代码行数:5,代码来源:LocalGamer.cs
示例20: UpdatePlayerData
/// <summary>
/// Update the player data for the sender based on the data in the packet.
/// </summary>
/// <param name="sender">The sender of the packet.</param>
private void UpdatePlayerData(NetworkGamer sender)
{
if ((networkSession != null) && (networkSession.LocalGamers.Count > 0) &&
(sender != null))
{
PlayerData playerData = sender.Tag as PlayerData;
if (playerData != null)
{
playerData.Deserialize(packetReader);
// see if we're still unique
// -- this can happen legitimately as we receive introductory data
//foreach (LocalNetworkGamer localNetworkGamer in
// networkSession.LocalGamers)
//{
// PlayerData localPlayerData =
// localNetworkGamer.Tag as PlayerData;
// if ((localPlayerData != null) &&
// !Ship.HasUniqueColorIndex(localNetworkGamer,
// networkSession))
// {
// localPlayerData.ShipColor = Ship.GetNextUniqueColorIndex(
// localPlayerData.ShipColor, networkSession);
// packetWriter.Write((int)World.PacketTypes.PlayerData);
// localPlayerData.Serialize(packetWriter);
// networkSession.LocalGamers[0].SendData(packetWriter,
// SendDataOptions.ReliableInOrder);
// }
//}
}
}
}
开发者ID:robotButler,项目名称:battlelines,代码行数:35,代码来源:World.cs
注:本文中的Microsoft.Xna.Framework.Net.NetworkGamer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论