public MenuScreen(Game game, Enemy enemy)
     : base(game)
 {
     this.game = game;
     this.enemy = enemy;
     inMenu = true;
     // TODO: Construct any child components here
 }
Exemple #2
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferHeight = BackBufferHeight;
            graphics.PreferredBackBufferWidth = BackBufferWidth;
            Content.RootDirectory = "Content";
            world = new WorldComponent(this);
            crossHair1 = new CursorComponent(this, 0, world, Content);
            crossHair2 = new CursorComponent(this, 1, world, Content);
            enemy = new Enemy(this, world.treasureBounds, 0);
            menuScreen = new MenuScreen(this, enemy);
            Components.Add(crossHair1);
            Components.Add(crossHair2);
            crossHair1.mEnemy = enemy;
            crossHair2.mEnemy = enemy;
            crossHair1.menuScreen = menuScreen;
            crossHair2.menuScreen = menuScreen;

            //graphics.ToggleFullScreen();
        }
Exemple #3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyboardState keyBoard = Keyboard.GetState();

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                    keyBoard.IsKeyDown(Keys.Escape))
                this.Exit();

            menuScreen.Update(gameTime);

            if(menuScreen.playerNumber == 1) Components.Remove(crossHair2);

            if (menuScreen.restart)
            {
                //add a reset function
                enemy = new Enemy(this, world.treasureBounds, 0);
                menuScreen.restart = false;
                gameBegin = true;

            }
            world.Update(gameTime);
            if(!menuScreen.inMenu)
                enemy.Update(gameTime);
            crossHair1.mEnemy = enemy;
            crossHair2.mEnemy = enemy;
            crossHair1.menuScreen = menuScreen;
            crossHair2.menuScreen = menuScreen;
            base.Update(gameTime);
        }