Beispiel #1
0
        private void ResetGame()
        {
            lives = 4;
            score = 0;
            DIContainer.Add <Dictionary <int, GameObject> >("GameObjects", GameObjects);
            DIContainer.Add <Queue <Tuple <int, GameObject> > >("AddQueue", addQueue);
            DIContainer.Add <Queue <Tuple <int, GameObject> > >("RemoveQueue", removeQueue);

            collider = new Collider();
            DIContainer.Add <Collider>("Collider", collider);
            alienBag = new AlienBag();
            DIContainer.Add <AlienBag>("AlienBag", alienBag);
            alienBag.AllDead      += (o, e) => NextLevel(currentLevel++);
            alienBag.AlienDead    += (o, e) => updateScore(e);
            alienBag.AlienVictory += (o, e) =>
            {
                isAlienVictorious = true;
                commander.Kill();
            };
            font = DIContainer.Get <AssetLoader>("AssetLoader").Content.Load <SpriteFont>("courier");
        }
Beispiel #2
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();
        }