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


C# GamePlayer.GetCurrentMoney方法代码示例

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


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

示例1: EnchanterDialogResponse

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


			if (response != 0x01 || !this.IsWithinRadius(player, WorldMgr.INTERACT_DISTANCE))
				return;

			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.Account.Language, "Enchanter.EnchanterDialogResponse.Text1"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
			}

			long Fee = CalculEnchantPrice(item);

			if (player.GetCurrentMoney() < Fee)
			{
                SayTo(player, eChatLoc.CL_SystemWindow, LanguageMgr.GetTranslation(player.Client.Account.Language, "Enchanter.EnchanterDialogResponse.Text2", Money.GetString(Fee)));
                return;
			}
			if (item.Level < 50)
				item.Bonus = BONUS_TABLE[(item.Level/5) - 2];
			else
				item.Bonus = 35;

            item.Name = LanguageMgr.GetTranslation(player.Client.Account.Language, "Enchanter.EnchanterDialogResponse.Text3") + " " + item.Name;
            player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
            player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Enchanter.EnchanterDialogResponse.Text4", 
                                    GetName(0, false, player.Client.Account.Language, this), Money.GetString(Fee)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            player.RemoveMoney(Fee, null);
            InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, Fee);
            SayTo(player, eChatLoc.CL_SystemWindow, LanguageMgr.GetTranslation(player.Client.Account.Language, "Enchanter.EnchanterDialogResponse.Text5", item.GetName(1, false)));
            return;
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:42,代码来源:Enchanter.cs

