本文整理汇总了C#中Microsoft.Xna.Framework.Net.NetworkGamer类的典型用法代码示例。如果您正苦于以下问题:C# NetworkGamer类的具体用法?C# NetworkGamer怎么用?C# NetworkGamer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkGamer类属于Microsoft.Xna.Framework.Net命名空间,在下文中一共展示了NetworkGamer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnableSendVoice
public void EnableSendVoice (
NetworkGamer remoteGamer,
bool enable
)
{
throw new NotImplementedException();
}
示例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;
}
}
示例3: ReceiveData
public int ReceiveData (
byte[] data,
out NetworkGamer sender
)
{
throw new NotImplementedException();
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例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;
}
}
}
示例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();
//}
}
}
示例10: HostChangedEventArgs
public HostChangedEventArgs(NetworkGamer aNewHost, NetworkGamer aOldHost)
{
this.newHost = aNewHost;
this.oldHost = aOldHost;
}
示例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
}
}
示例12: SendData
public void SendData (
PacketWriter data,
SendDataOptions options,
NetworkGamer recipient
)
{
throw new NotImplementedException();
}
示例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);
}
}
示例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);
}
}
}
示例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
{
}
//.........这里部分代码省略.........