本文整理汇总了C#中Weapon.getCost方法的典型用法代码示例。如果您正苦于以下问题:C# Weapon.getCost方法的具体用法?C# Weapon.getCost怎么用?C# Weapon.getCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon.getCost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: returnItem
/// <summary>
/// Returns an item. Has no effect if the item is not in purchased list.
/// </summary>
/// <param name='w'>
/// The weapon to return.
/// </param>
public void returnItem(Weapon w)
{
int amount;
if (purchasedItems.TryGetValue (w, out amount) && amount > 0)
{
purchasedItems[w]--;
if (purchasedItems[w] == 0)
purchasedItems.Remove(w);
gameManager.Instance.earnMoney(w.getCost());
storageUsed -= w.getStorageSpace();
}
}
示例2: purchaseItem
/// <summary>
/// Purchases an item. Does not check if there is enough money, storage space, or items manufactured.
/// This is the responsibility of the caller.
/// </summary>
/// <param name='w'>
/// The weapon to purchase.
/// </param>
public void purchaseItem(Weapon w)
{
if (purchasedItems.ContainsKey(w))
purchasedItems[w]++;
else
purchasedItems.Add(w, 1);
gameManager.Instance.spendMoney(w.getCost());
storageUsed += w.getStorageSpace();
}