private static PolygonSave ConvertTmxObjectToFrbPolygonSave(this TiledMapSave tiledMapSave, string name, double x, double y, double rotation, string points, bool connectBackToStart) { if (string.IsNullOrEmpty(points)) { return(null); } var polygon = new PolygonSave(); string[] pointString = points.Split(" ".ToCharArray()); polygon.Name = name; // Nov. 19th, 2014 - Domenic: // I am ripping this code apart a little, because shapes really should not involve tile sizes in their x/y calculations. // I'm not sure why this was ever done this way, as TMX gives the X/Y and width/height already. The old way was basically to convert // the x/y coordinates into tile based coordinates and then re-convert back to full x/y coordinates. This makes no sense any more to me. // // Having examined TMX format a little more, it seems that the x/y position is always specified // //float fx = x; //float fy = y; //if ("orthogonal".Equals(tiledMapSave.orientation)) //{ // fx -= tiledMapSave.tilewidth / 2.0f; // fy -= tiledMapSave.tileheight + (tiledMapSave.tileheight / 2.0f); //} //else if ("isometric".Equals(tiledMapSave.orientation)) //{ // fx -= tiledMapSave.tilewidth / 4.0f; // fy -= tiledMapSave.tileheight / 2.0f; //} //tiledMapSave.CalculateWorldCoordinates( // 0, fx / tiledMapSave.tileheight, fy / tiledMapSave.tileheight, // tiledMapSave.tilewidth, tiledMapSave.tileheight, // w * tiledMapSave.tilewidth, out newx, out newy, out z); //polygon.X = newx - tiledMapSave.tilewidth / 2.0f; //polygon.Y = newy - tiledMapSave.tileheight / 2.0f; //var pointsArr = new Point[pointString.Length + (connectBackToStart ? 1 : 0)]; var pointsList = pointString.Select(p => { var xy = p.Split(",".ToCharArray()); return(new Point { X = Convert.ToDouble(xy[0]), Y = -Convert.ToDouble(xy[1]) }); }).ToList(); if (connectBackToStart) { pointsList.Add(new Point(pointsList[0].X, pointsList[0].Y)); } polygon.Points = pointsList.ToArray(); polygon.X = (float)x; polygon.Y = (float)-y; polygon.RotationZ = -MathHelper.ToRadians((float)rotation); return(polygon); }