/// <summary> /// Indicates to the game mode that it is activated. /// </summary> public void Activate() { try { // Get the manifest string Stream stream = typeof(ChestBonusInfo).Assembly .GetManifestResourceStream("CuteGod.credits.xml"); // Create an XML reader out of it XmlTextReader xml = new XmlTextReader(stream); LinkedList <CreditsLine> category = null; CreditsLine creator = null; // Loop through the file while (xml.Read()) { // Ignore all but start elements if (xml.NodeType != XmlNodeType.Element) { continue; } // Check for name if (xml.LocalName == "category") { // Get the category from the given name string title = xml["title"]; if (!credits.Contains(title)) { credits[title] = new LinkedList <CreditsLine>(); } category = credits[title]; } else if (xml.LocalName == "creator") { // Seed the name string name = xml["name"]; creator = new CreditsLine(); creator.Name = name; category.Add(creator); } else if (xml.LocalName == "asset") { // Increment the creator's asset counter creator.Assets++; } } } catch (Exception e) { Error("Cannot load credits: {0}", e.Message); throw e; } }
/// <summary> /// Indicates to the game mode that it is activated. /// </summary> public void Activate() { try { // Get the manifest string Stream stream = typeof(ChestBonusInfo).Assembly .GetManifestResourceStream("CuteGod.credits.xml"); // Create an XML reader out of it XmlTextReader xml = new XmlTextReader(stream); LinkedList<CreditsLine> category = null; CreditsLine creator = null; // Loop through the file while (xml.Read()) { // Ignore all but start elements if (xml.NodeType != XmlNodeType.Element) continue; // Check for name if (xml.LocalName == "category") { // Get the category from the given name string title = xml["title"]; if (!credits.Contains(title)) credits[title] = new LinkedList<CreditsLine>(); category = credits[title]; } else if (xml.LocalName == "creator") { // Seed the name string name = xml["name"]; creator = new CreditsLine(); creator.Name = name; category.Add(creator); } else if (xml.LocalName == "asset") { // Increment the creator's asset counter creator.Assets++; } } } catch (Exception e) { Error("Cannot load credits: {0}", e.Message); throw e; } }
public void Update(UpdateArgs args) { // See if we have a new category if (currentCategory == null) { // Create a category and force the first credit to show ChooseCategory(); Debug("Starting category: {0}", currentCategory); newSeconds = 0; } // If we don't have a category, we are done if (currentCategory == null) { Game.GameMode = new MainMenuMode(); return; } // Update any of the displayed ones LinkedList <CreditsLine> tmpList = new LinkedList <CreditsLine>(); tmpList.AddAll(displayed); foreach (CreditsLine cl in tmpList) { // Add the time cl.SecondsDisplayed += args.SecondsSinceLastUpdate; // If we exceeded the life, kill it if (cl.SecondsDisplayed > cl.SecondsToLive) { displayed.Remove(cl); sprites.Remove(cl.Sprite); Debug("Removing credit line: {0}", cl.Name); } } // If the displayed and pending list are empty, then we // are done if (displayed.Count == 0 && pending.Count == 0) { Debug("Finished category: {0}", currentCategory); currentCategory = null; return; } // See if we are showing a new one newSeconds -= args.SecondsSinceLastUpdate; if (slots > 0 && newSeconds <= 0 && pending.Count > 0) { // Reset the counter newSeconds = 0.2; // See if we have too many if (displayed.Count <= slots) { // Pick a random location for this int kill = slots * 2; while (true) { // Check the kill if (kill-- < 0) { break; } // Set up some variables int row = Entropy.Next(0, slots); float y = row * CreditsLine.FontSize + FontSize * 2; bool found = false; foreach (CreditsLine cl0 in displayed) { if (cl0.Point.Y == y) { found = true; break; } } // If we found something, try again if (found) { continue; } // Add a new one CreditsLine cl = pending.RemoveFirst(); displayed.Add(cl); cl.Point = new PointF( Entropy.NextFloat(sprites.Size.Width - cl.Sprite.Size.Width - 160) + 80, y); sprites.Add(cl.Sprite); break; } } } // Update the sprites sprites.Update(args); }