Ejemplo 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);
     }
 }
Ejemplo n.º 2
0
        // TODO: Fix based on GetJumpCornerCorrection
        private float GetMoveCornerCorrection(float xMoveAmount, float correctionAmount, DirY dir)
        {
            Bounds  testBounds = movement.boxCollider.bounds;
            float   xSign      = Mathf.Sign(xMoveAmount);
            float   ySign      = dir.value;
            Vector2 rayVector  = dir;
            float   rayLength  = correctionAmount + RaycastHelpers.skinWidth;

            {
                Vector2 rayOrigin = new Vector2(
                    testBounds.center.x + xSign * testBounds.extents.x + xMoveAmount,
                    testBounds.center.y + ySign * (testBounds.extents.y - rayLength)
                    );
                RaycastHit2D rayHit = Physics2D.Raycast(rayOrigin, rayVector, rayLength, movement.layerMask);
                Debug.DrawRay(rayOrigin + Vector2.right * 5 * xSign, rayVector * rayLength);
                if (IsCorrectDistance(rayHit.distance, correctionAmount) && !CanMoveInto(rayHit, rayLength, Dir4.FromYFloat(dir)))
                {
                    return(-ySign * (rayLength - rayHit.distance));
                }
            }
            return(0);
        }
Ejemplo 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
     );