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


C# GamePlayer.GetNPCsInRadius方法代码示例

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


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

示例1: OnReceive

        public override void OnReceive(GamePlayer player)
        {
            base.OnReceive(player);

            foreach (GameNPC npc in player.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE))
                npc.BroadcastUpdate();
        }
开发者ID:mynew4,项目名称:DAoC,代码行数:7,代码来源:DesmonaCoin.cs

示例2: IsNearRegistrar

		private static bool IsNearRegistrar(GamePlayer player)
		{
			foreach (GameNPC registrar in player.GetNPCsInRadius(500))
			{
				if (registrar is GuildRegistrar)
					return true;
			}
			return false;
		}
开发者ID:boscorillium,项目名称:dol,代码行数:9,代码来源:guild.cs

示例3: UpdatePlayerNPCs

		/// <summary>
		/// Send Mobs Update to Player depending on last refresh time.
		/// </summary>
		/// <param name="player"></param>
		/// <param name="nowTicks"></param>
		private static void UpdatePlayerNPCs(GamePlayer player, long nowTicks)
		{
			// Get All Mobs in Range
			var npcs = player.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE).Cast<GameNPC>().Where(n => n != null && n.IsVisibleTo(player)).ToArray();

			try
			{
				// Clean Cache
				foreach (var objEntry in player.Client.GameObjectUpdateArray)
				{
					var objKey = objEntry.Key;
					GameObject obj = WorldMgr.GetRegion(objKey.Item1).GetObject(objKey.Item2);
					
					// Brain is updating to its master, no need to handle it.
					if (obj is GameNPC && ((GameNPC)obj).Brain is IControlledBrain && ((IControlledBrain)((GameNPC)obj).Brain).GetPlayerOwner() == player)
						continue;
					
					// We have a NPC in cache that is not in vincinity
					if (obj is GameNPC && !npcs.Contains((GameNPC)obj) && (nowTicks - objEntry.Value) >= GetPlayerNPCUpdateInterval)
					{
						// Update him out of View
						if (obj.IsVisibleTo(player))
							player.Client.Out.SendObjectUpdate(obj);
						
						long dummy;
						// this will add the object to the cache again, remove it after sending...
						player.Client.GameObjectUpdateArray.TryRemove(objKey, out dummy);
					}
				}
			}
			catch (Exception e)
			{
				if (log.IsErrorEnabled)
					log.ErrorFormat("Error while Cleaning NPC cache for Player : {0}, Exception : {1}", player.Name, e);
			}
			
			try
			{
				// Now Send remaining npcs
				foreach (GameNPC lnpc in npcs)
				{
					GameNPC npc = lnpc;
										
					// Get last update time
					long lastUpdate;
					if (player.Client.GameObjectUpdateArray.TryGetValue(new Tuple<ushort, ushort>(npc.CurrentRegionID, (ushort)npc.ObjectID), out lastUpdate))
					{
						// This NPC Needs Update
						if ((nowTicks - lastUpdate) >= GetPlayerNPCUpdateInterval)
						{
							player.Client.Out.SendObjectUpdate(npc);
						}
					}
					else
					{
						// Not in cache, Object entering in range, sending update will add it to cache.
						player.Client.Out.SendObjectUpdate(npc);
					}
				}
			}
			catch (Exception e)
			{
				if (log.IsErrorEnabled)
					log.ErrorFormat("Error while updating NPC for Player : {0}, Exception : {1}", player.Name, e);
			}
		}
开发者ID:dudemanvox,项目名称:Dawn-of-Light-Server,代码行数:71,代码来源:WorldUpdateThread.cs

示例4: SendMobsAndMobEquipmentToPlayer

			private static int SendMobsAndMobEquipmentToPlayer(GamePlayer player)
			{
				int mobs = 0;
				foreach (GameNPC npc in player.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE))
				{
					player.Out.SendNPCCreate(npc);
					mobs++;
					if (npc.Inventory != null)
						player.Out.SendLivingEquipmentUpdate(npc);
					player.CurrentUpdateArray[npc.ObjectID - 1] = true;

					//The following line can cause a racing condition
					//between client and server! Not neccessary
					//player.Out.SendNPCUpdate(npc); <-- BIG NO NO!
				}
				return mobs;
			}
