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


C# GameNPC.IsVisibleTo方法代码示例

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


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

示例1: SendNPCCreate

		public virtual void SendNPCCreate(GameNPC npc)
		{
			if (m_gameClient.Player == null || npc.IsVisibleTo(m_gameClient.Player) == false)
				return;

			if (npc is GameMovingObject)
			{
				SendMovingObjectCreate(npc as GameMovingObject);
				return;
			}

			using (var pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.NPCCreate)))
			{
				int speed = 0;
				ushort speedZ = 0;
				if (npc.IsMoving && !npc.IsAtTargetPosition)
				{
					speed = npc.CurrentSpeed;
					speedZ = (ushort) npc.TickSpeedZ;
				}
				pak.WriteShort((ushort) npc.ObjectID);
				pak.WriteShort((ushort) speed);
				pak.WriteShort(npc.Heading);
				pak.WriteShort((ushort) npc.Z);
				pak.WriteInt((uint) npc.X);
				pak.WriteInt((uint) npc.Y);
				pak.WriteShort(speedZ);
				pak.WriteShort(npc.Model);
				pak.WriteByte(npc.Size);
				pak.WriteByte(npc.GetDisplayLevel(m_gameClient.Player));

				var flags = (byte) (GameServer.ServerRules.GetLivingRealm(m_gameClient.Player, npc) << 6);
				if ((npc.Flags & GameNPC.eFlags.GHOST) != 0) flags |= 0x01;
				if (npc.Inventory != null)
					flags |= 0x02; //If mob has equipment, then only show it after the client gets the 0xBD packet
				if ((npc.Flags & GameNPC.eFlags.PEACE) != 0) flags |= 0x10;
				if ((npc.Flags & GameNPC.eFlags.FLYING) != 0) flags |= 0x20;

				pak.WriteByte(flags);
				pak.WriteByte(0x20); //TODO this is the default maxstick distance

				string add = "";
				if (m_gameClient.Account.PrivLevel > 1)
				{
					if ((npc.Flags & GameNPC.eFlags.CANTTARGET) != 0)
						add += "-DOR"; // indicates DOR flag for GMs
					if ((npc.Flags & GameNPC.eFlags.DONTSHOWNAME) != 0)
						add += "-NON"; // indicates NON flag for GMs
				}

                DBLanguageNPC translation = npc.GetTranslation(m_gameClient);

                string name = translation.Name;/*npc.Name;*/
				if (name.Length + add.Length + 2 > 47) // clients crash with too long names
					name = name.Substring(0, 47 - add.Length - 2);
				if (add.Length > 0)
					name = string.Format("[{0}]{1}", name, add);

				pak.WritePascalString(name);

                //if (npc.GuildName.Length > 47)
                //    pak.WritePascalString(npc.GuildName.Substring(0, 47));
                //else pak.WritePascalString(npc.GuildName);

                string guildName = translation.GuildName;
                if (guildName.Length > 47)
                    guildName = guildName.Substring(0, 47);

                pak.WritePascalString(guildName);
				pak.WriteByte(0x00);

				SendTCP(pak);
			}
		}
开发者ID:SkyFire,项目名称:Dawn-of-Light-core,代码行数:74,代码来源:PacketLib168.cs

