Example #1
0
        public string getStatus()
        {
            int    gameStatus = BubbleHolder.checkGameStatus();
            string toRet;

            if (gameStatus == 0)
            {
                //Console.WriteLine("You have won the game");//win
                toRet = ("You have won the game! with score:" + BubbleHolder.score);
                if (CurrentLevel == 1)
                {
                    //changeLevel();
                }
                else
                {
                    //Game.Exit();
                }
            }
            else if (gameStatus == 1)
            {
                //Console.WriteLine("You have lost the game!!");//lose
                toRet = "You have lost the game!" + BubbleHolder.score;
            }
            else
            {
                toRet = "score: " + BubbleHolder.score;
            }
            return(toRet);
        }
 public void checkCollisions()
 {
     if (BubbleHolder.checkColliding(bubbles[0]))
     {
         bubbles[0].stop();
         BubbleHolder.snapToGrid(bubbles[0]);
         changeBubbles();
         isReady = true;
         if (numberOfShots >= 3)
         {
             BubbleHolder.MoveCeilingDown();
             numberOfShots = 0;
         }
     }
     if (BoardMain.checkWallCollision(bubbles[0]))
     {
         Velocity temp = bubbles[0].getVelocity();
         bubbles[0].setVelocity(new Velocity(-temp.x, temp.y, temp.z));
     }
     if (BoardMain.checkReachedLimit(bubbles[0]))
     {
         bubbles[0].stop();
         BubbleHolder.snapToGrid(bubbles[0]);
         //bubbles[0].popBubble();
         changeBubbles();
     }
 }
