/// <summary> /// Set the Zoning regulation for a given area defined by the points p1 and p2 at the corners of the area. /// </summary> /// <param name="p1">One corner of the area</param> /// <param name="p2">The corner opposite p2</param> /// <param name="z">The type of zone to set</param> public static bool SetZoning(Point p1, Point p2, Haswell.Zones z) { if (Initialized) { Point tl = new Point(System.Math.Min(p1.X, p2.X), System.Math.Min(p1.Y, p2.Y)); Point br = new Point(System.Math.Max(p1.X, p2.X), System.Math.Max(p1.Y, p2.Y)); Haswell.Controller.City.SetZoning(new System.Drawing.Point(tl.X, tl.Y), new System.Drawing.Point(br.X, br.Y), z); for (int x = tl.X; x <= br.X; ++x) { for (int y = tl.Y; y <= br.Y; ++y) { if (!CityManager.Plots.ContainsKey(Haswell.Controller.City.Grid.ElementAt(x, y))) { RenderablePlot rp = new RenderablePlot(Haswell.Controller.City.Grid.ElementAt(x, y)); rp.Create(SceneMgr, cityNode); CityManager.Plots[Haswell.Controller.City.Grid.ElementAt(x, y)] = rp; } } } return(true); } else { GameConsole.ActiveInstance.WriteError("Unable to set zoning, no city initialized!"); } return(false); }
public static void OnLoad() { foreach (RenderableBuilding b in Buildings.Values) { b.Dispose(); } Buildings.Clear(); foreach (RenderablePlot p in Plots.Values) { p.Dispose(); } Plots.Clear(); foreach (Plot p in Haswell.Controller.City.Grid) { if (p.Building != null) { if (p.Building is Road) { Buildings[p.Building] = new RenderableRoad((Road)p.Building); } else { Buildings[p.Building] = new RenderableBuilding(p.Building); } } Plots[p] = new RenderablePlot(p); Plots[p].Create(SceneMgr, cityNode); } GameConsole.ActiveInstance.WriteLine("Game Loaded."); GuiMgr.AddInfoPopup("Game Loaded."); }
private static void CreateBuilding(object sender, BuildingEventArgs e) { GameConsole.ActiveInstance.WriteLine("Added a building at " + e.Building.Parent.X + ", " + e.Building.Parent.Y); RenderableBuilding rb; if (e.Building is Road) { rb = new RenderableRoad((Road)e.Building); } else { rb = new RenderableBuilding(e.Building); } if (!Buildings.ContainsKey(e.Building)) { Buildings.Add(e.Building, rb); } RenderablePlot rp; if (Plots.ContainsKey(e.Building.Parent)) { rp = Plots[e.Building.Parent]; rb.Create(SceneMgr, cityNode); } else { rp = new RenderablePlot(e.Building.Parent); rp.Create(SceneMgr, cityNode); Plots.Add(e.Building.Parent, rp); } rb.Deleted += (object sender2, EventArgs e2) => { Buildings.Remove(e.Building); }; }