示例#1
0
        /**
         * Creates a new two dimensional List. The outmost List represents the tile
         * game boards width and the Lists contained inside represent each column of
         * Tile objects. This makes it easy to visualize and work with the game board
         * as a collection of columns, rather than tons of individual tiles.
         */
        public TileList(int tileGridWidth, int tileGridHeight, GameboardStats stats)
        {
            this.tileGridWidth     = tileGridWidth;
            this.tileGridHeight    = tileGridHeight;
            this.previewRowEnabled = true;
            this.stats             = stats;

            tiles = new List <List <Tile> >();
            for (int i = 0; i < tileGridWidth; i++)
            {
                List <Tile> columns = new List <Tile>();
                tiles.Add(columns);
            }

            previewTiles = new List <Tile>();
        }
示例#2
0
 public void AddStats(GameboardStats statsToAdd)
 {
     score                                    += statsToAdd.score;
     power                                    += statsToAdd.power;
     level                                    += statsToAdd.level;
     timeElapsed                              += statsToAdd.timeElapsed;
     numberOfNukesFired                       += statsToAdd.numberOfNukesFired;
     numberOfBulletTimesFired                 += statsToAdd.numberOfBulletTimesFired;
     numberOfLasersFired                      += statsToAdd.numberOfLasersFired;
     numberOfBlocksDestroyed                  += statsToAdd.numberOfBlocksDestroyed;
     numberOfBlocksDestroyedByLaser           += statsToAdd.numberOfBlocksDestroyedByLaser;
     numberOfBlocksDestroyedByNuke            += statsToAdd.numberOfBlocksDestroyedByNuke;
     totalPowerObtained                       += statsToAdd.totalPowerObtained;
     numberOfCapsCompleted                    += statsToAdd.numberOfCapsCompleted;
     numberOfTilesDestroyedByCapping          += statsToAdd.numberOfTilesDestroyedByCapping;
     numberOf2xMulipliersCapped               += statsToAdd.numberOf2xMulipliersCapped;
     numberOf3xMulipliersCapped               += statsToAdd.numberOf3xMulipliersCapped;
     numberOf4xMulipliersCapped               += statsToAdd.numberOf4xMulipliersCapped;
     numberOfMultipliersCapped                += statsToAdd.numberOfMultipliersCapped;
     numberOfNukesFiredDuringActiveBulletTime += statsToAdd.numberOfNukesFiredDuringActiveBulletTime;
 }
示例#3
0
        /**
         * Constructor
         */
        public GameBoard(Vector2 boardPosition,
                         TileSet tileSet,
                         Difficulty difficulty,
                         int width,
                         int height,
                         int playerIndex)
        {
            //set constructor params
            this.position         = boardPosition;
            this.originalPosition = boardPosition;
            this.difficulty       = difficulty;
            this.height           = height;
            this.width            = width;
            this.numTilesHeight   = difficulty.GetNumberOfTilesInTheGameboardHeight();
            this.numTilesWidth    = difficulty.GetNumberOfTilesInTheGameboardWidth();
            this.startingSpeed    = difficulty.GetStartingSpeed(); //milliseconds
            this.currentSpeed     = startingSpeed;
            this.playerIndex      = playerIndex;
            this.tileSet          = tileSet;

            //init stuff
            this.random               = new Random();
            this.animatableSprites    = new List <SpriteObject>();
            this.timeBeforeSpeedUp    = 60000; //game speeds up every 60 seconds by default
            this.speedUpIncrement     = 50;    //tiles drop 1/20th of a second faster every time the game speeds up
            this.minGameSpeed         = difficulty.GetMaxSpeed();
            this.numTilesToDrop       = difficulty.GetNumberOfTilesToDropPerRound();
            this.paused               = true;
            this.scaleTiles           = false;
            this.bulletTimeActive     = false;
            this.bulletTimeLeft       = 0;
            this.gameOver             = false;
            this.timeDownHeld         = 0;
            this.speedUpIncrement     = 15;
            this.timeBeforeSpeedUp    = 60000;
            this.speedupEnabled       = true;
            this.minGameSpeed         = 150;
            this.timeSinceLastSpeedUp = 0;
            this.isShaking            = false;
            this.timeLeftShaking      = 0;
            this.timeSinceLastShake   = 0;
            this.fadeFromWhiteAlpha   = 1;
            this.maxBulletTime        = 15000; //bullet time is 15 seconds long by default

            this.rotater = new Rotater(this.tileSet.rotater, 0, this.numTilesWidth - 2, 1);
            this.animatableSprites.Add(this.rotater);

            int startingPower;

            if (!SwitchGame.DEBUG_MODE)
            {
                startingPower = 0;
            }
            else
            {
                startingPower = 100;
            }
            this.stats = new GameboardStats(startingPower);
            this.tiles = new TileList(numTilesWidth, numTilesHeight, stats);

            this.gameBoardRect = new Rectangle((int)boardPosition.X,
                                               (int)boardPosition.Y,
                                               (int)(boardPosition.X + width),
                                               (int)(boardPosition.Y + height));

            boardBackgroundSpriteObject = new DetailedSpriteObject(tileSet.boardBackground, new Rectangle((int)(boardPosition.X - 10), 0, width + 20, height + 111));
            nukeSpriteObject            = new DetailedSpriteObject(tileSet.nukeImage, new Rectangle((int)originalPosition.X, (int)originalPosition.Y, width, height));
            blankWhiteSpritObject       = new DetailedSpriteObject(tileSet.blankImage, new Rectangle((int)originalPosition.X, (int)originalPosition.Y, width, height));
        }
