本文整理汇总了C#中UserItem.Price方法的典型用法代码示例。如果您正苦于以下问题:C# UserItem.Price方法的具体用法?C# UserItem.Price怎么用?C# UserItem.Price使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserItem
的用法示例。
在下文中一共展示了UserItem.Price方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuyItem
private void BuyItem()
{
if (SelectedItem == null) return;
if (SelectedItem.StackSize > 1)
{
UserItem temp = new UserItem(SelectedItem) { Count = SelectedItem.StackSize };
if (temp.Price() > GameScene.Gold)
{
temp.Count = GameScene.Gold / SelectedItem.Price;
if (temp.Count == 0)
{
GameScene.Scene.ChatDialog.ReceiveChat("You do no have enough Gold.", ChatType.System);
return;
}
}
MapObject.User.GetMaxGain(temp);
if (temp.Count == 0) return;
MirAmountBox amountBox = new MirAmountBox("Purchase Amount:", SelectedItem.Image, temp.Count);
amountBox.OKButton.Click += (o, e) =>
{
if (amountBox.Amount > 0)
{
Network.Enqueue(new C.BuyItem { ItemIndex = SelectedItem.Index, Count = amountBox.Amount });
}
};
amountBox.Show();
}
else
{
if (SelectedItem.Price > GameScene.Gold)
{
GameScene.Scene.ChatDialog.ReceiveChat("You do not have enough gold.", ChatType.System);
return;
}
if (SelectedItem.Weight > (MapObject.User.MaxBagWeight - MapObject.User.CurrentBagWeight))
{
GameScene.Scene.ChatDialog.ReceiveChat("You do no have enough weight.", ChatType.System);
return;
}
for (int i = 0; i < MapObject.User.Inventory.Length; i++)
{
if (MapObject.User.Inventory[i] == null) break;
if (i == MapObject.User.Inventory.Length - 1)
{
GameScene.Scene.ChatDialog.ReceiveChat("Cannot purchase any more items.", ChatType.System);
return;
}
}
Network.Enqueue(new C.BuyItem { ItemIndex = SelectedItem.Index, Count = 1 });
}
}