PageRenderTime 264ms CodeModel.GetById 141ms app.highlight 7ms RepoModel.GetById 114ms app.codeStats 0ms

/Samples/Breakout/LevelData.cs

#
C# | 118 lines | 100 code | 9 blank | 9 comment | 7 complexity | 7f4a0fef6509f15fc67d4852ba5d6ebb MD5 | raw file
  1using Delta.Utilities.Datatypes;
  2
  3namespace Breakout
  4{
  5	/// <summary>
  6	/// Helper class to setup the different levels of the game, level 1-5 are
  7	/// custom made, then anything bigger will just use level 5 data again.
  8	/// </summary>
  9	public static class LevelData
 10	{
 11		#region SetupLevelColors
 12		/// <summary>
 13		/// Setup level colors for level 1-5
 14		/// </summary>
 15		/// <param name="bricks">Bricks to set the color to</param>
 16		/// <param name="level">Current level number</param>
 17		public static void SetupLevelColors(Brick[,] bricks, int level)
 18		{
 19			switch (level)
 20			{
 21				case 1:
 22					Level1(bricks);
 23					break;
 24				case 2:
 25					Level2(bricks);
 26					break;
 27				case 3:
 28					Level3(bricks);
 29					break;
 30				case 4:
 31					Level4(bricks);
 32					break;
 33				case 5:
 34					Level5(bricks);
 35					break;
 36			}
 37		}
 38		#endregion
 39
 40		#region Level1
 41		private static void Level1(Brick[,] bricks)
 42		{
 43			for (int i = 0; i < 2; i++)
 44			{
 45				bricks[i, 0].Color = Color.Green;// Color.Purple;
 46				bricks[i, 1].Color = Color.Orange;// Color.Blue;				
 47			}
 48		}
 49		#endregion
 50
 51		#region Level2
 52		private static void Level2(Brick[,] bricks)
 53		{
 54			for (int i = 0; i < 3; i++)
 55			{
 56				bricks[i, 0].Color = new Color(0.25f, 0.25f, 0.25f);
 57				bricks[i, 1].Color = Color.Red;
 58				bricks[i, 2].Color = Color.Gold;
 59			}
 60		}
 61		#endregion
 62
 63		#region Level3
 64		private static void Level3(Brick[,] bricks)
 65		{
 66			bricks[0, 0].Color = Color.Yellow;
 67			bricks[1, 1].Color = Color.Yellow;
 68			bricks[2, 2].Color = Color.Yellow;
 69			bricks[3, 3].Color = Color.Yellow;
 70
 71			bricks[1, 0].Color = Color.Teal;
 72			bricks[2, 1].Color = Color.Teal;
 73			bricks[3, 2].Color = Color.Teal;
 74			bricks[0, 1].Color = Color.Teal;
 75			bricks[1, 2].Color = Color.Teal;
 76			bricks[2, 3].Color = Color.Teal;
 77
 78			bricks[2, 0].Color = Color.Green;
 79			bricks[3, 1].Color = Color.Green;
 80			bricks[0, 2].Color = Color.Green;
 81			bricks[1, 3].Color = Color.Green;
 82
 83			bricks[3, 0].Color = Color.LightBlue;
 84			bricks[0, 3].Color = Color.LightBlue;
 85		}
 86		#endregion
 87
 88		#region Level4
 89		private static void Level4(Brick[,] bricks)
 90		{
 91			float factor = 1f / 255f;
 92			for (int x = 0; x < 5; x++)
 93			{
 94				for (int y = 0; y < 5; y++)
 95				{
 96					bricks[x, y].Color = new Color((x * 42) * factor,
 97						(64 + y * 32) * factor, 128 * factor);
 98				}
 99			}
100		}
101		#endregion
102
103		#region Level5
104		private static void Level5(Brick[,] bricks)
105		{
106			float factor = 1f / 255f;
107			for (int x = 0; x < 6; x++)
108			{
109				for (int y = 0; y < 6; y++)
110				{
111					bricks[x, y].Color = new Color((x * 36 + 32) * factor,
112						0.33f, (x * 36 + 32) * factor);
113				}
114			}
115		}
116		#endregion
117	}
118}