Esempio n. 1
0
 public static void RuntimeInit()
 {
     if (!instance)
     {
         instance = Resources.Load <KiteSettings>(resourceName);
         DirX.OnSettings(instance);
         DirY.OnSettings(instance);
         Dir4.OnSettings(instance);
         TileHelpers.OnSettings(instance);
     }
 }
Esempio n. 2
0
        private (bool, float) GetJumpCornerCorrectionFor(float topMovementAmount, DirX rayDirX)
        {
            Dir4         rayDir      = Dir4.FromXFloat(rayDirX);
            Bounds       bounds      = movement.boxCollider.bounds;
            float        rayLength   = jumpCornerCorrection;
            Vector2      upperCorner = BoundsHelpers.GetCorner(bounds, rayDirX, DirY.up);
            Vector2      rayDelta    = new Vector2(-rayDirX * rayLength, topMovementAmount);
            Vector2      rayOrigin   = upperCorner + rayDelta;
            RaycastHit2D cornerHit   = RaycastHelpers.SingleHit(rayOrigin, rayLength, rayDir, movement.layerMask);

            if (CanBeCornerCorrected(rayLength, rayDir, cornerHit))
            {
                float correctionValue = -rayDirX * (rayLength - cornerHit.distance);
                return(true, correctionValue);
            }
            return(false, 0);
        }
Esempio n. 3
0
 public static Vector2 GetCorner(this Bounds bounds, DirX dirX, DirY dirY) =>
 new Vector2(
     dirX == DirX.left ? bounds.min.x : bounds.max.x,
     dirY == DirY.down ? bounds.min.y : bounds.max.y
     );