Esempio n. 1
0
        /// <summary>
        /// Constructor of the game
        /// </summary>
        public WarGame()
        {
            // creating graphics and content managers
            Graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // creating input controller and adding it to the game
            Input = new InputController(this);
            Components.Add(Input);

            // creating camera controller and adding it to the game
            Camera = new CameraController(this);
            Components.Add(Camera);

            // creating sound controller and adding it to the game
            Sound = new SoundController(this);
            Components.Add(Sound);
        }
Esempio n. 2
0
        public void NewGame()
        {
            // if there is an old camera controller than destroy it
            if (Camera != null)
            {
                Components.Remove(Camera);
                Camera.Dispose();
            }

            // creating new camera controller and adding it to the game
            Camera = new CameraController(this);
            Components.Add(Camera);

            // if there is an old main Scene destroy it
            if (Scene != null)
            {
                Components.Remove(Scene);
                Scene.Dispose();
            }

            // creating new main Scene and adding it to the game
            Scene = new MainScene(this);
            Components.Add(Scene);

            // setting the base scenes for the Menu and main Scene
            Menu.baseScene = Scene;
            Scene.baseScene = Menu;

            // displaying the main Scene and hiding the Menu
            Scene.Show();
            CurrentScene = Scene;
            Menu.Hide();

            // playing the main music theme
            if (Sound.ThemeSoundInstance.State == SoundState.Paused)
                Sound.ThemeSoundInstance.Stop();
            Sound.ThemeSoundInstance.Play();

            // setting initial rendering technique
            currentTechnique = 0;
            PostEffect.CurrentTechnique = PostEffect.Techniques[currentTechnique];
        }