public override void AI(SMNPC mnpc) { var worm = (WormBodyNPC)(mnpc); npc.realLife = worm.Head.npc.realLife; mnpc.SetState <AttackState>(); }
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 >= 60 && mnpc.Timer < 80) { if (wmnpc.npc.velocity.Y < 20) { wmnpc.npc.velocity.Y += 0.5f; } } else { wmnpc.MoveToPlayer(); } mnpc.Timer++; if (mnpc.Timer == 360) { foreach (var n in Main.npc) { if (n.active && n.realLife == npc.whoAmI) { if (n.type == ModContent.NPCType <WormFakeHead>()) { var wormHead = n.modNPC as WormBodyNPC; wormHead.SetState <WormFakeHead.MergeState>(); } } } } else if (mnpc.Timer > 360) { if (wmnpc.npc.velocity.Y < 20) { wmnpc.npc.velocity.Y += 0.5f; } foreach (var n in Main.npc) { if (n.active && n.realLife == npc.whoAmI && n.type == ModContent.NPCType <WormFakeHead>()) { return; } } mnpc.Timer = 0; mnpc.SetState <NormalAttack>(); } }
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>(); } }
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>(); }
public override void AI(SMNPC mnpc) { mnpc.SetState <NormalAttack>(); }