示例#1
0
        public MainMenu(Game game, EffectRenderer renderer, StateManager parent)
            : base(game, renderer, parent)
        {
            titlePic = new Picture(game, guiManager, gameRef.Content.Load<Texture2D>("Gui/button-up"));
            characterPic = new Picture(game, guiManager, gameRef.Content.Load<Texture2D>("Freezling"));

            guiManager.AddPicture("titlePic", gameRef.Content.Load<Texture2D>("Gui/button-up"));
            guiManager["titlePic"].Position = new Vector2(400, 40.0f);
            guiManager["titlePic"].Size = new Vector2(400, 100);

            guiManager.AddButton("btnPlay", "Play", 60, guiManager["titlePic"].Position.Y + 100, 300, 75);
            guiManager.AddButton("btnSurvival", "Survival", 60, guiManager["btnPlay"].Position.Y + 100, 300, 75);
            guiManager.AddButton("btnRules", "Rules", 60, guiManager["btnSurvival"].Position.Y + 100, 300, 75);
            guiManager.AddButton("btnOptions", "Options", 60, guiManager["btnRules"].Position.Y + 100, 300, 75);
            guiManager.AddButton("btnExit", "Exit", 60, guiManager["btnOptions"].Position.Y + 100, 300, 75);

            guiManager.AddPicture("characterPic", gameRef.Content.Load<Texture2D>("Freezling"));
            guiManager["characterPic"].Position = new Vector2(guiManager["titlePic"].Position.X + 75, guiManager["titlePic"].Position.Y + 225);
            guiManager["characterPic"].Size = new Vector2(450, 450);

            btnPlay = guiManager["btnPlay"] as Button;
            btnPlay.Click += (control, button) =>
                {
                    GameState Play = this.parent[GameStateType.Playing];
                    if (Play != null)
                    {
                        this.parent.PushState(Play);

                        Play playState = new Play(this.gameRef, this.renderer, this.parent);
                        playState.Initialize();
                        this.parent.PushState(playState);

                    }

                };

            btnOptions = guiManager["btnOptions"] as Button;
            btnOptions.Click += (control, button) =>
            {
                GameState Options = this.parent[GameStateType.OptionsMenu];
                if (Options != null)
                {
                    this.parent.PushState(Options);

                    EndState endState = new EndState(this.gameRef, this.renderer, this.parent);
                    endState.Initialize();
                    this.parent.PushState(endState);

                }

            };

            btnExit = guiManager["btnExit"] as Button;
            btnExit.Click += (control, button) =>
            {
                gameRef.Exit();
            };
        }
示例#2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
             PresentationParameters pp = GraphicsDevice.PresentationParameters;
            renderer = new EffectRenderer( GraphicsDevice );
            renderer.AddLayer( BlendState.AlphaBlend, Content.Load<Effect>( "basic" ) );
            renderer[ 0 ].Destination = new Rectangle( 0, 0, pp.BackBufferWidth, pp.BackBufferHeight );
            renderer.AddLayer( BlendState.Additive );
            renderer[ 1 ].Destination = renderer[ 0 ].Destination;
            renderer.AddLayer(BlendState.AlphaBlend, Content.Load<Effect>("basic"));
            renderer[2].Destination = renderer[0].Destination;

            stateManager = new StateManager(this);
            Components.Add(stateManager);

            play = new Play( this, renderer, stateManager );
            mainMenu = new MainMenu(this, renderer, stateManager);
            endState = new EndState(this, renderer, stateManager);

            stateManager.RegisterState( GameStateType.Playing, play );
            stateManager.RegisterState(GameStateType.MainMenu, mainMenu);
            stateManager.RegisterState(GameStateType.OptionsMenu, endState);

            stateManager.PushState( mainMenu );
            stateManager.Initialize();

            // TODO: use this.Content to load your game content here
        }