Beispiel #1
0
        public override void AI()
        {
            Timer++;

            if (Timer == 1) // On-Spawn
            {
                leftLeg  = new KettleLimb(this, new Vector2(-10, 0));
                rightLeg = new KettleLimb(this, new Vector2(10, 0));
            }

            if (!Floating)
            {
                npc.velocity *= 0;
                npc.Center    = Vector2.Lerp(leftLeg.foot, rightLeg.foot, 0.5f) + new Vector2(0, -70);

                if (leftLeg.savedPoint == default && rightLeg.savedPoint == default && Landed == 0) //landing case
                {
                    WalkTimer           = 0;
                    rightLeg.savedPoint = rightLeg.foot + Vector2.UnitX * WALK_RADIUS;
                    rightLeg.foot.Y    -= 5;
                    FootOnGround        = leftLeg;
                    Landed = 1;
                }

                WalkTimer         += 0.14f;
                FootOffGround.foot = FootOffGround.savedPoint + (Vector2.UnitX * -WALK_RADIUS * npc.direction).RotatedBy(WalkTimer * npc.direction);

                if (WalkTimer > 4.68f)
                {
                    npc.velocity.Y -= 4;
                    npc.velocity.X += 4 * npc.direction;
                    leftLeg.MoveWholeLimb(npc.velocity);
                    rightLeg.MoveWholeLimb(npc.velocity);
                    WalkTimer = 0;
                }

                if (FootOffGround.footOnGround && WalkTimer > 0.5f)
                {
                    WalkTimer = 0;
                    FootOnGround.savedPoint = FootOnGround.foot + Vector2.UnitX * WALK_RADIUS * npc.direction;
                    FootOnGround.foot.Y    -= 16;
                    FootOnGround            = FootOffGround;

                    npc.TargetClosest(true);
                    npc.direction = Main.player[npc.target].Center.X > npc.Center.X ? 1 : -1;
                }
            }

            else
            {
                leftLeg.MoveWholeLimb(npc.velocity);
                rightLeg.MoveWholeLimb(npc.velocity);
                npc.velocity.Y += 0.43f;
                npc.velocity.X *= 0.95f;

                if (Landed == 1)
                {
                    rightLeg.savedPoint = rightLeg.foot + Vector2.UnitX * WALK_RADIUS;
                    leftLeg.savedPoint  = leftLeg.foot + Vector2.UnitX * WALK_RADIUS;
                }
            }

            leftLeg.Constrain();
            rightLeg.Constrain();
        }
Beispiel #2
0
        public override void AI()
        {
            Timer++;

            if (Timer == 1) // On-Spawn
            {
                leftLeg  = new KettleLimb(this, new Vector2(-10, 0));
                rightLeg = new KettleLimb(this, new Vector2(10, 0));
            }

            if (State == 0)
            {
                if (!Floating)
                {
                    npc.velocity *= 0;
                    npc.Center    = Vector2.Lerp(leftLeg.foot, rightLeg.foot, 0.5f) + new Vector2(0, -70);

                    if (leftLeg.savedPoint == default && rightLeg.savedPoint == default && Landed == 0) //landing case
                    {
                        WalkTimer           = 0;
                        rightLeg.savedPoint = rightLeg.foot + Vector2.UnitX * WALK_RADIUS;
                        rightLeg.foot.Y    -= 5;
                        FootOnGround        = leftLeg;
                        Landed = 1;
                    }

                    WalkTimer         += 0.14f;
                    FootOffGround.foot = FootOffGround.savedPoint + (Vector2.UnitX * -WALK_RADIUS * npc.direction).RotatedBy(WalkTimer * npc.direction);

                    if (WalkTimer > 4.68f)
                    {
                        npc.velocity.Y -= 4;
                        npc.velocity.X += 4 * npc.direction;
                        leftLeg.MoveWholeLimb(npc.velocity);
                        rightLeg.MoveWholeLimb(npc.velocity);
                        WalkTimer = 0;
                    }

                    if (FootOffGround.footOnGround && WalkTimer > 0.5f)
                    {
                        if (Timer % 300 > 200) //shoot
                        {
                            Timer = 0;
                            State = 1;
                            return;
                        }

                        WalkTimer = 0;
                        FootOnGround.savedPoint = FootOnGround.foot + Vector2.UnitX * WALK_RADIUS * npc.direction;
                        FootOnGround.foot.Y    -= 16;
                        FootOnGround            = FootOffGround;

                        npc.TargetClosest(true);
                        npc.direction = Main.player[npc.target].Center.X > npc.Center.X ? -1 : 1;
                    }
                }

                else
                {
                    leftLeg.MoveWholeLimb(npc.velocity);
                    rightLeg.MoveWholeLimb(npc.velocity);
                    npc.velocity.Y += 0.43f;
                    npc.velocity.X *= 0.95f;

                    if (Landed == 1)
                    {
                        rightLeg.savedPoint = rightLeg.foot + Vector2.UnitX * WALK_RADIUS;
                        leftLeg.savedPoint  = leftLeg.foot + Vector2.UnitX * WALK_RADIUS;
                    }
                }

                leftLeg.Constrain();
                rightLeg.Constrain();
            }

            if (State == 1)
            {
                if (Timer == 30)
                {
                    float angle = 0;



                    Projectile.NewProjectile(npc.Center, Vector2.UnitY.RotatedBy(angle) * -15, ProjectileType <KettleMortar>(), 20, 1, Main.myPlayer);
                }

                for (int k = 0; k < 2; k++)
                {
                    if (Timer == 30 + k * 5)
                    {
                        Projectile.NewProjectile(npc.Center, Vector2.UnitY.RotatedByRandom(1) * -15, ProjectileType <KettleMortar>(), 20, 1, Main.myPlayer);
                    }
                }

                if (Timer == 60)
                {
                    Timer = 2;
                    State = 0;
                }
            }
        }