/// <summary> /// Create an empty prayer. /// </summary> public Prayer() : base(GetRandomCharacterSprite()) { // Set the block information Height = 1; CastsShadows = false; // TODO Set the mass to half a normal block to make sure // they fall properly instead of just getting stuck. Mass = Constants.BlockMass / 2; // Create a random board and assign it this.board = Game.PrayerFactory.CreatePrayerBoard(); // Set up the bounce timeUntilBounce = Entropy.NextDouble( Constants.MinimumCharacterBounce, Constants.MaximumCharacterBounce); // Connect some events DirectionChanged += OnDirectionChanged; }
/// <summary> /// Loads the prayers into memory. /// </summary> private void LoadPrayers() { // Get the manifest string Stream stream = GetType().Assembly .GetManifestResourceStream("CuteGod.layouts.xml"); // Create an XML reader out of it XmlTextReader xml = new XmlTextReader(stream); // Loop through the file while (xml.Read()) { // Ignore all but start elements if (xml.NodeType != XmlNodeType.Element) continue; // Check for name if (xml.LocalName == "board") { // Load the board Board board = new Board(); board.Read(xml, AssetLoader.Instance); boards.Add(board); } } }
/// <summary> /// Migrates the current board to the other one, dropping /// everything on top. /// </summary> /// <param name="board"></param> /// <param name="x"></param> /// <param name="y"></param> public void MigrateBoard(Board board, int x, int y) { // Go through the columns for (int i = 0; i < Columns; i++) { // Get the data for speed IList<BlockStack> stacks = Game.State.Board[x + i]; IList<BlockStack> stacks0 = this[i]; // Go through the rows for (int j = 0; j < Rows; j++) { // Get the stacks BlockStack stack = stacks[y + j]; BlockStack stack0 = stacks0[j]; // Get the position Block bBlock = stack.TopBlock; float position = stack.TopPosition; // Move everything but the bottom-most one foreach (Block block in stack0) { // Seal it to change how it looks on the // mini map switch (block.Sprite.ID) { case "Water Block": bBlock.Sprite = AssetLoader.Instance .CreateSprite("Sealed Water Block"); bBlock.Data = false; break; case "Grass Block": bBlock.Sprite = AssetLoader.Instance .CreateSprite("Sealed Grass Block"); bBlock.Data = false; break; case "Dirt Block": bBlock.Sprite = AssetLoader.Instance .CreateSprite("Sealed Dirt Block"); bBlock.Data = false; break; } // Positions 0's are sealed if (block.BottomPosition != 0) { // Move it over to the new one and add the position // to the bottom, minus one because we ignore the // bottom row block.BottomPosition += position -1f; stack.Add(new Block(block)); } } } } }
/// <summary> /// Create a bug with a specific board. /// </summary> /// <param name="board"></param> public Bug(Board board) : this() { }
/// <summary> /// Create a prayer with a specific board. /// </summary> /// <param name="board"></param> public Prayer(Board board) : this() { this.board = board; }