本文整理汇总了C#中BaseEntity.GiveItem方法的典型用法代码示例。如果您正苦于以下问题:C# BaseEntity.GiveItem方法的具体用法?C# BaseEntity.GiveItem怎么用?C# BaseEntity.GiveItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseEntity
的用法示例。
在下文中一共展示了BaseEntity.GiveItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Gathering
public static void Gathering(ResourceDispenser dispenser, BaseEntity to, ItemAmount itemAmt, int amount)
{
itemAmt.amount += amount;
BaseEntity from = (BaseEntity)dispenser.GetFieldValue("baseEntity");
GatherEvent ge = new GatherEvent(dispenser, from, to, itemAmt, amount);
OnGathering.OnNext(ge);
if (ge.Amount > 0) {
if (amount > 0) {
itemAmt.amount -= amount;
if (itemAmt.amount < 0)
itemAmt.amount = 0;
Item item = ItemManager.CreateByItemID(itemAmt.itemid, ge.Amount, false);
if (item == null) {
return;
}
to.GiveItem(item);
}
}
}
示例2: On_PlayerGathering
public static void On_PlayerGathering(ResourceDispenser dispenser, BaseEntity to, ItemAmount itemAmt, float gatherDamage, float destroyFraction)
{
BaseEntity from = (BaseEntity)dispenser.GetFieldValue("baseEntity");
if (itemAmt.amount == 0) {
return;
}
float num = gatherDamage / from.MaxHealth ();
float num2 = itemAmt.startAmount / (float)dispenser.GetFieldValue("startingItemCounts");
float value = itemAmt.startAmount * num / num2;
float num3 = Mathf.Clamp (value, 0, itemAmt.amount);
float num4 = num3 * destroyFraction * 2;
if (itemAmt.amount < num3 + num4) {
itemAmt.amount -= destroyFraction * num3;
num3 = itemAmt.amount;
num4 = 0;
}
float amount = itemAmt.amount;
itemAmt.amount -= num3;
if (itemAmt.amount < 0) {
itemAmt.amount = 0;
}
int num5 = Mathf.Clamp (Mathf.RoundToInt (num3), 0, Mathf.CeilToInt (amount));
itemAmt.amount -= num4;
if (itemAmt.amount < 0) {
itemAmt.amount = 0;
}
GatherEvent ge = new GatherEvent(dispenser, from, to, itemAmt, num5);
OnNext("On_PlayerGathering", ge);
if (ge.Amount <= 0) {
return;
}
Item item = ItemManager.CreateByItemID (itemAmt.itemid, ge.Amount);
if (item == null) {
return;
}
to.GiveItem (item, BaseEntity.GiveItemReason.ResourceHarvested);
}