bool LoadMap(string fileName) { if (!File.Exists(fileName)) { MessageBox.Show("File not found or access denied\n" + fileName, "File access error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } StreamReader f = new StreamReader(fileName); string l = f.ReadLine(); uint count, i; ClientSize = new Size(int.Parse(l.Split()[0]), int.Parse(l.Split()[1])); m = new ContentManager(this, Color.FromArgb(25, 75, 90), true); while ((l = f.ReadLine()) != null) { switch (l) { case "lands": count = uint.Parse(f.ReadLine()); lands = new Land[count]; for (i = 0; i < count; i++) { lands[i] = new Land(m, ReadPoints(f)); } break; case "shoal": shoal = new Shoal(m, ReadPoints(f)); break; default: MessageBox.Show("Error parsing file\n" + fileName, "Parse error", MessageBoxButtons.OK, MessageBoxIcon.Error); f.Close(); return(false); } } f.Close(); return(true); }
public void AddObstacle(Shoal s, Land[] l) { obstacle = new Obstacle[l.Length + 1]; Array.Copy(l, obstacle, l.Length); obstacle[l.Length] = s; }