当前位置: 首页>>代码示例>>C#>>正文


C# NPC.AnyInteractions方法代码示例

本文整理汇总了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"));
             }
         }
     }
 }
开发者ID:PJB3005,项目名称:tModLoader,代码行数:65,代码来源:ExampleItemDrop.cs

示例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;
             }
         }
     }
 }
开发者ID:bluemagic123,项目名称:tModLoader,代码行数:81,代码来源:ExampleGlobalNPC.cs


注:本文中的Terraria.NPC.AnyInteractions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。