internal Background DeserializeBackground(JObject obj, Section ownerSection) { Background result = new Background(ownerSection); result.TopColor = obj["topColor"].ToColor(); result.BottomColor = obj["bottomColor"].ToColor(); JArray layersData = (JArray)obj["layers"]; result.Layers = DeserializeBackgroundLayers(layersData, ownerSection.Camera, ownerSection.Bounds); return result; }
private static Background GenerateBackground(Section owner) { Background result = new Background(owner); result.TopColor = result.BottomColor = new Color(0, 0, 0, 0); BackgroundLayer layer = new BackgroundLayer(GameServices.Camera, owner.Bounds); layer.BackgroundTextureResourceName = "Background"; layer.ScrollDirection = (BackgroundScrollDirection)1; layer.ScrollRate = 0.5f; result.AddLayerToFront(layer); return result; }
internal object GetBackgroundLayerObjects(Background background) { List<object> result = new List<object>(background.Layers.Count); foreach (var layer in background.Layers) { result.Add(new { resourceName = layer.BackgroundTextureResourceName, scrollDirection = (int)layer.ScrollDirection, scrollRate = layer.ScrollRate }); } return result; }