public override void AI() { if (Twilight.FindHead() == -1 || ApoBirdSky.CurrentState != ApoBirdSky.State.ApoSky) { projectile.Kill(); return; } else { projectile.Center = Main.npc[Twilight.FindHead()].Center + new Vector2(0, -100); } projectile.ai[1]++; if (projectile.ai[1] < 30) //0-30显形,30-60静止,60-70旋转,70-120惯性,120-160静止,160-190消失 { projectile.Opacity = projectile.ai[1] / 30; } else if (projectile.ai[1] < 60) { projectile.Opacity = 1; } else if (projectile.ai[1] < 70) { projectile.rotation += MathHelper.Pi / 50; ArmRot = MathHelper.Pi / 6 * (projectile.ai[1] - 60) / 10; } else if (projectile.ai[1] < 120) { float k = (120f - projectile.ai[1]) / 50 * MathHelper.Pi / 6; float a = (projectile.ai[1] - 70f) / 10f * MathHelper.Pi; ArmRot = k * (float)Math.Cos(a); } else if (projectile.ai[1] < 160) { ArmRot = 0; } else { projectile.Opacity = (190f - projectile.ai[1]) / 30; if (projectile.ai[1] >= 190) { projectile.Kill(); return; } } if (projectile.ai[1] == 70) { int dmg = (int)(TwilightData.JusticeDamage * TwilightPlayer.GetDamageBonus(Main.player[projectile.owner])); Projectile.NewProjectile(Main.screenPosition, Vector2.Zero, ModContent.ProjectileType <JusticeDamage>(), dmg, 0, projectile.owner); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/JusticeOn"), Main.player[projectile.owner].Center); } if (projectile.ai[1] == 60) { Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType <JustitiaEffect2>(), 0, 0, projectile.owner); } //projectile.rotation += 0.05f; }
public override void AI() { //npc.ai[3] = Player.FindClosest(npc.Center, 1, 1); Player owner = Main.player[(int)npc.ai[3]]; if (ApoBirdSky.CurrentState == ApoBirdSky.State.NoSky) { npc.active = false; return; } if (Twilight.FindBody() != npc.whoAmI) { npc.active = false; return; } if (ApoBirdSky.CurrentState == ApoBirdSky.State.ApoSky) { WingLight = (WingLight + 1) % 100; } if (npc.ai[0] == 0) { npc.ai[0] = 1; npc.localAI[0] = -1; npc.localAI[1] = -1; NPC.NewNPC((int)npc.Center.X - 750, (int)npc.Center.Y - 300, ModContent.NPCType <ApoBirdClaw>(), npc.whoAmI, -1, 0, 0, owner.whoAmI); NPC.NewNPC((int)npc.Center.X + 750, (int)npc.Center.Y - 300, ModContent.NPCType <ApoBirdClaw>(), npc.whoAmI, 1, 0, 0, owner.whoAmI); NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 250, ModContent.NPCType <ApoBirdHead>(), npc.whoAmI, 0, 0, 0, owner.whoAmI); } NPC Head = Main.npc[Twilight.FindHead()]; NPC ClawL = Main.npc[Twilight.FindArmLeft()]; NPC ClawR = Main.npc[Twilight.FindArmRight()]; //Main.NewText(CurrentState); if (CurrentState == State.ClawAttack && ApoBirdClaw.IsStrike() == 0) { OldWingRot = null; NormalWingTimer = 0; CurrentState = State.Default; } if (CurrentState == State.Lantern && Head.ai[1] == 0) { CurrentState = State.Default; } if (CurrentState == State.Justice && Head.ai[1] == 0) { CurrentState = State.Default; } //Main.NewText(npc.ai[2]); if (ApoBirdSky.CurrentState == ApoBirdSky.State.ApoSky) { if (owner.channel) { int dir = owner.direction; Vector2 MouseDir = Vector2.Normalize(Main.MouseWorld - owner.Center); owner.itemRotation = (float)Math.Atan2(MouseDir.Y * dir, MouseDir.X * dir); } if (owner.channel && !owner.GetModPlayer <TwilightPlayer>().RightClick) { if (CurrentState == State.Default) { npc.ai[2]++; } if (npc.ai[2] == TwilightData.EyeBulletCD) { npc.ai[2]++; InitiateBullet(); } if (npc.ai[2] == TwilightData.EyeBulletCD + TwilightData.ClawCD) { npc.ai[2] = 0; bool Left = Main.MouseWorld.X <= Main.LocalPlayer.Center.X; InitiateStrike(Left); } } if (owner.GetModPlayer <TwilightPlayer>().RightClick) { if (CurrentState == State.Default) { if (owner.GetModPlayer <TwilightPlayer>().SpecialAttackCD == 0) { switch (owner.GetModPlayer <TwilightPlayer>().CurrentEgg) { case 0: InitiateLantern(); owner.GetModPlayer <TwilightPlayer>().SpecialAttackCD = TwilightData.EyeSpecialCD; break; case 1: InitiateJustice(); owner.GetModPlayer <TwilightPlayer>().SpecialAttackCD = TwilightData.JusticeSpecialCD; break; case 2: InitiatePeck(); owner.GetModPlayer <TwilightPlayer>().SpecialAttackCD = TwilightData.PeckSpecialCD; break; default: break; } } } } } bool Moven = false; if (ApoBirdSky.CurrentState == ApoBirdSky.State.ApoSky) { if (CurrentState == State.Default) { OldWingRot = null; NormalWingTimer = (NormalWingTimer + 1) % 200; WingRot = (float)Math.Sin(MathHelper.TwoPi * NormalWingTimer / 200f) * MathHelper.Pi / 60; } } #region 控制下砸时的身体活动 if (CurrentState == State.ClawAttack) { NPC StrikingClaw; //Main.NewText(ApoBirdClaw.IsStrike()); if (ApoBirdClaw.IsStrike() == -1) { StrikingClaw = ClawL; } else if (ApoBirdClaw.IsStrike() == 1) { StrikingClaw = ClawR; } else { StrikingClaw = null; } if (StrikingClaw != null) { if (StrikingClaw.ai[2] < 60) { if (OldWingRot == null) { OldWingRot = WingRot; } npc.rotation = MathHelper.Lerp(0, MathHelper.Pi / 12 * (-ApoBirdClaw.IsStrike()), StrikingClaw.ai[2] / 60f); WingRot = MathHelper.Lerp(OldWingRot.Value, MathHelper.Pi / 10, StrikingClaw.ai[2] / 60f); } else if (StrikingClaw.ai[2] < 80) { npc.rotation = MathHelper.Lerp(MathHelper.Pi / 12 * (-ApoBirdClaw.IsStrike()), 0, (StrikingClaw.ai[2] - 60) / 20f); WingRot = MathHelper.Lerp(MathHelper.Pi / 10, 0, (StrikingClaw.ai[2] - 60) / 20f); } else { npc.rotation = 0; WingRot = 0; } Head.rotation = npc.rotation; } else { npc.rotation = 0; WingRot = 0; } } #endregion #region 射线攻击活动 if (CurrentState == State.EyeAttack) { ExtraTimer++; if (ExtraTimer < 60) { if (OldWingRot == null) { OldWingRot = WingRot; } WingRot = MathHelper.Lerp(OldWingRot.Value, 0, ExtraTimer / 60f); } else { WingRot = 0; if (ExtraTimer == 60) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/EyeBulletStart"), owner.Center); int dmg = (int)(TwilightData.BulletDamage * TwilightPlayer.GetDamageBonus(Main.player[(int)npc.ai[3]])); //左翅膀 Vector2 WingPos = npc.Center + new Vector2(5, 0); for (int i = 0; i < 6; i++) { Vector2 EyePos = WingEyePos[i].RotatedBy(-WingRot) * 0.9f; EyePos.X = -EyePos.X; float EyeRot = WingEyeRot[i]; int protmp = Projectile.NewProjectile(WingPos + EyePos, Vector2.Zero, ModContent.ProjectileType <EyeBulletReady>(), dmg, 0, (int)npc.ai[3]); Main.projectile[protmp].ai[0] = -Main.rand.Next(60); Main.projectile[protmp].rotation = EyeRot; (Main.projectile[protmp].modProjectile as EyeBulletReady).Pos = WingPos + EyePos - npc.Center; } //右翅膀 WingPos = npc.Center + new Vector2(-5, 0); for (int i = 0; i < 6; i++) { Vector2 EyePos = WingEyePos[i].RotatedBy(WingRot) * 0.9f; float EyeRot = -WingEyeRot[i]; int protmp = Projectile.NewProjectile(WingPos + EyePos, Vector2.Zero, ModContent.ProjectileType <EyeBulletReady>(), dmg, 0, (int)npc.ai[3]); Main.projectile[protmp].ai[0] = -Main.rand.Next(60); Main.projectile[protmp].rotation = EyeRot; (Main.projectile[protmp].modProjectile as EyeBulletReady).Pos = WingPos + EyePos - npc.Center; } } if (ExtraTimer > 121) { ExtraTimer = 0; CurrentState = State.Default; OldWingRot = null; NormalWingTimer = 0; } } } #endregion #region 尖喙时翅膀运动相关 if (CurrentState == State.Beak) { if (ExtraTimer < 120) { if (OldWingRot == null) { OldWingRot = WingRot; } WingRot = MathHelper.Lerp(OldWingRot.Value, MathHelper.Pi / 15, ExtraTimer / 120f); } else if (ExtraTimer < 130) { WingRot = MathHelper.Pi / 15; } else if (ExtraTimer < 140) { WingRot = MathHelper.Lerp(MathHelper.Pi / 15, 0, (ExtraTimer - 130) / 10f); } else { WingRot = 0; } } #endregion if (CurrentState == State.Default || CurrentState == State.ClawAttack || CurrentState == State.EyeAttack || CurrentState == State.Lantern || CurrentState == State.Justice) { Movement(owner.Center); Moven = true; } if (CurrentState == State.Beak) { ExtraTimer++; if (ExtraTimer < 60) //移动到指定位置 { Movement(owner.Center + TargetPos * ExtraTimer / 60f); Moven = true; } else if (ExtraTimer < 170) //60-100停止,100-160攻击,160-170停止 { if (ExtraTimer == 100) { int dmg = (int)(TwilightData.PeckDamage * TwilightPlayer.GetDamageBonus(Main.player[(int)npc.ai[3]])); Projectile.NewProjectile(npc.Center + new Vector2(0, 138), Vector2.Zero, ModContent.ProjectileType <PeckCenter>(), dmg, 0, (int)npc.ai[3]); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/PeckAttack"), owner.Center); } Movement(owner.Center + TargetPos); Moven = true; } else if (ExtraTimer < 230) //返回 { Movement(owner.Center + TargetPos * (230 - ExtraTimer) / 60f); Moven = true; } else { ExtraTimer = 0; CurrentState = State.Default; OldWingRot = null; NormalWingTimer = 0; } } if (!Moven) { npc.velocity *= 0.8f; } }
public override void AI() { Player owner = Main.player[(int)npc.ai[3]]; if (Twilight.FindArmLeft() != npc.whoAmI && Twilight.FindArmRight() != npc.whoAmI) { npc.active = false; return; } if (Twilight.FindBody() == -1) { npc.active = false; return; } NPC Body = Main.npc[Twilight.FindBody()]; if (npc.ai[1] == (int)State.Normal) //正常移动 { Movement(Body.Center + new Vector2(750 * npc.ai[0], -300)); RelaPos = npc.Center - Body.Center; } else if (npc.ai[1] == (int)State.ClawAttack) //下砸 { npc.Center = Body.Center + RelaPos; npc.ai[2]++; if (npc.ai[2] < 60) //抬手 { npc.Center += new Vector2(0, -15); } else if (npc.ai[2] < 80) //砸 { npc.Center += new Vector2(0, 60); if (npc.ai[2] == 70) { int dmg = (int)(TwilightData.ClawDamage * TwilightPlayer.GetDamageBonus(Main.player[(int)npc.ai[3]])); Projectile.NewProjectile(npc.Center + new Vector2(0, 300), Vector2.Zero, ModContent.ProjectileType <MeleeHitEffect>(), dmg, 0, (int)npc.ai[3]); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/ClawAttack"), owner.Center); } } else if (npc.ai[2] < 110) { } else if (npc.ai[2] < 140) //收回 { npc.Center += new Vector2(0, -10); } else //复位 { //Body.ai[1] = 0; npc.ai[1] = (int)State.Normal; npc.ai[2] = 0; } //move RelaPos = npc.Center - Body.Center; if (npc.ai[2] == 80) { Main.LocalPlayer.GetModPlayer <TwilightUIPlayer>().InitialiseShake(25, 1); } } else if (npc.ai[1] == (int)State.HoldingUpForPeck) { npc.Center = Body.Center + RelaPos; npc.ai[2]++; if (npc.ai[2] > 45 && npc.ai[2] < 95) { npc.Center -= new Vector2(0, 12); } if (npc.ai[2] > 170 && npc.ai[2] < 220) { npc.Center += new Vector2(0, 12); } if (npc.ai[2] >= 230) { npc.ai[2] = 0; npc.ai[1] = (int)State.Normal; } RelaPos = npc.Center - Body.Center; } else if (npc.ai[1] == (int)State.ClawAlt) { npc.Center = Body.Center + RelaPos; npc.ai[2]++; if (npc.ai[2] < 60) //抬手 180 { npc.Center += new Vector2(0, 3); } else if (npc.ai[2] < 80) //砸 240 { npc.Center += new Vector2(0, -12); } else if (npc.ai[2] < 110) { } else if (npc.ai[2] < 140) //收回 60 { npc.Center += new Vector2(0, 2); } else //复位 { npc.ai[1] = (int)State.Normal; npc.ai[2] = 0; } //move RelaPos = npc.Center - Body.Center; } }