/// <summary> /// Checks a specific location for a given set of prayers. /// </summary> /// <param name="x"></param> /// <param name="y"></param> private bool CheckLayouts(int x, int y, Prayer prayer) { // We check all the board coordinates that may include // this point as a coordinate. int pCols = prayer.Board.Columns; int pRows = prayer.Board.Rows; for (int ox = -pCols; ox < pCols; ox++) { for (int oy = -pRows; oy < pRows; oy++) { // Check it bool results = CheckLayout(x + ox, y + oy, prayer); // If we are true, process it if (results) { // We found a layout, so process the layout event ProcessFoundLayout(x + ox, y + oy, prayer); return(true); } } } // We didn't find a prayer return(false); }
/// <summary> /// Generates a prayer from one randomly selected of the boards. /// </summary> /// <param name="maxSize"></param> /// <returns></returns> public Prayer CreatePrayer() { // Create a new prayer Prayer prayer = new Prayer(CreatePrayerBoard()); // Return the results return prayer; }
/// <summary> /// Generates a prayer from one randomly selected of the boards. /// </summary> /// <param name="maxSize"></param> /// <returns></returns> public Prayer CreatePrayer() { // Create a new prayer Prayer prayer = new Prayer(CreatePrayerBoard()); // Return the results return(prayer); }
/// <summary> /// This creates a new stage for the game, using the /// properties of the state to determine how the board is /// generated. /// </summary> public void GenerateStage() { // See if we already have a gate column (i.e. if we have // any columns, then we do). int newColumns = Constants.StageWidth; // Extend the board by the number of columns int oldColumns = Columns; Columns = Columns + newColumns; // Populate the base level board for (int i = 0; i < newColumns; i++) { // Get the column IList <BlockStack> stacks = this[oldColumns + i]; // Go through the rows for (int j = 0; j < Constants.BoardRows; j++) { // Get the stack BlockStack stack = stacks[j]; stack.IsInInitialPlacement = true; // Set a new immobile block into place Block block = AssetLoader.Instance .CreateBlock(Constants.ImmobileBlockName); block.BottomPosition = 0; block.Height = 1; // Add it to the stack stack.Add(block); } } // Populate the additional immobile boards AddBlocks(Game.State.ImmobileCount, Constants.ImmobileBlockName); // Add the grass, dirt, and water blocks AddBlocks(); // Add the character prayer, but not on the far-right side Prayer prayer = new Prayer(); int px = Entropy.Next(0, Constants.StageWidth - 1); int py = Entropy.Next(0, Constants.BoardRows); prayer.X = px + oldColumns; prayer.Y = py; Game.State.Prayers.Add(prayer); BlockStack ps = Game.State.Board[oldColumns + px, py]; prayer.BottomPosition = ps.TopPosition; prayer.Vector = Constants.DroppedVector; ps.Add(prayer); }
public PrayerSpeechSprite(Prayer prayer) : base(AssetLoader.Instance.CreateDrawable("Speech Bubble")) { this.prayer = prayer; }
/// <summary> /// Constructs the basic minor mode and sets up the internal /// structures. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="prayer"></param> public PrayerCompletedMinorMode(int x, int y, Prayer prayer) : base() { // Save the values X = x; Y = y; // Set up the prayer board Prayer = prayer; Prayer.Board.MaximumPosition = 5; Prayer.Board.MinimumPosition = -2; // Create the block viewport blockViewport = new BlockViewport(Prayer.Board, AssetLoader.Instance); blockViewport.Size = blockViewport.Extents.Size; blockViewport.ClipContents = false; Viewport.Add(blockViewport); // We modify the prayer to simulate a drop by raising // everything but the bottommost one. for (int i = 0; i < prayer.Board.Columns; i++) { // Get the stack IList <BlockStack> stacks = prayer.Board[i]; // Go through the stack for (int j = 0; j < stacks.Count; j++) { // Get the stack BlockStack stack = stacks[j]; stack.IsInInitialPlacement = false; // Go through the blocks foreach (Block block in stack) { // Mark this as unusable block.Data = false; // Figure out the position if (block.BottomPosition != 0) { // For the top blocks block.BottomPosition *= Constants.PrayerDroppingMultiplier; block.BottomPosition += Entropy.NextFloat(-0.5f, 0.5f); block.IsMoving = true; block.Mass = Constants.PrayerBlockMass; block.Vector = Constants.PrayerDroppedVector; } else { // For the bottom blocks block.IsMoving = false; block.Vector = 0; block.Mass = 0; } } } } // Attack some new events prayer.Board.BlockMovingChanged += OnBlockMovingChanged; prayer.Board.MovingChanged += OnMovingChanged; }
/// <summary> /// Handles the actual processing of a found prayer layout and /// places the game in completion mode. /// </summary> private void ProcessFoundLayout(int x, int y, Prayer prayer) { // Activate the minor mode (Game.GameMode as PlayMode).MinorMode = new PrayerCompletedMinorMode(x, y, prayer); }
/// <summary> /// Checks a specific location for a given set of prayers. /// </summary> /// <param name="x"></param> /// <param name="y"></param> private bool CheckLayouts(int x, int y, Prayer prayer) { // We check all the board coordinates that may include // this point as a coordinate. int pCols = prayer.Board.Columns; int pRows = prayer.Board.Rows; for (int ox = -pCols; ox < pCols; ox++) { for (int oy = -pRows; oy < pRows; oy++) { // Check it bool results = CheckLayout(x + ox, y + oy, prayer); // If we are true, process it if (results) { // We found a layout, so process the layout event ProcessFoundLayout(x + ox, y + oy, prayer); return true; } } } // We didn't find a prayer return false; }
/// <summary> /// Checks a specific prayer against a specific location, /// returning true if the layout is found and false if it /// is invalid. /// </summary> private bool CheckLayout(int x, int y, Prayer prayer) { // Figure out the extents for searching on this point int pRows = prayer.Board.Rows; int pCols = prayer.Board.Columns; int bRows = Game.State.Board.Rows; int bCols = Game.State.Board.Columns; Block first = null; // Sanity checking if (x < 0 || y < 0 || x + pCols > bCols || y + pRows > bRows) { return false; } // Noise Debug("Checking for prayer at {0},{1}", x, y); // Loop through the columns for (int i = 0; i < pCols; i++) { // Get the game column IList<BlockStack> boardColumn = Game.State.Board[x + i]; // Loop through each of the rows for (int j = 0; j < pRows; j++) { // Grab the top block BlockStack stack = prayer.Board[i, j]; // If this stack is empty, just skip it as valid if (stack.Count == 0) continue; // Grab the stack Block pBottom = stack.BottomBlock; // Grab the board block BlockStack bStack = boardColumn[y + j]; Block bTop = bStack.TopBlock; // Compare the drawable names if (pBottom.Sprite.ID == "Invisible") { // Invisible always matches continue; } if (bTop.Sprite.ID != pBottom.Sprite.ID) { Debug(" Name rejected prayer: {0} v. {1}", bTop.Sprite.ID, pBottom.Sprite.ID); return false; } // Copy first or verify that the position is valid if (first == null) { first = bTop; } else { if (first.BottomPosition != bTop.BottomPosition) { Debug(" Position rejected prayer: {0} v {1}", first.BottomPosition, bTop.BottomPosition); return false; } } } } // We didn't have any errors Debug(" Found prayer!"); return true; }
/// <summary> /// This creates a new stage for the game, using the /// properties of the state to determine how the board is /// generated. /// </summary> public void GenerateStage() { // See if we already have a gate column (i.e. if we have // any columns, then we do). int newColumns = Constants.StageWidth; // Extend the board by the number of columns int oldColumns = Columns; Columns = Columns + newColumns; // Populate the base level board for (int i = 0; i < newColumns; i++) { // Get the column IList<BlockStack> stacks = this[oldColumns + i]; // Go through the rows for (int j = 0; j < Constants.BoardRows; j++) { // Get the stack BlockStack stack = stacks[j]; stack.IsInInitialPlacement = true; // Set a new immobile block into place Block block = AssetLoader.Instance .CreateBlock(Constants.ImmobileBlockName); block.BottomPosition = 0; block.Height = 1; // Add it to the stack stack.Add(block); } } // Populate the additional immobile boards AddBlocks(Game.State.ImmobileCount, Constants.ImmobileBlockName); // Add the grass, dirt, and water blocks AddBlocks(); // Add the character prayer, but not on the far-right side Prayer prayer = new Prayer(); int px = Entropy.Next(0, Constants.StageWidth - 1); int py = Entropy.Next(0, Constants.BoardRows); prayer.X = px + oldColumns; prayer.Y = py; Game.State.Prayers.Add(prayer); BlockStack ps = Game.State.Board[oldColumns + px, py]; prayer.BottomPosition = ps.TopPosition; prayer.Vector = Constants.DroppedVector; ps.Add(prayer); }
/// <summary> /// Triggered when a prayer is completed. /// </summary> /// <param name="prayer"></param> public void PrayerCompleted(Prayer prayer) { InterruptMusic("Prayer Completed"); }
/// <summary> /// Triggered when the user releases or presses a key. /// </summary> public void Key(KeyboardEventArgs args) { // We only care about keyboard presses if (!args.Pressed) { return; } // Switch the mode switch (args.Key) { case BooGameKeys.Escape: // Go to the main menu Game.GameMode = new MainMenuMode(); break; #if DEBUG case BooGameKeys.F3: // Add to the minor mode if we already have one if (MinorMode != null && MinorMode is ChestOpenedMinorMode) { // Just increment it (MinorMode as ChestOpenedMinorMode).ChestCounter++; } else { // Open up the new mode MinorMode = new ChestOpenedMinorMode(1); } return; case BooGameKeys.F4: // Add a bug into the board Game.State.Board.AddBugs(1); return; case BooGameKeys.F5: // Give another stage with penalties MinorMode = new NewStageMinorMode(); return; case BooGameKeys.F6: // Creates a test prayer and inserts it into the system. Prayer prayer = Game.PrayerFactory.CreatePrayer(); prayer.IsAccepted = true; Game.State.Prayers.Add(prayer); return; case BooGameKeys.F7: Game.State.GrabCount = 3; return; case BooGameKeys.F8: // Finish up a prayer Prayer p = Game.PrayerFactory.CreatePrayer(); MinorMode = new PrayerCompletedMinorMode(0, 0, p); return; case BooGameKeys.F9: // Finish the game MinorMode = new EndOfGameMinorMode(); return; #endif } // If we have a minor mode, pass it on if (minorMode != null) { minorMode.Key(args); } }
/// <summary> /// Checks a specific prayer against a specific location, /// returning true if the layout is found and false if it /// is invalid. /// </summary> private bool CheckLayout(int x, int y, Prayer prayer) { // Figure out the extents for searching on this point int pRows = prayer.Board.Rows; int pCols = prayer.Board.Columns; int bRows = Game.State.Board.Rows; int bCols = Game.State.Board.Columns; Block first = null; // Sanity checking if (x < 0 || y < 0 || x + pCols > bCols || y + pRows > bRows) { return(false); } // Noise Debug("Checking for prayer at {0},{1}", x, y); // Loop through the columns for (int i = 0; i < pCols; i++) { // Get the game column IList <BlockStack> boardColumn = Game.State.Board[x + i]; // Loop through each of the rows for (int j = 0; j < pRows; j++) { // Grab the top block BlockStack stack = prayer.Board[i, j]; // If this stack is empty, just skip it as valid if (stack.Count == 0) { continue; } // Grab the stack Block pBottom = stack.BottomBlock; // Grab the board block BlockStack bStack = boardColumn[y + j]; Block bTop = bStack.TopBlock; // Compare the drawable names if (pBottom.Sprite.ID == "Invisible") { // Invisible always matches continue; } if (bTop.Sprite.ID != pBottom.Sprite.ID) { Debug(" Name rejected prayer: {0} v. {1}", bTop.Sprite.ID, pBottom.Sprite.ID); return(false); } // Copy first or verify that the position is valid if (first == null) { first = bTop; } else { if (first.BottomPosition != bTop.BottomPosition) { Debug(" Position rejected prayer: {0} v {1}", first.BottomPosition, bTop.BottomPosition); return(false); } } } } // We didn't have any errors Debug(" Found prayer!"); return(true); }
/// <summary> /// Constructs the basic minor mode and sets up the internal /// structures. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="prayer"></param> public PrayerCompletedMinorMode(int x, int y, Prayer prayer) : base() { // Save the values X = x; Y = y; // Set up the prayer board Prayer = prayer; Prayer.Board.MaximumPosition = 5; Prayer.Board.MinimumPosition = -2; // Create the block viewport blockViewport = new BlockViewport(Prayer.Board, AssetLoader.Instance); blockViewport.Size = blockViewport.Extents.Size; blockViewport.ClipContents = false; Viewport.Add(blockViewport); // We modify the prayer to simulate a drop by raising // everything but the bottommost one. for (int i = 0; i < prayer.Board.Columns; i++) { // Get the stack IList<BlockStack> stacks = prayer.Board[i]; // Go through the stack for (int j = 0; j < stacks.Count; j++) { // Get the stack BlockStack stack = stacks[j]; stack.IsInInitialPlacement = false; // Go through the blocks foreach (Block block in stack) { // Mark this as unusable block.Data = false; // Figure out the position if (block.BottomPosition != 0) { // For the top blocks block.BottomPosition *= Constants.PrayerDroppingMultiplier; block.BottomPosition += Entropy.NextFloat(-0.5f, 0.5f); block.IsMoving = true; block.Mass = Constants.PrayerBlockMass; block.Vector = Constants.PrayerDroppedVector; } else { // For the bottom blocks block.IsMoving = false; block.Vector = 0; block.Mass = 0; } } } } // Attack some new events prayer.Board.BlockMovingChanged += OnBlockMovingChanged; prayer.Board.MovingChanged += OnMovingChanged; }