當前位置: 首頁>>代碼示例>>C#>>正文


C# NPC.CheckDead方法代碼示例

本文整理匯總了C#中Terraria_Server.NPC.CheckDead方法的典型用法代碼示例。如果您正苦於以下問題:C# NPC.CheckDead方法的具體用法?C# NPC.CheckDead怎麽用?C# NPC.CheckDead使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Terraria_Server.NPC的用法示例。


在下文中一共展示了NPC.CheckDead方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AITheDestroyer

        // 37 - 1.1.2
        private void AITheDestroyer(NPC npc, bool flag, Func<Int32, Int32, ITile> TileRefs)
        {
            if (npc.ai[3] > 0f)
            {
                npc.realLife = (int)npc.ai[3];
            }
            if (npc.target < 0 || npc.target == 255 || Main.players[npc.target].dead)
            {
                npc.TargetClosest(true);
            }
            if (npc.type > NPCType.N134_THE_DESTROYER)
            {
                bool flag34 = false;
                if (npc.ai[1] <= 0f)
                {
                    flag34 = true;
                }
                else
                {
                    if (Main.npcs[(int)npc.ai[1]].life <= 0)
                    {
                        flag34 = true;
                    }
                }
                if (flag34)
                {
                    npc.life = 0;
                    npc.HitEffect(0, 10.0);
                    npc.CheckDead();
                }
            }
            if (npc.ai[0] == 0f && npc.type == NPCType.N134_THE_DESTROYER)
            {
                npc.ai[3] = (float)npc.whoAmI;
                npc.realLife = npc.whoAmI;
                int num447 = npc.whoAmI;
                int num448 = 80;
                for (int num449 = 0; num449 <= num448; num449++)
                {
                    int num450 = 135;
                    if (num449 == num448)
                    {
                        num450 = 136;
                    }
                    int num451 = NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)(npc.Position.Y + (float)npc.Height), num450, npc.whoAmI, Main.stopSpawns);
                    Main.npcs[num451].ai[3] = (float)npc.whoAmI;
                    Main.npcs[num451].realLife = npc.whoAmI;
                    Main.npcs[num451].ai[1] = (float)num447;
                    Main.npcs[num447].ai[0] = (float)num451;
                    NetMessage.SendData(23, -1, -1, "", num451, 0f, 0f, 0f, 0);
                    num447 = num451;
                }
            }
            if (npc.type == NPCType.N135_THE_DESTROYER_BODY)
            {
                npc.localAI[0] += (float)Main.rand.Next(4);
                if (npc.localAI[0] >= (float)Main.rand.Next(1400, 26000))
                {
                    npc.localAI[0] = 0f;
                    npc.TargetClosest(true);
                    if (Collision.CanHit(npc.Position, npc.Width, npc.Height, Main.players[npc.target].Position, Main.players[npc.target].Width, Main.players[npc.target].Height))
                    {
                        float num452 = 8f;
                        Vector2 vector56 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)(npc.Height / 2));
                        float num453 = Main.players[npc.target].Position.X + (float)Main.players[npc.target].Width * 0.5f - vector56.X + (float)Main.rand.Next(-20, 21);
                        float num454 = Main.players[npc.target].Position.Y + (float)Main.players[npc.target].Height * 0.5f - vector56.Y + (float)Main.rand.Next(-20, 21);
                        float num455 = (float)Math.Sqrt((double)(num453 * num453 + num454 * num454));
                        num455 = num452 / num455;
                        num453 *= num455;
                        num454 *= num455;
                        num453 += (float)Main.rand.Next(-20, 21) * 0.05f;
                        num454 += (float)Main.rand.Next(-20, 21) * 0.05f;
                        int num456 = 22;
                        int num457 = 100;
                        vector56.X += num453 * 5f;
                        vector56.Y += num454 * 5f;
                        int num458 = Projectile.NewProjectile(vector56.X, vector56.Y, num453, num454, num457, num456, 0f, Main.myPlayer);
                        Main.projectile[num458].timeLeft = 300;
                        npc.netUpdate = true;
                    }
                }
            }

            int num459 = (int)(npc.Position.X / 16f) - 1;
            int num460 = (int)((npc.Position.X + (float)npc.Width) / 16f) + 2;
            int num461 = (int)(npc.Position.Y / 16f) - 1;
            int num462 = (int)((npc.Position.Y + (float)npc.Height) / 16f) + 2;
            if (num459 < 0)
            {
                num459 = 0;
            }
            if (num460 > Main.maxTilesX)
            {
                num460 = Main.maxTilesX;
            }
            if (num461 < 0)
            {
                num461 = 0;
            }
//.........這裏部分代碼省略.........
開發者ID:jason14747,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs


注:本文中的Terraria_Server.NPC.CheckDead方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。