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


C# GameServerPacket.WriteUnicode方法代码示例

本文整理汇总了C#中YGOCore.Game.GameServerPacket.WriteUnicode方法的典型用法代码示例。如果您正苦于以下问题:C# GameServerPacket.WriteUnicode方法的具体用法?C# GameServerPacket.WriteUnicode怎么用?C# GameServerPacket.WriteUnicode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YGOCore.Game.GameServerPacket的用法示例。


在下文中一共展示了GameServerPacket.WriteUnicode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnChat

		public static void OnChat(GameSession client, GameClientPacket packet){
			if (!client.IsAuthentified){
				return;
			}
			string msg = packet.ReadUnicode(256);
			if(client.Game==null){
				return;
			}
			if(!client.OnChatCommand(msg)){
				using(GameServerPacket chat = new GameServerPacket(StocMessage.Chat)){
					chat.Write((short)client.Type);
					chat.WriteUnicode(msg, msg.Length + 1);
					client.Game.SendToAllBut(chat, client);
				}
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:16,代码来源:GameEvent.cs

示例2: LobbyError

		public static void LobbyError(this GameSession client, string message,bool isNow=true)
		{
			using(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);
				client.Send(join, false);
			}
			
			using(GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter)){
				enter.WriteUnicode("[err]" + message, 20);
				enter.Write((byte)0);
				client.Send(enter, isNow);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:25,代码来源:GameEvent.cs

示例3: ServerMessage

		public void ServerMessage(string msg, PlayerType type=PlayerType.Yellow, string head="[Server] ")
		{
			string finalmsg = head + msg;
			GameServerPacket packet = new GameServerPacket(StocMessage.Chat);
			packet.Write((short)type);
			packet.WriteUnicode(finalmsg, finalmsg.Length + 1);
			Send(packet);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:8,代码来源:Player.cs

示例4: ServerMessage

		public static void ServerMessage(this GameSession client, string msg, PlayerType type=PlayerType.Yellow,bool isNow=true)
		{
			string finalmsg = "[Server] " + msg;
			using(GameServerPacket packet = new GameServerPacket(StocMessage.Chat)){
				packet.Write((short)type);
				packet.WriteUnicode(finalmsg, finalmsg.Length + 1);
				client.Send(packet, isNow);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:9,代码来源:GameEvent.cs

示例5: ServerMessage

 public void ServerMessage(string msg, PlayerType color = PlayerType.Yellow, bool isNow = true)
 {
     string finalmsg = "[Server] " + msg;
     using (GameServerPacket packet = new GameServerPacket(StocMessage.Chat))
     {
         packet.Write((short)color);
         packet.WriteUnicode(finalmsg, finalmsg.Length + 1);
         SendToAll(packet, isNow);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:10,代码来源:GameRoom.cs

示例6: LobbyError

		public 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.WriteUnicode("[err]" + message, 20);
			enter.Write((byte)0);
			Send(enter);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:23,代码来源:Player.cs

示例7: HandleError

 private void HandleError(string error)
 {
     using (GameServerPacket packet = new GameServerPacket(StocMessage.Chat))
     {
         packet.Write((short)PlayerType.Observer);
         packet.WriteUnicode(error, error.Length + 1);
         SendToAll(packet);
     }
     Logger.Error("Lua Error:" + error);
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:10,代码来源:GameRoom.cs

示例8: HandleError

		private void HandleError(string error)
		{
			const string log = "LuaErrors.log";
			if (File.Exists(log))
			{
				foreach (string line in File.ReadAllLines(log))
				{
					if (line == error)
						return;
				}
			}

			StreamWriter writer = new StreamWriter(log, true);
			writer.WriteLine(error);
			writer.Close();

			GameServerPacket packet = new GameServerPacket(StocMessage.Chat);
			packet.Write((short)PlayerType.Observer);
			packet.WriteUnicode(error, error.Length + 1);
			SendToAll(packet);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:21,代码来源:Game.cs

示例9: MoveToDuelist

        public void MoveToDuelist(GameSession player)
        {
            if (State != GameState.Lobby)
                return;
            int pos = GetAvailablePlayerPos();
            if (pos == -1)
                return;
            if (player.Type != (int)PlayerType.Observer)
            {
                if (!IsTag || IsReady[player.Type])
                    return;

                pos = (player.Type + 1) % 4;
                while (Players[pos] != null)
                    pos = (pos + 1) % 4;

                using (GameServerPacket change = new GameServerPacket(StocMessage.HsPlayerChange))
                {
                    change.Write((byte)((player.Type << 4) + pos));
                    SendToAll(change);
                }
                Players[player.Type] = null;
                Players[pos] = player;
                player.Type = pos;
                player.SendTypeChange();
            }
            else
            {
                lock (Observers)
                    Observers.Remove(player);
                Players[pos] = player;
                player.Type = pos;

                using (GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter))
                {
                    enter.WriteUnicode(player.Name, 20);
                    enter.Write((byte)pos);
                    SendToAll(enter);
                }

                using (GameServerPacket nwatch = new GameServerPacket(StocMessage.HsWatchChange))
                {
                    nwatch.Write((short)Observers.Count);
                    SendToAll(nwatch);
                }

                player.SendTypeChange();
            }
        }
开发者ID:247321453,项目名称:YgoServer,代码行数:49,代码来源:GameRoom.cs

示例10: AddPlayer

        public void AddPlayer(GameSession player)
        {
            //			if(IsJoin(player)){
            ////				/玩家已经在游戏
            //				player.LobbyError(Messages.MSG_PLAYER_INGAME);
            //				return;
            //			}
            Logger.Debug("add " + player.Name + " to " + Name);
            if (State != GameState.Lobby)
            {
                if (State == GameState.End)
                    return;
                player.Type = (int)PlayerType.Observer;
                SendJoinGame(player);
                player.SendTypeChange();
                player.Send(GameServerPacket.EmtryMessage(StocMessage.DuelStart));
                lock (Observers)
                    Observers.Add(player);
                if (State == GameState.Duel)
                {
                    //中途观战
                    InitNewSpectator(player);
                }
                else if (State == GameState.Side)
                {
                    player.ServerMessage(Messages.MSG_WATCH_SIDE);
                }
                ServerApi.OnPlayerEnter(player, this);
                return;
            }
            if (HostPlayer == null)
                HostPlayer = player;
            int pos = GetAvailablePlayerPos();
            if (pos != -1)
            {
                Players[pos] = player;
                IsReady[pos] = false;

                player.Type = pos;
                using (GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter))
                {
                    enter.WriteUnicode(player.Name, 20);
                    enter.Write((byte)pos);
                    SendToAll(enter);
                }
                //	Server.OnPlayEvent(PlayerStatu.PlayerReady, player);
            }
            else
            {
                using (GameServerPacket watch = new GameServerPacket(StocMessage.HsWatchChange))
                {
                    watch.Write((short)(Observers.Count + 1));
                    SendToAll(watch);
                }
                player.Type = (int)PlayerType.Observer;
                lock (Observers)
                    Observers.Add(player);
                //				if(player.IsAuthentified){
                //					ServerMessage("[Server] "+player.Name+" watch game.", PlayerType.White);
                //				}
            }
            SendJoinGame(player);
            player.SendTypeChange();

            for (int i = 0; i < Players.Length; i++)
            {
                if (Players[i] != null)
                {
                    using (GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter))
                    {
                        enter.WriteUnicode(Players[i].Name, 20);
                        enter.Write((byte)i);
                        player.Send(enter, false);
                    }
                    if (IsReady[i])
                    {
                        using (GameServerPacket change = new GameServerPacket(StocMessage.HsPlayerChange))
                        {
                            change.Write((byte)((i << 4) + (int)PlayerChange.Ready));
                            player.Send(change, false);
                        }
                    }
                }
            }
            bool _watch = false;
            lock (Observers)
            {
                _watch = Observers.Count > 0;
            }
            if (_watch)
            {
                using (GameServerPacket nwatch = new GameServerPacket(StocMessage.HsWatchChange))
                {
                    nwatch.Write((short)Observers.Count);
                    player.Send(nwatch, false);
                }
            }
            player.PeekSend();
            ServerApi.OnPlayerEnter(player, this);
        }
开发者ID:247321453,项目名称:YgoServer,代码行数:100,代码来源:GameRoom.cs

示例11: ServerMessage

		public void ServerMessage(string msg)
		{
			string finalmsg = "[Server] " + msg;
			GameServerPacket packet = new GameServerPacket(StocMessage.Chat);
			packet.Write((short)PlayerType.Yellow);
			packet.WriteUnicode(finalmsg, finalmsg.Length + 1);
			SendToAll(packet);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:8,代码来源:Game.cs

示例12: Chat

		public void Chat(Player player, string msg)
		{
			GameServerPacket packet = new GameServerPacket(StocMessage.Chat);
			packet.Write((short)player.Type);
			packet.WriteUnicode(msg, msg.Length + 1);
			SendToAllBut(packet, player);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:Game.cs

示例13: AddPlayer

		public void AddPlayer(Player player)
		{
			if (State != GameState.Lobby)
			{
				if (State == GameState.End)
					return;
				//断线重连
//				if(CanPause && IsPause){
//					for(int i=0;i<PlayerNames.Length;i++){
//						if(PlayerNames[i] == player.Name){
//							if(Players[i] == null){
//								//重新加入游戏
//								player.Type = i;
//								Players[i] = player;
//								AutoEndTrun = Program.Config.AutoEndTurn;
//								GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter);
//								enter.Write(player.Name, 20);
//								enter.Write((byte)i);
//								SendToAll(enter);
//								SendJoinGame(player);
//								player.SendTypeChange();
//								//player.Send(new GameServerPacket(StocMessage.DuelStart));
//								InitNewSpectator(player, i);
//								IsPause = false;
//								return;
//							}
//							break;
//						}
//					}
//				}
				player.Type = (int)PlayerType.Observer;
				SendJoinGame(player);
				player.SendTypeChange();
				player.Send(new GameServerPacket(StocMessage.DuelStart));
				Observers.Add(player);
				if (State == GameState.Duel){
					//中途观战
					InitNewSpectator(player);
				}else if(State == GameState.Side){
					player.ServerMessage(Messages.MSG_WATCH_SIDE);
				}
				return;
			}

			if (HostPlayer == null)
				HostPlayer = player;

			int pos = GetAvailablePlayerPos();
			if (pos != -1)
			{
				GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter);
				enter.WriteUnicode(player.Name, 20);
				enter.Write((byte)pos);
				SendToAll(enter);
				PlayerNames[pos] = player.Name;
				Players[pos] = player;
				IsReady[pos] = false;
				player.Type = pos;
			}
			else
			{
				GameServerPacket watch = new GameServerPacket(StocMessage.HsWatchChange);
				watch.Write((short)(Observers.Count + 1));
				SendToAll(watch);

				player.Type = (int)PlayerType.Observer;
				Observers.Add(player);
				if(player.IsAuthentified){
					SendToAll(GameManager.getMessage("[Server] "+player.Name+" watch game.", PlayerType.White));
				}
			}

			SendJoinGame(player);
			player.SendTypeChange();

			for (int i = 0; i < Players.Length; i++)
			{
				if (Players[i] != null)
				{
					GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter);
					enter.WriteUnicode(Players[i].Name, 20);
					enter.Write((byte)i);
					player.Send(enter);
					if (IsReady[i])
					{
						GameServerPacket change = new GameServerPacket(StocMessage.HsPlayerChange);
						change.Write((byte)((i << 4) + (int)PlayerChange.Ready));
						player.Send(change);
					}
				}
			}

			if (Observers.Count > 0)
			{
				GameServerPacket nwatch = new GameServerPacket(StocMessage.HsWatchChange);
				nwatch.Write((short)Observers.Count);
				player.Send(nwatch);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:99,代码来源:Game.cs

示例14: Connect

		public void Connect(ServerInfo info, User user){
			if(client!=null){
				client.Close();
			}
			client = new AsyncClient();
			try{
				client.Connect(info.Host, info.Port);
				using(GameServerPacket login = new GameServerPacket()){
					login.WriteUnicode(user.Name, 20);
					login.WriteUnicode(user.Password, 32);
					login.Use();
					client.BeginSend(login.Content);
				}
			}catch(Exception){
				
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:17,代码来源:UserForm.cs

示例15: SendDuelingPlayers

 private void SendDuelingPlayers(GameSession player, bool isNow = true)
 {
     for (int i = 0; i < Players.Length; i++)
     {
         using (GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter))
         {
             int id = i;
             if (m_swapped)
             {
                 if (IsTag)
                 {
                     if (i == 0 || id == 1)
                         id = i + 2;
                     else
                         id = i - 2;
                 }
                 else
                     id = 1 - i;
             }
             enter.WriteUnicode(Players[id] == null ? "???" : Players[id].Name, 20);
             enter.Write((byte)i);
             player.Send(enter, isNow);
         }
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:25,代码来源:GameRoom.cs


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