public static Unit UnitEventToUnit(UnitEvent unit, int pos, GameHistory game) { Vector2 vec = MoveService.RotatePoint(new Vector2(unit.x, unit.y), center, -45); float newx = 0; // postition 1-3 => 4-6 and 4-6 => 1-3 ... if (pos > 3) { newx = ((vec.X - 62.946175f) / 2); } else if (pos <= 3) { newx = ((vec.X - 177.49748f) / 2); } float newy = vec.Y - 107.686295f; // Team2 // Ymax: 131,72792 => Battlefield.YMax // Ymin: 107,686295 => 0 // Xmax: 78,502525 => 10 // Xmin: 62,946175 => 0 // Fix Names if (unit.Name.EndsWith("Lightweight")) { unit.Name = unit.Name.Replace("Lightweight", ""); } if (unit.Name.EndsWith("Starlight")) { unit.Name = unit.Name.Replace("Starlight", ""); } Unit punit = null; Unit myunit = UnitPool.Units.SingleOrDefault(x => x.Name == unit.Name); if (myunit == null) { myunit = UnitPool.Units.SingleOrDefault(x => x.Name == "NA").DeepCopy(); myunit.Name = unit.Name; } if (myunit != null) { punit = myunit.DeepCopy(); punit.ID = game.GetUnitID(); newx = MathF.Round((MathF.Round(newx * 2, MidpointRounding.AwayFromZero) / 2), 1); newy = MathF.Round((MathF.Round(newy * 2, MidpointRounding.AwayFromZero) / 2), 1); punit.PlacePos = new Vector2(newy, newx); punit.Owner = pos; } return(punit); }