• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Terraria_Server.NPC类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Terraria_Server.NPC的典型用法代码示例。如果您正苦于以下问题:C# NPC类的具体用法?C# NPC怎么用?C# NPC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NPC类属于Terraria_Server命名空间,在下文中一共展示了NPC类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: getActiveNPCs

        // Summary:
        //       Get the array of Active NPCs
        public NPC[] getActiveNPCs()
        {
            NPC[] npcs = null;

            int npcCount = 0;
            for (int i = 0; i < Main.npc.Length-1; i++)
            {
                if (Main.npc[i].active)
                {
                    npcCount++;
                }
            }

            if (npcCount > 0)
            {
                npcs = new NPC[npcCount];
                npcCount = 0;
                for (int i = 0; i < Main.npc.Length-1; i++)
                {
                    if (Main.npc[i].active)
                    {
                        npcs[npcCount] = Main.npc[i];
                        npcCount++;
                    }
                }
            }

            return npcs;
        }
开发者ID:Genesis999,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:31,代码来源:Server.cs


示例2: AISkeletronHand

 // 12
 private void AISkeletronHand(NPC npc, bool flag)
 {
     npc.spriteDirection = -(int)npc.ai[0];
     if (!Main.npcs[(int)npc.ai[1]].Active || Main.npcs[(int)npc.ai[1]].aiStyle != 11)
     {
         npc.ai[2] += 10f;
         if (npc.ai[2] > 50f)
         {
             npc.life = -1;
             npc.HitEffect(0, 10.0);
             npc.Active = false;
         }
     }
     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)
         {
             if (npc.Position.Y > Main.npcs[(int)npc.ai[1]].Position.Y - 100f)
             {
                 if (npc.Velocity.Y > 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                 }
                 npc.Velocity.Y = npc.Velocity.Y - 0.07f;
                 if (npc.Velocity.Y > 6f)
                 {
                     npc.Velocity.Y = 6f;
                 }
             }
             else
             {
                 if (npc.Position.Y < Main.npcs[(int)npc.ai[1]].Position.Y - 100f)
                 {
                     if (npc.Velocity.Y < 0f)
                     {
                         npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                     }
                     npc.Velocity.Y = npc.Velocity.Y + 0.07f;
                     if (npc.Velocity.Y < -6f)
                     {
                         npc.Velocity.Y = -6f;
                     }
                 }
             }
             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) - 120f * npc.ai[0])
             {
                 if (npc.Velocity.X > 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X * 0.96f;
                 }
                 npc.Velocity.X = npc.Velocity.X - 0.1f;
                 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) - 120f * npc.ai[0])
             {
                 if (npc.Velocity.X < 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X * 0.96f;
                 }
                 npc.Velocity.X = npc.Velocity.X + 0.1f;
                 if (npc.Velocity.X < -8f)
                 {
                     npc.Velocity.X = -8f;
                 }
             }
         }
         else
         {
             npc.ai[3] += 1f;
             if (npc.ai[3] >= 300f)
             {
                 npc.ai[2] += 1f;
                 npc.ai[3] = 0f;
                 npc.netUpdate = true;
             }
             if (npc.Position.Y > Main.npcs[(int)npc.ai[1]].Position.Y + 230f)
             {
                 if (npc.Velocity.Y > 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                 }
                 npc.Velocity.Y = npc.Velocity.Y - 0.04f;
                 if (npc.Velocity.Y > 3f)
                 {
                     npc.Velocity.Y = 3f;
                 }
             }
             else
             {
                 if (npc.Position.Y < Main.npcs[(int)npc.ai[1]].Position.Y + 230f)
                 {
                     if (npc.Velocity.Y < 0f)
//.........这里部分代码省略.........
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:NPC.cs


示例3: AIFish

        // 16
        private void AIFish(NPC npc, bool flag)
        {
            if (npc.direction == 0)
            {
                npc.TargetClosest(true);
            }
            if (npc.wet)
            {
                if (npc.collideX)
                {
                    npc.Velocity.X = npc.Velocity.X * -1f;
                    npc.direction *= -1;
                }
                if (npc.collideY)
                {
                    if (npc.Velocity.Y > 0f)
                    {
                        npc.Velocity.Y = Math.Abs(npc.Velocity.Y) * -1f;
                        npc.directionY = -1;
                        npc.ai[0] = -1f;
                    }
                    else
                    {
                        if (npc.Velocity.Y < 0f)
                        {
                            npc.Velocity.Y = Math.Abs(npc.Velocity.Y);
                            npc.directionY = 1;
                            npc.ai[0] = 1f;
                        }
                    }
                }
                bool flag16 = false;
                if (!npc.friendly)
                {
                    npc.TargetClosest(false);
                    if (Main.players[npc.target].wet && !Main.players[npc.target].dead)
                    {
                        flag16 = true;
                    }
                }
                if (flag16)
                {
                    npc.TargetClosest(true);
                    if (npc.Type == 65)
                    {
                        npc.Velocity.X = npc.Velocity.X + (float)npc.direction * 0.15f;
                        npc.Velocity.Y = npc.Velocity.Y + (float)npc.directionY * 0.15f;
                        if (npc.Velocity.X > 5f)
                        {
                            npc.Velocity.X = 5f;
                        }
                        if (npc.Velocity.X < -5f)
                        {
                            npc.Velocity.X = -5f;
                        }
                        if (npc.Velocity.Y > 3f)
                        {
                            npc.Velocity.Y = 3f;
                        }
                        if (npc.Velocity.Y < -3f)
                        {
                            npc.Velocity.Y = -3f;
                        }
                    }
                    else
                    {
                        npc.Velocity.X = npc.Velocity.X + (float)npc.direction * 0.1f;
                        npc.Velocity.Y = npc.Velocity.Y + (float)npc.directionY * 0.1f;
                        if (npc.Velocity.X > 3f)
                        {
                            npc.Velocity.X = 3f;
                        }
                        if (npc.Velocity.X < -3f)
                        {
                            npc.Velocity.X = -3f;
                        }
                        if (npc.Velocity.Y > 2f)
                        {
                            npc.Velocity.Y = 2f;
                        }
                        if (npc.Velocity.Y < -2f)
                        {
                            npc.Velocity.Y = -2f;
                        }
                    }
                }
                else
                {
                    npc.Velocity.X = npc.Velocity.X + (float)npc.direction * 0.1f;
                    if (npc.Velocity.X < -1f || npc.Velocity.X > 1f)
                    {
                        npc.Velocity.X = npc.Velocity.X * 0.95f;
                    }
                    if (npc.ai[0] == -1f)
                    {
                        npc.Velocity.Y = npc.Velocity.Y - 0.01f;
                        if ((double)npc.Velocity.Y < -0.3)
                        {
                            npc.ai[0] = 1f;
//.........这里部分代码省略.........
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:NPC.cs


示例4: AIEoC

        // 4
        private void AIEoC(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 dead = Main.players[npc.target].dead;
            float num6 = npc.Position.X + (float)(npc.Width / 2) - Main.players[npc.target].Position.X - (float)(Main.players[npc.target].Width / 2);
            float num7 = npc.Position.Y + (float)npc.Height - 59f - Main.players[npc.target].Position.Y - (float)(Main.players[npc.target].Height / 2);
            float num8 = (float)Math.Atan2((double)num7, (double)num6) + 1.57f;
            if (num8 < 0f)
            {
                num8 += 6.283f;
            }
            else
            {
                if ((double)num8 > 6.283)
                {
                    num8 -= 6.283f;
                }
            }
            float num9 = 0f;
            if (npc.ai[0] == 0f && npc.ai[1] == 0f)
            {
                num9 = 0.02f;
            }
            if (npc.ai[0] == 0f && npc.ai[1] == 2f && npc.ai[2] > 40f)
            {
                num9 = 0.05f;
            }
            if (npc.ai[0] == 3f && npc.ai[1] == 0f)
            {
                num9 = 0.05f;
            }
            if (npc.ai[0] == 3f && npc.ai[1] == 2f && npc.ai[2] > 40f)
            {
                num9 = 0.08f;
            }
            if (npc.rotation < num8)
            {
                if ((double)(num8 - npc.rotation) > 3.1415)
                {
                    npc.rotation -= num9;
                }
                else
                {
                    npc.rotation += num9;
                }
            }
            else
            {
                if (npc.rotation > num8)
                {
                    if ((double)(npc.rotation - num8) > 3.1415)
                    {
                        npc.rotation += num9;
                    }
                    else
                    {
                        npc.rotation -= num9;
                    }
                }
            }
            if (npc.rotation > num8 - num9 && npc.rotation < num8 + num9)
            {
                npc.rotation = num8;
            }
            if (npc.rotation < 0f)
            {
                npc.rotation += 6.283f;
            }
            else
            {
                if ((double)npc.rotation > 6.283)
                {
                    npc.rotation -= 6.283f;
                }
            }
            if (npc.rotation > num8 - num9 && npc.rotation < num8 + num9)
            {
                npc.rotation = num8;
            }
            if (Main.dayTime || dead)
            {
                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 num11 = 5f;
                        float num12 = 0.04f;
//.........这里部分代码省略.........
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:NPC.cs


示例5: AICursedSkull

 // 10
 private void AICursedSkull(NPC npc, bool flag)
 {
     float num110 = 1f;
     float num111 = 0.011f;
     npc.TargetClosest(true);
     Vector2 vector12 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
     float num112 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector12.X;
     float num113 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector12.Y;
     float num114 = (float)Math.Sqrt((double)(num112 * num112 + num113 * num113));
     float num115 = num114;
     npc.ai[1] += 1f;
     if (npc.ai[1] > 600f)
     {
         num111 *= 8f;
         num110 = 4f;
         if (npc.ai[1] > 650f)
         {
             npc.ai[1] = 0f;
         }
     }
     else
     {
         if (num115 < 250f)
         {
             npc.ai[0] += 0.9f;
             if (npc.ai[0] > 0f)
             {
                 npc.Velocity.Y = npc.Velocity.Y + 0.019f;
             }
             else
             {
                 npc.Velocity.Y = npc.Velocity.Y - 0.019f;
             }
             if (npc.ai[0] < -100f || npc.ai[0] > 100f)
             {
                 npc.Velocity.X = npc.Velocity.X + 0.019f;
             }
             else
             {
                 npc.Velocity.X = npc.Velocity.X - 0.019f;
             }
             if (npc.ai[0] > 200f)
             {
                 npc.ai[0] = -200f;
             }
         }
     }
     if (num115 > 350f)
     {
         num110 = 5f;
         num111 = 0.3f;
     }
     else
     {
         if (num115 > 300f)
         {
             num110 = 3f;
             num111 = 0.2f;
         }
         else
         {
             if (num115 > 250f)
             {
                 num110 = 1.5f;
                 num111 = 0.1f;
             }
         }
     }
     num114 = num110 / num114;
     num112 *= num114;
     num113 *= num114;
     if (Main.players[npc.target].dead)
     {
         num112 = (float)npc.direction * num110 / 2f;
         num113 = -num110 / 2f;
     }
     if (npc.Velocity.X < num112)
     {
         npc.Velocity.X = npc.Velocity.X + num111;
     }
     else
     {
         if (npc.Velocity.X > num112)
         {
             npc.Velocity.X = npc.Velocity.X - num111;
         }
     }
     if (npc.Velocity.Y < num113)
     {
         npc.Velocity.Y = npc.Velocity.Y + num111;
     }
     else
     {
         if (npc.Velocity.Y > num113)
         {
             npc.Velocity.Y = npc.Velocity.Y - num111;
         }
     }
     if (num112 > 0f)
//.........这里部分代码省略.........
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:NPC.cs


示例6: AIBird

        // 24
        private void AIBird(NPC npc, bool flag)
        {
            npc.noGravity = true;
            if (npc.ai[0] == 0f)
            {
                npc.noGravity = false;
                npc.TargetClosest(true);
                if (npc.Velocity.X != 0f || npc.Velocity.Y < 0f || (double)npc.Velocity.Y > 0.3)
                {
                    npc.ai[0] = 1f;
                    npc.netUpdate = true;
                    npc.direction = -npc.direction;
                }
                else
                {
                    Rectangle rectangle7 = new Rectangle((int)Main.players[npc.target].Position.X,
                        (int)Main.players[npc.target].Position.Y, Main.players[npc.target].Width, Main.players[npc.target].Height);
                    Rectangle rectangle8 = new Rectangle((int)npc.Position.X - 100, (int)npc.Position.Y - 100, npc.Width + 200, npc.Height + 200);
                    if (rectangle8.Intersects(rectangle7) || npc.life < npc.lifeMax)
                    {
                        npc.ai[0] = 1f;
                        npc.Velocity.Y = npc.Velocity.Y - 6f;
                        npc.netUpdate = true;
                        npc.direction = -npc.direction;
                    }
                }
            }
            else
            {
                if (!Main.players[npc.target].dead)
                {
                    if (npc.collideX)
                    {
                        npc.direction *= -1;
                        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 (npc.direction == -1 && npc.Velocity.X > -3f)
                    {
                        npc.Velocity.X = npc.Velocity.X - 0.1f;
                        if (npc.Velocity.X > 3f)
                            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 < -3f)
                            npc.Velocity.X = -3f;
                    }
                    else
                    {
                        if (npc.direction == 1 && npc.Velocity.X < 3f)
                        {
                            npc.Velocity.X = npc.Velocity.X + 0.1f;
                            if (npc.Velocity.X < -3f)
                                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 > 3f)
                                npc.Velocity.X = 3f;
                        }
                    }
                    int num276 = (int)((npc.Position.X + (float)(npc.Width / 2)) / 16f) + npc.direction;
                    int num277 = (int)((npc.Position.Y + (float)npc.Height) / 16f);
                    bool flag30 = true;
                    int num278 = 15;
                    bool flag31 = false;
                    for (int num279 = num277; num279 < num277 + num278; num279++)
                    {
                        if ((Main.tile.At(num276, num279).Active && Main.tileSolid[(int)Main.tile.At(num276, num279).Type]) || Main.tile.At(num276, num279).Liquid > 0)
                        {
                            if (num279 < num277 + 5)flag31 = true;

                            flag30 = false;
                            break;
                        }
                    }
                    if (flag30)
                        npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                    else
                        npc.Velocity.Y = npc.Velocity.Y - 0.1f;
                    if (flag31)
                        npc.Velocity.Y = npc.Velocity.Y - 0.2f;
                    if (npc.Velocity.Y > 3f)
                        npc.Velocity.Y = 3f;
                    if (npc.Velocity.Y < -4f)
                        npc.Velocity.Y = -4f;
                }
//.........这里部分代码省略.........
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:NPC.cs


示例7: InvokeNpcCreationHook

        static bool InvokeNpcCreationHook(int x, int y, string type, out NPC npc)
        {
            npc = null;

            if (!WorldModify.gen)
            {
                var ctx = new HookContext
                {
                };

                var args = new HookArgs.NpcCreation
                {
                    X = x, Y = y,
                    Name = type,
                };

                HookPoints.NpcCreation.Invoke (ref ctx, ref args);

                if (ctx.Result == HookResult.IGNORE)
                    return false;

                npc = args.CreatedNpc;
            }

            return true;
        }
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:26,代码来源:NPC.cs


示例8: 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


示例9: AISphere

 // 9
 private void AISphere(NPC npc, bool flag)
 {
     if (npc.target == 255)
     {
         npc.TargetClosest(true);
         float num102 = 6f;
         if (npc.Type == 25)
         {
             num102 = 5f;
         }
         Vector2 vector11 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
         float num103 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector11.X;
         float num104 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector11.Y;
         float num105 = (float)Math.Sqrt((double)(num103 * num103 + num104 * num104));
         num105 = num102 / num105;
         npc.Velocity.X = num103 * num105;
         npc.Velocity.Y = num104 * num105;
     }
     if (npc.timeLeft > 100)
     {
         npc.timeLeft = 100;
     }
     npc.rotation += 0.4f * (float)npc.direction;
     return;
 }
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:26,代码来源:NPC.cs


示例10: AISpazmatism

        // 31
        private void AISpazmatism(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 dead3 = Main.players[npc.target].dead;
            float num355 = npc.Position.X + (float)(npc.Width / 2) - Main.players[npc.target].Position.X - (float)(Main.players[npc.target].Width / 2);
            float num356 = npc.Position.Y + (float)npc.Height - 59f - Main.players[npc.target].Position.Y - (float)(Main.players[npc.target].Height / 2);
            float num357 = (float)Math.Atan2((double)num356, (double)num355) + 1.57f;

            if (num357 < 0f)
                num357 += 6.283f;
            else if ((double)num357 > 6.283)
                num357 -= 6.283f;

            float num358 = 0.15f;
            if (npc.rotation < num357)
            {
                if ((double)(num357 - npc.rotation) > 3.1415)
                    npc.rotation -= num358;
                else
                    npc.rotation += num358;
            }
            else if (npc.rotation > num357)
            {
                if ((double)(npc.rotation - num357) > 3.1415)
                    npc.rotation += num358;
                else
                    npc.rotation -= num358;
            }
            if (npc.rotation > num357 - num358 && npc.rotation < num357 + num358)
                npc.rotation = num357;

            if (npc.rotation < 0f)
                npc.rotation += 6.283f;
            else if ((double)npc.rotation > 6.283)
                npc.rotation -= 6.283f;

            if (npc.rotation > num357 - num358 && npc.rotation < num357 + num358)
                npc.rotation = num357;

            if (Main.dayTime || dead3)
            {
                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)
                    {
                        npc.TargetClosest(true);
                        float num360 = 12f;
                        float num361 = 0.4f;
                        int num362 = 1;
                        if (npc.Position.X + (float)(npc.Width / 2) < Main.players[npc.target].Position.X + (float)Main.players[npc.target].Width)
                            num362 = -1;

                        Vector2 vector36 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                        float num363 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) + (float)(num362 * 400) - vector36.X;
                        float num364 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector36.Y;
                        float num365 = (float)Math.Sqrt((double)(num363 * num363 + num364 * num364));
                        num365 = num360 / num365;
                        num363 *= num365;
                        num364 *= num365;
                        if (npc.Velocity.X < num363)
                        {
                            npc.Velocity.X = npc.Velocity.X + num361;
                            if (npc.Velocity.X < 0f && num363 > 0f)
                                npc.Velocity.X = npc.Velocity.X + num361;
                        }
                        else
                        {
                            if (npc.Velocity.X > num363)
                            {
                                npc.Velocity.X = npc.Velocity.X - num361;
                                if (npc.Velocity.X > 0f && num363 < 0f)
                                    npc.Velocity.X = npc.Velocity.X - num361;
                            }
                        }
                        if (npc.Velocity.Y < num364)
                        {
                            npc.Velocity.Y = npc.Velocity.Y + num361;
                            if (npc.Velocity.Y < 0f && num364 > 0f)
                                npc.Velocity.Y = npc.Velocity.Y + num361;
                        }
                        else
                        {
                            if (npc.Velocity.Y > num364)
                            {
                                npc.Velocity.Y = npc.Velocity.Y - num361;
                                if (npc.Velocity.Y > 0f && num364 < 0f)
                                    npc.Velocity.Y = npc.Velocity.Y - num361;
//.........这里部分代码省略.........
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:NPC.cs


示例11: AISlowDebuffFlying

        // 22
        private void AISlowDebuffFlying(NPC npc, bool flag)
        {
            bool flag25 = false;
            if (npc.justHit)
            {
                npc.ai[2] = 0f;
            }
            if (npc.ai[2] >= 0f)
            {
                int num258 = 16;
                bool flag26 = false;
                bool flag27 = false;
                if (npc.Position.X > npc.ai[0] - (float)num258 && npc.Position.X < npc.ai[0] + (float)num258)
                {
                    flag26 = true;
                }
                else
                {
                    if ((npc.Velocity.X < 0f && npc.direction > 0) || (npc.Velocity.X > 0f && npc.direction < 0))
                    {
                        flag26 = true;
                    }
                }
                num258 += 24;
                if (npc.Position.Y > npc.ai[1] - (float)num258 && npc.Position.Y < npc.ai[1] + (float)num258)
                {
                    flag27 = true;
                }
                if (flag26 && flag27)
                {
                    npc.ai[2] += 1f;
                    if (npc.ai[2] >= 30f && num258 == 16)
                    {
                        flag25 = true;
                    }
                    if (npc.ai[2] >= 60f)
                    {
                        npc.ai[2] = -200f;
                        npc.direction *= -1;
                        npc.Velocity.X = npc.Velocity.X * -1f;
                        npc.collideX = false;
                    }
                }
                else
                {
                    npc.ai[0] = npc.Position.X;
                    npc.ai[1] = npc.Position.Y;
                    npc.ai[2] = 0f;
                }
                npc.TargetClosest(true);
            }
            else
            {
                npc.ai[2] += 1f;
                if (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) > npc.Position.X + (float)(npc.Width / 2))
                {
                    npc.direction = -1;
                }
                else
                {
                    npc.direction = 1;
                }
            }
            int num259 = (int)((npc.Position.X + (float)(npc.Width / 2)) / 16f) + npc.direction * 2;
            int num260 = (int)((npc.Position.Y + (float)npc.Height) / 16f);
            bool flag28 = true;
            bool flag29 = false;
            int num261 = 3;
            if (npc.Type == 122)
            {
                if (npc.justHit)
                {
                    npc.ai[3] = 0f;
                    npc.localAI[1] = 0f;
                }
                float num262 = 7f;
                Vector2 vector27 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                float num263 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector27.X;
                float num264 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector27.Y;
                float num265 = (float)Math.Sqrt((double)(num263 * num263 + num264 * num264));
                num265 = num262 / num265;
                num263 *= num265;
                num264 *= num265;
                if (npc.ai[3] == 32f)
                {
                    int num266 = 25;
                    int num267 = 84;
                    Projectile.NewProjectile(vector27.X, vector27.Y, num263, num264, num267, num266, 0f, Main.myPlayer);
                }
                num261 = 8;
                if (npc.ai[3] > 0f)
                {
                    npc.ai[3] += 1f;
                    if (npc.ai[3] >= 64f)
                    {
                        npc.ai[3] = 0f;
                    }
                }
                if (npc.ai[3] == 0f)
//.........这里部分代码省略.........
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:NPC.cs


示例12: NewNPC

        public static int NewNPC(int x, int y, NPC npc, int npcIndex)
        {
            npc.Position.X = (float)(x - npc.Width / 2);
            npc.Position.Y = (float)(y - npc.Height);
            npc.Active = true;
            npc.timeLeft = (int)((double)NPC.active_TIME * 1.25);
            npc.wet = Collision.WetCollision(npc.Position, npc.Width, npc.Height);

            Main.npcs[npcIndex] = npc;

            return npcIndex;
        }
开发者ID:jocull,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:12,代码来源:NPC.cs


示例13: 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


示例14: 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


示例15: 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. 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Logging.ProgressLogger类代码示例发布时间:2022-05-26
下一篇:
C# UI.UIMouseEvent类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap