public FurnitureGrid furniture_direction(FurnitureGrid furniture_grid_temp) { //Grid_Manager.Test_sphere(Grid_Manager.Grid_x_max / 2, Grid_Manager.Grid_y_max / 2, 0.3f, Color.red); Vector3 target = furniture_grid_temp.furniture_grid().transform.position - Grid_Manager.point((int)(Grid_Manager.Grid_x_max() * 0.5f), (int)(Grid_Manager.Grid_y_max() * 0.5f)).pos; Vector3 source = new Vector3(1.0f, 0, 0); float angle = Mathf.Acos( ((source.x * target.x) + (source.y * target.y)) / (Mathf.Sqrt(Mathf.Pow(source.x, 2) + Mathf.Pow(source.y, 2)) * Mathf.Sqrt(Mathf.Pow(target.x, 2) + Mathf.Pow(target.y, 2))) ) * Mathf.Rad2Deg; Debug.Log("角度 " + angle + ", " + "位置 " + target.y); if (0 <= angle && angle <= 15) { furniture_grid_temp.set_direction(FurnitureGrid.PlacedDirection.East); } else if (15 < angle && angle <= 75) { if (target.y > 0) { furniture_grid_temp.set_direction(FurnitureGrid.PlacedDirection.NorthEast); } else if (target.y < 0) { furniture_grid_temp.set_direction(FurnitureGrid.PlacedDirection.SouthEast); } } else if (75 < angle && angle <= 105) { if (target.y > 0) { furniture_grid_temp.set_direction(FurnitureGrid.PlacedDirection.North); } else if (target.y < 0) { furniture_grid_temp.set_direction(FurnitureGrid.PlacedDirection.South); } } else if (105 < angle && angle <= 165) { if (target.y > 0) { furniture_grid_temp.set_direction(FurnitureGrid.PlacedDirection.NorthWest); } else if (target.y < 0) { furniture_grid_temp.set_direction(FurnitureGrid.PlacedDirection.SouthWest); } } else if (165 < angle && angle <= 180) { furniture_grid_temp.set_direction(FurnitureGrid.PlacedDirection.West); } return(furniture_grid_temp); }