/* Whenever a new level is created, random blocks are generated and the stack is set to 3 rows (more depending on difficulty). * The blocks will rise at a speed depending on player's level. The higher the level, the faster the blocks rise. */ public Level(Texture2D player, Texture2D background, Texture2D ground, Texture2D platform) { //set up rise rate riseRate = maxRate; //set up controls levelArea = new Rectangle(0, 0, Screen.ScreenWidth, Screen.ScreenHeight); input.AddTouchGestureInput(playArea, GestureType.HorizontalDrag, levelArea); }
protected override void LoadScreenContent(ContentManager content) { atkBlock = content.Load <Texture2D>(@"Blocks/attack"); shldBlock = content.Load <Texture2D>(@"Blocks/shield"); redBlock = content.Load <Texture2D>(@"Blocks/red"); greenBlock = content.Load <Texture2D>(@"Blocks/green"); blueBlock = content.Load <Texture2D>(@"Blocks/blue"); multiBlock = content.Load <Texture2D>(@"Blocks/multi"); well = content.Load <Texture2D>(@"Images/wellbackground"); debugFont = content.Load <SpriteFont>(@"Fonts/debugFont"); //lifebar emptyBarTexture = content.Load <Texture2D>(@"Images/lifebar_empty"); lifeBarTexture = content.Load <Texture2D>(@"Images/lifebar_solid"); redLifeTexture = content.Load <Texture2D>(@"Images/lifebar_red"); screenArea = new Rectangle(0, 0, Screen.ScreenWidth, Screen.ScreenHeight); input.AddTouchGestureInput(screenTapped, GestureType.Tap, screenArea); input.AddTouchGestureInput(screenHold, GestureType.Hold, screenArea); level = new Level(atkBlock, shldBlock, redBlock, greenBlock, blueBlock, multiBlock, well, 3); playerBar = new Lifebar(emptyBarTexture, lifeBarTexture, redLifeTexture, 100, 20); }
/* Whenever a new level is created, random blocks are generated and the stack is set to 3 rows (more depending on difficulty). * The blocks will rise at a speed depending on player's level. The higher the level, the faster the blocks rise. */ public Level(Texture2D atk, Texture2D shield, Texture2D red, Texture2D green, Texture2D blue, Texture2D multi, Texture2D wellBG, ushort rowCount) { attackBlock = atk; shieldBlock = shield; redBlock = red; greenBlock = green; blueBlock = blue; multiBlock = multi; wellBackground = wellBG; initRowCount = rowCount; currentRowCount = rowCount; //set up rise rate riseRate = maxRate; //set up controls wellArea = new Rectangle(offsetX, 0, blockSize * MAX_COLS, Screen.ScreenHeight); input.AddTouchGestureInput(playArea, GestureType.HorizontalDrag, wellArea); //fill up well with blocks for (int i = 0; i < MAX_ROWS; i++) { //we need to check if a block occupies the current space for (int j = 0; j < MAX_COLS; j++) { if (i >= (MAX_ROWS - initRowCount) - 1) //I'm subtracting 1 because of the Y offset. Without it, the number of rows displayed is inaccurate. { //Create a random block and store it in the list Vector2 blockLocation = new Vector2((j * blockSize) + offsetX, (i * blockSize) + offsetY); //note the i and j //block = new Block(GenerateBlock(), blockTexture, blockLocation); //check the previous block to see if it's the same as the current block. If true, then generate another block. do { block = new Block(GenerateBlock(), blockTexture, blockLocation); }while (blockList.Count > 0 && block.BlockType() == blockList[blockList.Count - 1].BlockType()); blockList.Add(block); } } } //set up the buffer buffer = MAX_ROWS; }
protected override void SetupInputs() { input.AddTouchGestureInput(screenTapped, GestureType.Tap, screenArea); input.AddTouchGestureInput(jumpButtonPressed, GestureType.Tap, jumpButtonArea); }
/* Whenever a new level is created, a level with all normal tiles should be displayed by default, with no starting player position. */ public Level(Texture2D playerTexture, Texture2D normalTileTexture, Texture2D emptyTileTexture, SpriteFont font) { ball = playerTexture; normalTile = normalTileTexture; emptyTile = emptyTileTexture; /* The level parameter determines what kind of grid the player gets. A case statement is used to * create the level and pass it on to the global 2D array called "grid." * * Level contents **************** * 1 = normal tile * 0 = empty tile node * -1 = blocked area. Used to vary the shapes of the puzzles * 2-10 = durable tile. Requires more than 1 pass to destroy. * 11 = invincible tile. cannot be destroyed. Does not reduce the turn count. Does not count towards tile count * 12 = target tile. can only be destroyed if the player destroyed a given number of tiles. * 13 = chain tile. Changes normal tiles to empty tiles in all rows and/or columns adjacent to the tile. * Has the opposite effect if rolled on again. Excluded from tile count * * The player can start at different positions which can make puzzles harder or easier. */ //set the player's position // playerRowPosition = 0; //playerColPosition = 0; //currentRow = 0; //currentCol = 0; //default turn count is 10 turnCount = 10; //default level is 1 level = 1; //set move count moveCount = 0; int[,] newLevel = { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }; //copy the level to the global array for (int i = 0; i < GRID_ROWS; i++) { for (int j = 0; j < GRID_COLS; j++) { grid[i, j] = newLevel[i, j]; //initialize target grid targetGrid[i, j] = 0; //keep track of number of nodes //if (grid[i, j] == 1) // tileCount++; } } //set up controls levelArea = new Rectangle(offsetX, offsetY, tileSize * GRID_COLS, tileSize * GRID_ROWS); input.AddTouchGestureInput(ActionLevel, GestureType.Tap, levelArea); }