Пример #1
0
 public override void TargetedMovement(Vector2 vectorToTargetPosition)
 {
     if (!didLand)
     {
         return;
     }
     if (vectorToTargetPosition.Y > 32 && gHelper.DropThroughPlatform())
     {
         didLand = false;                 // now falling through the air again
         return;
     }
     if (vectorToTargetPosition.Y < -4 * defaultJumpVelocity)
     {
         projectile.velocity.Y = Math.Max(-12, vectorToTargetPosition.Y / 4);
     }
     else
     {
         projectile.velocity.Y = -defaultJumpVelocity;
     }
     base.TargetedMovement(vectorToTargetPosition);
     didLand = false;
 }
Пример #2
0
        public override void TargetedMovement(Vector2 vectorToTargetPosition)
        {
            if (isStone)
            {
                if (vectorToTargetPosition.Y > 16)
                {
                    gHelper.DropThroughPlatform();
                }
                DoStoneMovement();
                return;
            }
            int     targetAbove = 80;
            Vector2 vectorAbove = vectorToTargetPosition;

            projectile.friendly = false;
            // only check for exact position once close to target
            if (vectorToTargetPosition.LengthSquared() < 256 * 256)
            {
                for (int i = 16; i < targetAbove; i += 8)
                {
                    vectorAbove = new Vector2(vectorToTargetPosition.X, vectorToTargetPosition.Y - i);
                    if (!Collision.CanHit(projectile.Center, 1, 1, projectile.Center + vectorAbove, 1, 1))
                    {
                        break;
                    }
                }
            }
            myTurnToDrop |= Math.Abs(vectorAbove.X) < 64 && IsMyTurn();
            if (myTurnToDrop && Math.Abs(vectorAbove.X) <= 16 && Math.Abs(vectorAbove.Y) <= 16 && animationFrame - stoneStartFrame > 80)
            {
                DoStoneDust();
                isStone         = true;
                myTurnToDrop    = false;
                stoneStartFrame = animationFrame;
                if (targetNPCIndex is int idx && Main.npc[idx].active)
                {
                    //// approximately home in
                    if (vectorToTargetPosition.Y > 16)
                    {
                        float xSpeed = FallSpeed * vectorToTargetPosition.X / vectorToTargetPosition.Y;
                        projectile.velocity.X = Math.Min(xSpeed, 8);
                    }
                    else
                    {
                        projectile.velocity.X = 0;
                    }
                }
                return;
            }
            if (vectorAbove.Y > 16)
            {
                gHelper.DropThroughPlatform();
            }
            int speed = Math.Abs(vectorAbove.X) < 64 ? 14 : 11;

            DistanceFromGroup(ref vectorAbove);
            vectorAbove.SafeNormalize();
            vectorAbove *= speed;
            int inertia = 16;

            projectile.velocity = (projectile.velocity * (inertia - 1) + vectorAbove) / inertia;
        }