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


C# GamePlayer.RemoveMoney方法代码示例

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


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

示例1: BuyItem

		protected virtual void BuyItem(GamePlayer player, bool usingMarketExplorer = false)
		{
			eInventorySlot fromClientSlot = player.TempProperties.getProperty<eInventorySlot>(CONSIGNMENT_BUY_ITEM, eInventorySlot.Invalid);
			player.TempProperties.removeProperty(CONSIGNMENT_BUY_ITEM);

			InventoryItem item = null;

			lock (LockObject())
			{

				if (fromClientSlot != eInventorySlot.Invalid)
				{
					IDictionary<int, InventoryItem> clientInventory = GetClientInventory(player);

					if (clientInventory.ContainsKey((int)fromClientSlot))
					{
						item = clientInventory[(int)fromClientSlot];
					}
				}

				if (item == null)
				{
					ChatUtil.SendErrorMessage(player, "I can't find the item you want to purchase!");
					log.ErrorFormat("{0}:{1} tried to purchase an item from slot {2} for consignment merchant on lot {3} and the item does not exist.", player.Name, player.Client.Account, (int)fromClientSlot, HouseNumber);

					return;
				}

				int sellPrice = item.SellPrice;
				int purchasePrice = sellPrice;

				if (usingMarketExplorer && ServerProperties.Properties.MARKET_FEE_PERCENT > 0)
				{
					purchasePrice += ((purchasePrice * ServerProperties.Properties.MARKET_FEE_PERCENT) / 100);
				}

				lock (player.Inventory)
				{
					if (purchasePrice <= 0)
					{
						ChatUtil.SendErrorMessage(player, "This item can't be purchased!");
						log.ErrorFormat("{0}:{1} tried to purchase {2} for consignment merchant on lot {3} and purchasePrice was {4}.", player.Name, player.Client.Account, item.Name, HouseNumber, purchasePrice);
						return;
					}

					if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
					{
						if (player.BountyPoints < purchasePrice)
						{
							ChatUtil.SendSystemMessage(player, "GameMerchant.OnPlayerBuy.YouNeedBP", purchasePrice);
							return;
						}
					}
					else
					{
						if (player.GetCurrentMoney() < purchasePrice)
						{
							ChatUtil.SendSystemMessage(player, "GameMerchant.OnPlayerBuy.YouNeed", Money.GetString(purchasePrice));
							return;
						}
					}

					eInventorySlot toClientSlot = player.Inventory.FindFirstEmptySlot(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);

					if (toClientSlot == eInventorySlot.Invalid)
					{
						ChatUtil.SendSystemMessage(player, "GameMerchant.OnPlayerBuy.NotInventorySpace", null);
						return;
					}

					if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
					{
						ChatUtil.SendMerchantMessage(player, "GameMerchant.OnPlayerBuy.BoughtBP", item.GetName(1, false), purchasePrice);
						player.BountyPoints -= purchasePrice;
						player.Out.SendUpdatePoints();
					}
					else
					{
						if (player.RemoveMoney(purchasePrice))
						{
							InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, purchasePrice);
							ChatUtil.SendMerchantMessage(player, "GameMerchant.OnPlayerBuy.Bought", item.GetName(1, false), Money.GetString(purchasePrice));
						}
						else
						{
							return;
						}
					}

					TotalMoney += sellPrice;

					if (ServerProperties.Properties.MARKET_ENABLE_LOG)
					{
						log.DebugFormat("CM: {0}:{1} purchased '{2}' for {3} from consignment merchant on lot {4}.", player.Name, player.Client.Account.Name, item.Name, purchasePrice, HouseNumber);
					}

					NotifyObservers(player, this.MoveItemFromObject(player, fromClientSlot, toClientSlot));
				}
			}
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:100,代码来源:ConsignmentMerchant.cs

