Exemple #1
0
 private void startNewGame()
 {
     //TODO: Refactor this DIContainer part and see where it should sit rather than call it twice
     //DIContainer.Clear();
     //DIContainer.Add<AssetLoader>("AssetLoader", loader);
     currentStage = createGameStages();
     currentStage.BeforeStart();
     currentStage.Start();
 }
Exemple #2
0
        /// <summary>
        /// Create all the stages of the game and wire them up to load one after the other
        /// </summary>
        private IGameStage createGameStages()
        {
            var stage1         = new MainScreen("MainScreen");
            var stage2         = new Level("Level");
            var stage2Settings = new GameStageSettings();

            stage2Settings.Set("replay", true);
            var stage3 = new GameOver("GameOver");

            stage1.Next = stage2;
            stage2.Next = stage3;
            stage3.Next = stage1;

            stage1.End += (o, e) =>
            {
                currentStage = stage2;
                currentStage.BeforeStart();
                currentStage.Start();
                bool?shouldRecord = stage2Settings["replay"] as bool?;
                if (shouldRecord.HasValue && shouldRecord == true)
                {
                    loopId = 0;
                    replay = new Replay();
                    replay.StartRecordingReplay();
                }
            };
            stage2.End += (o, e) =>
            {
                bool?shouldRecord = stage2Settings["replay"] as bool?;
                if (shouldRecord.HasValue && shouldRecord == true)
                {
                    replay.CompleteReplay();
                }
                currentStage = stage3;
                currentStage.BeforeStart();
                currentStage.Start();
            };
            stage3.End += (o, e) => { startNewGame(); };
            return(stage1);
        }
Exemple #3
0
        protected override void BeginRun()
        {
            DIContainer.Clear();
            DIContainer.Add <AssetLoader>("AssetLoader", loader);

            if (doReplay == false)
            {
                startNewGame();
            }
            else
            {
                this.IsFixedTimeStep = true;
                //this.graphics.SynchronizeWithVerticalRetrace = false;
                //this.graphics.ApplyChanges();
                this.TargetElapsedTime = TimeSpan.FromMilliseconds(8.333333);
                replayEvents           = Replay.Load(replayFilePath);
                currentStage           = new Level("Level");
                currentStage.End      += (o, e) => Exit();
                currentStage.BeforeStart();
                currentStage.Start();
            }
            base.BeginRun();
        }