Пример #1
0
        public static void DuckMoveTo(Duck duck, Vec2 position, float maxSpeed = 3)
        {
            if (duck?.CanMove() == false && (duck.crouch || duck.sliding))
            {
                return;
            }

            if (duck.y - 2 > position.y && !duck.HasJumpModEquipment())
            {
                duck._jumpValid = 4;
                if (!duck.grounded && duck.crouch)
                {
                    duck.skipPlatFrames = 10;
                }
            }

            duck.hSpeed = MathHelper.Clamp((position - duck.position).x, -maxSpeed, maxSpeed);

            if (Level.CheckLine <Window>(duck.position, duck.position + (new Vec2(20, 0) * duck.offDir)) != null && Level.CheckLine <Block>(duck.position, duck.position + (new Vec2(20, 5) * duck.offDir)) == null)
            {
                duck.crouch  = true;
                duck.sliding = true;
            }
        }