Пример #1
0
        public void SpawnPowerup(string powerupName)
        {
            // Set general powerup properties
            Rectangle powerupTile = new Rectangle();

            powerupTile.Height = GameWindow.ReturnTileSize();
            powerupTile.Width  = GameWindow.ReturnTileSize();
            Grid.SetColumn(powerupTile, xPos);
            Grid.SetRow(powerupTile, yPos);

            GameBoardManager.curTileState[xPos, yPos] = TileStates.Powerup;
            // Set properties unique to each powerup
            switch (powerupName)
            {
            case ("SuperBomb"):
                pName            = "Superbomb";
                powerupTile.Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\superbomb.png", UriKind.Relative)));
                _localGameBoard.ChangeTileState(xPos, yPos, "Superbomb");
                break;

            case ("Shield"):
                pName            = "Shield";
                powerupTile.Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\shield.png", UriKind.Relative)));
                _localGameBoard.ChangeTileState(xPos, yPos, "Shield");
                break;

            case ("Lifeup"):
                pName            = "Lifeup";
                powerupTile.Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\heart.png", UriKind.Relative)));
                _localGameBoard.ChangeTileState(xPos, yPos, "Lifeup");
                break;
            }

            curGameGrid.Children.Add(powerupTile);
        }
Пример #2
0
        // ------------------------- Player Controller Constructor ------------
        public PlayerController()
        {
            tileSize = GameWindow.ReturnTileSize();

            playerTimerRef = GameWindow.ReturnTimerInstance();

            //Debug.WriteLine("HELLO " + playerTimerRef);
            playerTimerRef.processFrameEvent_TICK += PlayerTimerRef_tickEventPROCESS;
        }
Пример #3
0
        void DrawExplosion()
        {
            if (explosionStep < explosionMatrix.GetLength(0))
            {
                Int32 colPos = explosionMatrix[explosionStep, 0];
                Int32 rowPos = explosionMatrix[explosionStep, 1];

                if (explosionStep == 0)
                {
                    curGameGrid.Children.Remove(bombImage);
                    playBombSndFX.playBombExplode();
                    bombImage        = new Rectangle();
                    bombImage.Height = GameWindow.ReturnTileSize();
                    bombImage.Width  = GameWindow.ReturnTileSize();


                    Grid.SetColumn(bombImage, colPos);
                    Grid.SetRow(bombImage, rowPos);
                    curGameGrid.Children.Add(bombImage);
                }

                if (colPos != 0 || rowPos != 0)
                {
                    Rectangle explosion = new Rectangle();

                    Color tempColour = myOwner.playerColour;
                    explosion.Height = GameWindow.ReturnTileSize();
                    explosion.Width  = GameWindow.ReturnTileSize();

                    explosion.Fill             = new SolidColorBrush(tempColour);
                    explosion.Fill.Opacity     = 0.5f;
                    explosion.IsHitTestVisible = false;
                    explosionTiles.Add(explosion);

                    Grid.SetColumn(explosion, colPos);
                    Grid.SetRow(explosion, rowPos);
                    curGameGrid.Children.Add(explosion);
                }
                explosionStep++;
            }
            else
            {
                iCanDestroy = true;
            }
        }
        // public PlayerLivesAndScore(Canvas mainCanvas, Int32 tileSize)

        public PlayerLivesAndScore()
        {
            InitializeComponent();

            //mainCanvasLocalRef = mainCanvas;
            tileSizeLocal = GameWindow.ReturnTileSize();

            //--------------- Player Lives (HAS TO BE CHANGED HERE)--------------------------
            playerLivesNumber = playerLivesNumber + 3;

            //--------------- Player Score (HAS TO BE CHANGED HERE)--------------------------
            currentScore = 0;

            // -------------- INITIALISATION of PLAYER STATS----------------------------------------
            initialiseHomeBases();
            initialiseLives();
            initialiseScore();
        }
Пример #5
0
        void DrawBomb()
        {
            Int32 colPos = explosionMatrix[0, 0];
            Int32 rowPos = explosionMatrix[0, 1];


            bombImage        = new Rectangle();
            bombImage.Height = GameWindow.ReturnTileSize();
            bombImage.Width  = GameWindow.ReturnTileSize();

            bombImage.Fill             = new ImageBrush(new BitmapImage(new Uri(@".\Resources\Bomb2.png", UriKind.Relative)));
            bombImage.IsHitTestVisible = false;

            Grid.SetColumn(bombImage, colPos);
            Grid.SetRow(bombImage, rowPos);
            curGameGrid.Children.Add(bombImage);
            playBombSndFX.playBombTick();
        }
