Esempio n. 1
0
        public void addArrow(int column, int row, Variables.Direction dir, Gameboard gameboard, int dirtex)
        {
            if (column < Variables.columns || row < Variables.rows)
            {
                Cell cell = gameboard.getCell(row, column);
                if (!cell.isBase && !cell.isSpawn)
                {
                    if (!hasArrow(cell) && rdy)
                    {
                        if (p_arrows.Count >= MAX_ARROWS)
                        {
                            Cell c = p_arrows[p_arrows.Count - 1];
                            removeArrow(c, gameboard);
                        }

                        p_arrows.Insert(0, cell);
                        cell.setOwnedBy(index);
                        gameboard.updateTile(column, row, dir, arrows[dirtex - 1]);
                    }
                    else
                    {
                        removeArrow(cell, gameboard);
                        p_arrows.Insert(0, cell);
                        cell.setOwnedBy(index);
                        gameboard.updateTile(column, row, dir, arrows[dirtex - 1]);
                    }
                }
            }
        }
Esempio n. 2
0
        //FOLLOWING SECTION IS TO BE REMOVED, IT IS THE PLAYER 1 MOUSE DEBUG TOOL FOR DEVELOPER WITHOUT XBOX CONTROLLER
        //*************************************************************************************************************
        public void addArrow(Vector2 position, Variables.Direction dir, Gameboard gameboard, int dirtex)
        {
            int tempCol = (int)position.X / Variables.cellWidth;
            int tempRow = (int)position.Y / Variables.cellHeigth;
            Cell temp_c = gameboard.getCell(tempRow, tempCol);

            if (!hasArrow(temp_c) && rdy)
            {

                if (p_arrows.Count >= 4)
                {
                    Cell c = p_arrows[p_arrows.Count - 1];
                    int c_column = c.getPositionY();
                    int c_row = c.getPositionX();

                    gameboard.updateTile(c_column, c_row, Variables.Direction.None, Tile.cellBorder);

                    p_arrows.Remove(c);
                }

                p_arrows.Insert(0, temp_c);
                gameboard.updateTile(position, dir, arrows[dirtex - 1]);
            }
        }
Esempio n. 3
0
 public void removeArrow(Cell cell, Gameboard gameboard)
 {
     if(p_arrows.Contains(cell))
     {
         gameboard.updateTile(cell.getPositionY(), cell.getPositionX(), Variables.Direction.None, Tile.cellBorder);
         p_arrows.Remove(cell);
         cell.setOwnedBy(0);
     }
 }
