Esempio n. 1
0
        /// <summary>
        /// Initialises the game.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.state = GameState.Menu;

            this.OnDraw += new GameDrawDelegate(Draw);
            this.OnUpdate += new GameUpdateDelegate(Update);

            this.dialogueStartDelegate = new DialogueEventDelegate(DialogueStart);
            this.dialogueEndDelegate = new DialogueEventDelegate(DialogueEnd);

            this.RegisterDefaultDialogueHandlers();
        }
Esempio n. 2
0
        /// <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");
        }
Esempio n. 3
0
File: Maro.cs Progetto: mbg/FSEGame
        /// <summary>
        /// Performs Maro's action based on the current state of the game.
        /// </summary>
        protected override void PerformAction()
        {
            if (this.HasAcquiredCoal())
            {
                GameBase.Singleton.DialogueManager.PlayDialogue(
                    @"FSEGame\Dialogues\MaroPostCoal.xml");
            }
            else if (this.CanAcquireCoal())
            {
                FSEGame.Singleton.UnregisterDefaultDialogueHandlers();

                DialogueEventDelegate endDelegate = null;
                endDelegate = new DialogueEventDelegate(delegate
                {
                    FSEGame.Singleton.DialogueManager.OnEnd -= endDelegate;
                    FSEGame.Singleton.RegisterDefaultDialogueHandlers();

                    FSEGame.Singleton.State = GameState.Exploring;

                    this.GiveCoal();
                });

                FSEGame.Singleton.DialogueManager.OnEnd += endDelegate;
                FSEGame.Singleton.State = GameState.Cutscene;

                GameBase.Singleton.DialogueManager.PlayDialogue(
                    @"FSEGame\Dialogues\MaroCoal.xml");
            }
            else
            {
                GameBase.Singleton.DialogueManager.PlayDialogue(
                    @"FSEGame\Dialogues\MaroDefault.xml");
            }
        }
Esempio n. 4
0
        public void BeginBattle(String configuration)
        {
            DialogueEventDelegate outroDelegate = null;
            outroDelegate = new DialogueEventDelegate(delegate
            {
                this.DialogueManager.OnEnd -= outroDelegate;
                this.RegisterDefaultDialogueHandlers();
                this.state = GameState.Menu;
                this.OpenMainMenu();
            });

            BattleEndedDelegate battleDelegate = null;
            battleDelegate = new BattleEndedDelegate(delegate(Boolean victory)
            {
                this.battleManager.Ended -= battleDelegate;

                if (victory)
                {
                    this.CurrentLevel.Unload();

                    this.character.Orientation = 180.0f;

                    this.UnregisterDefaultDialogueHandlers();
                    this.DialogueManager.OnEnd += outroDelegate;
                    this.DialogueManager.PlayDialogue(@"FSEGame\Dialogues\Outro.xml");
                }
                else
                {
                    this.state = GameState.Menu;
                    this.gameOverScreen.Show();
                }
            });

            this.BeginBattle(configuration, battleDelegate);
        }
Esempio n. 5
0
        /// <summary>
        /// Performs Markus' action based on the current state of the game.
        /// </summary>
        protected override void PerformAction()
        {
            if (this.HasAcquiredStick())
            {
                GameBase.Singleton.DialogueManager.PlayDialogue(
                    @"FSEGame\Dialogues\MarkusPostStick.xml");
            }
            else if (this.CanAcquireStick())
            {
                FSEGame.Singleton.UnregisterDefaultDialogueHandlers();

                DialogueEventDelegate stickDelegate = null;
                stickDelegate = new DialogueEventDelegate(delegate
                {
                    FSEGame.Singleton.DialogueManager.OnEnd -= stickDelegate;
                    FSEGame.Singleton.RegisterDefaultDialogueHandlers();

                    FSEGame.Singleton.State = GameState.Exploring;

                    this.GiveStick();
                });

                // :: Declare the event handler for the end of the combat sequence. This
                // :: delegate will be called when the battle has ended and the outcome
                // :: will be supplied as argument.
                BattleEndedDelegate battleEndedDelegate = null;
                battleEndedDelegate = new BattleEndedDelegate(delegate(Boolean victory)
                {
                    FSEGame.Singleton.LoadLevel(@"Levels\House3.xml", "TutorialEnd", false);
                    FSEGame.Singleton.Character.Orientation = 0.0f;
                    FSEGame.Singleton.PlayerCharacter.CurrentAttributes.Health =
                        FSEGame.Singleton.PlayerCharacter.BaseAttributes.Health;

                    // :: If the player is victorious, give him the stick and play
                    // :: a short dialogue - however, if the player has lost, don't
                    // :: give him the stick.
                    if (victory)
                    {
                        FSEGame.Singleton.UnregisterDefaultDialogueHandlers();
                        FSEGame.Singleton.DialogueManager.OnEnd += stickDelegate;

                        FSEGame.Singleton.State = GameState.Cutscene;

                        GameBase.Singleton.DialogueManager.PlayDialogue(
                            @"FSEGame\Dialogues\MarkusPostTutorial.xml");
                    }
                    else
                    {
                        FSEGame.Singleton.RegisterDefaultDialogueHandlers();

                        GameBase.Singleton.DialogueManager.PlayDialogue(
                            @"FSEGame\Dialogues\MarkusPostTutorialLoss.xml");
                    }
                });

                DialogueEventDelegate endDelegate = null;
                endDelegate = new DialogueEventDelegate(delegate
                {
                    FSEGame.Singleton.DialogueManager.OnEnd -= endDelegate;
                    FSEGame.Singleton.RegisterDefaultDialogueHandlers();

                    FSEGame.Singleton.BeginBattle(@"BattleData\Tutorial1.xml", battleEndedDelegate);
                });

                FSEGame.Singleton.DialogueManager.OnEnd += endDelegate;
                FSEGame.Singleton.State = GameState.Cutscene;

                GameBase.Singleton.DialogueManager.PlayDialogue(
                    @"FSEGame\Dialogues\MarkusStick.xml");
            }
            else
            {
                GameBase.Singleton.DialogueManager.PlayDialogue(
                    @"FSEGame\Dialogues\MarkusDefault.xml");
            }
        }