private void ChangeWind(WindController.Patterns wind) { WindController first = Scene.Entities.FindFirst <WindController>(); if (first == null) { Scene.Add(new WindController(wind)); } else { first.SetPattern(wind); } }
public void WindAction(string parameter) { Module.BirdyHelper.BirdCaw(); WindController.Patterns pattern = WindController.Patterns.Right; if (parameter.IndexOf("left", StringComparison.OrdinalIgnoreCase) >= 0) { pattern = WindController.Patterns.Left; } else if (parameter.IndexOf("right", StringComparison.OrdinalIgnoreCase) >= 0) { pattern = WindController.Patterns.Right; } else if (parameter.IndexOf("up", StringComparison.OrdinalIgnoreCase) >= 0) { pattern = WindController.Patterns.Up; } else if (parameter.IndexOf("down", StringComparison.OrdinalIgnoreCase) >= 0) { pattern = WindController.Patterns.Down; } if (!Settings.WindEnabled) { currentLevel.Foreground.Backdrops.Add(new CrowControlWindSnowFG() { Alpha = 0f }); Audio.SetAmbience("event:/env/amb/04_main", true); WindController controller = currentLevel.Entities.FindFirst <WindController>(); if (controller == null) { controller = new WindController(pattern); controller.SetStartPattern(); currentLevel.Add(controller); } else { controller.SetPattern(pattern); } Settings.WindEnabled = true; } }
public LevelData(BinaryPacker.Element data) { this.Bounds = new Rect(); foreach (KeyValuePair <string, object> attribute in data.Attributes) { switch (attribute.Key) { case "alt_music": this.AltMusic = (string)attribute.Value; break; case "ambience": this.Ambience = (string)attribute.Value; break; case "ambienceProgress": string s1 = attribute.Value.ToString(); if (string.IsNullOrEmpty(s1) || !int.TryParse(s1, out this.AmbienceProgress)) { this.AmbienceProgress = -1; break; } break; case "c": this.EditorColorIndex = (int)attribute.Value; break; case "cameraOffsetX": this.CameraOffset.x = Convert.ToSingle(attribute.Value, (IFormatProvider)CultureInfo.InvariantCulture); break; case "cameraOffsetY": this.CameraOffset.y = Convert.ToSingle(attribute.Value, (IFormatProvider)CultureInfo.InvariantCulture); break; case "dark": this.Dark = (bool)attribute.Value; break; case "delayAltMusicFade": this.DelayAltMusic = (bool)attribute.Value; break; case "disableDownTransition": this.DisableDownTransition = (bool)attribute.Value; break; case "enforceDashNumber": this.EnforceDashNumber = (int)attribute.Value; break; case "height": this.Bounds.height = (int)attribute.Value; if (this.Bounds.height == 184) { this.Bounds.height = 180; break; } break; case "music": this.Music = (string)attribute.Value; break; case "musicLayer1": this.MusicLayers[0] = (bool)attribute.Value ? 1f : 0.0f; break; case "musicLayer2": this.MusicLayers[1] = (bool)attribute.Value ? 1f : 0.0f; break; case "musicLayer3": this.MusicLayers[2] = (bool)attribute.Value ? 1f : 0.0f; break; case "musicLayer4": this.MusicLayers[3] = (bool)attribute.Value ? 1f : 0.0f; break; case "musicProgress": string s2 = attribute.Value.ToString(); if (string.IsNullOrEmpty(s2) || !int.TryParse(s2, out this.MusicProgress)) { this.MusicProgress = -1; break; } break; case "name": this.Name = attribute.Value.ToString().Substring(4); break; case "space": this.Space = (bool)attribute.Value; break; case "underwater": this.Underwater = (bool)attribute.Value; break; case "whisper": this.MusicWhispers = (bool)attribute.Value; break; case "width": this.Bounds.width = (int)attribute.Value; break; case "windPattern": this.WindPattern = (WindController.Patterns)Enum.Parse(typeof(WindController.Patterns), (string)attribute.Value); break; case "x": this.Bounds.x = (int)attribute.Value; break; case "y": this.Bounds.y = (int)attribute.Value; break; } } this.Spawns = new List <Vector2>(); this.Entities = new List <EntityData>(); this.Triggers = new List <EntityData>(); this.BgDecals = new List <DecalData>(); this.FgDecals = new List <DecalData>(); foreach (BinaryPacker.Element child1 in data.Children) { if (child1.Name == "entities") { if (child1.Children != null) { foreach (BinaryPacker.Element child2 in child1.Children) { if (child2.Name == "player") { this.Spawns.Add(new Vector2((float)this.Bounds.x + Convert.ToSingle(child2.Attributes["x"], (IFormatProvider)CultureInfo.InvariantCulture), (float)this.Bounds.y + Convert.ToSingle(child2.Attributes["y"], (IFormatProvider)CultureInfo.InvariantCulture))); } else if (child2.Name == "strawberry" || child2.Name == "snowberry") { ++this.Strawberries; } else if (child2.Name == "shard") { this.HasGem = true; } else if (child2.Name == "blackGem") { this.HasHeartGem = true; } else if (child2.Name == "checkpoint") { this.HasCheckpoint = true; } if (!child2.Name.Equals("player")) { this.Entities.Add(this.CreateEntityData(child2)); } } } } else if (child1.Name == "triggers") { if (child1.Children != null) { foreach (BinaryPacker.Element child2 in child1.Children) { this.Triggers.Add(this.CreateEntityData(child2)); } } } else if (child1.Name == "bgdecals") { if (child1.Children != null) { foreach (BinaryPacker.Element child2 in child1.Children) { this.BgDecals.Add(new DecalData() { Position = new Vector2(Convert.ToSingle(child2.Attributes["x"], (IFormatProvider)CultureInfo.InvariantCulture), Convert.ToSingle(child2.Attributes["y"], (IFormatProvider)CultureInfo.InvariantCulture)), Scale = new Vector2(Convert.ToSingle(child2.Attributes["scaleX"], (IFormatProvider)CultureInfo.InvariantCulture), Convert.ToSingle(child2.Attributes["scaleY"], (IFormatProvider)CultureInfo.InvariantCulture)), Texture = (string)child2.Attributes["texture"] }); } } } else if (child1.Name == "fgdecals") { if (child1.Children != null) { foreach (BinaryPacker.Element child2 in child1.Children) { this.FgDecals.Add(new DecalData() { Position = new Vector2(Convert.ToSingle(child2.Attributes["x"], (IFormatProvider)CultureInfo.InvariantCulture), Convert.ToSingle(child2.Attributes["y"], (IFormatProvider)CultureInfo.InvariantCulture)), Scale = new Vector2(Convert.ToSingle(child2.Attributes["scaleX"], (IFormatProvider)CultureInfo.InvariantCulture), Convert.ToSingle(child2.Attributes["scaleY"], (IFormatProvider)CultureInfo.InvariantCulture)), Texture = (string)child2.Attributes["texture"] }); } } } else if (child1.Name == "solids") { this.Solids = child1.Attr("innerText", ""); } else if (child1.Name == "bg") { this.Bg = child1.Attr("innerText", ""); } else if (child1.Name == "fgtiles") { this.FgTiles = child1.Attr("innerText", ""); } else if (child1.Name == "bgtiles") { this.BgTiles = child1.Attr("innerText", ""); } else if (child1.Name == "objtiles") { this.ObjTiles = child1.Attr("innerText", ""); } } this.Dummy = this.Spawns.Count <= 0; }