Esempio n. 4
0
        //Checks if Sprite has reached edge of gameboard and if so, changes direction clockwise
        public void collisionCheck(Gameboard gameboard)
        {
            foreach (Vector4 wall in gameboard.wallList)
            {
                //Check Horizontal Wall
                if (wall.X == wall.Z)
                {
                    if (this.direction == Variables.Direction.Up &&
                        getSpriteCenter().Y <= (wall.W * Variables.cellHeigth) + Variables.cellHeigth / 2 &&
                        getSpriteCenter().Y >= (wall.W * Variables.cellHeigth) &&
                        getSpriteCenter().X >= (wall.Z * Variables.cellWidth) &&
                        getSpriteCenter().X <= ((wall.Z + 1) * Variables.cellWidth))
                    {
                        if (getSpriteCenter().X > (gameboard.numberOfColumns - 1) * Variables.cellWidth + Variables.cellWidth / 2)
                        {
                            this.direction = Variables.Direction.Left;
                        }
                        else this.direction = Variables.Direction.Right;
                    }

                    if (this.direction == Variables.Direction.Down &&
                        getSpriteCenter().Y >= (wall.W * Variables.cellHeigth) - Variables.cellHeigth / 2 &&
                        getSpriteCenter().Y <= (wall.W * Variables.cellHeigth) &&
                        getSpriteCenter().X >= (wall.X * Variables.cellWidth) &&
                        getSpriteCenter().X <= ((wall.Z + 1) * Variables.cellWidth))
                    {
                        if (getSpriteCenter().X < Variables.cellWidth / 2)
                        {
                            this.direction = Variables.Direction.Right;
                        }
                        else this.direction = Variables.Direction.Left;
                    }
                }
                //Check Verticle Wall
                else if (wall.Y == wall.W)
                {
                    if (this.direction == Variables.Direction.Right &&
                        getSpriteCenter().X >= (wall.Z * Variables.cellWidth) - Variables.cellWidth / 2 &&
                        getSpriteCenter().X <= (wall.Z * Variables.cellWidth) &&
                        getSpriteCenter().Y >= (wall.Y * Variables.cellHeigth) &&
                        getSpriteCenter().Y <= ((wall.W + 1) * Variables.cellHeigth))
                    {
                        if (getSpriteCenter().Y > (gameboard.numberOfRows - 1) * Variables.cellHeigth + Variables.cellHeigth / 2)
                        {
                            this.direction = Variables.Direction.Up;
                        }
                        else this.direction = Variables.Direction.Down;
                    }

                    if (this.direction == Variables.Direction.Left &&
                        getSpriteCenter().X <= (wall.Z * Variables.cellWidth) + Variables.cellWidth / 2 &&
                        getSpriteCenter().X >= (wall.Z * Variables.cellWidth) &&
                        getSpriteCenter().Y >= (wall.Y * Variables.cellHeigth) &&
                        getSpriteCenter().Y <= ((wall.W + 1) * Variables.cellHeigth))
                    {
                        if (getSpriteCenter().Y < Variables.cellHeigth / 2)
                        {
                            this.direction = Variables.Direction.Down;
                        }
                        else this.direction = Variables.Direction.Up;
                    }
                }
            }

            if (this.direction == Variables.Direction.Right && getSpriteCenter().X > (gameboard.numberOfColumns - 1) * Variables.cellWidth + Variables.cellWidth/2)
            {
                if (getSpriteCenter().Y > (gameboard.numberOfRows - 1) * Variables.cellHeigth + Variables.cellHeigth / 2)
                {
                    this.direction = Variables.Direction.Up;
                }
                else this.direction = Variables.Direction.Down;
            }

            if (this.direction == Variables.Direction.Left && getSpriteCenter().X < Variables.cellWidth / 2)
            {
                if (getSpriteCenter().Y < Variables.cellHeigth / 2)
                {
                    this.direction = Variables.Direction.Down;
                }
                else this.direction = Variables.Direction.Up;
            }

            if (this.direction == Variables.Direction.Up && getSpriteCenter().Y < Variables.cellHeigth / 2)
            {
                if (getSpriteCenter().X > (gameboard.numberOfColumns - 1) * Variables.cellWidth + Variables.cellWidth / 2)
                {
                    this.direction = Variables.Direction.Left;
                }
                else this.direction = Variables.Direction.Right;
            }

            if (this.direction == Variables.Direction.Down && getSpriteCenter().Y > (gameboard.numberOfRows - 1) * Variables.cellHeigth + Variables.cellHeigth/2)
            {
                if (getSpriteCenter().X < Variables.cellWidth / 2)
                {
                    this.direction = Variables.Direction.Right;
                }
                else this.direction = Variables.Direction.Left;
            }
        }
Esempio n. 5
0
 public void removeArrow(int column, int row, Gameboard gameboard)
 {
     if (column < Variables.columns || row < Variables.rows)
     {
         Cell cell = gameboard.getCell(row, column);
         removeArrow(cell, gameboard);
     }
 }
