本文整理汇总了C#中Terraria.NPC.AnyInteractions方法的典型用法代码示例。如果您正苦于以下问题:C# NPC.AnyInteractions方法的具体用法?C# NPC.AnyInteractions怎么用?C# NPC.AnyInteractions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terraria.NPC
的用法示例。
在下文中一共展示了NPC.AnyInteractions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NPCLoot
public override void NPCLoot(NPC npc)
{
if (npc.lifeMax > 5 && npc.value > 0f)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ExampleItem"));
}
if (((npc.type == NPCID.Pumpking && Main.pumpkinMoon) || (npc.type == NPCID.IceQueen && Main.snowMoon)) && NPC.waveCount > 10)
{
int chance = NPC.waveCount - 10;
if (Main.expertMode)
{
chance++;
}
if (Main.rand.Next(5) < chance)
{
int stack = 1;
if (NPC.waveCount >= 15)
{
stack = Main.rand.Next(4, 7);
if (Main.expertMode)
{
stack++;
}
}
else if (Main.rand.Next(2) == 0)
{
stack++;
}
string type = npc.type == NPCID.Pumpking ? "ScytheBlade" : "Icicle";
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType(type), stack);
}
}
if (npc.type == NPCID.DukeFishron && !Main.expertMode)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Bubble"), Main.rand.Next(5, 8));
}
if (npc.type == NPCID.Bunny && npc.AnyInteractions())
{
Vector2 pos = npc.Center;
int i = (int)pos.X / 16;
int j = (int)pos.Y / 16;
Tile tile = Main.tile[i, j];
if (tile.active() && tile.type == mod.TileType("ElementalPurge") && !NPC.AnyNPCs(mod.NPCType("PuritySpirit")))
{
i -= Main.tile[i, j].frameX % 18;
j -= Main.tile[i, j].frameY % 18;
i = (i * 16) + 16;
j = (j * 16) - 8 + 60;
bool flag = false;
for (int k = 0; k < 255; k++)
{
Player player = Main.player[k];
if (player.active && player.position.X > i - NPC.sWidth / 2 && player.position.X + player.width < i + NPC.sWidth / 2 && player.position.Y > j - NPC.sHeight / 2 && player.position.Y < j + NPC.sHeight / 2)
{
flag = true;
break;
}
}
if (flag)
{
NPC.NewNPC(i, j, mod.NPCType("PuritySpirit"));
}
}
}
}
示例2: NPCLoot
public override void NPCLoot(NPC npc)
{
if (npc.lifeMax > 5 && npc.value > 0f)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ExampleItem"));
if (Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].GetModPlayer<ExamplePlayer>(mod).ZoneExample)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BossItem"));
}
}
if (((npc.type == NPCID.Pumpking && Main.pumpkinMoon) || (npc.type == NPCID.IceQueen && Main.snowMoon)) && NPC.waveNumber > 10)
{
int chance = NPC.waveNumber - 10;
if (Main.expertMode)
{
chance++;
}
if (Main.rand.Next(5) < chance)
{
int stack = 1;
if (NPC.waveNumber >= 15)
{
stack = Main.rand.Next(4, 7);
if (Main.expertMode)
{
stack++;
}
}
else if (Main.rand.Next(2) == 0)
{
stack++;
}
string type = npc.type == NPCID.Pumpking ? "ScytheBlade" : "Icicle";
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType(type), stack);
}
}
if (npc.type == NPCID.DukeFishron && !Main.expertMode)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Bubble"), Main.rand.Next(5, 8));
}
if (npc.type == NPCID.Bunny && npc.AnyInteractions())
{
int left = (int)(npc.position.X / 16f);
int top = (int)(npc.position.Y / 16f);
int right = (int)((npc.position.X + npc.width) / 16f);
int bottom = (int)((npc.position.Y + npc.height) / 16f);
bool flag = false;
for (int i = left; i <= right; i++)
{
for (int j = top; j <= bottom; j++)
{
Tile tile = Main.tile[i, j];
if (tile.active() && tile.type == mod.TileType("ElementalPurge") && !NPC.AnyNPCs(mod.NPCType("PuritySpirit")))
{
i -= Main.tile[i, j].frameX / 18;
j -= Main.tile[i, j].frameY / 18;
i = (i * 16) + 16;
j = (j * 16) + 24 + 60;
for (int k = 0; k < 255; k++)
{
Player player = Main.player[k];
if (player.active && player.position.X > i - NPC.sWidth / 2 && player.position.X + player.width < i + NPC.sWidth / 2 && player.position.Y > j - NPC.sHeight / 2 && player.position.Y < j + NPC.sHeight / 2)
{
flag = true;
break;
}
}
if (flag)
{
NPC.NewNPC(i, j, mod.NPCType("PuritySpirit"));
break;
}
}
}
if (flag)
{
break;
}
}
}
}