示例#1
0
            public override void AI(SMNPC mnpc)
            {
                var wmnpc = mnpc as WormHead;

                //唯一目标
                if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
                {
                    npc.TargetClosest(true);
                }
                if (mnpc.Timer >= 0 && mnpc.Timer < 80)
                {
                    if (wmnpc.npc.velocity.Y < 20)
                    {
                        wmnpc.npc.velocity.Y += 0.5f;
                    }
                }
                else
                {
                    wmnpc.MoveToPlayer();
                }
                mnpc.Timer++;
                if (mnpc.Timer == 400)
                {
                    WormBodyNPC cur = mnpc as WormBodyNPC;
                    for (int i = 0; i < 45; i++)
                    {
                        WormBodyNPC nxt = cur.Tail;
                        if (i % 6 == 5)
                        {
                            var lastHead = cur.Head;
                            var newHead  = SpawnWormPart(cur.npc, ModContent.NPCType <WormFakeHead>());
                            newHead.npc.velocity = Main.rand.NextVector2CircularEdge(1, 1) * 25f;
                            newHead.Head         = cur.Head;
                            newHead.Tail         = cur;
                            cur.Head             = newHead;

                            var newTail = SpawnWormPart(cur.npc, ModContent.NPCType <WormTail>());
                            newTail.Head  = lastHead;
                            lastHead.Tail = newTail;
                        }
                        cur = nxt;
                    }
                    mnpc.Timer = 0;
                    mnpc.SetState <SplitAttack>();
                }
            }
示例#2
0
            public override void AI(SMNPC mnpc)
            {
                npc.realLife = npc.whoAmI;
                int         length = 50;
                WormBodyNPC cur    = (WormBodyNPC)mnpc;

                for (int i = 0; i < length; i++)
                {
                    int type = (i == length - 1) ? ModContent.NPCType <WormTail>() : ModContent.NPCType <WormBody>();
                    var part = SpawnWormPart(npc, type);
                    part.npc.realLife     = npc.realLife;
                    part.Head             = cur;
                    GetWorm(cur.npc).Tail = part;
                    // 每个蠕虫身体维护双向链表,前驱和后继
                    cur = part;
                }
                mnpc.SetState <NormalAttack>();
            }