当前位置: 首页>>代码示例>>C#>>正文


C# GameServerPacket.Write方法代码示例

本文整理汇总了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);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:Player.cs

示例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();
            }
        }
开发者ID:247321453,项目名称:YgoServer,代码行数:69,代码来源:GameRoom.cs

示例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);
 }
开发者ID:InvisibleMoon,项目名称:YGOCore,代码行数:8,代码来源:Player.cs

示例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);
        }
开发者ID:InvisibleMoon,项目名称:YGOCore,代码行数:23,代码来源:Player.cs

示例5: SendToAll

		private void SendToAll(CoreMessage msg)
		{
			byte[] buffer = msg.CreateBuffer();
			using(GameServerPacket packet = new GameServerPacket(msg.Message)){
				packet.Write(buffer);
				Game.SendToAll(packet);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:8,代码来源:GameAnalyser.cs

示例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);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:21,代码来源:GameAnalyser.cs

示例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);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:24,代码来源:GameAnalyser.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);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:15,代码来源:GameAnalyser.cs

示例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);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:17,代码来源:GameRoom.cs

示例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);
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:22,代码来源:GameRoom.cs

示例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);
                }
            }
        }
开发者ID:247321453,项目名称:YgoServer,代码行数:37,代码来源:GameRoom.cs

示例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);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:GameRoom.cs

示例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);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:GameRoom.cs

示例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);
            }
        }
开发者ID:247321453,项目名称:YgoServer,代码行数:43,代码来源:GameRoom.cs

示例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);
            }
        }
开发者ID:247321453,项目名称:YgoServer,代码行数:44,代码来源:GameRoom.cs


注:本文中的YGOCore.Game.GameServerPacket.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。