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


C# GameNPC.GetName方法代码示例

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


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

示例1: GenerateLoot

		public override LootList GenerateLoot(GameNPC mob, GameObject killer)
		{
			LootList loot = base.GenerateLoot(mob, killer);
			List<LootOTD> lootOTDs = null;

			try
			{
				if (m_mobOTDList.ContainsKey(mob.Name.ToLower()))
				{
					lootOTDs = m_mobOTDList[mob.Name.ToLower()];
				}

				if (lootOTDs != null)
				{
					foreach (GameObject gainer in mob.XPGainers.Keys)
					{
						GamePlayer player = null;

						if (gainer is GamePlayer)
						{
							player = gainer as GamePlayer;
						}
						else if (gainer is GameNPC)
						{
							IControlledBrain brain = ((GameNPC)gainer).Brain as IControlledBrain;
							if (brain != null)
							{
								player = brain.GetPlayerOwner();
							}
						}

						if (player != null)
						{
							foreach (LootOTD drop in lootOTDs)
							{
								if (drop.MinLevel <= player.Level)
								{
									CharacterXOneTimeDrop hasDrop = GameServer.Database.SelectObject<CharacterXOneTimeDrop>("CharacterID = '" + GameServer.Database.Escape(player.QuestPlayerID) + "' AND ItemTemplateID = '" + GameServer.Database.Escape(drop.ItemTemplateID) + "'");

									if (hasDrop == null)
									{
										ItemTemplate item = GameServer.Database.FindObjectByKey<ItemTemplate>(drop.ItemTemplateID);

										if (item != null)
										{
											if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, GameInventoryItem.Create<ItemTemplate>(item)))
											{
												CharacterXOneTimeDrop charXDrop = new CharacterXOneTimeDrop();
												charXDrop.CharacterID = player.QuestPlayerID;
												charXDrop.ItemTemplateID = drop.ItemTemplateID;
												GameServer.Database.AddObject(charXDrop);

												player.Out.SendMessage(string.Format("You receive {0} from {1}!", item.GetName(1, false), mob.GetName(1, false)), eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
                                                InventoryLogging.LogInventoryAction(mob, player, eInventoryActionType.Loot, item);
											}
											else
											{
												// do not drop, player will have to try again
												player.Out.SendMessage("Your inventory is full and a one time drop cannot be added!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
												log.DebugFormat("OTD Failed, Inventory full: {0} from mob {1} for player {2}.", drop.ItemTemplateID, drop.MobName, player.Name);
												break;
											}
										}
										else
										{
											log.ErrorFormat("Error trying to drop ItemTemplate {0} from {1}.  Item not found.", drop.ItemTemplateID, drop.MobName);
										}
									}
								}
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				log.Error("LootGeneratorOneTimeDrop exception for mob " + mob.Name + ":", ex);
			}

			return loot;
		}
开发者ID:andyhebear,项目名称:DOLSharp,代码行数:81,代码来源:LootGeneratorOneTimeDrop.cs


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