/// <summary> /// Erstellt ein Challenge-Objekt aus einem gegebenen Challenge-Metadaten-Objekt. /// Erstellt ein Challenge-Objekt aus einer gegebenen Challenge-Datei. /// </summary> public Challenge(ChallengeMetaData meta, Knot start, Knot target) { MetaData = meta; Start = start; Target = target; }
/// <summary> /// Diese Methode wird für jede gefundene Spielstanddatei aufgerufen /// </summary> private void AddSavegameToList(string filename, ChallengeMetaData meta) { // Erstelle eine Lamdafunktion, die beim Auswählen des Menüeintrags ausgeführt wird Action<GameTime> LoadFile = (time) => { if (previewChallenge == null || previewChallenge.MetaData != meta) { RemoveGameComponents (time, challengeInfo); challengeInfo.Clear (); previewChallenge = loader.FileFormat.Load (filename); previewRenderer.RenderKnot (previewChallenge.Target); previewWorld.Camera.ResetCamera (); startButton.IsVisible = true; MenuEntry countEntry = new MenuEntry ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: Localizer.Localize ("Edge Count: ") + meta.Target.CountEdges, onClick: (t) => {} ); countEntry.Enabled = false; challengeInfo.Add (countEntry); MenuEntry avgtimeEntry = new MenuEntry ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: ("Avg Time: ").Localize () + (meta.FormatedAvgTime).Localize (), onClick: (t) => {} ); avgtimeEntry.IsLocalized = false; avgtimeEntry.Enabled = false; challengeInfo.Add (avgtimeEntry); if (filename.Contains (SystemInfo.SavegameDirectory)) { MenuEntry deleteEntry = new MenuEntry ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: "Delete", onClick: (t) => deleteSavegame (filename, t) ); deleteEntry.AddKey (Keys.Delete); challengeInfo.Add (deleteEntry); } AddGameComponents (time, challengeInfo); } }; // Finde den Namen der Challenge string name = meta.Name.Length > 0 ? meta.Name : filename; // Erstelle den Menüeintrag MenuEntry button = new MenuEntry ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: name, onClick: LoadFile ); button.IsSelectable = true; button.IsLocalized = false; savegameMenu.Add (button); }
/// <summary> /// Versucht ein Challenge-Objekt zu erstellen. /// </summary> private bool TryConstructChallenge() { bool can = createButton.IsEnabled = createButtonBorder.IsEnabled = CanCreateChallenge; if (can) { ChallengeMetaData challengeMeta = new ChallengeMetaData ( name: challengeName.InputText, start: selectedStartKnot.MetaData, target: selectedTargetKnot.MetaData, filename: null, format: new ChallengeFileIO (), highscore: new List<KeyValuePair<string,int>> () ); selectedChallenge = new Challenge ( meta: challengeMeta, start: selectedStartKnot, target: selectedTargetKnot ); } else { selectedChallenge = null; } return can; }
public bool Equals(ChallengeMetaData other) { return other != null && name == other.name; }