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


C# GameServerPacket.ReadByte方法代码示例

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


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

示例1: OnPlayerEnter

		private void OnPlayerEnter(GameServerPacket packet)
		{
			string name = packet.ReadUnicode(20);
			if(name.StartsWith("[err]")){
				Logger.WriteLine(name);
				Connection.Close();
				return;
			}
			int pos = packet.ReadByte();
			if (pos < 8)
				_room.Names[pos] = name;
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:12,代码来源:GameBehavior.cs

示例2: OnSelectSum

		private void OnSelectSum(GameServerPacket packet)
		{
			packet.ReadByte(); // mode
			packet.ReadByte(); // player
			int sumval = packet.ReadInt32();
			int min = packet.ReadByte();
			int max = packet.ReadByte();

			IList<ClientCard> cards = new List<ClientCard>();
			int count = packet.ReadByte();
			for (int i = 0; i < count; ++i)
			{
				int cardId = packet.ReadInt32();
				int player = GetLocalPlayer(packet.ReadByte());
				CardLocation loc = (CardLocation)packet.ReadByte();
				int seq = packet.ReadByte();
				ClientCard card = _duel.GetCard(player, loc, seq);
				if (card != null)
				{
					if (cardId != 0 && card.Id != cardId)
						card.SetId(cardId);
					cards.Add(card);
				}
				packet.ReadInt32();
			}

			IList<ClientCard> selected = _ai.OnSelectSum(cards, sumval, min, max);

			byte[] result = new byte[selected.Count + 1];
			result[0] = (byte)selected.Count;
			for (int i = 0; i < selected.Count; ++i)
			{
				int id = 0;
				for (int j = 0; j < count; ++j)
				{
					if (cards[j] == null) continue;
					if (cards[j].Equals(selected[i]))
					{
						id = j;
						break;
					}
				}
				result[i + 1] = (byte)id;
			}

			GameClientPacket reply = new GameClientPacket(CtosMessage.Response);
			reply.Write(result);
			Connection.Send(reply);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:49,代码来源:GameBehavior.cs

示例3: OnAnnounceAttrib

		private void OnAnnounceAttrib(GameServerPacket packet)
		{
			IList<CardAttribute> attributes = new List<CardAttribute>();
			packet.ReadByte(); // player
			int count = packet.ReadByte();
			int available = packet.ReadInt32();
			int filter = 0x1;
			for (int i = 0; i < 7; ++i)
			{
				if ((available & filter) != 0)
					attributes.Add((CardAttribute) filter);
				filter <<= 1;
			}
			attributes = _ai.OnAnnounceAttrib(count, attributes);
			int reply = 0;
			for (int i = 0; i < count; ++i)
				reply += (int)attributes[i];
			Connection.Send(CtosMessage.Response, reply);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:19,代码来源:GameBehavior.cs

示例4: OnSelectIdleCmd

		private void OnSelectIdleCmd(GameServerPacket packet)
		{
			packet.ReadByte(); // player

			_duel.MainPhase = new MainPhase();
			MainPhase main = _duel.MainPhase;
			int count;
			for (int k = 0; k < 5; k++)
			{
				count = packet.ReadByte();
				for (int i = 0; i < count; ++i)
				{
					packet.ReadInt32(); // card id
					int con = GetLocalPlayer(packet.ReadByte());
					CardLocation loc = (CardLocation)packet.ReadByte();
					int seq = packet.ReadByte();
					ClientCard card = _duel.GetCard(con, loc, seq);
					if (card == null) continue;
					card.ActionIndex[k] = i;
					switch (k)
					{
						case 0:
							main.SummonableCards.Add(card);
							break;
						case 1:
							main.SpecialSummonableCards.Add(card);
							break;
						case 2:
							main.ReposableCards.Add(card);
							break;
						case 3:
							main.MonsterSetableCards.Add(card);
							break;
						case 4:
							main.SpellSetableCards.Add(card);
							break;
					}
				}
			}
			count = packet.ReadByte();
			for (int i = 0; i < count; ++i)
			{
				packet.ReadInt32(); // card id
				int con = GetLocalPlayer(packet.ReadByte());
				CardLocation loc = (CardLocation)packet.ReadByte();
				int seq = packet.ReadByte();
				int desc = packet.ReadInt32();

				ClientCard card = _duel.GetCard(con, loc, seq);
				if (card == null) continue;
				card.ActionIndex[5] = i;
				if (card.ActionActivateIndex.ContainsKey(desc))
					card.ActionActivateIndex.Remove(desc);
				card.ActionActivateIndex.Add(desc, i);
				main.ActivableCards.Add(card);
				main.ActivableDescs.Add(desc);
			}

			main.CanBattlePhase = packet.ReadByte() != 0;
			main.CanEndPhase = packet.ReadByte() != 0;
			packet.ReadByte(); // CanShuffle

			Connection.Send(CtosMessage.Response, _ai.OnSelectIdleCmd(main).ToValue());
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:64,代码来源:GameBehavior.cs

示例5: OnSelectPlace

		private void OnSelectPlace(GameServerPacket packet)
		{
			packet.ReadByte(); // player
			packet.ReadByte(); // min
			int field = ~packet.ReadInt32();

			byte[] resp = new byte[3];

			bool pendulumZone = false;
            
			int filter;
			if ((field & 0x1f) != 0)
			{
				resp[0] = (byte)GetLocalPlayer(0);
				resp[1] = 0x4;
				filter = field & 0x1f;
			}
			else if ((field & 0x1f00) != 0)
			{
				resp[0] = (byte)GetLocalPlayer(0);
				resp[1] = 0x8;
				filter = (field >> 8) & 0x1f;
			}
			else if ((field & 0xc000) != 0)
			{
				resp[0] = (byte)GetLocalPlayer(0);
				resp[1] = 0x8;
				filter = (field >> 14) & 0x3;
				pendulumZone = true;
			}
			else if ((field & 0x1f0000) != 0)
			{
				resp[0] = (byte)GetLocalPlayer(1);
				resp[1] = 0x4;
				filter = (field >> 16) & 0x1f;
			}
			else if ((field & 0x1f000000) != 0)
			{
				resp[0] = (byte) GetLocalPlayer(1);
				resp[1] = 0x8;
				filter = (field >> 24) & 0x1f;
			}
			else
			{
				resp[0] = (byte) GetLocalPlayer(1);
				resp[1] = 0x8;
				filter = (field >> 30) & 0x3;
				pendulumZone = true;
			}

			if (!pendulumZone)
			{
				if ((filter & 0x4) != 0) resp[2] = 2;
				else if ((filter & 0x2) != 0) resp[2] = 1;
				else if ((filter & 0x8) != 0) resp[2] = 3;
				else if ((filter & 0x1) != 0) resp[2] = 0;
				else if ((filter & 0x10) != 0) resp[2] = 4;
			}
			else
			{
				if ((filter & 0x1) != 0) resp[2] = 6;
				if ((filter & 0x2) != 0) resp[2] = 7;
			}

			GameClientPacket reply = new GameClientPacket(CtosMessage.Response);
			reply.Write(resp);
			Connection.Send(reply);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:68,代码来源:GameBehavior.cs

示例6: InternalOnSelectCard

		private void InternalOnSelectCard(GameServerPacket packet, Func<IList<ClientCard>, int, int, bool, IList<ClientCard>> func)
		{
			packet.ReadByte(); // player
			bool cancelable = packet.ReadByte() != 0;
			int min = packet.ReadByte();
			int max = packet.ReadByte();

			IList<ClientCard> cards = new List<ClientCard>();
			int count = packet.ReadByte();
			for (int i = 0; i < count; ++i)
			{
				int id = packet.ReadInt32();
				int player = GetLocalPlayer(packet.ReadByte());
				CardLocation loc = (CardLocation)packet.ReadByte();
				int seq = packet.ReadByte();
				packet.ReadByte(); // pos
				ClientCard card;
				if (((int)loc & (int)CardLocation.Overlay) != 0)
					card = new ClientCard(id, CardLocation.Overlay);
				else
					card = _duel.GetCard(player, loc, seq);
				if (card == null) continue;
				if (card.Id == 0)
					card.SetId(id);
				cards.Add(card);
			}

			IList<ClientCard> selected = func(cards, min, max, cancelable);

			if (selected.Count == 0 && cancelable)
			{
				Connection.Send(CtosMessage.Response, -1);
				return;
			}

			byte[] result = new byte[selected.Count + 1];
			result[0] = (byte)selected.Count;
			for (int i = 0; i < selected.Count; ++i)
			{
				int id = 0;
				for (int j = 0; j < count; ++j)
				{
					if (cards[j] == null) continue;
					if (cards[j].Equals(selected[i]))
					{
						id = j;
						break;
					}
				}
				result[i + 1] = (byte)id;
			}

			GameClientPacket reply = new GameClientPacket(CtosMessage.Response);
			reply.Write(result);
			Connection.Send(reply);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:56,代码来源:GameBehavior.cs

示例7: OnSelectCounter

		private void OnSelectCounter(GameServerPacket packet)
		{
			packet.ReadByte(); // player
			int type = packet.ReadInt16();
			int quantity = packet.ReadByte();

			IList<ClientCard> cards = new List<ClientCard>();
			IList<int> counters = new List<int>();
			int count = packet.ReadByte();
			for (int i = 0; i < count; ++i)
			{
				packet.ReadInt32(); // card id
				int player = GetLocalPlayer(packet.ReadByte());
				CardLocation loc = (CardLocation) packet.ReadByte();
				int seq = packet.ReadByte();
				int num = packet.ReadByte();
				cards.Add(_duel.GetCard(player, loc, seq));
				counters.Add(num);
			}

			IList<int> used = _ai.OnSelectCounter(type, quantity, cards, counters);
			byte[] result = new byte[used.Count];
			for (int i = 0; i < quantity; ++i)
				result[i] = (byte) used[i];
			GameClientPacket reply = new GameClientPacket(CtosMessage.Response);
			reply.Write(result);
			Connection.Send(reply);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:28,代码来源:GameBehavior.cs

示例8: OnShuffleHand

		private void OnShuffleHand(GameServerPacket packet)
		{
			int player = GetLocalPlayer(packet.ReadByte());
			packet.ReadByte();
			foreach (ClientCard card in _duel.Fields[player].Hand)
				card.SetId(packet.ReadInt32());
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:GameBehavior.cs

示例9: OnNewTurn

		private void OnNewTurn(GameServerPacket packet)
		{
			_duel.Turn++;
			_duel.Player = GetLocalPlayer(packet.ReadByte());
			_ai.OnNewTurn();
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:6,代码来源:GameBehavior.cs

示例10: OnWin

		private void OnWin(GameServerPacket packet)
		{
			int result = GetLocalPlayer(packet.ReadByte());

			string otherName = _room.Names[0] == Game.Username ? _room.Names[1] : _room.Names[0];
			string textResult = (result == 2 ? "Draw" : result == 0 ? "Win" : "Lose");
			Logger.WriteLine("Duel finished against " + otherName + ", result: " + textResult);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:8,代码来源:GameBehavior.cs

示例11: OnDraw

		private void OnDraw(GameServerPacket packet)
		{
			int player = GetLocalPlayer(packet.ReadByte());
			int count = packet.ReadByte();

			for (int i = 0; i < count; ++i)
			{
				_duel.Fields[player].Deck.RemoveAt(_duel.Fields[player].Deck.Count - 1);
				_duel.Fields[player].Hand.Add(new ClientCard(0, CardLocation.Hand));
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:GameBehavior.cs

示例12: OnStart

		private void OnStart(GameServerPacket packet)
		{
			int type = packet.ReadByte();
			_duel.IsFirst = (type & 0xF) == 0;
			_duel.LifePoints[GetLocalPlayer(0)] = packet.ReadInt32();
			_duel.LifePoints[GetLocalPlayer(1)] = packet.ReadInt32();
			int deck = packet.ReadInt16();
			int extra = packet.ReadInt16();
			_duel.Fields[GetLocalPlayer(0)].Init(deck, extra);
			deck = packet.ReadInt16();
			extra = packet.ReadInt16();
			_duel.Fields[GetLocalPlayer(1)].Init(deck, extra);
			if (!IsInGame())
			{
				Logger.WriteLine("AI is watch.");
				Connection.Close();
				return;
			}
			Logger.WriteLine("Duel started: " + _room.Names[0] + " versus " + _room.Names[1]);
			_ai.OnStart();
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:21,代码来源:GameBehavior.cs

示例13: OnTimeLimit

		private void OnTimeLimit(GameServerPacket packet)
		{
			int player = GetLocalPlayer(packet.ReadByte());
			if (player == 0)
				Connection.Send(CtosMessage.TimeConfirm);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:6,代码来源:GameBehavior.cs

示例14: OnPlayerChange

		private void OnPlayerChange(GameServerPacket packet)
		{
			int change = packet.ReadByte();
			int pos = (change >> 4) & 0xF;
			int state = change & 0xF;
            //TODO tag
            if (pos > 3)
				return;
			if (state < 8)
			{
				string oldname = _room.Names[pos];
				_room.Names[pos] = null;
				_room.Names[state] = oldname;
				_room.IsReady[pos] = false;
				_room.IsReady[state] = false;
			}
			else if (state == (int)PlayerChange.Ready)
				_room.IsReady[pos] = true;
			else if (state == (int)PlayerChange.NotReady)
				_room.IsReady[pos] = false;
			else if (state == (int)PlayerChange.Leave || state == (int)PlayerChange.Observe)
			{
				_room.IsReady[pos] = false;
				_room.Names[pos] = null;
			}

			if (_room.IsHost && _room.IsReady[0] && _room.IsReady[1])
				Connection.Send(CtosMessage.HsStart);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:29,代码来源:GameBehavior.cs

示例15: OnUpdateData

		private void OnUpdateData(GameServerPacket packet)
		{
			int player = GetLocalPlayer(packet.ReadByte());
			CardLocation loc = (CardLocation)packet.ReadByte();

			IList<ClientCard> cards = null;
			switch (loc)
			{
				case CardLocation.Hand:
					cards = _duel.Fields[player].Hand;
					break;
				case CardLocation.MonsterZone:
					cards = _duel.Fields[player].MonsterZone;
					break;
				case CardLocation.SpellZone:
					cards = _duel.Fields[player].SpellZone;
					break;
				case CardLocation.Grave:
					cards = _duel.Fields[player].Graveyard;
					break;
				case CardLocation.Removed:
					cards = _duel.Fields[player].Banished;
					break;
				case CardLocation.Deck:
					cards = _duel.Fields[player].Deck;
					break;
				case CardLocation.Extra:
					cards = _duel.Fields[player].ExtraDeck;
					break;
			}
			if (cards != null)
			{
				foreach (ClientCard card in cards)
				{
					try{
						int len = packet.ReadInt32();
						if (len < 8) continue;
						long pos = packet.GetPosition();
						card.Update(packet, _duel);
						packet.SetPosition(pos + len - 4);
					}catch(Exception){
						
					}
				}
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:46,代码来源:GameBehavior.cs


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