private void DiamondExpode(int centerX, int centerY) { this.Explode(centerX, centerY); for (int x = centerX - 1; x < centerX + 2; x++) { for (int y = centerY - 1; y < centerY + 2; y++) { if (x < this.model.Width && x >= 0 && y < this.model.Height && y >= 0) { if (!this.model.TitaniumMatrix[x, y]) { var d = new Blocks.Diamond(); d.TilePosition = new Point(x, y); d.TileOldPosition = new Point(x, y); this.model.Diamonds[x, y] = d; } } } } }
/// <summary> /// Loads the level. /// </summary> /// <param name="levelResource">The level resource from resorces.</param> /// <returns>GameModel.</returns> public GameModel LoadLevel(byte[] levelResource) { this.originalMap = levelResource; string[] lines = this.LoadFileLinesFromResource(levelResource); this.width = int.Parse(lines[0]); // cella szeleseeg, magasseg this.height = int.Parse(lines[1]); this.model = new GameModel(this.width, this.height); this.model.RequireDiamonds = int.Parse(lines[2]); this.model.TextureSet = int.Parse(lines[3]); for (int x = 0; x < this.width; x++) { for (int y = 0; y < this.height; y++) { char current = lines[y + 4][x]; var point = new Point(x, y); var initPrev = new Point(x, y); switch (current) { case 'w': this.model.WallMatrix[x, y] = true; break; case 'X': this.model.Rockford = new Rockford(); this.model.Rockford.TilePosition = point; this.model.Rockford.TileOldPosition = initPrev; // model.Camera.Follow(point); break; case 'P': this.model.Exit.TilePosition = new Point(x, y); break; case 'r': var boulder = new Blocks.Boulder(); boulder.TilePosition = point; boulder.TileOldPosition = initPrev; boulder.Variant = rnd.Next(1, 5); this.model.Boulders[x, y] = boulder; break; case 'd': var diamond = new Blocks.Diamond(); diamond.TilePosition = point; diamond.TileOldPosition = initPrev; this.model.Diamonds[x, y] = diamond; break; case '.': var dirt = new Blocks.Dirt(); dirt.Variant = rnd.Next(1, 5); this.model.DirtMatrix[x, y] = dirt; break; case 'W': this.model.TitaniumMatrix[x, y] = true; break; case 'q': this.model.Fireflies[x, y] = new Firefly(point); break; case 'B': this.model.Butterflies[x, y] = new Butterfly(point); break; } } } this.CameraFollowRockford(); this.model.Rockford.Direaction = State.Birth; return(this.model); }