Example #1
0
		public GDGameScreen(MainGame game, GraphicsDeviceManager gdm, LevelFile bp, FractionDifficulty diff) : base(game, gdm)
		{
			blueprint = bp;
			difficulty = diff;

			Initialize();
		}
Example #2
0
		public static void LoadContent(ContentManager content)
		{
			LEVEL_003 = content.Load<LevelFile>("levels/lvl003");
			LEVEL_DBG = content.Load<LevelFile>("levels/lvl_debug");
		}
Example #3
0
		public void SetLevelScreen(LevelFile blueprint)
		{
			SetCurrentScreen(new GDGameScreen(this, Graphics, blueprint, FractionDifficulty.KI_EASY));
		}
Example #4
0
		private void RecreateBuffer(LevelFile level)
		{
			timerCountDown = -1;

			using (Graphics g = Graphics.FromImage(graphicsBuffer))
			{
				if (level == null)
				{
					g.SmoothingMode = SmoothingMode.AntiAlias;
					g.Clear(Color.OrangeRed);

					g.DrawLine(new Pen(Color.DarkRed, 32), 0, 0, 1024, 640);
					g.DrawLine(new Pen(Color.DarkRed, 32), 1024, 0, 0, 640);
				}
				else
				{
					g.SmoothingMode = SmoothingMode.AntiAlias;
					g.Clear(Color.Black);

					for (int x = 0; x < 16; x++)
					{
						g.DrawLine((x%2==0)? Pens.DarkGray : Pens.DimGray, x * 64, 0, x * 64, 640);
					}
					for (int y = 0; y < 10; y++)
					{
						g.DrawLine((y % 2 == 0) ? Pens.DarkGray : new Pen(Color.FromArgb(88, 88, 88)), 0, y * 64, 1024, y * 64);
					}

					foreach (var c in level.BlueprintCannons)
					{
						var topleftX = (int) (c.X - c.Scale * 64);
						var topleftY = (int) (c.Y - c.Scale * 64);
						var width    = (int)(c.Scale * 128);
						var height   = (int)(c.Scale * 128);

						var rectReal   = new Rectangle(topleftX, topleftY, width, height);
						var rectCircle = new Rectangle(rectReal.Location, rectReal.Size);
						var rectOuter  = new Rectangle(rectReal.Location, rectReal.Size);
						rectCircle.Inflate((width * 48 / 64 - width) / 2, (height * 48 / 64 - height) / 2);
						rectOuter.Inflate((width * 80 / 64 - width) / 2, (height * 80 / 64 - height) / 2);

						var save = g.Save();
						{
							g.TranslateTransform(c.X, c.Y);
							g.RotateTransform(c.Rotation);

							var bHeight = height / 4;
							var bWidth  = width  / 2;
							var bPosX   = width  / 8;

							var br = new Rectangle(bPosX, -bHeight / 2, bWidth, bHeight);

							g.FillRectangle(new SolidBrush(CANNON_COLORS[c.Player]), br);
						}
						g.Restore(save);

						g.FillRectangle(new SolidBrush(Color.FromArgb(64, CANNON_COLORS[c.Player])), rectReal);
						g.FillEllipse(new SolidBrush(CANNON_COLORS[c.Player]), rectCircle);
						g.DrawEllipse(new Pen(Color.Black), rectCircle);
						g.DrawEllipse(new Pen(CANNON_COLORS[c.Player], 2), rectOuter);

					}
				}
			}

			canvas?.BeginInvoke(new Action(() => canvas.Invalidate()));
		}
Example #5
0
		private void RecreateMap(LevelFile lp)
		{
			var rex = new Regex(@"^#<map>.*^#</map>", RegexOptions.Multiline | RegexOptions.Singleline);
			
			var newCode = rex.Replace(edCode.Text, lp.GenerateASCIIMap());

			if (newCode != edCode.Text)
			{
				int tc = timerCountDown;
				int selS = edCode.SelectionStart;
				int selL = edCode.SelectionLength;

				edCode.Text = newCode;

				try
				{
					timerCountDown = tc;
					edCode.SelectionStart = selS;
					edCode.SelectionLength = selL;
				}
				catch (Exception) { /* wayne */ }

				Console.WriteLine("Regenerate map");
			}
		}
Example #6
0
		private LevelFile ParseLevelFile()
		{
			Func<string, string> includesFunc = x => null;
			if (File.Exists(edPath.Text))
			{
				var path = Path.GetDirectoryName(edPath.Text) ?? "";
				var pattern = "*" + Path.GetExtension(edPath.Text);

				var includes = Directory.EnumerateFiles(path, pattern).ToDictionary(p => Path.GetFileName(p) ?? p, p => File.ReadAllText(p, Encoding.UTF8));

				includesFunc = x => includes.FirstOrDefault(p => LevelFile.IsIncludeMatch(p.Key, x)).Value;
			}

			var lp = new LevelFile(edCode.Text, includesFunc);
			lp.Parse();

			return lp;
		}