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


C# GameServerPacket.ReadInt32方法代码示例

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


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

示例1: 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

示例2: OnSelectEffectYn

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

			int cardId = packet.ReadInt32();
			int player = GetLocalPlayer(packet.ReadByte());
			CardLocation loc = (CardLocation)packet.ReadByte();
			int seq = packet.ReadByte();
			packet.ReadByte();

			ClientCard card = _duel.GetCard(player, loc, seq);
			if (card == null)
			{
				Connection.Send(CtosMessage.Response, 0);
				return;
			}

			if (card.Id == 0) card.SetId(cardId);

			int reply = _ai.OnSelectEffectYn(card) ? (1) : (0);
			Connection.Send(CtosMessage.Response, reply);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:22,代码来源:GameBehavior.cs

示例3: 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

示例4: OnSelectChain

		private void OnSelectChain(GameServerPacket packet)
		{
			packet.ReadByte(); // player
			int count = packet.ReadByte();
			packet.ReadByte(); // specount
			bool forced = packet.ReadByte() != 0;
			packet.ReadInt32(); // hint1
			packet.ReadInt32(); // hint2

			IList<ClientCard> cards = new List<ClientCard>();
			IList<int> descs = new List<int>();

			for (int i = 0; i < count; ++i)
			{
				packet.ReadInt32(); // card id
				int con = GetLocalPlayer(packet.ReadByte());
				int loc = packet.ReadByte();
				int seq = packet.ReadByte();
				int sseq = 0; //packet.ReadByte();

				int desc = packet.ReadInt32();
				cards.Add(_duel.GetCard(con, loc, seq, sseq));
				descs.Add(desc);
			}

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

			if (cards.Count == 1 && forced)
			{
				Connection.Send(CtosMessage.Response, 0);
				return;
			}

			Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forced));
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:39,代码来源:GameBehavior.cs

示例5: 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

示例6: 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

示例7: OnChaining

		private void OnChaining(GameServerPacket packet)
		{
			packet.ReadInt32(); // card id
			int pcc = GetLocalPlayer(packet.ReadByte());
			int pcl = packet.ReadByte();
			int pcs = packet.ReadSByte();
			int subs = packet.ReadSByte();
			ClientCard card = _duel.GetCard(pcc, pcl, pcs, subs);
			int cc = GetLocalPlayer(packet.ReadByte());
			_ai.OnChaining(card, cc);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:GameBehavior.cs

示例8: 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

示例9: OnMove

		private void OnMove(GameServerPacket packet)
		{
			int cardId = packet.ReadInt32();
			int pc = GetLocalPlayer(packet.ReadByte());
			int pl = packet.ReadByte();
			int ps = packet.ReadSByte();
			packet.ReadSByte(); // pp
			int cc = GetLocalPlayer(packet.ReadByte());
			int cl = packet.ReadByte();
			int cs = packet.ReadSByte();
			int cp = packet.ReadSByte();
			packet.ReadInt32(); // reason

			ClientCard card = _duel.GetCard(pc, (CardLocation)pl, ps);

			if ((pl & (int)CardLocation.Overlay) != 0)
			{
				pl = pl & 0x7f;
				card = _duel.GetCard(pc, (CardLocation)pl, ps);
				if (card != null)
					card.Overlays.Remove(cardId);
			}
			else
				_duel.RemoveCard((CardLocation)pl, card, pc, ps);

			if ((cl & (int)CardLocation.Overlay) != 0)
			{
				cl = cl & 0x7f;
				card = _duel.GetCard(cc, (CardLocation)cl, cs);
				if (card != null)
					card.Overlays.Add(cardId);
			}
			else
			{
				_duel.AddCard((CardLocation)cl, cardId, cc, cs, cp);
				if ((pl & (int)CardLocation.Overlay) == 0 && card != null)
				{
					ClientCard newcard = _duel.GetCard(cc, (CardLocation)cl, cs);
					if (newcard != null)
						newcard.Overlays.AddRange(card.Overlays);
				}
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:43,代码来源:GameBehavior.cs

示例10: OnPosChange

		private void OnPosChange(GameServerPacket packet)
		{
			packet.ReadInt32(); // card id
			int pc = GetLocalPlayer(packet.ReadByte());
			int pl = packet.ReadByte();
			int ps = packet.ReadSByte();
			packet.ReadSByte(); // pp
			int cp = packet.ReadSByte();
			ClientCard card = _duel.GetCard(pc, (CardLocation)pl, ps);
			if (card != null)
				card.Position = cp;
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:12,代码来源:GameBehavior.cs

示例11: OnLpUpdate

		private void OnLpUpdate(GameServerPacket packet)
		{
			int player = GetLocalPlayer(packet.ReadByte());
			_duel.LifePoints[player] = packet.ReadInt32();
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:5,代码来源:GameBehavior.cs

示例12: OnDamage

		private void OnDamage(GameServerPacket packet)
		{
			int player = GetLocalPlayer(packet.ReadByte());
			int final = _duel.LifePoints[player] - packet.ReadInt32();
			if (final < 0) final = 0;
			_duel.LifePoints[player] = final;
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:GameBehavior.cs

示例13: 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

示例14: 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

示例15: OnUpdateCard

		private void OnUpdateCard(GameServerPacket packet)
		{
			int player = GetLocalPlayer(packet.ReadByte());
			int loc = packet.ReadByte();
			int seq = packet.ReadByte();

			packet.ReadInt32(); // ???

			ClientCard card = _duel.GetCard(player, (CardLocation)loc, seq);
			if (card == null) return;

			card.Update(packet,_duel);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:13,代码来源:GameBehavior.cs


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