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


C# NPC.TargetClosest方法代碼示例

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


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

示例1: AIPrimeLaser


//.........這裏部分代碼省略.........
                            }
                            npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                            if (npc.Velocity.Y < -3f)
                            {
                                npc.Velocity.Y = -3f;
                            }
                        }
                    }
                    if (npc.Position.X + (float)(npc.Width / 2) > Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 180f * npc.ai[0])
                    {
                        if (npc.Velocity.X > 0f)
                        {
                            npc.Velocity.X = npc.Velocity.X * 0.96f;
                        }
                        npc.Velocity.X = npc.Velocity.X - 0.14f;
                        if (npc.Velocity.X > 8f)
                        {
                            npc.Velocity.X = 8f;
                        }
                    }
                    if (npc.Position.X + (float)(npc.Width / 2) < Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 180f * npc.ai[0])
                    {
                        if (npc.Velocity.X < 0f)
                        {
                            npc.Velocity.X = npc.Velocity.X * 0.96f;
                        }
                        npc.Velocity.X = npc.Velocity.X + 0.14f;
                        if (npc.Velocity.X < -8f)
                        {
                            npc.Velocity.X = -8f;
                        }
                    }
                }
                npc.TargetClosest(true);
                Vector2 vector54 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                float num435 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector54.X;
                float num436 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector54.Y;
                float num437 = (float)Math.Sqrt((double)(num435 * num435 + num436 * num436));
                npc.rotation = (float)Math.Atan2((double)num436, (double)num435) - 1.57f;
                npc.localAI[0] += 1f;
                if (npc.localAI[0] > 200f)
                {
                    npc.localAI[0] = 0f;
                    float num438 = 8f;
                    int num439 = 25;
                    int num440 = 100;
                    num437 = num438 / num437;
                    num435 *= num437;
                    num436 *= num437;
                    num435 += (float)Main.rand.Next(-40, 41) * 0.05f;
                    num436 += (float)Main.rand.Next(-40, 41) * 0.05f;
                    vector54.X += num435 * 8f;
                    vector54.Y += num436 * 8f;
                    Projectile.NewProjectile(vector54.X, vector54.Y, num435, num436, num440, num439, 0f, Main.myPlayer);
                    return;
                }
            }
            else
            {
                if (npc.ai[2] == 1f)
                {
                    npc.ai[3] += 1f;
                    if (npc.ai[3] >= 200f)
                    {
                        npc.localAI[0] = 0f;
                        npc.ai[2] = 0f;
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:67,代碼來源:NPC.cs

示例2: AIDemonEye

 // 2
 private void AIDemonEye(NPC npc, bool flag)
 {
     npc.noGravity = true;
     if (npc.collideX)
     {
         npc.Velocity.X = npc.oldVelocity.X * -0.5f;
         if (npc.direction == -1 && npc.Velocity.X > 0f && npc.Velocity.X < 2f)
         {
             npc.Velocity.X = 2f;
         }
         if (npc.direction == 1 && npc.Velocity.X < 0f && npc.Velocity.X > -2f)
         {
             npc.Velocity.X = -2f;
         }
     }
     if (npc.collideY)
     {
         npc.Velocity.Y = npc.oldVelocity.Y * -0.5f;
         if (npc.Velocity.Y > 0f && npc.Velocity.Y < 1f)
         {
             npc.Velocity.Y = 1f;
         }
         if (npc.Velocity.Y < 0f && npc.Velocity.Y > -1f)
         {
             npc.Velocity.Y = -1f;
         }
     }
     if (Main.dayTime && (double)npc.Position.Y <= Main.worldSurface * 16.0 && npc.Type == 2)
     {
         if (npc.timeLeft > 10)
         {
             npc.timeLeft = 10;
         }
         npc.directionY = -1;
         if (npc.Velocity.Y > 0f)
         {
             npc.direction = 1;
         }
         npc.direction = -1;
         if (npc.Velocity.X > 0f)
         {
             npc.direction = 1;
         }
     }
     else
     {
         npc.TargetClosest(true);
     }
     if (npc.direction == -1 && npc.Velocity.X > -4f)
     {
         npc.Velocity.X = npc.Velocity.X - 0.1f;
         if (npc.Velocity.X > 4f)
         {
             npc.Velocity.X = npc.Velocity.X - 0.1f;
         }
         else
         {
             if (npc.Velocity.X > 0f)
             {
                 npc.Velocity.X = npc.Velocity.X + 0.05f;
             }
         }
         if (npc.Velocity.X < -4f)
         {
             npc.Velocity.X = -4f;
         }
     }
     else
     {
         if (npc.direction == 1 && npc.Velocity.X < 4f)
         {
             npc.Velocity.X = npc.Velocity.X + 0.1f;
             if (npc.Velocity.X < -4f)
             {
                 npc.Velocity.X = npc.Velocity.X + 0.1f;
             }
             else
             {
                 if (npc.Velocity.X < 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X - 0.05f;
                 }
             }
             if (npc.Velocity.X > 4f)
             {
                 npc.Velocity.X = 4f;
             }
         }
     }
     if (npc.directionY == -1 && (double)npc.Velocity.Y > -1.5)
     {
         npc.Velocity.Y = npc.Velocity.Y - 0.04f;
         if ((double)npc.Velocity.Y > 1.5)
         {
             npc.Velocity.Y = npc.Velocity.Y - 0.05f;
         }
         else
         {
             if (npc.Velocity.Y > 0f)
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例3: AIFighter

        // 3
        private void AIFighter(NPC npc, bool flag)
        {
            int num3 = 60;
            bool flag2 = false;
            if (npc.Velocity.Y == 0f && ((npc.Velocity.X > 0f && npc.direction < 0) || (npc.Velocity.X < 0f && npc.direction > 0)))
            {
                flag2 = true;
            }
            if (npc.Position.X == npc.oldPosition.X || npc.ai[3] >= (float)num3 || flag2)
            {
                npc.ai[3] += 1f;
            }
            else
            {
                if ((double)Math.Abs(npc.Velocity.X) > 0.9 && npc.ai[3] > 0f)
                {
                    npc.ai[3] -= 1f;
                }
            }
            if (npc.ai[3] > (float)(num3 * 10))
            {
                npc.ai[3] = 0f;
            }
            if (npc.justHit)
            {
                npc.ai[3] = 0f;
            }
            if (npc.ai[3] == (float)num3)
            {
                npc.netUpdate = true;
            }
            if ((!Main.dayTime || (double)npc.Position.Y > Main.worldSurface * 16.0 || npc.Type == 26 || npc.Type == 27 || npc.Type == 28 || npc.Type == 31 || npc.Type == 47 || npc.Type == 67 || npc.Type == 73) && npc.ai[3] < (float)num3)
            {
                npc.TargetClosest(true);
            }
            else
            {
                if (Main.dayTime && (double)(npc.Position.Y / 16f) < Main.worldSurface && npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                }
                if (npc.Velocity.X == 0f)
                {
                    if (npc.Velocity.Y == 0f)
                    {
                        npc.ai[0] += 1f;
                        if (npc.ai[0] >= 2f)
                        {
                            npc.direction *= -1;
                            npc.spriteDirection = npc.direction;
                            npc.ai[0] = 0f;
                        }
                    }
                }
                else
                {
                    npc.ai[0] = 0f;
                }
                if (npc.direction == 0)
                {
                    npc.direction = 1;
                }
            }
            if (npc.Type == 27)
            {
                if (npc.Velocity.X < -2f || npc.Velocity.X > 2f)
                {
                    if (npc.Velocity.Y == 0f)
                    {
                        npc.Velocity *= 0.8f;
                    }
                }
                else
                {
                    if (npc.Velocity.X < 2f && npc.direction == 1)
                    {
                        npc.Velocity.X = npc.Velocity.X + 0.07f;
                        if (npc.Velocity.X > 2f)
                        {
                            npc.Velocity.X = 2f;
                        }
                    }
                    else
                    {
                        if (npc.Velocity.X > -2f && npc.direction == -1)
                        {
                            npc.Velocity.X = npc.Velocity.X - 0.07f;
                            if (npc.Velocity.X < -2f)
                            {
                                npc.Velocity.X = -2f;
                            }
                        }
                    }
                }
            }
            else
            {
                if (npc.Type == 21 || npc.Type == 26 || npc.Type == 31 || npc.Type == 47 || npc.Type == 73)
                {
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例4: AIAntlion

        // 19
        private void AIAntlion(NPC npc, bool flag)
        {
            npc.TargetClosest(true);
            float num174 = 12f;
            Vector2 vector22 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
            float num175 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector22.X;
            float num176 = Main.players[npc.target].Position.Y - vector22.Y;
            float num177 = (float)Math.Sqrt((double)(num175 * num175 + num176 * num176));
            num177 = num174 / num177;
            num175 *= num177;
            num176 *= num177;
            bool flag18 = false;
            if (npc.directionY < 0)
            {
                npc.rotation = (float)(Math.Atan2((double)num176, (double)num175) + 1.57);
                flag18 = ((double)npc.rotation >= -1.2 && (double)npc.rotation <= 1.2);
                if ((double)npc.rotation < -0.8)
                {
                    npc.rotation = -0.8f;
                }
                else
                {
                    if ((double)npc.rotation > 0.8)
                    {
                        npc.rotation = 0.8f;
                    }
                }
                if (npc.Velocity.X != 0f)
                {
                    npc.Velocity.X = npc.Velocity.X * 0.9f;
                    if ((double)npc.Velocity.X > -0.1 || (double)npc.Velocity.X < 0.1)
                    {
                        npc.netUpdate = true;
                        npc.Velocity.X = 0f;
                    }
                }
            }
            if (npc.ai[0] > 0f)
            {
                npc.ai[0] -= 1f;
            }
            if (flag18 && npc.ai[0] == 0f && Collision.CanHit(npc.Position, npc.Width, npc.Height, Main.players[npc.target].Position, Main.players[npc.target].Width, Main.players[npc.target].Height))
            {
                npc.ai[0] = 200f;
                int num178 = 10;
                int num179 = 31;
                int num180 = Projectile.NewProjectile(vector22.X, vector22.Y, num175, num176, num179, num178, 0f, Main.myPlayer);
                Main.projectile[num180].ai[0] = 2f;
                Main.projectile[num180].timeLeft = 300;
                Main.projectile[num180].friendly = false;
                NetMessage.SendData(27, -1, -1, "", num180, 0f, 0f, 0f, 0);
                npc.netUpdate = true;
            }
            try
            {
                int num181 = (int)npc.Position.X / 16;
                int num182 = (int)(npc.Position.X + (float)(npc.Width / 2)) / 16;
                int num183 = (int)(npc.Position.X + (float)npc.Width) / 16;
                int num184 = (int)(npc.Position.Y + (float)npc.Height) / 16;
                bool flag19 = false;

                if ((Main.tile.At(num181, num184).Active && Main.tileSolid[
                    (int)Main.tile.At(num181, num184).Type]) ||
                        (Main.tile.At(num182, num184).Active && Main.tileSolid[
                            (int)Main.tile.At(num182, num184).Type]) ||
                                (Main.tile.At(num183, num184).Active && Main.tileSolid[
                                    (int)Main.tile.At(num183, num184).Type]))
                {
                    flag19 = true;
                }
                if (flag19)
                {
                    npc.noGravity = true;
                    npc.noTileCollide = true;
                    npc.Velocity.Y = -0.2f;
                }
                else
                {
                    npc.noGravity = false;
                    npc.noTileCollide = false;
                }
                return;
            }
            catch
            {
                return;
            }
        }
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:89,代碼來源:NPC.cs

示例5: AIBlazingWheel

 // 21
 private void AIBlazingWheel(NPC npc, bool flag)
 {
     if (npc.ai[0] == 0f)
     {
         npc.TargetClosest(true);
         npc.directionY = 1;
         npc.ai[0] = 1f;
     }
     int num189 = 6;
     if (npc.ai[1] == 0f)
     {
         npc.rotation += (float)(npc.direction * npc.directionY) * 0.13f;
         if (npc.collideY)
         {
             npc.ai[0] = 2f;
         }
         if (!npc.collideY && npc.ai[0] == 2f)
         {
             npc.direction = -npc.direction;
             npc.ai[1] = 1f;
             npc.ai[0] = 1f;
         }
         if (npc.collideX)
         {
             npc.directionY = -npc.directionY;
             npc.ai[1] = 1f;
         }
     }
     else
     {
         npc.rotation -= (float)(npc.direction * npc.directionY) * 0.13f;
         if (npc.collideX)
         {
             npc.ai[0] = 2f;
         }
         if (!npc.collideX && npc.ai[0] == 2f)
         {
             npc.directionY = -npc.directionY;
             npc.ai[1] = 0f;
             npc.ai[0] = 1f;
         }
         if (npc.collideY)
         {
             npc.direction = -npc.direction;
             npc.ai[1] = 0f;
         }
     }
     npc.Velocity.X = (float)(num189 * npc.direction);
     npc.Velocity.Y = (float)(num189 * npc.directionY);
     return;
 }
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:52,代碼來源:NPC.cs

示例6: AIWallOfFlesh


//.........這裏部分代碼省略.........
            tileY -= 4;

            if (Main.WallOfFlesh_T == -1)
                Main.WallOfFlesh_T = tileY * 16;

            else if (Main.WallOfFlesh_T > tileY * 16)
            {
                Main.WallOfFlesh_T--;

                if (Main.WallOfFlesh_T < tileY * 16)
                    Main.WallOfFlesh_T = tileY * 16;
            }
            else if (Main.WallOfFlesh_T < tileY * 16)
            {
                Main.WallOfFlesh_T++;

                if (Main.WallOfFlesh_T > tileY * 16)
                    Main.WallOfFlesh_T = tileY * 16;
            }

            float num294 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2 - npc.Height / 2);
            if (npc.Position.Y > num294 + 1f)
                npc.Velocity.Y = -1f;
            else if (npc.Position.Y < num294 - 1f)
                    npc.Velocity.Y = 1f;

            npc.Velocity.Y = 0f;
            npc.Position.Y = num294;

            float num295 = 1.5f;
            if ((double)npc.life < (double)npc.lifeMax * 0.75)
            {
                num295 += 0.25f;
            }
            if ((double)npc.life < (double)npc.lifeMax * 0.5)
                num295 += 0.4f;

            if ((double)npc.life < (double)npc.lifeMax * 0.25)
                num295 += 0.5f;

            if ((double)npc.life < (double)npc.lifeMax * 0.1)
                num295 += 0.6f;

            if (npc.Velocity.X == 0f)
            {
                npc.TargetClosest(true);
                npc.Velocity.X = (float)npc.direction;
            }
            if (npc.Velocity.X < 0f)
            {
                npc.Velocity.X = -num295;
                npc.direction = -1;
            }
            else
            {
                npc.Velocity.X = num295;
                npc.direction = 1;
            }
            npc.spriteDirection = npc.direction;
            Vector2 vector29 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
            float num296 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector29.X;
            float num297 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector29.Y;
            float num298 = (float)Math.Sqrt((double)(num296 * num296 + num297 * num297));
            num296 *= num298;
            num297 *= num298;
            if (npc.direction > 0)
            {
                if (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) > npc.Position.X + (float)(npc.Width / 2))
                    npc.rotation = (float)Math.Atan2((double)(-(double)num297), (double)(-(double)num296)) + 3.14f;
                else
                    npc.rotation = 0f;
            }
            else
            {
                if (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) < npc.Position.X + (float)(npc.Width / 2))
                    npc.rotation = (float)Math.Atan2((double)num297, (double)num296) + 3.14f;
                else
                    npc.rotation = 0f;
            }
            if (npc.localAI[0] == 1f)
            {
                npc.localAI[0] = 2f;
                num294 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2);
                num294 = (num294 + (float)Main.WallOfFlesh_T) / 2f;
                int num299 = NPC.NewNPC((int)npc.Position.X, (int)num294, 114, npc.whoAmI);
                Main.npcs[num299].ai[0] = 1f;
                num294 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2);
                num294 = (num294 + (float)Main.WallOfFlesh_B) / 2f;
                num299 = NPC.NewNPC((int)npc.Position.X, (int)num294, 114, npc.whoAmI);
                Main.npcs[num299].ai[0] = -1f;
                num294 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2);
                num294 = (num294 + (float)Main.WallOfFlesh_B) / 2f;
                for (int num300 = 0; num300 < 11; num300++)
                {
                    num299 = NPC.NewNPC((int)npc.Position.X, (int)num294, 115, npc.whoAmI);
                    Main.npcs[num299].ai[0] = (float)num300 * 0.1f - 0.05f;
                }
                return;
            }
        }
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例7: AIWizard

 // 8
 private void AIWizard(NPC npc, bool flag)
 {
     npc.TargetClosest(true);
     npc.Velocity.X = npc.Velocity.X * 0.93f;
     if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
     {
         npc.Velocity.X = 0f;
     }
     if (npc.ai[0] == 0f)
     {
         npc.ai[0] = 500f;
     }
     if (npc.ai[2] != 0f && npc.ai[3] != 0f)
     {
         npc.Position.X = npc.ai[2] * 16f - (float)(npc.Width / 2) + 8f;
         npc.Position.Y = npc.ai[3] * 16f - (float)npc.Height;
         npc.Velocity.X = 0f;
         npc.Velocity.Y = 0f;
         npc.ai[2] = 0f;
         npc.ai[3] = 0f;
     }
     npc.ai[0] += 1f;
     if (npc.ai[0] == 100f || npc.ai[0] == 200f || npc.ai[0] == 300f)
     {
         npc.ai[1] = 30f;
         npc.netUpdate = true;
     }
     else
     {
         if (npc.ai[0] >= 650f)
         {
             npc.ai[0] = 1f;
             int num90 = (int)Main.players[npc.target].Position.X / 16;
             int num91 = (int)Main.players[npc.target].Position.Y / 16;
             int num92 = (int)npc.Position.X / 16;
             int num93 = (int)npc.Position.Y / 16;
             int num94 = 20;
             int num95 = 0;
             bool flag14 = false;
             if (Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) + Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 2000f)
             {
                 num95 = 100;
                 flag14 = true;
             }
             while (!flag14 && num95 < 100)
             {
                 num95++;
                 int num96 = Main.rand.Next(num90 - num94, num90 + num94);
                 int num97 = Main.rand.Next(num91 - num94, num91 + num94);
                 for (int num98 = num97; num98 < num91 + num94; num98++)
                 {
                     if ((num98 < num91 - 4 || num98 > num91 + 4 || num96 < num90 - 4 || num96 > num90 + 4) && (num98 < num93 - 1 || num98 > num93 + 1 || num96 < num92 - 1 || num96 > num92 + 1) && Main.tile.At(num96, num98).Active)
                     {
                         bool flag15 = true;
                         if (npc.Type == 32 && Main.tile.At(num96, num98 - 1).Wall == 0)
                         {
                             flag15 = false;
                         }
                         else
                         {
                             if (Main.tile.At(num96, num98 - 1).Lava)
                             {
                                 flag15 = false;
                             }
                         }
                         if (flag15 && Main.tileSolid[(int)Main.tile.At(num96, num98).Type] && !Collision.SolidTiles(num96 - 1, num96 + 1, num98 - 4, num98 - 1))
                         {
                             npc.ai[1] = 20f;
                             npc.ai[2] = (float)num96;
                             npc.ai[3] = (float)num98;
                             flag14 = true;
                             break;
                         }
                     }
                 }
             }
             npc.netUpdate = true;
         }
     }
     if (npc.ai[1] > 0f)
     {
         npc.ai[1] -= 1f;
         if (npc.ai[1] == 25f)
         {
             if (npc.Type == 29 || npc.Type == 45)
             {
                 NPC.NewNPC((int)npc.Position.X + npc.Width / 2, (int)npc.Position.Y - 8, 30, 0);
             }
             else
             {
                 if (npc.Type == 32)
                 {
                     NPC.NewNPC((int)npc.Position.X + npc.Width / 2, (int)npc.Position.Y - 8, 33, 0);
                 }
                 else
                 {
                     NPC.NewNPC((int)npc.Position.X + npc.Width / 2 + npc.direction * 8, (int)npc.Position.Y + 20, 25, 0);
                 }
             }
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例8: AISkeletronPrime

 // 32
 private void AISkeletronPrime(NPC npc, bool flag)
 {
     npc.damage = npc.defDamage;
     npc.defense = npc.defDefense;
     if (npc.ai[0] == 0f)
     {
         npc.TargetClosest(true);
         npc.ai[0] = 1f;
         if (npc.Type != 68)
         {
             int num388 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 128, npc.whoAmI);
             Main.npcs[num388].ai[0] = -1f;
             Main.npcs[num388].ai[1] = (float)npc.whoAmI;
             Main.npcs[num388].target = npc.target;
             Main.npcs[num388].netUpdate = true;
             num388 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 129, npc.whoAmI);
             Main.npcs[num388].ai[0] = 1f;
             Main.npcs[num388].ai[1] = (float)npc.whoAmI;
             Main.npcs[num388].target = npc.target;
             Main.npcs[num388].netUpdate = true;
             num388 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 130, npc.whoAmI);
             Main.npcs[num388].ai[0] = -1f;
             Main.npcs[num388].ai[1] = (float)npc.whoAmI;
             Main.npcs[num388].target = npc.target;
             Main.npcs[num388].ai[3] = 150f;
             Main.npcs[num388].netUpdate = true;
             num388 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 131, npc.whoAmI);
             Main.npcs[num388].ai[0] = 1f;
             Main.npcs[num388].ai[1] = (float)npc.whoAmI;
             Main.npcs[num388].target = npc.target;
             Main.npcs[num388].netUpdate = true;
             Main.npcs[num388].ai[3] = 150f;
         }
     }
     if (npc.Type == 68 && npc.ai[1] != 3f && npc.ai[1] != 2f)
     {
         npc.ai[1] = 2f;
     }
     if (Main.players[npc.target].dead || Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) > 6000f || Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 6000f)
     {
         npc.TargetClosest(true);
         if (Main.players[npc.target].dead || Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) > 6000f || Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 6000f)
         {
             npc.ai[1] = 3f;
         }
     }
     if (Main.dayTime && npc.ai[1] != 3f && npc.ai[1] != 2f)
     {
         npc.ai[1] = 2f;
     }
     if (npc.ai[1] == 0f)
     {
         npc.ai[2] += 1f;
         if (npc.ai[2] >= 600f)
         {
             npc.ai[2] = 0f;
             npc.ai[1] = 1f;
             npc.TargetClosest(true);
             npc.netUpdate = true;
         }
         npc.rotation = npc.Velocity.X / 15f;
         if (npc.Position.Y > Main.players[npc.target].Position.Y - 200f)
         {
             if (npc.Velocity.Y > 0f)
             {
                 npc.Velocity.Y = npc.Velocity.Y * 0.98f;
             }
             npc.Velocity.Y = npc.Velocity.Y - 0.1f;
             if (npc.Velocity.Y > 2f)
             {
                 npc.Velocity.Y = 2f;
             }
         }
         else
         {
             if (npc.Position.Y < Main.players[npc.target].Position.Y - 500f)
             {
                 if (npc.Velocity.Y < 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                 }
                 npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                 if (npc.Velocity.Y < -2f)
                 {
                     npc.Velocity.Y = -2f;
                 }
             }
         }
         if (npc.Position.X + (float)(npc.Width / 2) > Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) + 100f)
         {
             if (npc.Velocity.X > 0f)
             {
                 npc.Velocity.X = npc.Velocity.X * 0.98f;
             }
             npc.Velocity.X = npc.Velocity.X - 0.1f;
             if (npc.Velocity.X > 8f)
             {
                 npc.Velocity.X = 8f;
             }
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例9: AISlime

        // 1
        private void AISlime(NPC npc, bool flagg)
        {
            bool flag = (!Main.dayTime) || (npc.life != npc.lifeMax) || (npc.Position.Y > Main.worldSurface * 16.0) || (npc.Type == 81);

            if (npc.ai[2] > 1f)
            {
                npc.ai[2] -= 1f;
            }
            if (npc.wet)
            {
                if (this.collideY)
                {
                    this.Velocity.Y = -2f;
                }
                if (npc.Velocity.Y < 0f && npc.ai[3] == npc.Position.X)
                {
                    npc.direction *= -1;
                    npc.ai[2] = 200f;
                }
                if (npc.Velocity.Y > 0f)
                {
                    npc.ai[3] = npc.Position.X;
                }
                if (npc.Type == 59)
                {
                    if (npc.Velocity.Y > 2f)
                    {
                        npc.Velocity.Y = npc.Velocity.Y * 0.9f;
                    }
                    else
                    {
                        if (npc.directionY < 0)
                        {
                            npc.Velocity.Y = npc.Velocity.Y - 0.8f;
                        }
                    }
                    npc.Velocity.Y = npc.Velocity.Y - 0.5f;
                    if (npc.Velocity.Y < -10f)
                    {
                        npc.Velocity.Y = -10f;
                    }
                }
                else
                {
                    if (npc.Velocity.Y > 2f)
                    {
                        npc.Velocity.Y = npc.Velocity.Y * 0.9f;
                    }
                    npc.Velocity.Y = npc.Velocity.Y - 0.5f;
                    if (npc.Velocity.Y < -4f)
                    {
                        npc.Velocity.Y = -4f;
                    }
                }
                if (npc.ai[2] == 1f && flag)
                {
                    npc.TargetClosest(true);
                }
            }
            npc.aiAction = 0;
            if (npc.ai[2] == 0f)
            {
                npc.ai[0] = -100f;
                npc.ai[2] = 1f;
                npc.TargetClosest(true);
            }
            if (npc.Velocity.Y == 0f)
            {
                if (npc.ai[3] == npc.Position.X)
                {
                    npc.direction *= -1;
                    npc.ai[2] = 200f;
                }
                npc.ai[3] = 0f;
                npc.Velocity.X = npc.Velocity.X * 0.8f;
                if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
                {
                    npc.Velocity.X = 0f;
                }
                if (flag)
                {
                    npc.ai[0] += 1f;
                }
                npc.ai[0] += 1f;
                if (npc.Type == 59)
                {
                    npc.ai[0] += 2f;
                }
                if (npc.Type == 71)
                {
                    npc.ai[0] += 3f;
                }
                if (this.Type == 138)
                {
                    this.ai[0] += 2f;
                }
                if (this.Type == 81)
                {
                    if (this.scale >= 0f)
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例10: AISkeletronHand


//.........這裏部分代碼省略.........
                 if (npc.Velocity.X < 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X * 0.96f;
                 }
                 npc.Velocity.X = npc.Velocity.X + 0.07f;
                 if (npc.Velocity.X < -8f)
                 {
                     npc.Velocity.X = -8f;
                 }
             }
         }
         Vector2 vector15 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
         float num125 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0] - vector15.X;
         float num126 = Main.npcs[(int)npc.ai[1]].Position.Y + 230f - vector15.Y;
         Math.Sqrt((double)(num125 * num125 + num126 * num126));
         npc.rotation = (float)Math.Atan2((double)num126, (double)num125) + 1.57f;
         return;
     }
     if (npc.ai[2] == 1f)
     {
         Vector2 vector16 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
         float num127 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0] - vector16.X;
         float num128 = Main.npcs[(int)npc.ai[1]].Position.Y + 230f - vector16.Y;
         float num129 = (float)Math.Sqrt((double)(num127 * num127 + num128 * num128));
         npc.rotation = (float)Math.Atan2((double)num128, (double)num127) + 1.57f;
         npc.Velocity.X = npc.Velocity.X * 0.95f;
         npc.Velocity.Y = npc.Velocity.Y - 0.1f;
         if (npc.Velocity.Y < -8f)
         {
             npc.Velocity.Y = -8f;
         }
         if (npc.Position.Y < Main.npcs[(int)npc.ai[1]].Position.Y - 200f)
         {
             npc.TargetClosest(true);
             npc.ai[2] = 2f;
             vector16 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
             num127 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector16.X;
             num128 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector16.Y;
             num129 = (float)Math.Sqrt((double)(num127 * num127 + num128 * num128));
             num129 = 18f / num129;
             npc.Velocity.X = num127 * num129;
             npc.Velocity.Y = num128 * num129;
             npc.netUpdate = true;
             return;
         }
     }
     else
     {
         if (npc.ai[2] == 2f)
         {
             if (npc.Position.Y > Main.players[npc.target].Position.Y || npc.Velocity.Y < 0f)
             {
                 npc.ai[2] = 3f;
                 return;
             }
         }
         else
         {
             if (npc.ai[2] == 4f)
             {
                 Vector2 vector17 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                 float num130 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0] - vector17.X;
                 float num131 = Main.npcs[(int)npc.ai[1]].Position.Y + 230f - vector17.Y;
                 float num132 = (float)Math.Sqrt((double)(num130 * num130 + num131 * num131));
                 npc.rotation = (float)Math.Atan2((double)num131, (double)num130) + 1.57f;
                 npc.Velocity.Y = npc.Velocity.Y * 0.95f;
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:67,代碼來源:NPC.cs

示例11: AISkeletronHead

        // 11
        private void AISkeletronHead(NPC npc, bool flag)
        {
            if (npc.ai[0] == 0f)
            {
                npc.TargetClosest(true);
                npc.ai[0] = 1f;
                if (npc.Type != 68)
                {
                    int num116 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 36, npc.whoAmI);
                    Main.npcs[num116].ai[0] = -1f;
                    Main.npcs[num116].ai[1] = (float)npc.whoAmI;
                    Main.npcs[num116].target = npc.target;
                    Main.npcs[num116].netUpdate = true;
                    num116 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 36, npc.whoAmI);
                    Main.npcs[num116].ai[0] = 1f;
                    Main.npcs[num116].ai[1] = (float)npc.whoAmI;
                    Main.npcs[num116].ai[3] = 150f;
                    Main.npcs[num116].target = npc.target;
                    Main.npcs[num116].netUpdate = true;
                }
            }
            if (npc.Type == 68 && npc.ai[1] != 3f && npc.ai[1] != 2f)
            {
                npc.ai[1] = 2f;
            }
            if (Main.players[npc.target].dead || Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) > 2000f || Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 2000f)
            {
                npc.TargetClosest(true);
                if (Main.players[npc.target].dead || Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) > 2000f || Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 2000f)
                {
                    npc.ai[1] = 3f;
                }
            }
            if (Main.dayTime && npc.ai[1] != 3f && npc.ai[1] != 2f)
            {
                npc.ai[1] = 2f;
            }
            if (npc.ai[1] == 0f)
            {
                npc.defense = 10;
                npc.ai[2] += 1f;
                if (npc.ai[2] >= 800f)
                {
                    npc.ai[2] = 0f;
                    npc.ai[1] = 1f;
                    npc.TargetClosest(true);
                    npc.netUpdate = true;
                }
                npc.rotation = npc.Velocity.X / 15f;
                if (npc.Position.Y > Main.players[npc.target].Position.Y - 250f)
                {
                    if (npc.Velocity.Y > 0f)
                    {
                        npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                    }
                    npc.Velocity.Y = npc.Velocity.Y - 0.02f;
                    if (npc.Velocity.Y > 2f)
                    {
                        npc.Velocity.Y = 2f;
                    }
                }
                else
                {
                    if (npc.Position.Y < Main.players[npc.target].Position.Y - 250f)
                    {
                        if (npc.Velocity.Y < 0f)
                        {
                            npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                        }
                        npc.Velocity.Y = npc.Velocity.Y + 0.02f;
                        if (npc.Velocity.Y < -2f)
                        {
                            npc.Velocity.Y = -2f;
                        }
                    }
                }
                if (npc.Position.X + (float)(npc.Width / 2) > Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2))
                {
                    if (npc.Velocity.X > 0f)
                    {
                        npc.Velocity.X = npc.Velocity.X * 0.98f;
                    }
                    npc.Velocity.X = npc.Velocity.X - 0.05f;
                    if (npc.Velocity.X > 8f)
                    {
                        npc.Velocity.X = 8f;
                    }
                }
                if (npc.Position.X + (float)(npc.Width / 2) < Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2))
                {
                    if (npc.Velocity.X < 0f)
                    {
                        npc.Velocity.X = npc.Velocity.X * 0.98f;
                    }
                    npc.Velocity.X = npc.Velocity.X + 0.05f;
                    if (npc.Velocity.X < -8f)
                    {
                        npc.Velocity.X = -8f;
                    }
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例12: AIRetinazer

        // 30
        private void AIRetinazer(NPC npc, bool flag)
        {
            if (npc.target < 0 || npc.target == 255 || Main.players[npc.target].dead || !Main.players[npc.target].Active)
            {
                npc.TargetClosest(true);
            }
            bool dead2 = Main.players[npc.target].dead;
            float num317 = npc.Position.X + (float)(npc.Width / 2) - Main.players[npc.target].Position.X - (float)(Main.players[npc.target].Width / 2);
            float num318 = npc.Position.Y + (float)npc.Height - 59f - Main.players[npc.target].Position.Y - (float)(Main.players[npc.target].Height / 2);
            float num319 = (float)Math.Atan2((double)num318, (double)num317) + 1.57f;
            if (num319 < 0f)
            {
                num319 += 6.283f;
            }
            else
            {
                if ((double)num319 > 6.283)
                {
                    num319 -= 6.283f;
                }
            }
            float num320 = 0.1f;
            if (npc.rotation < num319)
            {
                if ((double)(num319 - npc.rotation) > 3.1415)
                {
                    npc.rotation -= num320;
                }
                else
                {
                    npc.rotation += num320;
                }
            }
            else
            {
                if (npc.rotation > num319)
                {
                    if ((double)(npc.rotation - num319) > 3.1415)
                    {
                        npc.rotation += num320;
                    }
                    else
                    {
                        npc.rotation -= num320;
                    }
                }
            }
            if (npc.rotation > num319 - num320 && npc.rotation < num319 + num320)
            {
                npc.rotation = num319;
            }
            if (npc.rotation < 0f)
            {
                npc.rotation += 6.283f;
            }
            else
            {
                if ((double)npc.rotation > 6.283)
                {
                    npc.rotation -= 6.283f;
                }
            }
            if (npc.rotation > num319 - num320 && npc.rotation < num319 + num320)
            {
                npc.rotation = num319;
            }
            if (Main.dayTime || dead2)
            {
                npc.Velocity.Y = npc.Velocity.Y - 0.04f;
                if (npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                    return;
                }
            }
            else
            {
                if (npc.ai[0] == 0f)
                {
                    if (npc.ai[1] == 0f)
                    {
                        float num322 = 7f;
                        float num323 = 0.1f;
                        int num324 = 1;
                        if (npc.Position.X + (float)(npc.Width / 2) < Main.players[npc.target].Position.X + (float)Main.players[npc.target].Width)
                        {
                            num324 = -1;
                        }
                        Vector2 vector32 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                        float num325 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) + (float)(num324 * 300) - vector32.X;
                        float num326 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - 300f - vector32.Y;
                        float num327 = (float)Math.Sqrt((double)(num325 * num325 + num326 * num326));
                        float num328 = num327;
                        num327 = num322 / num327;
                        num325 *= num327;
                        num326 *= num327;
                        if (npc.Velocity.X < num325)
                        {
                            npc.Velocity.X = npc.Velocity.X + num323;
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例13: AIPrimeVice

 // 34
 private void AIPrimeVice(NPC npc, bool flag)
 {
     npc.spriteDirection = -(int)npc.ai[0];
     Vector2 vector47 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
     float num409 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0] - vector47.X;
     float num410 = Main.npcs[(int)npc.ai[1]].Position.Y + 230f - vector47.Y;
     float num411 = (float)Math.Sqrt((double)(num409 * num409 + num410 * num410));
     if (npc.ai[2] != 99f)
     {
         if (num411 > 800f)
         {
             npc.ai[2] = 99f;
         }
     }
     else
     {
         if (num411 < 400f)
         {
             npc.ai[2] = 0f;
         }
     }
     if (!Main.npcs[(int)npc.ai[1]].Active || Main.npcs[(int)npc.ai[1]].aiStyle != 32)
     {
         npc.ai[2] += 10f;
     }
     if (npc.ai[2] == 99f)
     {
         if (npc.Position.Y > Main.npcs[(int)npc.ai[1]].Position.Y)
         {
             if (npc.Velocity.Y > 0f)
             {
                 npc.Velocity.Y = npc.Velocity.Y * 0.96f;
             }
             npc.Velocity.Y = npc.Velocity.Y - 0.1f;
             if (npc.Velocity.Y > 8f)
             {
                 npc.Velocity.Y = 8f;
             }
         }
         else
         {
             if (npc.Position.Y < Main.npcs[(int)npc.ai[1]].Position.Y)
             {
                 if (npc.Velocity.Y < 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                 }
                 npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                 if (npc.Velocity.Y < -8f)
                 {
                     npc.Velocity.Y = -8f;
                 }
             }
         }
         if (npc.Position.X + (float)(npc.Width / 2) > Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2))
         {
             if (npc.Velocity.X > 0f)
             {
                 npc.Velocity.X = npc.Velocity.X * 0.96f;
             }
             npc.Velocity.X = npc.Velocity.X - 0.5f;
             if (npc.Velocity.X > 12f)
             {
                 npc.Velocity.X = 12f;
             }
         }
         if (npc.Position.X + (float)(npc.Width / 2) < Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2))
         {
             if (npc.Velocity.X < 0f)
             {
                 npc.Velocity.X = npc.Velocity.X * 0.96f;
             }
             npc.Velocity.X = npc.Velocity.X + 0.5f;
             if (npc.Velocity.X < -12f)
             {
                 npc.Velocity.X = -12f;
                 return;
             }
         }
     }
     else
     {
         if (npc.ai[2] == 0f || npc.ai[2] == 3f)
         {
             if (Main.npcs[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10)
             {
                 npc.timeLeft = 10;
             }
             if (Main.npcs[(int)npc.ai[1]].ai[1] != 0f)
             {
                 npc.TargetClosest(true);
                 npc.TargetClosest(true);
                 if (Main.players[npc.target].dead)
                 {
                     npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                     if (npc.Velocity.Y > 16f)
                     {
                         npc.Velocity.Y = 16f;
                     }
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例14: AIPrimeSaw

 // 33
 private void AIPrimeSaw(NPC npc, bool flag)
 {
     Vector2 vector42 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
     float num395 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0] - vector42.X;
     float num396 = Main.npcs[(int)npc.ai[1]].Position.Y + 230f - vector42.Y;
     float num397 = (float)Math.Sqrt((double)(num395 * num395 + num396 * num396));
     if (npc.ai[2] != 99f)
     {
         if (num397 > 800f)
         {
             npc.ai[2] = 99f;
         }
     }
     else
     {
         if (num397 < 400f)
         {
             npc.ai[2] = 0f;
         }
     }
     npc.spriteDirection = -(int)npc.ai[0];
     if (!Main.npcs[(int)npc.ai[1]].Active || Main.npcs[(int)npc.ai[1]].aiStyle != 32)
     {
         npc.ai[2] += 10f;
     }
     if (npc.ai[2] == 99f)
     {
         if (npc.Position.Y > Main.npcs[(int)npc.ai[1]].Position.Y)
         {
             if (npc.Velocity.Y > 0f)
             {
                 npc.Velocity.Y = npc.Velocity.Y * 0.96f;
             }
             npc.Velocity.Y = npc.Velocity.Y - 0.1f;
             if (npc.Velocity.Y > 8f)
             {
                 npc.Velocity.Y = 8f;
             }
         }
         else
         {
             if (npc.Position.Y < Main.npcs[(int)npc.ai[1]].Position.Y)
             {
                 if (npc.Velocity.Y < 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                 }
                 npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                 if (npc.Velocity.Y < -8f)
                 {
                     npc.Velocity.Y = -8f;
                 }
             }
         }
         if (npc.Position.X + (float)(npc.Width / 2) > Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2))
         {
             if (npc.Velocity.X > 0f)
             {
                 npc.Velocity.X = npc.Velocity.X * 0.96f;
             }
             npc.Velocity.X = npc.Velocity.X - 0.5f;
             if (npc.Velocity.X > 12f)
             {
                 npc.Velocity.X = 12f;
             }
         }
         if (npc.Position.X + (float)(npc.Width / 2) < Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2))
         {
             if (npc.Velocity.X < 0f)
             {
                 npc.Velocity.X = npc.Velocity.X * 0.96f;
             }
             npc.Velocity.X = npc.Velocity.X + 0.5f;
             if (npc.Velocity.X < -12f)
             {
                 npc.Velocity.X = -12f;
                 return;
             }
         }
     }
     else
     {
         if (npc.ai[2] == 0f || npc.ai[2] == 3f)
         {
             if (Main.npcs[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10)
             {
                 npc.timeLeft = 10;
             }
             if (Main.npcs[(int)npc.ai[1]].ai[1] != 0f)
             {
                 npc.TargetClosest(true);
                 if (Main.players[npc.target].dead)
                 {
                     npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                     if (npc.Velocity.Y > 16f)
                     {
                         npc.Velocity.Y = 16f;
                     }
                 }
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs

示例15: AIUnicorn

 // 26
 private void AIUnicorn(NPC npc, bool flag)
 {
     int num281 = 30;
     bool flag32 = false;
     if (npc.Velocity.Y == 0f && ((npc.Velocity.X > 0f && npc.direction < 0) || (npc.Velocity.X < 0f && npc.direction > 0)))
     {
         flag32 = true;
         npc.ai[3] += 1f;
     }
     if (npc.Position.X == npc.oldPosition.X || npc.ai[3] >= (float)num281 || flag32)
     {
         npc.ai[3] += 1f;
     }
     else
     {
         if (npc.ai[3] > 0f)
         {
             npc.ai[3] -= 1f;
         }
     }
     if (npc.ai[3] > (float)(num281 * 10))
     {
         npc.ai[3] = 0f;
     }
     if (npc.justHit)
     {
         npc.ai[3] = 0f;
     }
     if (npc.ai[3] == (float)num281)
     {
         npc.netUpdate = true;
     }
     if (npc.ai[3] < (float)num281)
     {
         npc.TargetClosest(true);
     }
     else
     {
         if (npc.Velocity.X == 0f)
         {
             if (npc.Velocity.Y == 0f)
             {
                 npc.ai[0] += 1f;
                 if (npc.ai[0] >= 2f)
                 {
                     npc.direction *= -1;
                     npc.spriteDirection = npc.direction;
                     npc.ai[0] = 0f;
                 }
             }
         }
         else
         {
             npc.ai[0] = 0f;
         }
         npc.directionY = -1;
         if (npc.direction == 0)
         {
             npc.direction = 1;
         }
     }
     float num282 = 6f;
     if (npc.Velocity.Y == 0f || npc.wet || (npc.Velocity.X <= 0f && npc.direction < 0) || (npc.Velocity.X >= 0f && npc.direction > 0))
     {
         if (npc.Velocity.X < -num282 || npc.Velocity.X > num282)
         {
             if (npc.Velocity.Y == 0f)
             {
                 npc.Velocity *= 0.8f;
             }
         }
         else
         {
             if (npc.Velocity.X < num282 && npc.direction == 1)
             {
                 npc.Velocity.X = npc.Velocity.X + 0.07f;
                 if (npc.Velocity.X > num282)
                 {
                     npc.Velocity.X = num282;
                 }
             }
             else
             {
                 if (npc.Velocity.X > -num282 && npc.direction == -1)
                 {
                     npc.Velocity.X = npc.Velocity.X - 0.07f;
                     if (npc.Velocity.X < -num282)
                     {
                         npc.Velocity.X = -num282;
                     }
                 }
             }
         }
     }
     if (npc.Velocity.Y == 0f)
     {
         int num283 = (int)((npc.Position.X + (float)(npc.Width / 2) + (float)((npc.Width / 2 + 2) * npc.direction) + npc.Velocity.X * 5f) / 16f);
         int num284 = (int)((npc.Position.Y + (float)npc.Height - 15f) / 16f);
         if ((npc.Velocity.X < 0f && npc.spriteDirection == -1) || (npc.Velocity.X > 0f && npc.spriteDirection == 1))
//.........這裏部分代碼省略.........
開發者ID:jocull,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:NPC.cs


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