示例2: Show_Info

        private void Show_Info(GamePlayer player, GameClient client)
        {
            var text = new List<string>();
            text.Add(" ");
            text.Add("PLAYER INFORMATION (Client # " + player.Client.SessionID + ", " + player.GetType().FullName + ")");
            text.Add("  - Name Lastname : " + player.Name + " " + player.LastName);
            text.Add("  - Realm Level Class : " + GlobalConstants.RealmToName(player.Realm) + " " + player.Level + " " + player.CharacterClass.Name + " (" + player.CharacterClass.ID + ")");
            text.Add("  - Guild : " + player.GuildName + " " + (player.GuildRank != null ? "Rank: " + player.GuildRank.RankLevel.ToString() : ""));
            text.Add("  - XPs/RPs/BPs : " + player.Experience + " xp, " + player.RealmPoints + " rp, " + player.BountyPoints + " bp");

            if (player.DamageRvRMemory > 0)
                text.Add("  - Damage RvR Memory: " + player.DamageRvRMemory);

            if (player.Champion)
            {
                text.Add("  - Champion :  CL " + player.ChampionLevel + ", " + player.ChampionExperience + " clxp");

                string activeBags = "None";
                if (player.ActiveSaddleBags != 0)
                {
                    if (player.ActiveSaddleBags == (byte)GamePlayer.eHorseSaddleBag.All)
                    {
                        activeBags = "All";
                    }
                    else
                    {
                        activeBags = "";

                        if ((player.ActiveSaddleBags & (byte)GamePlayer.eHorseSaddleBag.LeftFront) > 0)
                        {
                            if (activeBags != "")
                                activeBags += ", ";

                            activeBags += "LeftFront";
                        }
                        if ((player.ActiveSaddleBags & (byte)GamePlayer.eHorseSaddleBag.RightFront) > 0)
                        {
                            if (activeBags != "")
                                activeBags += ", ";

                            activeBags += "RightFront";
                        }
                        if ((player.ActiveSaddleBags & (byte)GamePlayer.eHorseSaddleBag.LeftRear) > 0)
                        {
                            if (activeBags != "")
                                activeBags += ", ";

                            activeBags += "LeftRear";
                        }
                        if ((player.ActiveSaddleBags & (byte)GamePlayer.eHorseSaddleBag.RightRear) > 0)
                        {
                            if (activeBags != "")
                                activeBags += ", ";

                            activeBags += "RightRear";
                        }
                    }
                }

                text.Add(string.Format("  - ActiveSaddleBags : {0} (0x{1:X2})", activeBags, player.ActiveSaddleBags));
            }
            else
            {
                text.Add("  - Champion :  Not Started");
            }
            if (player.MLGranted)
            {
                text.Add("  - Master Levels :  ML " + player.MLLevel + ", " + player.MLExperience + " mlxp , MLLine " + player.MLLine);
            }
            else
            {
                text.Add("  - Master Levels :  Not Started");
            }
            text.Add("  - Craftingskill : " + player.CraftingPrimarySkill + "");
            text.Add("  - Money : " + Money.GetString(player.GetCurrentMoney()) + "");
            text.Add("  - Model ID : " + player.Model);
            text.Add("  - AFK Message: " + player.TempProperties.getProperty<string>(GamePlayer.AFK_MESSAGE) + "");
            text.Add(" ");
            text.Add("HOUSE INFORMATION ");
            text.Add("  - Personal House : " + HouseMgr.GetHouseNumberByPlayer(player));
            if (player.CurrentHouse != null && player.CurrentHouse.HouseNumber > 0)
                text.Add("  - Current House : " + player.CurrentHouse.HouseNumber);
            text.Add("  - In House : " + player.InHouse);
            text.Add(" ");
            text.Add("ACCOUNT INFORMATION ");
            text.Add("  - Account Name & IP : " + player.Client.Account.Name + " from " + player.Client.Account.LastLoginIP);
            text.Add("  - Priv. Level : " + player.Client.Account.PrivLevel);
            text.Add("  - Client Version: " + player.Client.Account.LastClientVersion);
            text.Add(" ");
            text.Add("CHARACTER STATS ");

            String sCurrent = "";
            String sTitle = "";
            int cnt = 0;

            for (eProperty stat = eProperty.Stat_First; stat <= eProperty.Stat_Last; stat++, cnt++)
            {
                sTitle += GlobalConstants.PropertyToName(stat) + "/";
                sCurrent += player.GetModified(stat) + "/";
                if (cnt == 3)
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:101,代码来源:Player.cs

示例3: EmblemChange

		/// <summary>
		/// method to handle the emblem change
		/// </summary>
		/// <param name="player"></param>
		/// <param name="reponse"></param>
		public static void EmblemChange(GamePlayer player, byte reponse)
		{
			if (reponse != 0x01)
				return;
			if (player.TargetObject is EmblemNPC == false)
			{
				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Scripts.Player.Guild.EmblemNeedNPC"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
				return;
			}
			if (player.GetCurrentMoney() < GuildMgr.COST_RE_EMBLEM) //200 gold to re-emblem
			{
				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Scripts.Player.Guild.EmblemNeedGold"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
				return;
			}
			player.Out.SendEmblemDialogue();
			player.Guild.UpdateGuildWindow();
		}
开发者ID:boscorillium,项目名称:dol,代码行数:22,代码来源:guild.cs

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

示例5: Show_Inventory

        private void Show_Inventory(GamePlayer player, GameClient client, string limitType)
        {
            var text = new List<string>();
            text.Add("  - Name Lastname : " + player.Name + " " + player.LastName);
            text.Add("  - Realm Level Class : " + GlobalConstants.RealmToName(player.Realm) + " " + player.Level + " " +
                     player.CharacterClass.Name);
            text.Add(" ");
            text.Add(Money.GetShortString(player.GetCurrentMoney()));
            text.Add(" ");

            bool limitShown = false;

            if (limitType == "" || limitType == "wear")
            {
                limitShown = true;
                text.Add("  ----- Wearing:");

                foreach (InventoryItem item in player.Inventory.EquippedItems)
                {
                    text.Add("     [" + GlobalConstants.SlotToName(item.Item_Type) + "] " + item.Name + " (" + item.Id_nb + ")");
                }
                text.Add(" ");
            }

            if (limitType == "" || limitType == "bag")
            {
                limitShown = true;
                text.Add("  ----- Backpack:");
                foreach (InventoryItem item in player.Inventory.AllItems)
                {
                    if (item.SlotPosition >= (int)eInventorySlot.FirstBackpack &&
                        item.SlotPosition <= (int)eInventorySlot.LastBackpack)
                    {
                        text.Add(item.Count.ToString("000") + " " + item.Name + " (" + item.Id_nb + ")");
                    }
                }
            }

            if (limitType == "vault")
            {
                limitShown = true;
                text.Add("  ----- Vault:");
                foreach (InventoryItem item in player.Inventory.AllItems)
                {
                    if (item.SlotPosition >= (int)eInventorySlot.FirstVault && item.SlotPosition <= (int)eInventorySlot.LastVault)
                    {
                        text.Add(item.Count.ToString("000") + " " + item.Name + " (" + item.Id_nb + ")");
                    }
                }
            }

            if (limitType == "house")
            {
                limitShown = true;
                text.Add("  ----- Housing:");
                foreach (InventoryItem item in player.Inventory.AllItems)
                {
                    if (item.SlotPosition >= (int)eInventorySlot.HouseVault_First &&
                        item.SlotPosition <= (int)eInventorySlot.HouseVault_Last)
                    {
                        text.Add(item.Count.ToString("000") + " " + item.Name + " (" + item.Id_nb + ")");
                    }
                }
            }

            if (limitType == "cons")
            {
                limitShown = true;
                text.Add("  ----- GameConsignmentMerchant:");
                foreach (InventoryItem item in player.Inventory.AllItems)
                {
                    if (item.SlotPosition >= (int)eInventorySlot.Consignment_First &&
                        item.SlotPosition <= (int)eInventorySlot.Consignment_Last)
                    {
                        text.Add(item.Count.ToString("000") + " " + item.Name + " (" + item.Id_nb + ")");
                    }
                }
            }

            if (!limitShown)
            {
                text.Add("Unkown command.  Use wear | bag | vault | house | cons");
            }

            client.Out.SendCustomTextWindow("PLAYER INVENTORY LISTING", text);
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:86,代码来源:Player.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: 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

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

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

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

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

示例12: SetSpeed

        public void SetSpeed(GamePlayer player, int speed)
        {
            InventoryItem item = player.TempProperties.getProperty<InventoryItem>(EFFECTNPC_ITEM_WEAK);

            player.TempProperties.removeProperty(EFFECTNPC_ITEM_WEAK);

            if (item == null)
            {
                SendReply(player, "I cannot work on anything else than weapons.");
                return;
            }
            if ((item.Object_Type < 1 || item.Object_Type > 28) && item.Object_Type != 42)
            {
                SendReply(player, "I cannot work on anything else than weapons.");
                return;
            }

            if (speed > 43 && item.Item_Type != 12 && item.Item_Type != 13)
            {
                SendReply(player, "This Item cannot be that slow.");
                return;
            }

            if (speed < 39 && item.Item_Type == 12)
            {
                SendReply(player, "This Item cannot be that fast.");
                return;
            }

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

            if (player.GetCurrentMoney() <= Price)
            {
                SayTo(player, eChatLoc.CL_PopupWindow, "I need " + Money.GetString(Price) + " to enchant that.");
                return;
            }
            /*
            if (item.Name.StartsWith(Prefix0) || item.Name.StartsWith(Prefix1) || item.Name.StartsWith(Prefix2) ||
                item.Name.StartsWith(Prefix3) || item.Name.StartsWith(Prefix4) || item.Name.StartsWith(Prefix5) ||
                item.Name.StartsWith(Prefix6))
            {
                ItemTemplate item2 = (ItemTemplate)GameServer.Database.FindObjectByKey(typeof(ItemTemplate), item.Id_nb);
                if (item2 != null)
                {
                    item.Name = item2.Name;
                }
            }
            */
            m_timer.Enqueue(new RegionTimer(this, new RegionTimerCallback(Effect), duration));
            castplayer.Enqueue(player);

            player.Inventory.RemoveItem(item);
            ItemUnique unique = new ItemUnique(item.Template);
            unique.SPD_ABS = speed;
            GameServer.Database.AddObject(unique);

            InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique);
            player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem);
            player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem });

            SendReply(player, "It has been quite a piece of work but now it's done.\n May the " + item.Name + " aid you on your ways.");
            foreach (GamePlayer visplayer in this.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                visplayer.Out.SendSpellCastAnimation(this, spell, 30);
            }
        }