示例#4
0
        /**
         * Called by the screen that is utilizing this board during every Update() cycle
         */
        public void Update(GameTime gameTime)
        {
            int elapsedTime = gameTime.ElapsedGameTime.Milliseconds;

            stats.timeElapsed         += elapsedTime;
            timeDownHeld              += elapsedTime;
            this.timeSinceLastSpeedUp += elapsedTime;

            //let all sprite objects know the current elapsed game time in case they need to update a frame
            foreach (SpriteObject sprite in animatableSprites)
            {
                sprite.UpdateGameTime(elapsedTime);
            }

            foreach (Tile sprite in tiles.GetTilesAsList())
            {
                sprite.UpdateGameTime(elapsedTime, this.GetCurrentSpeed(), (int)this.GetTilePixelHeight());
            }

            AnimationManager.Instance.UpdateGameTime(elapsedTime);
            VibrationManager.Instance.Update(elapsedTime);

            //make sure the power level isnt over max
            this.stats.power = (int)MathHelper.Clamp(this.stats.power, 0, 100);

            //shake the board if shaking is enabled
            if (this.isShaking)
            {
                VibrationManager.Instance.VibrateController((PlayerIndex)this.playerIndex, 200);

                if (this.timeLeftShaking <= 0)
                {
                    this.isShaking = false;
                    SetPaused(false);
                    this.position = this.originalPosition;
                }
                else if (this.timeSinceLastShake >= 75)
                {
                    this.timeSinceLastShake = 0;
                    int xVariation = random.Next(20) - 10;
                    int YVariation = random.Next(20) - 10;

                    this.position = new Vector2(this.originalPosition.X + xVariation,
                                                this.originalPosition.Y + YVariation);
                }

                this.fadeFromWhiteAlpha -= 0.005f;
                this.timeLeftShaking    -= elapsedTime;
                this.timeSinceLastShake += elapsedTime;
            }

            //if bullet time is currently engaged, check to see if it is time to turn it off
            if (this.bulletTimeActive)
            {
                this.bulletTimeLeft -= elapsedTime;
                if (this.bulletTimeLeft <= 0)
                {
                    this.StopBulletTime();
                }
            }

            //this is the core logic that defines gameplay
            if (!this.paused)
            {
                if (tiles.AreAllTilesSeated())
                {
                    DropNewTileSet(this.numTilesToDrop);
                }
                else
                {
                    if (tiles.WillTilesGetDropped(GetCurrentSpeed()))
                    {
                        tiles.SeatTilesOnTopOfOtherTiles();
                        tiles.SeatTilesAtFloor();

                        if (this.timeSinceLastSpeedUp >= this.timeBeforeSpeedUp &&
                            this.speedupEnabled)
                        {
                            LevelUp();
                        }

                        tiles.DropTilesOlderThanAge(GetCurrentSpeed());

                        int scoreBeforeTileDeletion = stats.score;
                        stats = tiles.MarkTilesForDeletion();
                        PointsGained(stats.score - scoreBeforeTileDeletion);
                    }

                    tiles.DeleteTilesMarkedForDeletion(this);
                }

                tiles.AgeTiles(elapsedTime);
            }
        }