本文整理汇总了C#中PlayerObject.GainItem方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerObject.GainItem方法的具体用法?C# PlayerObject.GainItem怎么用?C# PlayerObject.GainItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject.GainItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Harvest
public override bool Harvest(PlayerObject player)
{
if (RemainingSkinCount == 0)
{
for (int i = _drops.Count - 1; i >= 0; i--)
if (player.CanGainItem(_drops[i]))
{
player.GainItem(_drops[i]);
_drops.RemoveAt(i);
}
if (_drops.Count == 0)
{
Harvested = true;
_drops = null;
Broadcast(new S.ObjectHarvested { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
}
else player.ReceiveChat("You cannot carry anymore.", ChatType.System);
return true;
}
if (--RemainingSkinCount > 0) return true;
_drops = new List<UserItem>();
for (int i = 0; i < Info.Drops.Count; i++)
{
DropInfo drop = Info.Drops[i];
int rate = (int)(drop.Chance / Settings.DropRate); if (rate < 1) rate = 1;
if (drop.Gold > 0 || Envir.Random.Next(rate) != 0) continue;
UserItem item = Envir.CreateDropItem(drop.Item);
if (item == null) continue;
if (item.Info.Type == ItemType.Meat)
item.CurrentDura = (ushort)Math.Max(0, item.CurrentDura + Quality);
_drops.Add(item);
}
if (_drops.Count == 0)
{
player.ReceiveChat("Nothing was found.", ChatType.System);
Harvested = true;
_drops = null;
Broadcast(new S.ObjectHarvested { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
}
return true;
}