/// <summary> /// Triggered when an entire block stack stops moving. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnMovingChanged(object sender, BlockStackEventArgs args) { // Check the board, but only if we dropped a block if (Board.IsGroundBlock(args.Stack.TopBlock)) { Game.State.Board.CheckLayout(args.Stack.X, args.Stack.Y); } }
/// <summary> /// Triggered when a block stops moving. /// </summary> private void OnBlockMovingChanged( object sender, BlockStackEventArgs args) { // Only bother if we are dropping a ground block if (!Board.IsGroundBlock(args.Block) || !droppingBlocks.Contains(args.Block)) { return; } // First check for bugs foreach (Block block in args.Stack) { // Ignore processing ourselves if (args.Block == block) { continue; } // Ignore if the position isn't close if ((int)args.Block.BottomPosition != (int)block.TopPosition) { continue; } // Check for the drawable if (block.Sprite.ID == Constants.BugBlockName) { // Remove the bug (block as Bug).Remove(); // Start falling again args.Block.BottomPosition -= 1f; args.Block.Vector = Constants.DroppedVector; // Finish processing return; } } // Remove it droppingBlocks.Remove(args.Block); }
/// <summary> /// This returns true if the current stack may be grabbed from. /// </summary> /// <param name="stack"></param> /// <returns></returns> private bool CanGrab() { // Ignore everything if we don't have a stack if (currentStack == null) { return(false); } // See if we have room to grab things if (grabStack[Game.State.GrabCount - 1] != null) { // The highest one is filled, so we can't grab return(false); } // Get the positions we use float topPosition = currentStack.TopPosition; Block topBlock = currentStack.TopBlock; // Check the top position if (topPosition == Constants.TopImmobilePosition) { // We only have an immobile block return(false); } // See if we are a ground block if (!Board.IsGroundBlock(topBlock)) { // We aren't a grabbable block return(false); } // If we have data in the block, it is immobile if (topBlock.Data != null) { return(false); } // It appears to be a valid block return(true); }
/// <summary> /// This returns true if the currently selected block can be /// dropped on by the bottom-most (index 0) index of the grab /// stack. /// </summary> /// <param name="stack"></param> /// <returns></returns> private bool CanDrop() { // Ignore nulls stacks if (currentStack == null) { return(false); } // We don't bother if we don't have anything to drop if (grabStack[0] == null) { return(false); } // Get the positions we use float topPosition = currentStack.TopPosition; Block topBlock = currentStack.TopBlock; // Check the top position if (topPosition >= Constants.TopGroundPosition) { // We have too many blocks return(false); } // See if we are a ground block if (!Board.IsGroundBlock(topBlock) && !Board.IsImmobileBlock(topBlock) && topBlock.Sprite.ID != Constants.BugBlockName || topBlock.Data != null) { // We aren't a grabbable block return(false); } // It appears to be a valid block return(true); }