开发者ID:mynew4,项目名称:DAoC,代码行数:71,代码来源:effectNPC.cs

示例13: SetEffect

        public void SetEffect(GamePlayer player, int effect)
        {
            if (player == null)
                return;

            InventoryItem item = player.TempProperties.getProperty<InventoryItem>(EFFECTNPC_ITEM_WEAK);
            player.TempProperties.removeProperty(EFFECTNPC_ITEM_WEAK);

            if (item == null)
                return;

            if (item.Object_Type < 1 || item.Object_Type > 26)
            {
                SendReply(player, "I cannot work on anything else than weapons.");
                return;
            }

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

            if (player.GetCurrentMoney() <= Price)
            {
                SayTo(player, eChatLoc.CL_PopupWindow, "I need " + Money.GetString(Price) + " to enchant that.");
                return;
            }
            /*
            if (item.Name.StartsWith(Prefix0) || item.Name.StartsWith(Prefix1) || item.Name.StartsWith(Prefix2) ||
                item.Name.StartsWith(Prefix3) || item.Name.StartsWith(Prefix4) || item.Name.StartsWith(Prefix5) ||
                item.Name.StartsWith(Prefix6))
            {
                ItemTemplate item2 = (ItemTemplate)GameServer.Database.FindObjectByKey(typeof(ItemTemplate), item.Id_nb);
                if (item2 != null)
                {
                    item.Name = item2.Name;
                }
            }
            */
            m_timer.Enqueue(new RegionTimer(this, new RegionTimerCallback(Effect), duration));
            castplayer.Enqueue(player);

            /*  Chance = rnd.Next(1, 100);
              if (effect == 0) item.Name = Prefix0 + item.Name;
              if (Chance >= 0 && Chance <= 25 && effect != 0) item.Name = Prefix1 + item.Name;
              if (Chance >= 25 && Chance <= 50 && effect != 0) item.Name = Prefix2 + item.Name;
              if (Chance >= 50 && Chance <= 75 && effect != 0) item.Name = Prefix3 + item.Name;
              if (Chance >= 75 && Chance <= 100 && effect != 0) item.Name = Prefix4 + item.Name;
              */

            player.Inventory.RemoveItem(item);
            ItemUnique unique = new ItemUnique(item.Template);
            unique.Effect = effect;
            GameServer.Database.AddObject(unique);

            InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique);
            player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem);
            player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem });

            SendReply(player, "May the " + item.Name + " lead you to a bright future.");
            foreach (GamePlayer visplayer in this.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                visplayer.Out.SendSpellCastAnimation(this, spell, 30);
            }
        }
