public Image DrawMap() { Bitmap bm; Image files = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\justgreen.png")); Bitmap bitmap; Bitmap finalImage = new Bitmap(1300, 805); Image TreeFiles = (Image)Trees; foreach (MapPoint obj in this.mapTab) { if (obj != null && (obj is MapMainPoint)) { MapMainPoint tmp = (MapMainPoint)obj; files = new Bitmap(tmp.Bitmap, tmp.Width, tmp.Height); using (Graphics g = Graphics.FromImage(finalImage)) { g.DrawImage(files, new Point(tmp.X, tmp.Y)); } if (tmp is MapMainPoint.Tree) { using (Graphics g = Graphics.FromImage(TreeFiles)) { g.DrawImage(files, new Point(tmp.X, tmp.Y)); } } } } Trees = (Bitmap)TreeFiles; return(finalImage); }
public void MakeObjectRightHere(int x, int y, string name, Map map, bool n) { int Width = 0, Height = 0; Bitmap bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\justgreen.png")); //Console.Writeline() if (name[0] == 't') { if (name == "t1") { Width = 64; Height = 95; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\tree1.png")); } else if (name == "t2") { Width = 112; Height = 96; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\tree2.png")); } else if (name == "t3") { Width = 69; Height = 111; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\tree3.png")); } else if (name == "t4") { Width = 117; Height = 111; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\tree4.png")); } } else if (name[0] == 'g') { if (name == "g1") { Width = 11; Height = 8; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass1.png")); } else if (name == "g2") { Width = 10; Height = 8; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass2.png")); } else if (name == "g3") { Width = 16; Height = 14; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass3.png")); } else if (name == "g4") { Width = 13; Height = 12; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass4.png")); } else if (name == "g5") { Width = 10; Height = 13; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass5.png")); } else if (name == "g6") { Width = 12; Height = 11; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass6.png")); } else if (name == "g7") { Width = 13; Height = 15; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass7.png")); } else if (name == "g8") { Width = 15; Height = 13; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass8.png")); } else if (name == "g9") { Width = 25; Height = 21; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\grass9.png")); } } else if (name[0] == 's') { if (name == "s1") { Width = 28; Height = 16; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\stone1.png")); } else if (name == "s2") { Width = 24; Height = 16; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\stone2.png")); } else if (name == "s3") { Width = 46; Height = 39; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\stone3.png")); } } else if (name[0] == 'p') { if (name == "p1") { Width = 64; Height = 43; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\stump1.png")); } else if (name == "p2") { Width = 69; Height = 43; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\stump2.png")); } else if (name == "p3") { Width = 112; Height = 44; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\stump3.png")); } else if (name == "p4") { Width = 117; Height = 43; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\stump4.png")); } else if (name == "ps1") { Width = 54; Height = 41; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\plowedSoilUnwatered.png")); } } else if (name[0] == 'm') { if (name == "me1") { Width = 10; Height = 8; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\Mushroom1.png")); } else if (name == "me2") { Width = 13; Height = 13; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\Mushroom2.png")); } else if (name == "me3") { Width = 15; Height = 14; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\Mushroom3.png")); } else if (name == "mn1") { Width = 10; Height = 8; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\Mushroom4.png")); } else if (name == "mn2") { Width = 13; Height = 13; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\Mushroom5.png")); } } else if (name[0] == 'b') { if (name == "bh1") { Width = 94; Height = 87; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\house1.png")); } } else if (name[0] == 'w') { if (name == "w1") { Width = 62; Height = 62; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\pond1.png")); } else if (name == "w2") { Width = 62; Height = 52; bm = new Bitmap(System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName, "WindowsFormsApp2\\Resources\\pond2.png")); } } bool isFree = true; if (n) { for (int i = y; i <= y + Height; i++) { for (int j = x; j <= x + Width; j++) { if (i != y || j != x) { if (map.mapTab[j, i] != null) { isFree = false; break; } } } } } else { for (int i = y; i <= y + Height; i++) { for (int j = x; j <= x + Width; j++) { if (i != y || j != x) { if (map.mapTab[j, i] != null) { MapMainPoint tmp = (MapMainPoint)map.mapTab[map.mapTab[j, i].X, map.mapTab[j, i].Y]; if (tmp.Name[0] != 'g' && tmp.Name[0] != 'm') { isFree = false; break; } } } } } } if (isFree) { if (name[0] == 't') { map.mapTab[x, y] = new MapMainPoint.Tree(x, y, name, Width, Height, bm, map); } else if (name[0] == 'g') { map.mapTab[x, y] = new MapMainPoint.Grass(x, y, name, Width, Height, bm, map); } else if (name[0] == 's') { map.mapTab[x, y] = new MapMainPoint.Stone(x, y, name, Width, Height, bm, map); } else if (name[0] == 'p') { if (name[1] == 's') { map.mapTab[x, y] = new MapMainPoint.PlowedSoil(x, y, name, Width, Height, bm, map); } else { map.mapTab[x, y] = new MapMainPoint.Stump(x, y, name, Width, Height, bm, map); } } else if (name[0] == 'm') { map.mapTab[x, y] = new MapMainPoint.Mushroom(x, y, name, Width, Height, bm, map); } else if (name[0] == 'b') { map.mapTab[x, y] = new MapMainPoint.Building(x, y, name, Width, Height, bm, map); } else if (name[0] == 'w') { map.mapTab[x, y] = new MapMainPoint.Pond(x, y, name, Width, Height, bm, map); } } else { map.mapTab[x, y] = null; } }