开发者ID:SkyFire,项目名称:Dawn-of-Light-core,代码行数:17,代码来源:PlayerInitRequestHandler.cs

示例5: Execute

        /// <summary>
        /// Executes the stealth ability
        /// </summary>
        /// <param name="spec"></param>
        /// <param name="player"></param>
        public void Execute(Specialization spec, GamePlayer player)
        {
            // Can't stealth while in combat
            if(player.InCombat && !player.IsStealthed && player.Client.Account.PrivLevel == (int)ePrivLevel.Player)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Stealth.CannotUseInCombat"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            long stealthChangeTick = player.TempProperties.getProperty<long>(GamePlayer.STEALTH_CHANGE_TICK);
            long changeTime = player.CurrentRegion.Time - stealthChangeTick;
            if(changeTime < 2000)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Stealth.CannotUseStealthChangeTick", ((2000 - changeTime) / 1000).ToString()), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }
            player.TempProperties.setProperty(GamePlayer.STEALTH_CHANGE_TICK, player.CurrentRegion.Time);

            if (!player.IsStealthed)
            {
                // Dead can't stealth
                if(!player.IsAlive)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Stealth.CannotUseDead"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                // Can't stealth if in attack mode
                if(player.AttackState || (player.CurrentSpellHandler != null && player.CurrentSpellHandler.IsCasting))
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Stealth.CannotUseCombatState"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                //TODO: more checks in this order

                //"You can't hide with a relic!"

                if (player.ConcentrationEffects.GetOfType(typeof (PulsingSpellEffect)) != null)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Stealth.CannotUseActivePulsingSpell"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                //HasVanishRealmAbilityActivated -> Allow stealthing, Stop further checks ...

                if (player.IsMezzed)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Stealth.CannotUseMezzed"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (player.IsStunned)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Stealth.CannotUseStunned"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                // Check if enemy player is close
                foreach (GamePlayer ply in player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                {
                    if (ply.ObjectState != GameObject.eObjectState.Active) continue;

                    //Dead players don't prevent stealth!
                    if (!ply.IsAlive) continue;

                    //TODO: "True Seeing" realm ability check
                    //True Seeing denies restealthing for VISIBILITY_DISTANCE!
                    //There was/is a huge discussion about this on live servers since
                    //all Assessins found this quite unfair!
                    //But the discussion has died down since True Seeing etc.

                    //Friendly players/mobs don't prevent stealth!
                    if (!GameServer.ServerRules.IsAllowedToAttack(ply, player, true)) continue;

                    //GM's don't prevent stealth
                    if (ply.Client.Account.PrivLevel > 1) continue;

                    //Range check
                    if (!IsObjectTooClose(ply, player)) continue;

                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.Stealth.CannotUseToCloseAnEnemy"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                // Check if enemy NPC is close
                foreach (GameNPC npc in player.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE))
                {
                    if (npc.ObjectState != GameObject.eObjectState.Active) continue;

                    //Dead npc don't prevent stealth!
                    if (!npc.IsAlive) continue;

                    //Friendly players/mobs don't prevent stealth!
                    if (!GameServer.ServerRules.IsAllowedToAttack(npc, player, true)) continue;
//.........这里部分代码省略.........
开发者ID:mynew4,项目名称:DOLSharp,代码行数:101,代码来源:StealthSpecHandler.cs

示例6: SendMobsAndMobEquipmentToPlayer

			private static int SendMobsAndMobEquipmentToPlayer(GamePlayer player)
			{
				int mobs = 0;

				if (player.CurrentRegion != null)
				{
					var npcs = player.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE).Cast<GameNPC>().ToArray();
					foreach (GameNPC npc in npcs)
					{
						player.Out.SendNPCCreate(npc);
						mobs++;
						if (npc.Inventory != null)
							player.Out.SendLivingEquipmentUpdate(npc);
					}
				}

				return mobs;
			}
开发者ID:dudemanvox,项目名称:Dawn-of-Light-Server,代码行数:18,代码来源:PlayerInitRequestHandler.cs


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