public void LoadLevel(String name, String entryPoint, Boolean fade) { if (fade) { this.character.Enabled = false; FadeScreenEventDelegate cleanupDelegate = null; cleanupDelegate = new FadeScreenEventDelegate(delegate { this.fadeScreen.Visible = false; this.fadeScreen.Enabled = false; this.fadeScreen.Finished -= cleanupDelegate; this.character.Enabled = true; }); FadeScreenEventDelegate loadDelegate = null; loadDelegate = new FadeScreenEventDelegate(delegate { base.LoadLevel(name, entryPoint); LevelEntryPoint ep = this.CurrentLevel.GetEntryPoint(entryPoint); this.character.CellPosition = new Vector2(ep.X, ep.Y); this.fadeScreen.Finished -= loadDelegate; this.fadeScreen.Finished += cleanupDelegate; this.fadeScreen.FadeOut(1.0d); }); this.fadeScreen.Enabled = true; this.fadeScreen.Visible = true; this.fadeScreen.Finished += loadDelegate; this.fadeScreen.FadeIn(1.0d); } else { base.LoadLevel(name, entryPoint); LevelEntryPoint ep = this.CurrentLevel.GetEntryPoint(entryPoint); this.character.CellPosition = new Vector2(ep.X, ep.Y); this.character.Enabled = true; } }
/// <summary> /// Starts a new game. /// </summary> public void NewGame() { // :: Change the game state and make sure that no level // :: is loaded so that we have a black background. this.state = GameState.Intro; this.CurrentLevel.Unload(); this.mainMenu.Hide(); // :: Initialise a new player character. CharacterAttributes playerAttributes = new CharacterAttributes(); playerAttributes.Health = 100; playerAttributes.Defence = 2; playerAttributes.Strength = 15; playerAttributes.Magic = 50; this.playerCharacter = new PlayerCharacter(playerAttributes); this.playerCharacter.Moves.Add(new MeleeAttack()); // :: Temporarily change the dialogue event handlers so that // :: they don't change the game state to Exploring / Cutscene. DialogueEventDelegate introEndDelegate = null; introEndDelegate = new DialogueEventDelegate(delegate { this.DialogueManager.OnEnd -= introEndDelegate; this.DialogueManager.OnStart += this.dialogueStartDelegate; this.DialogueManager.OnEnd += this.dialogueEndDelegate; this.LoadLevel(@"Levels\PlayerHouse.xml", "Default", false); this.character.Enabled = false; FadeScreenEventDelegate fadeEndEvent = null; fadeEndEvent = new FadeScreenEventDelegate(delegate { this.fadeScreen.Finished -= fadeEndEvent; this.fadeScreen.Enabled = false; this.fadeScreen.Visible = false; this.character.Enabled = true; this.state = GameState.Exploring; }); this.fadeScreen.Finished += fadeEndEvent; this.fadeScreen.Visible = true; this.fadeScreen.Enabled = true; this.fadeScreen.FadeOut(1.0d); this.state = GameState.LevelTransition; }); this.DialogueManager.OnStart -= this.dialogueStartDelegate; this.DialogueManager.OnEnd -= this.dialogueEndDelegate; this.DialogueManager.OnEnd += introEndDelegate; this.DialogueManager.PlayDialogue(@"FSEGame\Dialogues\Intro.xml"); }
public void BeginBattle(String configuration, BattleEndedDelegate ended) { this.state = GameState.Battle; BattleEndedDelegate battleDelegate = null; battleDelegate = new BattleEndedDelegate(delegate(Boolean victory) { this.battleManager.Ended -= battleDelegate; ended(victory); }); FadeScreenEventDelegate fadeEndEvent = null; fadeEndEvent = new FadeScreenEventDelegate(delegate { this.fadeScreen.Finished -= fadeEndEvent; this.fadeScreen.Enabled = false; this.fadeScreen.Visible = false; this.UnregisterDefaultDialogueHandlers(); this.battleManager.Ended += battleDelegate; this.battleManager.Load(configuration); this.battleManager.Start(); }); this.fadeScreen.Visible = true; this.fadeScreen.Enabled = true; this.fadeScreen.Finished += fadeEndEvent; this.fadeScreen.FadeIn(1.0d); }