/// <summary> /// deprecated! ///// </summary> //private static bool CollisionTestAgainstMap(Fix64 colliderArea, FractionalHex position, ActiveMap activeMap, out List<int> collidingDirections) //{ // collidingDirections = new List<int>(); // bool outsideMapCollision = false; // bool geographycHexCollision = false; // bool movementMapCollision = false; // var directionsToOutsideMapCollitions = new List<int>(); // var directionsThatCauseGeographycCollisions = new List<int>(); // var directionsThatCauseMovementMapCollisions = new List<int>(); // Hex centerHex = position.Round(); // //hace un check en todas las esquinas del area de colision. // for (int i = 0; i < 6; i++) // { // var direction = Hex.directions[i]; // var corner = position + ((FractionalHex)direction * colliderArea); // if (activeMap.map.MovementMapValues.TryGetValue(corner.Round(), out bool walkable)) // { // if (! MapUtilities.IsTraversable(centerHex, corner.Round(), MapUtilities.MapType.GEOGRAPHYC)) // { // directionsThatCauseGeographycCollisions.Add(i); // geographycHexCollision = true; // } // else if (! walkable) // { // directionsThatCauseMovementMapCollisions.Add(i); // movementMapCollision = true; // } // } // else // { // directionsToOutsideMapCollitions.Add(i); // outsideMapCollision = true; // } // } // if (outsideMapCollision) // { // collidingDirections = directionsToOutsideMapCollitions; // return true; // } // else if (geographycHexCollision) // { // collidingDirections = directionsThatCauseGeographycCollisions; // return true; // } // else if (movementMapCollision) // { // collidingDirections = directionsThatCauseMovementMapCollisions; // return true; // } // else // { // return false; // } //} public static Fix64 GetCollisionDistance(Hex centerHex, FractionalHex collidingCorner) { //es importante conseguir el true mid point. //ese punto hace verdadera la igualdad -> collidingDistance = collidingCorner.Distance(centerHex) - 0.5(mid point distance); //ya que alinea los 3 puntos importantes; los dos centros y el borde. //hay 6 casos uwu.para sacar la distancia de colición var collidingHex = collidingCorner.Round(); var direction = MapUtilities.GetDirectionToAdjacentHex(centerHex, collidingHex); Fix64 q = collidingCorner.q - (Fix64)centerHex.q; Fix64 r = collidingCorner.r - (Fix64)centerHex.r; Fix64 s = collidingCorner.s - (Fix64)centerHex.s; FractionalHex trueMidPoint = new FractionalHex(); switch (direction) { case MapUtilities.HexDirection.TOP_RIGHT: //Q trueMidPoint = new FractionalHex ( (Fix64)centerHex.q, collidingCorner.r + (q * (Fix64)0.5) ); break; case MapUtilities.HexDirection.RIGHT: //R trueMidPoint = new FractionalHex ( collidingCorner.q + (r * (Fix64)0.5), (Fix64)centerHex.r ); break; case MapUtilities.HexDirection.DOWN_RIGHT: //S trueMidPoint = new FractionalHex ( collidingCorner.q + (s * (Fix64)0.5), collidingCorner.r + (s * (Fix64)0.5) ); break; case MapUtilities.HexDirection.DOWN_LEFT: //Q trueMidPoint = new FractionalHex ( (Fix64)centerHex.q, collidingCorner.r + (q * (Fix64)0.5) ); break; case MapUtilities.HexDirection.LEFT: //R trueMidPoint = new FractionalHex ( collidingCorner.q + r * (Fix64)0.5, (Fix64)centerHex.r ); break; case MapUtilities.HexDirection.TOP_LEFT: //S trueMidPoint = new FractionalHex ( collidingCorner.q + (s * (Fix64)0.5), collidingCorner.r + (s * (Fix64)0.5) ); break; default: throw new System.Exception(); } var collidingDistance = trueMidPoint.Distance((FractionalHex)centerHex) - (Fix64)0.5; if (collidingDistance < Fix64.Zero) { throw new System.Exception(); } return(collidingDistance); }