Пример #6
0
        // Spawn a powerup at a wall position
        public void WallSpawn(int PosX, int PosY, Grid GameGrid)
        {
            Rectangle powerupTile = new Rectangle();

            //Random r = new Random();
            //int rand = r.Next(0, 3);

            int rand = RNG.GenerateRandomNumber();

            //MessageBox.Show(string.Format("Random number: {0}", rand));

            // I believe that the rand number will always be between 1 and 255. So we divide 255 by 3 and see if 'rand' is equal to or less than one, two or three thirds of 255.\
            // Basically, this method of handling things should ensure an even chance of each power up spawning.
            if (rand <= 85)
            {
                pName            = "Superbomb";
                powerupTile.Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\superbomb.png", UriKind.Relative)));
                _localGameBoard.ChangeTileState(PosX, PosY, "Superbomb");
                //MessageBox.Show("Superbomb made");
            }
            else if (rand >= 86 && rand <= 190)
            {
                pName            = "Shield";
                powerupTile.Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\shield.png", UriKind.Relative)));
                _localGameBoard.ChangeTileState(PosX, PosY, "Shield");
                //MessageBox.Show("Shield made");
            }
            else if (rand >= 191)
            {
                pName            = "Lifeup";
                powerupTile.Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\heart.png", UriKind.Relative)));
                _localGameBoard.ChangeTileState(PosX, PosY, "Lifeup");
                //MessageBox.Show("Lifeup made");
            }


            powerupTile.Height = GameWindow.ReturnTileSize();
            powerupTile.Width  = GameWindow.ReturnTileSize();
            Grid.SetColumn(powerupTile, PosX);
            Grid.SetRow(powerupTile, PosY);
            GameBoardManager.curTileState[PosX, PosY] = TileStates.Powerup;
            GameGrid.Children.Add(powerupTile);
        }
        /// <summary>
        /// Sets up each players score initially. <para> Is called as part of calculate lives function. This function redraws the score after each time it is called. </para>
        /// </summary>
        public void initialiseScore()
        {
            //------------------------------------------------------------------------------------------------------------------
            //--------------------------------------------| Initialise Player Score |-------------------------------------------
            //------------------------------------------------------------------------------------------------------------------

            playerScore = new Label();

            playerScore.Content    = currentScore.ToString();
            playerScore.FontSize   = 32;
            playerScore.Foreground = new SolidColorBrush(Colors.Black);
            playerScore.Width      = 128;
            playerScore.Height     = GameWindow.ReturnTileSize();

            // --------------- Set position, within the local grid (scoreGrid) of this element --------------------------------

            Grid.SetRow(playerScore, 0);
            Grid.SetColumn(playerScore, 1);

            scoreGrid.Children.Add(playerScore);
            //-----------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------
        }
Пример #8
0
        //initialise the game board
        public void InitializeGameBoard()
        {
            Int32 tileSize = GameWindow.ReturnTileSize();

            //set the grid size
            //if (GameWindow.ReturnNumberOfPlayer() == 6)
            //{
            //    rows = 14;
            //    cols = 16;
            //}

            curTileState     = new TileStates[cols, rows];
            powerupTileState = new PowerupStates[cols, rows];


            GridLengthConverter myGridLengthConverter = new GridLengthConverter();
            GridLength          side = (GridLength)myGridLengthConverter.ConvertFromString("Auto");

            //Setup the grid Rows and Columns
            for (int i = 0; i < cols; i++)
            {
                gameGrid.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition());
                gameGrid.ColumnDefinitions[i].Width = side;
            }
            for (int x = 0; x < rows; x++)
            {
                gameGrid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition());
                gameGrid.RowDefinitions[x].Height = side;
            }

            AssignDestructibleWallPositions();

            //create an empty Rectangle array
            flrTiles = new Rectangle[cols, rows];

            //fill each element in the Rectangle array with an image "tile".
            for (int c = 0; c < cols; c++)
            {
                for (int r = 0; r < rows; r++)
                {
                    flrTiles[c, r] = new Rectangle();

                    powerupTileState[c, r] = PowerupStates.Empty;

                    //add a wall tile if along the grid extremes
                    if (InitialTilePlacementCheck(c, r, cols, rows) == true)
                    {
                        flrTiles[c, r].Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\Indesructable.png", UriKind.Relative)));
                        curTileState[c, r]  = TileStates.SolidWall;
                    }
                    //add destructible walls within the game grid
                    else if (DestructableWallPlacementCheck(c, r) == true)
                    {
                        flrTiles[c, r].Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\Destructible.png", UriKind.Relative)));
                        curTileState[c, r]  = TileStates.DestructibleWall;
                    }
                    //otherwise add a floor tile
                    else
                    {
                        flrTiles[c, r].Fill = new ImageBrush(new BitmapImage(new Uri(@".\Resources\Floor.png", UriKind.Relative)));
                        curTileState[c, r]  = TileStates.Floor;
                    }
                    //
                    //inner solid and destrutable walls still required!!
                    //
                    flrTiles[c, r].Height = tileSize;
                    flrTiles[c, r].Width  = tileSize;
                    Grid.SetColumn(flrTiles[c, r], c);
                    Grid.SetRow(flrTiles[c, r], r);


                    gameGrid.Children.Add(flrTiles[c, r]);
                }
            }
        }