本文整理匯總了C#中Terraria.NPC.NPCLoot方法的典型用法代碼示例。如果您正苦於以下問題:C# NPC.NPCLoot方法的具體用法?C# NPC.NPCLoot怎麽用?C# NPC.NPCLoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Terraria.NPC
的用法示例。
在下文中一共展示了NPC.NPCLoot方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnNPCLoot
public bool OnNPCLoot(NPC npc)
{
if (!rare)
{
if (recursionFlag) return false; // flag is set, avoid recursion
recursionFlag = true;
for (int i = 0; i < factor; i++)
npc.NPCLoot();
recursionFlag = false;
return true;
}
else
{
if (factor > 1)
{
int hundred = 100 / factor;
int oneFifty = 150 / factor;
int oneSeventyFive = 175 / factor;
int twoHundred = 200 / factor;
int twoFifty = 250 / factor;
int threeHundred = 300 / factor;
int fourHundred = 400 / factor;
int fiveHundred = 500 / factor;
int thousand = 1000 / factor;
int twoThousand = 2000 / factor;
int twentyFiveHundred = 2500 / factor;
int fourThousand = 4000 / factor;
int eightThousand = 8000 / factor;
if (Main.hardMode && npc.value > 0)
{
if (Main.rand.Next(twentyFiveHundred) == 0 && Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].ZoneJungle)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.JungleKey, 1, false, 0, false);
}
if (Main.rand.Next(twentyFiveHundred) == 0 && Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].ZoneCorrupt)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.CorruptionKey, 1, false, 0, false);
}
if (Main.rand.Next(twentyFiveHundred) == 0 && Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].ZoneCrimson)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.CrimsonKey, 1, false, 0, false);
}
if (Main.rand.Next(twentyFiveHundred) == 0 && Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].ZoneHoly)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.HallowedKey, 1, false, 0, false);
}
if (Main.rand.Next(twentyFiveHundred) == 0 && Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].ZoneSnow)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.FrozenKey, 1, false, 0, false);
}
}
if (npc.type >= 212 && npc.type <= 215)
{
if (Main.rand.Next(eightThousand) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.CoinGun, 1, false, -1, false);
}
if (Main.rand.Next(fourThousand) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.LuckyCoin, 1, false, -1, false);
}
if (Main.rand.Next(twoThousand) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.DiscountCard, 1, false, -1, false);
}
if (Main.rand.Next(twoThousand) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.PirateStaff, 1, false, -1, false);
}
if (Main.rand.Next(thousand) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.GoldRing, 1, false, -1, false);
}
}
if (npc.type == 216)
{
if (Main.rand.Next(twoThousand) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.CoinGun, 1, false, -1, false);
}
if (Main.rand.Next(thousand) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.LuckyCoin, 1, false, -1, false);
}
if (Main.rand.Next(fiveHundred) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.DiscountCard, 1, false, -1, false);
}
if (Main.rand.Next(fiveHundred) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.PirateStaff, 1, false, -1, false);
}
if (Main.rand.Next(twoFifty) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.GoldRing, 1, false, -1, false);
}
}
if (npc.type == 110 && Main.rand.Next(twoHundred) == 0)
//.........這裏部分代碼省略.........