Exemplo n.º 1
0
 //小喙特殊攻击
 public void InitiatePeck()
 {
     CurrentState = State.Beak;
     ExtraTimer   = 0;
     TargetPos    = Main.MouseWorld - Main.player[(int)npc.ai[3]].Center + new Vector2(0, -139);
     ApoBirdClaw.HoldUpForPeck();
 }
Exemplo n.º 2
0
 //巨爪拍击
 public void InitiateStrike(bool Left)
 {
     CurrentState = State.ClawAttack;
     ApoBirdClaw.InitiateStrike(Left);
 }
Exemplo n.º 3
0
        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;
            }
        }