public void AddBoss(BossInfo boss) { this.bosses.Add(boss); }
public StageSelect(XElement stageSelectNode, string baseDir) { BossSpacingHorizontal = 24; BossSpacingVertical = 16; XAttribute nameAttr = stageSelectNode.Attribute("name"); if (nameAttr != null) { Name = nameAttr.Value; } XElement frameNode = stageSelectNode.Element("BossFrame"); if (frameNode != null) { XElement bossSprite = frameNode.Element("Sprite"); if (bossSprite != null) this.BossFrame = Sprite.FromXml(bossSprite, baseDir); } XElement bgNode = stageSelectNode.Element("Background"); if (bgNode != null) this.Background = FilePath.FromRelative(bgNode.Value, baseDir); XElement musicNode = stageSelectNode.Element("Music"); if (musicNode != null) { this.Music = MusicInfo.FromXml(musicNode, baseDir); } XElement soundNode = stageSelectNode.Element("ChangeSound"); if (soundNode != null) { this.ChangeSound = SoundInfo.FromXml(soundNode, baseDir); } foreach (XElement bossNode in stageSelectNode.Elements("Boss")) { XAttribute slotAttr = bossNode.Attribute("slot"); int slot = -1; if (slotAttr != null) int.TryParse(slotAttr.Value, out slot); BossInfo info = new BossInfo(); info.Slot = slot; var bossNameAttr = bossNode.Attribute("name"); if (bossNameAttr != null) info.Name = bossNameAttr.Value; var portrait = bossNode.Attribute("portrait"); if (portrait != null) info.PortraitPath = FilePath.FromRelative(portrait.Value, baseDir); // load next handler var nextNode = bossNode.Element("Next"); if (nextNode != null) { info.NextHandler = HandlerTransfer.FromXml(nextNode); } else { // support old method info.NextHandler = new HandlerTransfer(); var stageNode = bossNode.Attribute("stage"); if (stageNode != null) { info.NextHandler.Type = HandlerType.Stage; info.NextHandler.Name = stageNode.Value; } else { var sceneAttr = bossNode.RequireAttribute("scene"); info.NextHandler.Type = HandlerType.Scene; info.NextHandler.Name = sceneAttr.Value; } } XElement selectSound = bossNode.Element("Sound"); if (selectSound != null) { info.Sound = SoundInfo.FromXml(selectSound, baseDir); } bosses.Add(info); } XElement spacingNode = stageSelectNode.Element("Spacing"); if (spacingNode != null) { int x; if (spacingNode.TryInteger("x", out x)) { BossSpacingHorizontal = x; } int y; if (spacingNode.TryInteger("y", out y)) { BossSpacingVertical = y; } int off; if (spacingNode.TryInteger("offset", out off)) { BossOffset = off; } } }
private BossInfo BossAtSlot(int slot) { foreach (var info in stageSelect.Bosses) { if (info.Slot == slot) return info; } // find the next available one foreach (var info in stageSelect.Bosses) { if (info.Slot == -1) { info.Slot = slot; return info; } } BossInfo boss = new BossInfo(); boss.Slot = slot; stageSelect.AddBoss(boss); return boss; }