Exemple #1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = 1024; // set screen dimensions 4:3 as per Bark's sketch
            graphics.PreferredBackBufferHeight = 768;
            graphics.ApplyChanges();

            Content.RootDirectory = "Content";
            IsMouseVisible        = true;

            musicPlayer = new MusicPlayer();
            musicPlayer.Initialize();

            string currentDir = Directory.GetCurrentDirectory();

            musicPlayer.AddSong(currentDir + "\\Kickin.mp3");
            musicPlayer.LoadSong(0, true);
            musicPlayer.Play();

            // User needs to register all the Screens that have been created!
            ScreenGameComponent screenGameComponent = new ScreenGameComponent(this);

            screenGameComponent.Register <Screen>(new MainMenuScreen(this.Services));
            screenGameComponent.Register <Screen>(new GameplayScreen(this.Services));
            Components.Add(screenGameComponent);
        }
Exemple #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            var screenGameComponent = new ScreenGameComponent(this);

            _fieldScreen = new FieldScreen(this, Content, _graphics);
            screenGameComponent.Register(_fieldScreen);
            _fieldScreen.Hide();

            _isometricScreen = new IsometricScreen(this, Content, _graphics);
            screenGameComponent.Register(_isometricScreen);
            _isometricScreen.Hide();

            this.CreditsScreen = new CreditsScreen(Content);
            screenGameComponent.Register(this.CreditsScreen);
            this.CreditsScreen.Hide();

            this.CaveScreen1 = new CaveScreen1(this, Content);
            screenGameComponent.Register(this.CaveScreen1);
            this.CaveScreen1.Hide();

            this.CaveScreen2 = new CaveScreen2(this, Content);
            screenGameComponent.Register(this.CaveScreen2);
            this.CaveScreen2.Hide();

            Components.Add(screenGameComponent);

            base.Initialize();
        }
Exemple #3
0
        public GameMain()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory       = "Content";
            CacheManager.ContentManager = Content;
            IsMouseVisible           = true;
            Window.AllowUserResizing = false;
            Window.Position          = Point.Zero;

            graphics.GraphicsProfile           = GraphicsProfile.HiDef;
            graphics.PreferredBackBufferWidth  = CacheManager.VirtualSize.Width;
            graphics.PreferredBackBufferHeight = CacheManager.VirtualSize.Height;
            graphics.HardwareModeSwitch        = false;

            GameSettingsRepository.Initialize();

            graphics.IsFullScreen = GameSettingsRepository.GameSettings.IsFullScreen;

            ScreenGameComponent screenComponent;

            Components.Add(screenComponent = new ScreenGameComponent(this));
            screenComponent.Register(new TitleScreen(Services, this));
            screenComponent.Register(new PlayScreen(Services, this));

            CacheManager.GameMain = this;
        }   // Awake
Exemple #4
0
        protected override void LoadContent()
        {
            LogHelper.Log("Game Root: Load Content..");

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            try
            {
                _usedSkin = SkinLoader.Load(Content, GraphicsDevice, _settings.Skin);
            }
            catch (Exception e)
            {
                LogHelper.Log($"GameRoot: Error while opening Skin, using Default skin instead: {e}");
                _usedSkin      = SkinLoader.Load(Content, GraphicsDevice, "Default");
                _settings.Skin = "Default";
            }

            _skinAssetManager = new SkinAssetManager(GraphicsDevice, _settings);
            _skinAssetManager.Load <Texture2D>("Button.png");

            Services.AddService(_usedSkin);
            Services.AddService(_skinAssetManager);



            _screenComponent = new ScreenGameComponent(this);
            Components.Add(_screenComponent);
            PlaySongSelectScreen playSongSelectScreen = new PlaySongSelectScreen(this);

            _screenComponent.Register(playSongSelectScreen);
            GameplayScreen gameplayScreen = new GameplayScreen(this);

            _screenComponent.Register(gameplayScreen);
            PauseScreen ps = new PauseScreen(this);

            _screenComponent.Register(ps);

            _graphCanvas.Font = _usedSkin.Font;

            base.LoadContent();

            LogHelper.Log("Game Root: End Load Content");
        }
Exemple #5
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            _startupScreen   = new StartupScreen(this);
            _screenComponent = new ScreenGameComponent(this);
            _screenComponent.Register(_startupScreen);

            Components.Add(_screenComponent);

            base.Initialize();
        }
Exemple #6
0
        public ScreensDemo(GameMain game) : base(game)
        {
            ScreenGameComponent screenGameComponent;

            Components.Add(screenGameComponent = new ScreenGameComponent(game));

            screenGameComponent.Register(new MainMenuScreen(game.Services, game));
            screenGameComponent.Register(new LoadGameScreen(game.Services));
            screenGameComponent.Register(new OptionsScreen(game.Services));
            screenGameComponent.Register(new AudioOptionsScreen(game.Services));
            screenGameComponent.Register(new VideoOptionsScreen(game.Services));
            screenGameComponent.Register(new KeyboardOptionsScreen(game.Services));
            screenGameComponent.Register(new MouseOptionsScreen(game.Services));
        }