本文整理汇总了C#中YGOCore.Game.GameServerPacket类的典型用法代码示例。如果您正苦于以下问题:C# GameServerPacket类的具体用法?C# GameServerPacket怎么用?C# GameServerPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameServerPacket类属于YGOCore.Game命名空间,在下文中一共展示了GameServerPacket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:Player.cs
示例2: TpResult
//.........这里部分代码省略.........
m_duel.SetAnalyzer(m_analyser.Analyse);
m_duel.SetErrorHandler(HandleError);
m_duel.InitPlayers(Config.StartLp, Config.StartHand, Config.DrawCount);
int opt = 0;
if (Config.EnablePriority)
opt += 0x08;
if (Config.NoShuffleDeck)
opt += 0x10;
if (IsTag)
opt += 0x20;
Replay = new Replay((uint)seed, IsTag);
Replay.Writer.WriteUnicode(Players[0].Name, 20);
Replay.Writer.WriteUnicode(Players[1].Name, 20);
if (IsTag)
{
Replay.Writer.WriteUnicode(Players[2].Name, 20);
Replay.Writer.WriteUnicode(Players[3].Name, 20);
}
Replay.Writer.Write(Config.StartLp);
Replay.Writer.Write(Config.StartHand);
Replay.Writer.Write(Config.DrawCount);
Replay.Writer.Write(opt);
for (int i = 0; i < Players.Length; i++)
{
Player dplayer = Players[i == 2 ? 3 : (i == 3 ? 2 : i)];
int pid = i;
if (IsTag)
pid = i >= 2 ? 1 : 0;
if (!Config.NoShuffleDeck)
{
IList<int> cards = ShuffleCards(rand, dplayer.Deck.Main);
Replay.Writer.Write(cards.Count);
foreach (int id in cards)
{
if (IsTag && (i == 1 || i == 3))
m_duel.AddTagCard(id, pid, CardLocation.Deck);
else
m_duel.AddCard(id, pid, CardLocation.Deck);
Replay.Writer.Write(id);
}
}
else
{
Replay.Writer.Write(dplayer.Deck.Main.Count);
for (int j = dplayer.Deck.Main.Count - 1; j >= 0; j--)
{
int id = dplayer.Deck.Main[j];
if (IsTag && (i == 1 || i == 3))
m_duel.AddTagCard(id, pid, CardLocation.Deck);
else
m_duel.AddCard(id, pid, CardLocation.Deck);
Replay.Writer.Write(id);
}
}
Replay.Writer.Write(dplayer.Deck.Extra.Count);
foreach (int id in dplayer.Deck.Extra)
{
if (IsTag && (i == 1 || i == 3))
m_duel.AddTagCard(id, pid, CardLocation.Extra);
else
m_duel.AddCard(id, pid, CardLocation.Extra);
Replay.Writer.Write(id);
}
}
GameServerPacket packet = new GameServerPacket(GameMessage.Start);
packet.Write((byte)0);
packet.Write(Config.StartLp);
packet.Write(Config.StartLp);
packet.Write((short)m_duel.QueryFieldCount(0, CardLocation.Deck));
packet.Write((short)m_duel.QueryFieldCount(0, CardLocation.Extra));
packet.Write((short)m_duel.QueryFieldCount(1, CardLocation.Deck));
packet.Write((short)m_duel.QueryFieldCount(1, CardLocation.Extra));
SendToTeam(packet, 0);
packet.SetPosition(2);
packet.Write((byte)1);
SendToTeam(packet, 1);
packet.SetPosition(2);
if (m_swapped)
packet.Write((byte)0x11);
else
packet.Write((byte)0x10);
SendToObservers(packet);
RefreshExtra(0);
RefreshExtra(1);
m_duel.Start(opt);
TurnCount = 0;
LifePoints[0] = Config.StartLp;
LifePoints[1] = Config.StartLp;
Process();
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:101,代码来源:Game.cs
示例3: SendMessage
public static List<string> SendMessage(GameServerPacket msg, string name=null){
List<string> playernames=new List<string>();
GameRoom[] rooms;
//MutexRooms.WaitOne();
rooms = new GameRoom[m_rooms.Count];
m_rooms.Values.CopyTo(rooms, 0);
//MutexRooms.ReleaseMutex();
foreach (GameRoom room in rooms)
{
if (room.IsOpen){
try{
if(string.IsNullOrEmpty(name)){
playernames.AddRange(room.Game.SendToAll(msg).ToArray());
}else{
foreach(Player pl in room.Game.Players){
if(pl!=null && pl.Name==name){
playernames.Add(pl.Name);
pl.Send(msg);
}
}
foreach(Player pl in room.Game.Observers){
if(pl!=null && pl.Name==name){
playernames.Add(pl.Name);
pl.Send(msg);
}
}
}
}catch(Exception){
}
}
}
return playernames;
}
开发者ID:247321453,项目名称:YgoServer,代码行数:34,代码来源:GameManager.cs
示例4: OnUpdateDeck
private void OnUpdateDeck(GameClientPacket packet)
{
if (Type == (int)PlayerType.Observer)
return;
Deck deck = new Deck();
int main = packet.ReadInt32();
int side = packet.ReadInt32();
for (int i = 0; i < main; i++)
deck.AddMain(packet.ReadInt32());
for (int i = 0; i < side; i++)
deck.AddSide(packet.ReadInt32());
if (Game.State == GameState.Lobby)
{
Deck = deck;
Game.IsReady[Type] = false;
}
else if (Game.State == GameState.Side)
{
if (Game.IsReady[Type])
return;
if (!Deck.Check(deck))
{
GameServerPacket error = new GameServerPacket(StocMessage.ErrorMsg);
error.Write((byte)3);
error.Write(0);
Send(error);
return;
}
Deck = deck;
Game.IsReady[Type] = true;
Game.ServerMessage(Name + " is ready.");
Send(new GameServerPacket(StocMessage.DuelStart));
Game.MatchSide();
}
}
开发者ID:InvisibleMoon,项目名称:YGOCore,代码行数:35,代码来源:Player.cs
示例5: Send
public void Send(GameServerPacket packet)
{
m_client.Send(packet.GetContent());
}
开发者ID:InvisibleMoon,项目名称:YGOCore,代码行数:4,代码来源:Player.cs
示例6: SendToAll
private void SendToAll(CoreMessage msg)
{
byte[] buffer = msg.CreateBuffer();
GameServerPacket packet = new GameServerPacket(msg.Message);
packet.Write(buffer);
Game.SendToAll(packet);
}
开发者ID:mx41shy,项目名称:YGOCore,代码行数:7,代码来源:GameAnalyser.cs
示例7: OnDraw
private void OnDraw(CoreMessage msg)
{
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);
}
开发者ID:mx41shy,项目名称:YGOCore,代码行数:20,代码来源:GameAnalyser.cs
示例8: 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);
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(0);
}
Game.SendToAllBut(packet, cc);
if (cl != 0 && (cl & 0x80) == 0 && (cl != pl || pc != cc))
Game.RefreshSingle(cc, cl, cs);
}
开发者ID:mx41shy,项目名称:YGOCore,代码行数:24,代码来源:GameAnalyser.cs
示例9: WaitForResponse
public void WaitForResponse(int player)
{
m_lastresponse = player;
CurPlayers[player].State = PlayerState.Response;
SendToAllBut(new GameServerPacket(GameMessage.Waiting), player);
TimeStart();
GameServerPacket packet = new GameServerPacket(StocMessage.TimeLimit);
packet.Write((byte)player);
packet.Write((byte)0); // C++ padding
packet.Write((short)m_timelimit[player]);
SendToPlayers(packet);
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:12,代码来源:Game.cs
示例10: 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;
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);
}
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:35,代码来源:Game.cs
示例11: RefreshExtra
public void RefreshExtra(int player, int flag = 0x81fff, bool useCache = true)
{
byte[] result = m_duel.QueryFieldCard(player, CardLocation.Extra, flag, useCache);
GameServerPacket update = new GameServerPacket(GameMessage.UpdateData);
update.Write((byte)player);
update.Write((byte)CardLocation.Extra);
update.Write(result);
CurPlayers[player].Send(update);
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:9,代码来源:Game.cs
示例12: RefreshGrave
public void RefreshGrave(int player, int flag = 0x81fff, bool useCache = true)
{
byte[] result = m_duel.QueryFieldCard(player, CardLocation.Grave, flag, useCache);
GameServerPacket update = new GameServerPacket(GameMessage.UpdateData);
update.Write((byte)player);
update.Write((byte)CardLocation.Grave);
update.Write(result);
SendToAll(update);
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:9,代码来源:Game.cs
示例13: RefreshHand
public void RefreshHand(int player, int flag = 0x181fff, bool useCache = true)
{
byte[] result = m_duel.QueryFieldCard(player, CardLocation.Hand, flag | 0x100000, useCache);
GameServerPacket update = new GameServerPacket(GameMessage.UpdateData);
update.Write((byte)player);
update.Write((byte)CardLocation.Hand);
update.Write(result);
CurPlayers[player].Send(update);
update = new GameServerPacket(GameMessage.UpdateData);
update.Write((byte)player);
update.Write((byte)CardLocation.Hand);
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)
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]);
}
}
update.Write(result);
SendToAllBut(update, player);
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:33,代码来源:Game.cs
示例14: RefreshSpells
public void RefreshSpells(int player, int flag = 0x681fff, bool useCache = true)
{
byte[] result = m_duel.QueryFieldCard(player, CardLocation.SpellZone, flag, useCache);
GameServerPacket update = new GameServerPacket(GameMessage.UpdateData);
update.Write((byte)player);
update.Write((byte)CardLocation.SpellZone);
update.Write(result);
SendToTeam(update, player);
update = new GameServerPacket(GameMessage.UpdateData);
update.Write((byte)player);
update.Write((byte)CardLocation.SpellZone);
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)
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]);
}
}
update.Write(result);
SendToTeam(update, 1 - player);
SendToObservers(update);
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:34,代码来源:Game.cs
示例15: Surrender
public void Surrender(Player player, int reason, bool force = false)
{
if (!force)
if (State != GameState.Duel)
return;
if (player.Type == (int)PlayerType.Observer)
return;
GameServerPacket win = new GameServerPacket(GameMessage.Win);
// if (Program.Config.STDOUT == true)
// Console.WriteLine("Surrender - {0}", player.Name); //Need API
int team = player.Type;
if (IsTag)
team = player.Type >= 2 ? 1 : 0;
win.Write((byte)(1 - team));
win.Write((byte)reason);
SendToAll(win);
MatchSaveResult(1 - team);
RecordWin(1 - team, reason, force);
EndDuel(reason == 4);
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:24,代码来源:Game.cs
示例16: 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();
GameServerPacket packet = new GameServerPacket(msg.Message);
packet.Write(buffer);
if ((CardLocation)buffer[7] == CardLocation.Hand)
Game.SendToAll(packet);
else
Game.CurPlayers[player].Send(packet);
}
开发者ID:mx41shy,项目名称:YGOCore,代码行数:14,代码来源:GameAnalyser.cs
示例17: OnShuffleHand
private void OnShuffleHand(CoreMessage msg)
{
GameServerPacket packet = new GameServerPacket(msg.Message);
int player = msg.Reader.ReadByte();
int count = msg.Reader.ReadByte();
packet.Write((byte)player);
packet.Write((byte)count);
msg.Reader.ReadBytes(count * 4);
for (int i = 0; i < count; i++)
packet.Write(0);
SendToPlayer(msg, player);
Game.SendToAllBut(packet, player);
Game.RefreshHand(player, 0x181fff, false);
}
开发者ID:mx41shy,项目名称:YGOCore,代码行数:16,代码来源:GameAnalyser.cs
示例18: SendToAll
public void SendToAll(GameServerPacket packet)
{
SendToPlayers(packet);
SendToObservers(packet);
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:5,代码来源:Game.cs
示例19: OnSet
private void OnSet(CoreMessage msg)
{
msg.Reader.ReadBytes(4);
byte[] raw = msg.Reader.ReadBytes(4);
GameServerPacket packet = new GameServerPacket(GameMessage.Set);
packet.Write(0);
packet.Write(raw);
Game.SendToAll(packet);
}
开发者ID:mx41shy,项目名称:YGOCore,代码行数:9,代码来源:GameAnalyser.cs
示例20: 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);
SendToAll(packet);
}
State = GameState.End;
m_duel.End();
}
if (m_swapped)
{
m_swapped = false;
Player 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("You have 120 seconds to side!");
SideTimer = DateTime.UtcNow;
State = GameState.Side;
SendToPlayers(new GameServerPacket(StocMessage.ChangeSide));
SendToObservers(new GameServerPacket(StocMessage.WaitingSide));
}
else
End();
}
开发者ID:A2152225,项目名称:YGOCore,代码行数:40,代码来源:Game.cs
注:本文中的YGOCore.Game.GameServerPacket类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论