Esempio n. 6
0
        //Updates the position of the Sprite on the gameboard
        public void updatePosition(Gameboard gameboard, GameTime gameTime)
        {
            directionTileCheck(gameboard);
            collisionCheck(gameboard); //checks if the Sprite has colided with the gameboard edge or a wall

            if (this.direction == Variables.Direction.Right)
            {
                this.coord = new Vector2(this.coord.X + speed, this.coord.Y);
            }

            if (this.direction == Variables.Direction.Left)
            {
                this.coord = new Vector2(this.coord.X - speed, this.coord.Y);
            }

            if (this.direction == Variables.Direction.Down)
            {
                this.coord = new Vector2(this.coord.X, this.coord.Y + speed);
            }

            if (this.direction == Variables.Direction.Up)
            {
                this.coord = new Vector2(this.coord.X, this.coord.Y - speed);
            }

            UpdateFrame((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
Esempio n. 7
0
        private bool collisionCheckNorth(Gameboard gameboard)
        {
            foreach (Vector4 wall in gameboard.wallList)
            {
                //Check Horizontal Wall
                if (wall.X == wall.Z)
                {
                    if (getSpriteCenter().Y <= (wall.W * Variables.cellHeigth) + Variables.cellHeigth / 2 &&
                        getSpriteCenter().Y >= (wall.W * Variables.cellHeigth) &&
                        getSpriteCenter().X >= (wall.Z * Variables.cellWidth) &&
                        getSpriteCenter().X <= ((wall.Z + 1) * Variables.cellWidth))
                    {
                        return true;
                    }
                }
            }

            if (getSpriteCenter().Y < Variables.cellHeigth / 2)
            {
                return true;
            }
            return false;
        }
Esempio n. 8
0
        public int getCurrentRow(Gameboard gameboard)
        {
            for (int i = 0; i < gameboard.numberOfRows; i++)
            {
                if (getSpriteCenter().Y >= (i * Variables.cellHeigth) && getSpriteCenter().Y <= (i + 1) * Variables.cellHeigth)
                {
                    return i;
                }
            }

            return 0;
        }
Esempio n. 9
0
        public int getCurrentColumn(Gameboard gameboard)
        {
            for (int i = 0; i < gameboard.numberOfColumns; i++)
            {
                if (getSpriteCenter().X >= (i * Variables.cellWidth) && getSpriteCenter().X <= ((i + 1) * Variables.cellWidth))
                {
                    return i;
                };
            }

            return 0;
        }
Esempio n. 10
0
        public void directionTileCheck(Gameboard gameboard)
        {
            if (getSpriteCenter().X >= getCurrentColumn(gameboard) * Variables.cellWidth + Variables.cellWidth / 2.5
                && getSpriteCenter().X <= (getCurrentColumn(gameboard) + 1) * Variables.cellWidth - Variables.cellWidth / 2.5
                && getSpriteCenter().Y >= getCurrentRow(gameboard) * Variables.cellHeigth + Variables.cellHeigth / 2.5
                && getSpriteCenter().Y <= (getCurrentRow(gameboard) + 1) * Variables.cellHeigth - Variables.cellHeigth / 2.5)
            {

                int tileID = gameboard.getCell(this.getCurrentRow(gameboard), this.getCurrentColumn(gameboard)).getTileID();

                switch (tileID)
                {
                    case 1:
                        direction = Variables.Direction.Up;
                        break;
                    case 2:
                        direction = Variables.Direction.Right;
                        break;
                    case 3:
                        direction = Variables.Direction.Down;
                        break;
                    case 4:
                        direction = Variables.Direction.Left;
                        break;
                    default: break;
                }
            }
        }
Esempio n. 11
0
 private void disposeGame()
 {
     gnomeList.Clear();
     foreach (Player p in playerList)
     {
         p.dispose();
     }
     gameboard = new Gameboard();
     timer = 120000;
     gnomeSpawnTimeRemaining = Variables.gnomeSpawnTime;
     evilGnomeSpawnTimeRemaining = Variables.evilGnomeSpawnTime;
     randomGnomeSpawnTimeRemaining = Variables.randomGnomeSpawnTime;
 }
Esempio n. 12
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            loadTextures();
            enterSound = Content.Load<SoundEffect>("pickup2");
            bgm = Content.Load<Song>("bgm_music");
            MediaPlayer.IsRepeating = true;

            #region MenuContentLoad

            mainMenuIconDimL = Content.Load<Texture2D>("button-dim-left");
            mainMenuIconDimR = Content.Load<Texture2D>("button-dim-right");
            mainMenuIconDimC = Content.Load<Texture2D>("button-dim-middle");
            mainMenuIconLitL = Content.Load<Texture2D>("button-lit-left");
            mainMenuIconLitR = Content.Load<Texture2D>("button-lit-right");
            mainMenuIconLitC = Content.Load<Texture2D>("button-lit-middle");

            int initialX = (Window.ClientBounds.Width / 2) - ((mainMenuIconDimL.Width + mainMenuIconDimR.Width + 350) / 2);
            int initialY = (Window.ClientBounds.Height / 4) + 75;

            mainMenuItems[0] = new MenuSelection("Play", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, initialX, initialY, 350, scoreFont);
            mainMenuItems[1] = new MenuSelection("Instructions", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, initialX, initialY + 90, 350, scoreFont);
            mainMenuItems[2] = new MenuSelection("Credits", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, initialX, initialY + 180, 350, scoreFont);
            mainMenuItems[3] = new MenuSelection("Exit", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, initialX, initialY + 270, 350, scoreFont);

            instructionOptions[0] = new MenuSelection("Controls", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, Window.ClientBounds.Width - 225 , 20, 100, scoreFont);
            instructionOptions[1] = new MenuSelection("Instructions", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, Window.ClientBounds.Width - 225, 20, 100, scoreFont);

            // Set up Pause Menu.
            initialY = (Window.ClientBounds.Height / 4) + 25;
            pauseMenuItems[0] = new MenuSelection("Resume", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, initialX, initialY, 350, scoreFont);
            pauseMenuItems[1] = new MenuSelection("Instructions", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, initialX, initialY + 90, 350, scoreFont);
            pauseMenuItems[2] = new MenuSelection("Return to Title", mainMenuIconDimL, mainMenuIconDimR, mainMenuIconDimC,
                mainMenuIconLitL, mainMenuIconLitR, mainMenuIconLitC, initialX, initialY + 180, 350, scoreFont);

            #endregion

            //Window fits to the gameboard.
            gameboard = new Gameboard();
            this.graphics.PreferredBackBufferWidth = gameboard.numberOfColumns * Variables.cellWidth;
            this.graphics.PreferredBackBufferHeight = (gameboard.numberOfRows * Variables.cellHeigth);

            initializePlayers();

            //increase screen size to fit scoreBoard
            this.graphics.PreferredBackBufferHeight = this.graphics.PreferredBackBufferHeight + scoreboards[0].Height;
        }