示例2: RespecDialogResponse

		protected void RespecDialogResponse(GamePlayer player, byte response)
		{

			if (response != 0x01) return; //declined

			int specPoints = 0;
			int realmSpecPoints = 0;

			if (player.TempProperties.getProperty(ALL_RESPEC, false))
			{
				specPoints = player.RespecAll();
				player.TempProperties.removeProperty(ALL_RESPEC);
			}
			if (player.TempProperties.getProperty(DOL_RESPEC, false))
			{
				specPoints = player.RespecDOL();
				player.TempProperties.removeProperty(DOL_RESPEC);
			}
			if (player.TempProperties.getProperty(RA_RESPEC, false))
			{
				realmSpecPoints = player.RespecRealm();
				player.TempProperties.removeProperty(RA_RESPEC);
			}
			if (player.TempProperties.getProperty<object>(LINE_RESPEC, null) != null)
			{
				Specialization specLine = (Specialization)player.TempProperties.getProperty<object>(LINE_RESPEC, null);
				specPoints = player.RespecSingle(specLine);
				player.TempProperties.removeProperty(LINE_RESPEC);
			}
			if (player.TempProperties.getProperty(BUY_RESPEC, false))
			{
				player.TempProperties.removeProperty(BUY_RESPEC);
				if (player.RespecCost >= 0 && player.RemoveMoney(player.RespecCost * 10000))
				{
                    InventoryLogging.LogInventoryAction(player, "(respec)", eInventoryActionType.Merchant, player.RespecCost * 10000);
					player.RespecAmountSingleSkill++;
					player.RespecBought++;
					DisplayMessage(player, "You bought a single line respec!");
				}
				player.Out.SendUpdateMoney();
			}			
			// Assign full points returned
			if (specPoints > 0)
			{
				player.SkillSpecialtyPoints += specPoints;
				player.RemoveAllStyles(); // Kill styles
				player.UpdateSpellLineLevels(false);
				DisplayMessage(player, "You regain " + specPoints + " specialization points!");
			}
			if (realmSpecPoints > 0)
			{
				player.RealmSpecialtyPoints += realmSpecPoints;
				DisplayMessage(player, "You regain " + realmSpecPoints + " realm specialization points!");
			}
			player.RefreshSpecDependantSkills(false);
			// Notify Player of points
			player.Out.SendUpdatePlayerSkills();
			player.Out.SendUpdatePoints();
			player.Out.SendUpdatePlayer();
			player.SendTrainerWindow();
			player.SaveIntoDatabase();
		}
开发者ID:boscorillium,项目名称:dol,代码行数:62,代码来源:respec.cs

示例3: RechargerDialogResponse

        protected void RechargerDialogResponse(GamePlayer player, byte response)
        {
            WeakReference itemWeak =
                (WeakReference)player.TempProperties.getProperty<object>(
                RECHARGE_ITEM_WEAK,
                new WeakRef(null)
                );
            player.TempProperties.removeProperty(RECHARGE_ITEM_WEAK);

            InventoryItem item = (InventoryItem)itemWeak.Target;

            if (item == null || item.SlotPosition == (int)eInventorySlot.Ground
                || item.OwnerID == null || item.OwnerID != player.InternalID)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Scripts.Recharger.RechargerDialogResponse.InvalidItem"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (response != 0x01)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Scripts.Recharger.RechargerDialogResponse.Decline", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            long cost = 0;
            if (item.Charges < item.MaxCharges)
            {
                cost += (item.MaxCharges - item.Charges) * Money.GetMoney(0, 0, 10, 0, 0);
            }

            if (item.Charges1 < item.MaxCharges1)
            {
                cost += (item.MaxCharges1 - item.Charges1) * Money.GetMoney(0, 0, 10, 0, 0);
            }

            if (!player.RemoveMoney(cost))
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Scripts.Recharger.RechargerDialogResponse.NotMoney"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }
            InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, cost);

            player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Scripts.Recharger.RechargerDialogResponse.GiveMoney", GetName(0, false), Money.GetString((long)cost)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            item.Charges = item.MaxCharges;
            item.Charges1 = item.MaxCharges1;

            player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
            SayTo(player, LanguageMgr.GetTranslation(player.Client, "Scripts.Recharger.RechargerDialogResponse.FullyCharged"));
            return;
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:50,代码来源:Recharger.cs

