本文整理汇总了C#中YGOCore.Game.GameServerPacket.Write方法的典型用法代码示例。如果您正苦于以下问题:C# GameServerPacket.Write方法的具体用法?C# GameServerPacket.Write怎么用?C# GameServerPacket.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YGOCore.Game.GameServerPacket
的用法示例。
在下文中一共展示了GameServerPacket.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendTypeChange
public void SendTypeChange()
{
if(Game==null)return;
GameServerPacket packet = new GameServerPacket(StocMessage.TypeChange);
packet.Write((byte)(Type + (Game.HostPlayer.Equals(this) ? (int)PlayerType.Host : 0)));
Send(packet);
}
示例2: EndDuel
public void EndDuel(bool force)
{
if (State == GameState.Duel)
{
if (!Replay.Disabled)
{
Replay.End();
byte[] replayData = Replay.GetFile();
GameServerPacket packet = new GameServerPacket(StocMessage.Replay);
packet.Write(replayData);
SendToPlayers(packet);
//SendToAll(packet);
}
State = GameState.End;
m_duel.End();
DuleTimer.Stop();
}
if (m_swapped)
{
m_swapped = false;
GameSession temp = Players[0];
Players[0] = Players[1];
Players[1] = temp;
Players[0].Type = 0;
Players[1].Type = 1;
}
if (IsMatch && !force && !MatchIsEnd())
{
IsReady[0] = false;
IsReady[1] = false;
ServerMessage(Messages.MSG_SIDE);
State = GameState.Side;
GameTimer.StartSideTimer();
// Server.OnPlayEvent(PlayerStatu.PlayerSide, Players);
using (GameServerPacket p = new GameServerPacket(StocMessage.ChangeSide))
{
SendToPlayers(p);
}
using (GameServerPacket p = new GameServerPacket(StocMessage.WaitingSide))
{
SendToObservers(p);
}
}
else {
if (State == GameState.Side)
{
//Logger.WriteLine("side is lose");
State = GameState.End;
GameSession pl = null;
try
{
if (Players[0] != null)
{
pl = (Players[0].IsConnected) ? Players[1] : Players[0];
}
}
catch { }
if (pl != null)
{
// && pl.Type != (int)PlayerType.Observer
Surrender(pl, 4, true);
}
}
End();
}
}
示例3: ServerMessage
private void ServerMessage(string msg)
{
string finalmsg = "[Server] " + msg;
GameServerPacket packet = new GameServerPacket(StocMessage.Chat);
packet.Write((short)PlayerType.Yellow);
packet.Write(finalmsg, finalmsg.Length + 1);
Send(packet);
}
示例4: LobbyError
private void LobbyError(string message)
{
GameServerPacket join = new GameServerPacket(StocMessage.JoinGame);
join.Write(0U);
join.Write((byte)0);
join.Write((byte)0);
join.Write(0);
join.Write(0);
join.Write(0);
// C++ padding: 5 bytes + 3 bytes = 8 bytes
for (int i = 0; i < 3; i++)
join.Write((byte)0);
join.Write(0);
join.Write((byte)0);
join.Write((byte)0);
join.Write((short)0);
Send(join);
GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter);
enter.Write("[" + message + "]", 20);
enter.Write((byte)0);
Send(enter);
}
示例5: SendToAll
private void SendToAll(CoreMessage msg)
{
byte[] buffer = msg.CreateBuffer();
using(GameServerPacket packet = new GameServerPacket(msg.Message)){
packet.Write(buffer);
Game.SendToAll(packet);
}
}
示例6: OnDraw
private void OnDraw(CoreMessage msg)
{
using(GameServerPacket packet = new GameServerPacket(msg.Message)){
int player = msg.Reader.ReadByte();
int count = msg.Reader.ReadByte();
packet.Write((byte)player);
packet.Write((byte)count);
for (int i = 0; i < count; i++)
{
uint code = msg.Reader.ReadUInt32();
if ((code & 0x80000000) != 0)
packet.Write(code);
else
packet.Write(0);
}
SendToPlayer(msg, player);
Game.SendToAllBut(packet, player);
}
}
示例7: OnMove
private void OnMove(CoreMessage msg)
{
byte[] raw = msg.Reader.ReadBytes(16);
int pc = raw[4];
int pl = raw[5];
int cc = raw[8];
int cl = raw[9];
int cs = raw[10];
int cp = raw[11];
SendToPlayer(msg, cc);
using(GameServerPacket packet = new GameServerPacket(msg.Message)){
packet.Write(raw);
if (!Convert.ToBoolean((cl & ((int)CardLocation.Grave + (int)CardLocation.Overlay))) && Convert.ToBoolean((cl & ((int)CardLocation.Deck + (int)CardLocation.Hand)))
|| Convert.ToBoolean((cp & (int)CardPosition.FaceDown)))
{
packet.SetPosition(2);
packet.Write((int)0);
}
Game.SendToAllBut(packet, cc);
}
if (cl != 0 && (cl & 0x80) == 0 && (cl != pl || pc != cc))
Game.RefreshSingle(cc, cl, cs);
}
示例8: OnConfirmCards
private void OnConfirmCards(CoreMessage msg)
{
int player = msg.Reader.ReadByte();
int count = msg.Reader.ReadByte();
msg.Reader.ReadBytes(count * 7);
byte[] buffer = msg.CreateBuffer();
using(GameServerPacket packet = new GameServerPacket(msg.Message)){
packet.Write(buffer);
if ((CardLocation)buffer[7] == CardLocation.Hand)
Game.SendToAll(packet);
else
Game.CurPlayers[player].Send(packet);
}
}
示例9: WaitForResponse
public void WaitForResponse(int player)
{
m_lastresponse = player;
CurPlayers[player].State = PlayerState.Response;
using (GameServerPacket wait = new GameServerPacket(GameMessage.Waiting))
{
SendToAllBut(wait, player);
}
TimeStart();
using (GameServerPacket packet = new GameServerPacket(StocMessage.TimeLimit))
{
packet.Write((byte)player);
packet.Write((byte)0); // C++ padding
packet.Write((short)m_timelimit[player]);
SendToPlayers(packet);
}
}
示例10: SendJoinGame
private void SendJoinGame(GameSession player)
{
using (GameServerPacket join = new GameServerPacket(StocMessage.JoinGame))
{
join.Write(Banlist == null ? 0U : Banlist.Hash);
join.Write((byte)Config.Rule);
join.Write((byte)Config.Mode);
join.Write(Config.EnablePriority);
join.Write(Config.NoCheckDeck);
join.Write(Config.NoShuffleDeck);
// C++ padding: 5 bytes + 3 bytes = 8 bytes
for (int i = 0; i < 3; i++)
join.Write((byte)0);
join.Write(Config.StartLp);
join.Write((byte)Config.StartHand);
join.Write((byte)Config.DrawCount);
join.Write((short)Config.GameTimer);
player.Send(join);
}
if (State != GameState.Lobby)
SendDuelingPlayers(player);
}
示例11: RefreshSingle
public void RefreshSingle(int player, int location, int sequence, int flag = 0x781fff)
{
byte[] result = m_duel.QueryCard(player, location, sequence, flag);
if (location == (int)CardLocation.Removed && (result[15] & (int)CardPosition.FaceDown) != 0)
return;
using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateCard))
{
update.Write((byte)player);
update.Write((byte)location);
update.Write((byte)sequence);
update.Write(result);
CurPlayers[player].Send(update);
if (IsTag)
{
if ((location & (int)CardLocation.Onfield) != 0)
{
SendToTeam(update, player);
if ((result[15] & (int)CardPosition.FaceUp) != 0)
SendToTeam(update, 1 - player);
}
else
{
CurPlayers[player].Send(update);
if ((location & 0x90) != 0)
SendToAllBut(update, player);
}
}
else
{
if ((location & 0x90) != 0 || ((location & 0x2c) != 0 && (result[15] & (int)CardPosition.FaceUp) != 0))
SendToAllBut(update, player);
}
}
}
示例12: RefreshExtra
public void RefreshExtra(int player, int flag = 0x81fff, bool useCache = true)
{
byte[] result = m_duel.QueryFieldCard(player, CardLocation.Extra, flag, useCache);
using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData))
{
update.Write((byte)player);
update.Write((byte)CardLocation.Extra);
update.Write(result);
CurPlayers[player].Send(update);
}
}
示例13: RefreshGrave
public void RefreshGrave(int player, int flag = 0x81fff, bool useCache = true)
{
byte[] result = m_duel.QueryFieldCard(player, CardLocation.Grave, flag, useCache);
using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData))
{
update.Write((byte)player);
update.Write((byte)CardLocation.Grave);
update.Write(result);
SendToAll(update);
}
}
示例14: RefreshHand
public void RefreshHand(int player, int flag = 0x181fff, bool useCache = true)
{
byte[] result = m_duel.QueryFieldCard(player, CardLocation.Hand, flag | 0x100000, useCache);
using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData))
{
update.Write((byte)player);
update.Write((byte)CardLocation.Hand);
update.Write(result);
CurPlayers[player].Send(update);
}
using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData))
{
update.Write((byte)player);
update.Write((byte)CardLocation.Hand);
using (MemoryStream ms = new MemoryStream(result))
{
BinaryReader reader = new BinaryReader(ms);
BinaryWriter writer = new BinaryWriter(ms);
while (ms.Position < ms.Length)
{
int len = reader.ReadInt32();
if (len == 4)
{
//update.Write(4);
continue;
}
long pos = ms.Position;
byte[] raw = reader.ReadBytes(len - 4);
if (raw[len - 8] == 0)
{
ms.Position = pos;
writer.Write(new byte[len - 4]);
}
}
writer.Close();
reader.Close();
}
update.Write(result);
SendToAllBut(update, player);
}
}
示例15: RefreshSpells
public void RefreshSpells(int player, int flag = 0x681fff, bool useCache = true)
{
byte[] result = m_duel.QueryFieldCard(player, CardLocation.SpellZone, flag, useCache);
using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData))
{
update.Write((byte)player);
update.Write((byte)CardLocation.SpellZone);
update.Write(result);
SendToTeam(update, player);
}
using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData))
{
update.Write((byte)player);
update.Write((byte)CardLocation.SpellZone);
using (MemoryStream ms = new MemoryStream(result))
{
BinaryReader reader = new BinaryReader(ms);
BinaryWriter writer = new BinaryWriter(ms);
for (int i = 0; i < 8; i++)
{
int len = reader.ReadInt32();
if (len == 4)
{
// update.Write(4);
continue;
}
long pos = ms.Position;
byte[] raw = reader.ReadBytes(len - 4);
if ((raw[11] & (int)CardPosition.FaceDown) != 0)
{
ms.Position = pos;
writer.Write(new byte[len - 4]);
}
}
reader.Close();
writer.Close();
}
update.Write(result);
SendToTeam(update, 1 - player);
SendToObservers(update);
}
}