开发者ID:mynew4,项目名称:DAoC,代码行数:67,代码来源:effectNPC.cs

示例14: SetColor

        public void SetColor(GamePlayer player, int color)
        {
            InventoryItem item = player.TempProperties.getProperty<InventoryItem>(EFFECTNPC_ITEM_WEAK);

            player.TempProperties.removeProperty(EFFECTNPC_ITEM_WEAK);

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

            if (item.Object_Type == 41 || item.Object_Type == 43 || item.Object_Type == 44 ||
               item.Object_Type == 46)
            {
                SendReply(player, "You can't dye that.");
            }
            if (player.GetCurrentMoney() <= Price)
            {
                SayTo(player, eChatLoc.CL_PopupWindow, "I need " + Money.GetString(Price) + " to enchant that.");
                return;
            }
            m_timer.Enqueue(new RegionTimer(this, new RegionTimerCallback(Effect), duration));
            castplayer.Enqueue(player);

            player.Inventory.RemoveItem(item);
            ItemUnique unique = new ItemUnique(item.Template);
            unique.Color = color;
            GameServer.Database.AddObject(unique);

            InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique);
            player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem);
            player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem });

            SendReply(player, "Look at that, the color has come out beautifully. Wear it with pride.");

            foreach (GamePlayer visplayer in this.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                visplayer.Out.SendSpellCastAnimation(this, spell, 30);
            }
        }
开发者ID:mynew4,项目名称:DAoC,代码行数:42,代码来源:effectNPC.cs


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