示例4: ChangeEmblem

        /// <summary>
        /// Process for changing an emblem
        /// </summary>
        /// <param name="player"></param>
        /// <param name="oldemblem"></param>
        /// <param name="newemblem"></param>
        public static void ChangeEmblem(GamePlayer player, int oldemblem, int newemblem)
        {
            player.Guild.Emblem = newemblem;
            if (oldemblem != 0)
            {
                player.RemoveMoney(COST_RE_EMBLEM, null);
                InventoryLogging.LogInventoryAction(player, "(GUILD;" + player.GuildName + ")", eInventoryActionType.Other, COST_RE_EMBLEM);
                var objs = GameServer.Database.SelectObjects<InventoryItem>("Emblem = " + GameServer.Database.Escape(oldemblem.ToString()));

                foreach (InventoryItem item in objs)
                {
                    item.Emblem = newemblem;
                    GameServer.Database.SaveObject(item);
                }

                // change guild house emblem

                if (player.Guild.GuildOwnsHouse && player.Guild.GuildHouseNumber > 0)
                {
                    Housing.House guildHouse = Housing.HouseMgr.GetHouse(player.Guild.GuildHouseNumber);

                    if (guildHouse != null)
                    {
                        guildHouse.Emblem = player.Guild.Emblem;
                        guildHouse.SaveIntoDatabase();
                        guildHouse.SendUpdate();
                    }
                }
            }
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:36,代码来源:GuildMgr.cs

示例5: ChangeEmblem

		/// <summary>
		/// Process for changing an emblem
		/// </summary>
		/// <param name="player"></param>
		/// <param name="oldemblem"></param>
		/// <param name="newemblem"></param>
		public static void ChangeEmblem(GamePlayer player, int oldemblem, int newemblem)
		{
			player.Guild.Emblem = newemblem;
			if (oldemblem != 0)
			{
				player.RemoveMoney(COST_RE_EMBLEM, null);
                InventoryLogging.LogInventoryAction(player, "(GUILD;" + player.GuildName + ")", eInventoryActionType.Other, COST_RE_EMBLEM);
				var objs = GameServer.Database.SelectObjects<InventoryItem>("Emblem = " + GameServer.Database.Escape(oldemblem.ToString()));
				
				foreach (InventoryItem item in objs)
				{
					item.Emblem = newemblem;
					GameServer.Database.SaveObject(item);
				}
			}
		}
开发者ID:boscorillium,项目名称:dol,代码行数:22,代码来源:GuildMgr.cs

示例6: HealerDialogResponse

		protected void HealerDialogResponse(GamePlayer player, byte response)
        {
            if (!this.IsWithinRadius(player, WorldMgr.INTERACT_DISTANCE))
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Healer.HealerDialogResponse.Text1",
                    GetName(0, false, player.Client.Account.Language, this)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (response != 0x01) //declined
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Healer.HealerDialogResponse.Text2"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            long cost = player.TempProperties.getProperty<long>(COST_BY_PTS);
            player.TempProperties.removeProperty(COST_BY_PTS);
            int restorePoints = (int)Math.Min(player.TotalConstitutionLostAtDeath, player.GetCurrentMoney() / cost);
            if (restorePoints < 1)
                restorePoints = 1; // at least one
            long totalCost = restorePoints * cost;
            if (player.RemoveMoney(totalCost))
            {
                InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, totalCost);
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Healer.HealerDialogResponse.Text3", this.Name, Money.GetString(totalCost)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                player.TotalConstitutionLostAtDeath -= restorePoints;
                player.Out.SendCharStatsUpdate();
            }
            else
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Healer.HealerDialogResponse.Text4", Money.GetString(totalCost), restorePoints), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
            return;
        }
开发者ID:mynew4,项目名称:DAoC,代码行数:34,代码来源:Healer.cs