示例2: SendNPCCreate

		public override void SendNPCCreate(GameNPC npc)
		{

			if (m_gameClient.Player == null || npc.IsVisibleTo(m_gameClient.Player) == false)
				return;

			//Added by Suncheck - Mines are not shown to enemy players
			if (npc is GameMine)
			{
				if (GameServer.ServerRules.IsAllowedToAttack((npc as GameMine).Owner, m_gameClient.Player, true))
				{
					return;
				}
			}

			if (npc is GameMovingObject)
			{
				SendMovingObjectCreate(npc as GameMovingObject);
				return;
			}

			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.NPCCreate)))
			{
				int speed = 0;
				ushort speedZ = 0;
				if (npc == null)
					return;
				if (!npc.IsAtTargetPosition)
				{
					speed = npc.CurrentSpeed;
					speedZ = (ushort)npc.TickSpeedZ;
				}
				pak.WriteShort((ushort)npc.ObjectID);
				pak.WriteShort((ushort)(speed));
				pak.WriteShort(npc.Heading);
				pak.WriteShort((ushort)npc.Z);
				pak.WriteInt((uint)npc.X);
				pak.WriteInt((uint)npc.Y);
				pak.WriteShort(speedZ);
				pak.WriteShort(npc.Model);
				pak.WriteByte(npc.Size);
				byte level = npc.GetDisplayLevel(m_gameClient.Player);
				if((npc.Flags&GameNPC.eFlags.STATUE)!=0)
				{
					level |= 0x80;
				}
				pak.WriteByte(level);
	
				byte flags = (byte)(GameServer.ServerRules.GetLivingRealm(m_gameClient.Player, npc) << 6);
				if ((npc.Flags & GameNPC.eFlags.GHOST) != 0) flags |= 0x01;
				if (npc.Inventory != null) flags |= 0x02; //If mob has equipment, then only show it after the client gets the 0xBD packet
				if ((npc.Flags & GameNPC.eFlags.PEACE) != 0) flags |= 0x10;
				if ((npc.Flags & GameNPC.eFlags.FLYING) != 0) flags |= 0x20;
				if((npc.Flags & GameNPC.eFlags.TORCH) != 0) flags |= 0x04;
				
				pak.WriteByte(flags);
				pak.WriteByte(0x20); //TODO this is the default maxstick distance
	
				string add = "";
				byte flags2 = 0x00;
				IControlledBrain brain = npc.Brain as IControlledBrain;
				if (m_gameClient.Version >= GameClient.eClientVersion.Version187)
				{
					if (brain != null)
					{
						flags2 |= 0x80; // have Owner
					}
				}
				if ((npc.Flags & GameNPC.eFlags.CANTTARGET) != 0)
					if (m_gameClient.Account.PrivLevel > 1) add += "-DOR"; // indicates DOR flag for GMs
				else flags2 |= 0x01;
				if ((npc.Flags & GameNPC.eFlags.DONTSHOWNAME) != 0)
					if (m_gameClient.Account.PrivLevel > 1) add += "-NON"; // indicates NON flag for GMs
				else flags2 |= 0x02;
	
				if( ( npc.Flags & GameNPC.eFlags.STEALTH ) > 0 )
					flags2 |= 0x04;
	
				eQuestIndicator questIndicator = npc.GetQuestIndicator(m_gameClient.Player);
	
				if (questIndicator == eQuestIndicator.Available)
					flags2 |= 0x08;//hex 8 - quest available
				if (questIndicator == eQuestIndicator.Finish)
					flags2 |= 0x10;//hex 16 - quest finish
				//flags2 |= 0x20;//hex 32 - water mob?
				//flags2 |= 0x40;//hex 64 - unknown
				//flags2 |= 0x80;//hex 128 - has owner
				
	
				pak.WriteByte(flags2); // flags 2
	
				byte flags3 = 0x00;
				if (questIndicator == eQuestIndicator.Lesson)
					flags3 |= 0x01;
				if (questIndicator == eQuestIndicator.Lore)
					flags3 |= 0x02;
				pak.WriteByte(flags3); // new in 1.71 (region instance ID from StoC_0x20) OR flags 3?
				pak.WriteShort(0x00); // new in 1.71 unknown
	
				string name = npc.Name;
//.........这里部分代码省略.........
开发者ID:dudemanvox,项目名称:Dawn-of-Light-Server,代码行数:101,代码来源:PacketLib171.cs

示例3: SendNPCCreate

		public override void SendNPCCreate(GameNPC npc)
		{

			if (m_gameClient.Player == null || npc.IsVisibleTo(m_gameClient.Player) == false)
				return;

			//Added by Suncheck - Mines are not shown to enemy players
			if (npc is GameMine)
			{
				if (GameServer.ServerRules.IsAllowedToAttack((npc as GameMine).Owner, m_gameClient.Player, true))
				{
					return;
				}
			}

			if (npc is GameMovingObject)
			{
				SendMovingObjectCreate(npc as GameMovingObject);
				return;
			}

			GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.NPCCreate));
			int speed = 0;
			ushort speedZ = 0;
			if (npc == null)
				return;
			if (!npc.IsAtTargetPosition)
			{
				speed = npc.CurrentSpeed;
				speedZ = (ushort)npc.TickSpeedZ;
			}
			pak.WriteShort((ushort)npc.ObjectID);
			pak.WriteShort((ushort)(speed));
			pak.WriteShort(npc.Heading);
			pak.WriteShort((ushort)npc.Z);
			pak.WriteInt((uint)npc.X);
			pak.WriteInt((uint)npc.Y);
			pak.WriteShort(speedZ);
			pak.WriteShort(npc.Model);
			pak.WriteByte(npc.Size);
			byte level = npc.GetDisplayLevel(m_gameClient.Player);
			if((npc.Flags&GameNPC.eFlags.STATUE)!=0)
			{
				level |= 0x80;
			}
			pak.WriteByte(level);

			byte flags = (byte)(GameServer.ServerRules.GetLivingRealm(m_gameClient.Player, npc) << 6);
			if ((npc.Flags & GameNPC.eFlags.GHOST) != 0) flags |= 0x01;
			if (npc.Inventory != null) flags |= 0x02; //If mob has equipment, then only show it after the client gets the 0xBD packet
			if ((npc.Flags & GameNPC.eFlags.PEACE) != 0) flags |= 0x10;
			if ((npc.Flags & GameNPC.eFlags.FLYING) != 0) flags |= 0x20;
			if((npc.Flags & GameNPC.eFlags.TORCH) != 0) flags |= 0x04;
			
			pak.WriteByte(flags);
			pak.WriteByte(0x20); //TODO this is the default maxstick distance

			string add = "";
			byte flags2 = 0x00;
			IControlledBrain brain = npc.Brain as IControlledBrain;
			if (m_gameClient.Version >= GameClient.eClientVersion.Version187)
			{
				if (brain != null)
				{
					flags2 |= 0x80; // have Owner
				}
			}
			if ((npc.Flags & GameNPC.eFlags.CANTTARGET) != 0)
				if (m_gameClient.Account.PrivLevel > 1) add += "-DOR"; // indicates DOR flag for GMs
			else flags2 |= 0x01;
			if ((npc.Flags & GameNPC.eFlags.DONTSHOWNAME) != 0)
				if (m_gameClient.Account.PrivLevel > 1) add += "-NON"; // indicates NON flag for GMs
			else flags2 |= 0x02;

			if( ( npc.Flags & GameNPC.eFlags.STEALTH ) > 0 )
				flags2 |= 0x04;

			if( npc.ShowQuestIndicator( m_gameClient.Player ) )
				flags2 |= 0x08;

			pak.WriteByte(flags2); // 4 high bits seems unused (new in 1.71)
			pak.WriteShort(0x00); // new in 1.71
			pak.WriteByte(0x00); // new in 1.71 (region instance ID from StoC_0x20)

            DBLanguageNPC translation = npc.GetTranslation(m_gameClient);

            string name = translation.Name;/*GameServer.ServerRules.GetNPCName(m_gameClient.Player, npc);*/
			if (name.Length + add.Length + 2 > 47) // clients crash with too long names
				name = name.Substring(0, 47 - add.Length - 2);
			if (add.Length > 0)
				name = string.Format("[{0}]{1}", name, add);

			pak.WritePascalString(name);

            string l_npcGuildname = translation.GuildName;/*GameServer.ServerRules.GetNPCGuildName(m_gameClient.Player, npc);;*/
			if (l_npcGuildname.Length > 47)
				pak.WritePascalString(l_npcGuildname.Substring(0, 47));
			else pak.WritePascalString(l_npcGuildname);

			pak.WriteByte(0x00);
//.........这里部分代码省略.........
开发者ID:boscorillium,项目名称:dol,代码行数:101,代码来源:PacketLib171.cs


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