public static IEnumerable <VehicleBitmapAndPoint> GetBitmapsAndPointsFor(IMoveableVehicle vehicle) { foreach (VehicleBitmapAndPoint x in TextureAtlas.TilesetAccessor.GetBitmapsAndPointsFor(vehicle)) { yield return(x); } }
public IEnumerable <VehicleBitmapAndPoint> GetBitmapsAndPointsFor(IMoveableVehicle vehicle) { if (vehicle.PreviousPreviousPreviousPreviousPosition == null) { yield break; } foreach (var pair in new[] { new { Render = (vehicle is ITrain), First = vehicle.CurrentPosition, Second = vehicle.PreviousPosition, Third = vehicle.PreviousPreviousPosition, Head = true }, new { Render = true, First = vehicle.PreviousPosition, Second = vehicle.PreviousPreviousPosition, Third = vehicle.PreviousPreviousPreviousPosition, Head = false }, new { Render = (vehicle is ITrain), First = vehicle.PreviousPreviousPosition, Second = vehicle.PreviousPreviousPreviousPosition, Third = vehicle.PreviousPreviousPreviousPreviousPosition, Head = false } }) { var orientation = (pair.Third.Point != pair.First.Point) ? pair.Third.Point.OrientationTo(pair.First.Point) : pair.Second.Point.OrientationTo(pair.First.Point); VehicleBitmap bitmap; if (vehicle is IAirplane) { bitmap = _vehicleBitmaps.Plane.GetBitmap(orientation); } else if (vehicle is ITrain) { bitmap = _vehicleBitmaps.Train.GetBitmap(orientation); } else if (vehicle is IShip) { bitmap = _vehicleBitmaps.GetShipBitmapFrame().GetBitmap(orientation); } else { throw new InvalidOperationException(); } if (pair.Render) { yield return(new VehicleBitmapAndPoint(bitmap, pair.Second, pair.Third, vehicle)); } } }