示例7: BlacksmithDialogResponse

		protected void BlacksmithDialogResponse(GamePlayer player, byte response)
		{
			WeakReference itemWeak =
				(WeakReference) player.TempProperties.getProperty<object>(
					REPAIR_ITEM_WEAK,
					new WeakRef(null)
				);
			player.TempProperties.removeProperty(REPAIR_ITEM_WEAK);
			InventoryItem item = (InventoryItem)itemWeak.Target;

			if (response != 0x01)
			{
				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language,
				                                                  "Scripts.Blacksmith.AbortRepair", item.Name), eChatType.CT_System,
				                       eChatLoc.CL_SystemWindow);

				return;
			}


			if (item == null || item.SlotPosition == (int)eInventorySlot.Ground
			    || item.OwnerID == null || item.OwnerID != player.InternalID)
			{
				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language,
				                                                  "Scripts.Blacksmith.InvalidItem"), eChatType.CT_System,
				                       eChatLoc.CL_SystemWindow);

				return;
			}

			int ToRecoverCond = item.MaxCondition - item.Condition;

			if (!player.RemoveMoney(item.RepairCost))
			{
                InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, item.RepairCost);
				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language,
				                                                  "Scripts.Blacksmith.NotEnoughMoney"), eChatType.CT_System,
				                       eChatLoc.CL_SystemWindow);

				return;
			}

			player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Scripts.Blacksmith.YouPay",
			                                                  GetName(0, false), Money.GetString(item.RepairCost)), eChatType.CT_System,
			                       eChatLoc.CL_SystemWindow);

			// Items with IsNotLosingDur are not....losing DUR.
			if (ToRecoverCond + 1 >= item.Durability)
			{
				item.Condition = item.Condition + item.Durability;
				item.Durability = 0;
				SayTo(player, LanguageMgr.GetTranslation(player.Client.Account.Language,
				                                         "Scripts.Blacksmith.ObjectRatherOld", item.Name));
			}
			else
			{
				item.Condition = item.MaxCondition;
				if (!item.IsNotLosingDur) item.Durability -= (ToRecoverCond + 1);
			}


			player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
			player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language,
			                                                  "Scripts.Blacksmith.ItsDone", item.Name), eChatType.CT_System,
			                       eChatLoc.CL_SystemWindow);

			return;
		}
开发者ID:Refizul,项目名称:DOL-Kheldron,代码行数:68,代码来源:Blacksmith.cs

