Ejemplo n.º 1
0
        public Leaderboards(ContentHolder content, int width, int height, Highscores hs)
            : base(content, width, height)
        {
            Items = new List<string>();
            scores = new List<string>();

            this.hs = hs;

            hst = new HighscoreTable();

            Active = false;
        }
Ejemplo n.º 2
0
        public Controller(ContentHolder content, SoundManager soundManager, Highscores hs, string title, int width, int height)
        {
            //playerObject = new GameObject[Constants.maxNumberOfObjectsInArray];
            this.soundManager = soundManager;
            playerObject = null;
            this.content = content;
            physicsEngine = new PhysicsEngine();
            menuHandler = new MenuHandler(content, width, height, hs);
            elapsed = 0;
            randGen = new Random();
            randomTimeBetweenSpawns = randGen.Next(1, 5);

            this.hs = hs;

            soundManager.playSoundtrack();
        }
Ejemplo n.º 3
0
        public void updateMenu(Gameworld gameWorld, InputHandler inputHandler, GameTime gameTime, Highscores highscores)
        {
            inputHandler.updateInput();

            Vector2 movementVector = inputHandler.getLeftStickMovement();

            bool aButton = false;                       // flagged if A button, or Enter, is pressed
            bool bButton = false;                       // flagged if B button, or backspace, is pressed

            int movementY = 0;                           // Tells the menu where to move next (-1 is up, 1 is down)
            int movementX = 0;

            if (inputHandler.ButtonPressed(Buttons.DPadDown) || movementVector.Y < 0 || inputHandler.KeyReleased(Keys.Down))
                movementY = 1;
            if (inputHandler.ButtonPressed(Buttons.DPadUp) || movementVector.Y > 0 || inputHandler.KeyReleased(Keys.Up))
                movementY = -1;

            if (inputHandler.ButtonPressed(Buttons.DPadLeft) || movementVector.X < 0 || inputHandler.KeyReleased(Keys.Left))
                movementX = -1;
            if (inputHandler.ButtonPressed(Buttons.DPadRight) || movementVector.X > 0 || inputHandler.KeyReleased(Keys.Right))
                movementX = 1;

            if (inputHandler.ButtonPressed(Buttons.A) || inputHandler.KeyDown(Keys.Enter))
                aButton = true;
            if (inputHandler.ButtonPressed(Buttons.B) || inputHandler.KeyDown(Keys.Back))
                bButton = true;

            if (menuHandler.ElapsedSinceLastInput > menuHandler.AllowedTimeBetweenInputs)
            {
                if (movementY != 0 || movementX != 0 || aButton || bButton)
                {
                    menuHandler.update(movementY, movementX, aButton, bButton);
                    menuHandler.ElapsedSinceLastInput = 0;
                }
            }

            menuHandler.ElapsedSinceLastInput += gameTime.ElapsedGameTime.Milliseconds;

            if (menuHandler.sendScore)
            {
                sendScore(gameWorld);

                menuHandler.ExitGame = true;
            }
        }
Ejemplo n.º 4
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
            gamestate = GameStates.Menu;
            highScores = new Highscores();
            contentHolder = new ContentHolder(this.Content);
            soundManager = new SoundManager(contentHolder);
            gameController = new Controllers.Controller(contentHolder, soundManager, highScores, gameName, width, height);
            inputHandler = new InputHandler();
            gameWorld = new Models.Gameworld(contentHolder, GraphicsDevice.Viewport, 4096);    //TODO SINGLETON

            base.Initialize();
        }