public void OnMouseLeftClick(ItemEnum itemInHand) { Vector2 mousePosition = UF.GetMousePos(); GameObject somethingUnderMouse = UF.FetchGameObject(UF.GetMousePos(), LayerMask.GetMask("Interractable")); if (somethingUnderMouse == null) //Jos hiiren alla ei ole mitään niin liikutaan { PlayerMovement.instance.Move(mousePosition); } else { somethingUnderMouse.GetComponent <Interractable>().GiveActivationCommand(itemInHand); } }
public List <Vector2> FindPath(Vector2 start, Vector2 goal) { if (!IsInsideMap(goal)) { return(new List <Vector2>() { }); } GameObject mapColliderUnderGoal = UF.FetchGameObject(goal, LayerMask.GetMask("MapColliders")); if (mapColliderUnderGoal != null) { Vector2 closestPointFromCollider = mapColliderUnderGoal.GetComponent <Collider2D>().bounds.ClosestPoint(start); goal = closestPointFromCollider + (start - closestPointFromCollider).normalized * 0.01f; } if (!IsInsideMap(UF.FromCoordinatesToWorld(UF.CoordinatePosition(start)))) { start = CorrectStart(start); } List <Vector2> path = AStarPathFinding(UF.CoordinatePosition(start), UF.CoordinatePosition(goal), goal); return(path); }