示例8: OnPlayerBuy

		/// <summary>
		/// Called when a player buys an item
		/// </summary>
		/// <param name="player">The player making the purchase</param>
		/// <param name="item_slot">slot of the item to be bought</param>
		/// <param name="number">Number to be bought</param>
		/// <param name="TradeItems"></param>
		/// <returns>true if buying is allowed, false if buying should be prevented</returns>
		public static void OnPlayerBuy(GamePlayer player, int item_slot, int number, MerchantTradeItems TradeItems)
		{
			//Get the template
			int pagenumber = item_slot / MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;
			int slotnumber = item_slot % MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;

			ItemTemplate template = TradeItems.GetItem(pagenumber, (eMerchantWindowSlot)slotnumber);
			if (template == null) return;

			//Calculate the amout of items
			int amountToBuy = number;
			if (template.PackSize > 0)
				amountToBuy *= template.PackSize;

			if (amountToBuy <= 0) return;

			//Calculate the value of items
			long totalValue = number * template.Price;

			lock (player.Inventory)
			{

				if (player.GetCurrentMoney() < totalValue)
				{
					player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.YouNeed", Money.GetString(totalValue)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
					return;
				}

				if (!player.Inventory.AddTemplate(GameInventoryItem.Create<ItemTemplate>(template), amountToBuy, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
				{
					player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.NotInventorySpace"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
					return;
				}
				InventoryLogging.LogInventoryAction("(TRADEITEMS;" + TradeItems.ItemsListID + ")", player, eInventoryActionType.Merchant, template, amountToBuy);
				//Generate the buy message
				string message;
				if (amountToBuy > 1)
					message = LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.BoughtPieces", amountToBuy, template.GetName(1, false), Money.GetString(totalValue));
				else
					message = LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.Bought", template.GetName(1, false), Money.GetString(totalValue));

				// Check if player has enough money and subtract the money
				if (!player.RemoveMoney(totalValue, message, eChatType.CT_Merchant, eChatLoc.CL_SystemWindow))
				{
					throw new Exception("Money amount changed while adding items.");
				}
				InventoryLogging.LogInventoryAction(player, "(TRADEITEMS;" + TradeItems.ItemsListID + ")", eInventoryActionType.Merchant, totalValue);
			}
		}
开发者ID:boscorillium,项目名称:dol,代码行数:57,代码来源:GameMerchant.cs

示例9: RemoveUsedMaterials

		/// <summary>
		/// Remove used raw material from player inventory
		/// </summary>
		/// <param name="player"></param>
		/// <param name="recipe"></param>
		/// <returns></returns>
		public virtual bool RemoveUsedMaterials(GamePlayer player, DBCraftedItem recipe, IList<DBCraftedXItem> rawMaterials)
		{
			Dictionary<int, int?> dataSlots = new Dictionary<int, int?>(10);

			lock (player.Inventory)
			{
				foreach (DBCraftedXItem material in rawMaterials)
				{

// WHRIA easy craft

                    if (material.IngredientId_nb=="whria_gold")
                    {
                        if (player.GetCurrentMoney() > 10000 * material.Count)
                        {
                            player.RemoveMoney(10000 * material.Count);
                            continue;
                        }
                    }
                    if (material.IngredientId_nb=="whria_silver")
                    {
                        if (player.GetCurrentMoney() > 100 * material.Count)
                        {
                            player.RemoveMoney(100 * material.Count);
                            continue;
                        }
                    }
// END

					ItemTemplate template = GameServer.Database.FindObjectByKey<ItemTemplate>(material.IngredientId_nb);

					if (template == null)
					{
						player.Out.SendMessage("Can't find a material (" + material.IngredientId_nb + ") needed for this recipe.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
						log.Error("RemoveUsedMaterials: Cannot find raw material ItemTemplate: " + material.IngredientId_nb + " needed for recipe: " + recipe.CraftedItemID);
						return false;
					}

					bool result = false;
					int count = material.Count;

					foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
					{
						if (item != null && item.Name == template.Name)
						{
							if (item.Count >= count)
							{
								if (item.Count == count)
								{
									dataSlots.Add(item.SlotPosition, null);
								}
								else
								{
									dataSlots.Add(item.SlotPosition, count);
								}
								result = true;
								break;
							}
							else
							{
								dataSlots.Add(item.SlotPosition, null);
								count -= item.Count;
							}
						}
					}
					if (result == false)
					{
						return false;
					}
				}
			}

			player.Inventory.BeginChanges();
			Dictionary<int, int?>.Enumerator enumerator = dataSlots.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<int, int?> de = enumerator.Current;
				InventoryItem item = player.Inventory.GetItem((eInventorySlot)de.Key);
				if (item != null)
				{
					if (!de.Value.HasValue)
					{
						player.Inventory.RemoveItem(item);
					}
					else
					{
						player.Inventory.RemoveCountFromStack(item, de.Value.Value);
					}
					InventoryLogging.LogInventoryAction(player, "(craft)", eInventoryActionType.Craft, item.Template, de.Value.HasValue ? de.Value.Value : item.Count);
				}
			}
			player.Inventory.CommitChanges();

			return true;//all raw material removed and item created
//.........这里部分代码省略.........
开发者ID:mynew4,项目名称:DAoC,代码行数:101,代码来源:AbstractCraftingSkill.cs

示例10: OnPlayerBuy

        public override void OnPlayerBuy(GamePlayer player, int item_slot, int number)
        {
            if (isBounty == true) //...pay with Bounty Points.
            {
                int pagenumber = item_slot / MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;
                int slotnumber = item_slot % MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;

                ItemTemplate template = this.TradeItems.GetItem(pagenumber, (eMerchantWindowSlot)slotnumber);
                if (template == null) return;

                int amountToBuy = number;
                if (template.PackSize > 0)
                    amountToBuy *= template.PackSize;

                if (amountToBuy <= 0) return;

                long totalValue = number * (template.Price);

                lock (player.Inventory)
                {
                    if (player.BountyPoints < totalValue)
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.YouNeedBP", totalValue), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (!player.Inventory.AddTemplate(GameInventoryItem.Create<ItemTemplate>(template), amountToBuy, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.NotInventorySpace"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    InventoryLogging.LogInventoryAction(this, player, eInventoryActionType.Merchant, template, amountToBuy);

                    string message;
                    if (number > 1)
                        message = LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.BoughtPiecesBP", totalValue, template.GetName(1, false));
                    else
                        message = LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.BoughtBP", template.GetName(1, false), totalValue);
                    player.BountyPoints -= totalValue;
                    player.Out.SendUpdatePoints();
                    player.Out.SendMessage(message, eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
                }
            }
            if (isBounty == false) //...pay with Money.
            {
                int pagenumber = item_slot / MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;
                int slotnumber = item_slot % MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;

                ItemTemplate template = this.TradeItems.GetItem(pagenumber, (eMerchantWindowSlot)slotnumber);
                if (template == null) return;

                int amountToBuy = number;
                if (template.PackSize > 0)
                    amountToBuy *= template.PackSize;

                if (amountToBuy <= 0) return;

                long totalValue = number * template.Price;

                lock (player.Inventory)
                {
                    if (player.GetCurrentMoney() < totalValue)
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.YouNeed", Money.GetString(totalValue)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    if (!player.Inventory.AddTemplate(GameInventoryItem.Create<ItemTemplate>(template), amountToBuy, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.NotInventorySpace"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    InventoryLogging.LogInventoryAction(this, player, eInventoryActionType.Merchant, template, amountToBuy);

                    string message;
                    if (amountToBuy > 1)
                        message = LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.BoughtPieces", amountToBuy, template.GetName(1, false), Money.GetString(totalValue));
                    else
                        message = LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.Bought", template.GetName(1, false), Money.GetString(totalValue));

                    if (!player.RemoveMoney(totalValue, message, eChatType.CT_Merchant, eChatLoc.CL_SystemWindow))
                    {
                        throw new Exception("Money amount changed while adding items.");
                    }
                    InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, totalValue);
                }
            }
            return;
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:88,代码来源:BuffMerchant.cs

示例11: Invoke

		public void Invoke(GamePlayer player, int payType, GameKeepHookPoint hookpoint, GameKeepComponent component)
		{
			if (!hookpoint.IsFree)
			{
				player.Out.SendMessage("The hookpoint is already used!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
				return;
			}
			//1=or 2=BP 3=GuildBP 4=contract
			//todo enum
			switch (payType)
			{
				case 1:
					{
						if (!player.RemoveMoney(Gold * 100 * 100, "You buy " + this.GetName(1, false) + "."))
						{
                            InventoryLogging.LogInventoryAction(player, "(keep)", eInventoryActionType.Merchant, Gold * 10000);
							player.Out.SendMessage("You dont have enough money!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
							return;
						}
					} break;
				case 2:
					{
						if (!player.RemoveBountyPoints(Gold, "You buy " + this.GetName(1, false) + "."))
						{
							player.Out.SendMessage("You dont have enough bounty point!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
							return;
						}
					} break;
				case 3:
					{
						if (player.Guild == null) return;
						if (!player.Guild.RemoveBountyPoints(Gold))
						{
							player.Out.SendMessage("You dont have enough bounty point!", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
							return;
						}
						else
							player.Out.SendMessage("You buy " + this.GetName(1, false) + ".", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);

					} break;
				case 4:
					{
						player.Out.SendMessage("NOT IMPLEMENTED YET, SORRY", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
						return;
					}

			}

			GameLiving hookPointObj = CreateHPInstance(this.GameObjectType);
			if (hookPointObj == null) return;
			//use default value so no need to load
			//hookPointObj.LoadFromDatabase(this.ObjectTemplate);
			hookPointObj.CurrentRegion = player.CurrentRegion;
			hookPointObj.Realm = hookpoint.Component.Keep.Realm;

			if (hookPointObj is GameSiegeWeapon)
				((GameSiegeWeapon)hookPointObj).EnableToMove = false;
			hookPointObj.X = hookpoint.X;
			hookPointObj.Y = hookpoint.Y;
			hookPointObj.Z = hookpoint.Z;
			hookPointObj.Heading = hookpoint.Heading;

			if (hookPointObj is GameSiegeWeapon)
				(hookPointObj as GameSiegeWeapon).HookPoint = hookpoint;
			if (hookPointObj is IKeepItem)
				(hookPointObj as IKeepItem).Component = component;
			if (hookPointObj is GameSiegeCauldron)
				(hookPointObj as GameSiegeCauldron).Component = component;
			if (hookPointObj is GameKeepGuard)
			{
				(hookPointObj as GameKeepGuard).HookPoint = hookpoint;
				Keeps.TemplateMgr.RefreshTemplate(hookPointObj as GameKeepGuard);
			}
			if (hookPointObj is GameNPC)
			{
				((GameNPC)hookPointObj).RespawnInterval = -1;//do not respawn
			}
			hookPointObj.AddToWorld();
			if (hookPointObj is GameKeepGuard)
			{
				(hookPointObj as GameKeepGuard).Component.Keep.Guards.Add(hookPointObj.ObjectID, hookPointObj);
				((GameNPC)hookPointObj).RespawnInterval = Util.Random(10, 30) * 60 * 1000;
			}
			hookpoint.Object = hookPointObj;

			//create the db entry
			Database.DBKeepHookPointItem item = new DOL.Database.DBKeepHookPointItem(component.Keep.KeepID, component.ID, hookpoint.ID, GameObjectType);
			GameServer.Database.AddObject(item);
		}
开发者ID:boscorillium,项目名称:dol,代码行数:89,代码来源:HookPointInventory.cs

示例12: LastNameDialogResponse

		protected void LastNameDialogResponse(GamePlayer player, byte response)
		{
			string NewLastName =
				(string)player.TempProperties.getProperty<object>(
					LASTNAME_WEAK,
					String.Empty
				);
			player.TempProperties.removeProperty(LASTNAME_WEAK);

			if (!(player.TargetObject is NameRegistrar))
			{
				player.Out.SendMessage("You must select a name registrar to set your last name with!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
				return;
			}

			if ( !player.IsWithinRadius( player.TargetObject, WorldMgr.INTERACT_DISTANCE ) )
			{
				player.Out.SendMessage("You are too far away to interact with " + player.TargetObject.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
				return;
			}

			/* Check money only if your lastname is not blank */
			if (player.LastName != "" && player.GetCurrentMoney() < Money.GetMoney(0, 0, LASTNAME_FEE, 0, 0))
			{
				player.Out.SendMessage("Changing your last name costs " + Money.GetString(Money.GetMoney(0, 0, LASTNAME_FEE, 0, 0)) + "!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
				return;
			}

			if (response != 0x01)
			{
				player.Out.SendMessage("You decline to " + (NewLastName != "" ? ("take " + NewLastName + " as") : "clear") + " your last name.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
				return;
			}

			/* Remove money only if your lastname is not blank and is different from the previous one */
            if (player.LastName != "" && player.LastName != NewLastName)
            {
                player.RemoveMoney(Money.GetMoney(0, 0, LASTNAME_FEE, 0, 0), null);
                InventoryLogging.LogInventoryAction(player, player.TargetObject, eInventoryActionType.Merchant, LASTNAME_FEE * 10000);
            }

		    /* Set the new lastname */
			player.LastName = NewLastName;
			player.Out.SendMessage("Your last name has been " + (NewLastName != "" ? ("set to " + NewLastName) : "cleared") + "!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
		}
开发者ID:mynew4,项目名称:DOLSharp,代码行数:45,代码来源:lastname.cs

示例13: EmblemerDialogResponse

		protected void EmblemerDialogResponse(GamePlayer player, byte response)
		{
			WeakReference itemWeak =
				(WeakReference) player.TempProperties.getProperty<object>(
					EMBLEMIZE_ITEM_WEAK,
					new WeakRef(null)
					);
			player.TempProperties.removeProperty(EMBLEMIZE_ITEM_WEAK);

			if (response != 0x01)
				return; //declined

			InventoryItem item = (InventoryItem) itemWeak.Target;

			if (item == null || item.SlotPosition == (int) eInventorySlot.Ground
				|| item.OwnerID == null || item.OwnerID != player.InternalID)
			{
				player.Out.SendMessage("Invalid item.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
				return;
			}

			if (!player.RemoveMoney(EMBLEM_COST))
			{
                InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, EMBLEM_COST);
				player.Out.SendMessage("You don't have enough money.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
				return;
			}

			item.Emblem = player.Guild.Emblem;
			player.Out.SendInventoryItemsUpdate(new InventoryItem[] {item});
			if (item.SlotPosition < (int) eInventorySlot.FirstBackpack)
				player.UpdateEquipmentAppearance();
			SayTo(player, eChatLoc.CL_ChatWindow, "I have put an emblem on your item.");
			return;
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:35,代码来源:EmblemNPC.cs

示例14: BuyLot

		private void BuyLot(GamePlayer player, byte response)
		{
			if (response != 0x01) 
				return;

			lock (DatabaseItem) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
			{
				if (!string.IsNullOrEmpty(DatabaseItem.OwnerID))
					return;

				if (HouseMgr.GetHouseNumberByPlayer(player) != 0 && player.Client.Account.PrivLevel != (int)ePrivLevel.Admin)
				{
					ChatUtil.SendMerchantMessage(player, "You already own another lot or house (Number " + HouseMgr.GetHouseNumberByPlayer(player) + ").");
					return;
				}

			    long totalCost = HouseTemplateMgr.GetLotPrice(DatabaseItem);
				if (player.RemoveMoney(totalCost, "You just bought this lot for {0}.",
				                       eChatType.CT_Merchant, eChatLoc.CL_SystemWindow))
				{
                    InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, totalCost);
					DatabaseItem.LastPaid = DateTime.Now;
					DatabaseItem.OwnerID = player.DBCharacter.ObjectId;
					CreateHouse(player, 0);
				}
				else
				{
					ChatUtil.SendMerchantMessage(player, "You dont have enough money!");
				}
			}
		}
开发者ID:boscorillium,项目名称:dol,代码行数:31,代码来源:LotMarker.cs

示例15: OnPlayerBuy

        /// <summary>
        /// The Player is buying an Item from the merchant
        /// </summary>
        /// <param name="player"></param>
        /// <param name="playerInventory"></param>
        /// <param name="fromSlot"></param>
        /// <param name="toSlot"></param>
        public void OnPlayerBuy(GamePlayer player, IGameInventory playerInventory, eInventorySlot fromSlot,
                                eInventorySlot toSlot, bool byMarketExplorer)
        {
            IDictionary<int, InventoryItem> inventory = ConInventory;

            if ((int)fromSlot >= (int)eInventorySlot.Consignment_First)
            {
                fromSlot = (eInventorySlot)(RecalculateSlot((int)fromSlot));
            }

            InventoryItem fromItem = inventory[(int)fromSlot];
            if (fromItem == null)
                return;

            int totalValue = fromItem.SellPrice;
            int orgValue = totalValue;
            if (byMarketExplorer)
            {
                int additionalfee = (totalValue * 20) / 100;
                totalValue += additionalfee;
            }

            lock (player.Inventory)
            {
                if (totalValue == 0)
                {
                    player.Out.SendMessage("This Item can not be bought.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (ConsignmentMoney.UseBP)
                {
                    if (player.BountyPoints < totalValue)
                    {
                        ChatUtil.SendSystemMessage(player, "GameMerchant.OnPlayerBuy.YouNeedBP", totalValue);
                        return;
                    }
                }
                else
                {
                    if (player.GetCurrentMoney() < totalValue)
                    {
                        ChatUtil.SendSystemMessage(player, "GameMerchant.OnPlayerBuy.YouNeed", Money.GetString(totalValue));
                        return;
                    }
                }

                if (player.Inventory.FindFirstEmptySlot(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack) ==
                    eInventorySlot.Invalid)
                {
                    ChatUtil.SendSystemMessage(player, "GameMerchant.OnPlayerBuy.NotInventorySpace", null);
                    return;
                }

                if (ConsignmentMoney.UseBP) // we buy with Bountypoints
                {
                    ChatUtil.SendMerchantMessage(player, "GameMerchant.OnPlayerBuy.BoughtBP", fromItem.GetName(1, false), totalValue);
                    player.BountyPoints -= totalValue;
                    player.Out.SendUpdatePoints();
                }
                else //we buy with money
                {
                    if (player.RemoveMoney(totalValue))
                    {
                        InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, totalValue);
                        ChatUtil.SendMerchantMessage(player, "GameMerchant.OnPlayerBuy.Bought", fromItem.GetName(1, false),
                                                     Money.GetString(totalValue));
                    }
                }

                TotalMoney += orgValue;

                NotifyObservers(MoveItemFromMerchant(player, playerInventory, fromSlot, toSlot));
            }
        }
开发者ID:boscorillium,项目名称:dol,代码行数:82,代码来源:ConsignmentMerchant.cs


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