Example #3
0
        protected void handleKeyboard()
        {
            KeyboardState keyState = Keyboard.GetState();

            if (keyState.IsKeyDown(Keys.Escape) && !oldState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
            if (keyState.IsKeyDown(Keys.Left))
            {
                board.changeAngle(-1);
            }
            if (keyState.IsKeyDown(Keys.Right))
            {
                board.changeAngle(1);
            }
            if (keyState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
            {
                board.shoot();
            }

            if (keyState.IsKeyDown(Keys.A))
            {
                CameraHolder.cameraFar.RotateY(Angle.toRadians(5));
            }
            if (keyState.IsKeyDown(Keys.S))
            {
                CameraHolder.cameraFar.MoveForwards(-2);
            }
            if (keyState.IsKeyDown(Keys.D))
            {
                CameraHolder.cameraFar.RotateY(Angle.toRadians(-5));
            }
            if (keyState.IsKeyDown(Keys.W))
            {
                CameraHolder.cameraFar.MoveForwards(2);
            }
            if (keyState.IsKeyDown(Keys.Q))
            {
                BubbleHolder.initGrid(0, 0, 0);
            }
            if (keyState.IsKeyDown(Keys.C) && !oldState.IsKeyDown(Keys.C))
            {
                isFp = !isFp;
                CameraHolder.switchCameras(isFp);
            }

            if (keyState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
            {
                proceed();
            }
            if (keyState.IsKeyDown(Keys.R) && !oldState.IsKeyDown(Keys.R))
            {
                changeLevel(CurrentLevel);
            }
            oldState = keyState;
        }
Example #4
0
 public override void Draw(GameTime gameTime)
 {
     for (int i = 0; i < walls.Count; i++)
     {
         walls[i].Draw(gameTime);
     }
     background.Draw(gameTime);
     base.Draw(gameTime);
     BubbleHolder.RemovePopped();
 }
Example #5
0
        public override void Update(GameTime gameTime)
        {
            childComponents = new List <GameComponent>();
            BubbleHolder.finalizeDropping();
            List <Bubble> temp = BubbleHolder.getBubbles();

            for (int i = 0; i < temp.Count; i++)
            {
                childComponents.Add(temp[i]);
            }
            base.Update(gameTime);
        }
Example #6
0
        private void proceed()
        {
            int gameStatus = BubbleHolder.checkGameStatus();

            if (gameStatus == 0)
            {
                if (CurrentLevel == 1)
                {
                    changeLevel(2);
                }
                else
                {
                    Exit();
                }
            }
            else if (gameStatus == 1)
            {
                changeLevel(1);
            }
        }
Example #7
0
        public override void Initialize()
        {
            BubbleHolder.initGrid(boardPosition.x, boardPosition.y, boardPosition.z);
            if (currentLevel == 2)
            {
                /*
                 * for (int j = 0; j < 4; j++)
                 * {
                 * for (int i = 0; i < 8; i++)
                 * {
                 *  BubbleHolder.grid[i, j].bubble = BubbleCreator.createRandomBubble(BubbleHolder.grid[i, j].point);
                 *  childComponents.Add(BubbleHolder.grid[i, j].bubble);
                 * }
                 * }
                 * */
                createLevel2();
            }
            else
            {
                /*
                 * int[] coordinates = new int[]{ 0, 0 };
                 * BubbleHolder.grid[coordinates[0], coordinates[1]].bubble = new Bubble(Game, BubbleColor.red, BubbleHolder.grid[coordinates[0], coordinates[1]].point);
                 * childComponents.Add(BubbleHolder.grid[coordinates[0], coordinates[1]].bubble);
                 *
                 * coordinates = new int[] { 0, 1 };
                 * BubbleHolder.grid[coordinates[0], coordinates[1]].bubble = new Bubble(Game, BubbleColor.red, BubbleHolder.grid[coordinates[0], coordinates[1]].point);
                 * childComponents.Add(BubbleHolder.grid[coordinates[0], coordinates[1]].bubble);
                 *
                 * coordinates = new int[] { 0, 2 };
                 * BubbleHolder.grid[coordinates[0], coordinates[1]].bubble = new Bubble(Game, BubbleColor.red, BubbleHolder.grid[coordinates[0], coordinates[1]].point);
                 * childComponents.Add(BubbleHolder.grid[coordinates[0], coordinates[1]].bubble);
                 * */
                createLevel1();
            }

            WallBlock w1 = new WallBlock(new Point(verteces[0], verteces[2], verteces[5]), new Point(verteces[0], verteces[3] + 3, verteces[4]));

            walls.Add(w1);

            //WallBlock w2 = new WallBlock(new Point(verteces[0], verteces[2], verteces[5]), new Point(verteces[1] + 2, verteces[2], verteces[5]));
            //walls.Add(w2);

            WallBlock w3 = new WallBlock(new Point(verteces[1], verteces[2], verteces[5]), new Point(verteces[1], verteces[3] + 3, verteces[4]));

            walls.Add(w3);

            WallBlock w4 = new WallBlock(new Point(verteces[0] + 2, verteces[3], verteces[4]), new Point(verteces[1] + 2, verteces[3], verteces[4]));

            walls.Add(w4);

            WallBlock w5 = new WallBlock(new Point(verteces[0], verteces[2], verteces[5] - Wall.size.depth), new Point(verteces[0], verteces[3] + 3, verteces[4] - Wall.size.depth));

            walls.Add(w5);

            //WallBlock w2 = new WallBlock(new Point(verteces[0], verteces[2], verteces[5]), new Point(verteces[1] + 2, verteces[2], verteces[5]));
            //walls.Add(w2);

            WallBlock w6 = new WallBlock(new Point(verteces[1], verteces[2], verteces[5] - Wall.size.depth), new Point(verteces[1], verteces[3] + 3, verteces[4] - Wall.size.depth));

            walls.Add(w6);

            WallBlock w7 = new WallBlock(new Point(verteces[0] + 2, verteces[3], verteces[4] - Wall.size.depth), new Point(verteces[1] + 2, verteces[3], verteces[4] - Wall.size.depth));

            walls.Add(w7);

            WallBlock w8 = new WallBlock(new Point(verteces[0], verteces[2], verteces[5] - 2 * Wall.size.depth), new Point(verteces[0], verteces[3] + 3, verteces[4] - 2 * Wall.size.depth));

            walls.Add(w8);

            //WallBlock w2 = new WallBlock(new Point(verteces[0], verteces[2], verteces[5]), new Point(verteces[1] + 2, verteces[2], verteces[5]));
            //walls.Add(w2);

            WallBlock w9 = new WallBlock(new Point(verteces[1], verteces[2], verteces[5] - 2 * Wall.size.depth), new Point(verteces[1], verteces[3] + 3, verteces[4] - 2 * Wall.size.depth));

            walls.Add(w9);

            WallBlock w10 = new WallBlock(new Point(verteces[0] + 2, verteces[3], verteces[4] - 2 * Wall.size.depth), new Point(verteces[1] + 2, verteces[3], verteces[4] - 2 * Wall.size.depth));

            walls.Add(w10);

            background = new WallArea(new Point(verteces[0] + 2, verteces[2], verteces[5] - 5), new Point(verteces[1], verteces[3] + 4, verteces[4] - 5));


            base.Initialize();
        }