/// <summary> /// Called by Snowflake when the user requests the creation of a road /// </summary> /// <param name="x">The plot X of the road</param> /// <param name="y">The plot Y of the road</param> public void CreateRoad(int x, int y) { Road r = new Road(); grid.ElementAt(x, y).Zone = r.Zone; if (grid.ElementAt(x, y).Building != null) { return; } if (grid.ElementAt(x, y).AddBuilding(r)) { BuildingCreated.Invoke(this, new BuildingEventArgs(r)); return; } }
/// <summary> /// Called by Snowflake when the user requests the creation of a building /// Throws an error if something goes wrong. /// </summary> /// <typeparam name="T">The Type of Building to create</typeparam> /// <param name="x">The plot X of the building</param> /// <param name="y">The plot Y of the building</param> private void CreateBuilding(int x, int y, Building b) { if (grid.ElementAt(x, y).AddBuilding(b)) { //Zone check already happens in AddBuilding if (BuildingCreated != null) { BuildingCreated.Invoke(this, new BuildingEventArgs(b)); } return; } if (grid.ElementAt(x, y).Building != null) { throw new Exceptions.BuildingCreationFailedException("Unable to place building - there's already something there!"); } else if (grid.ElementAt(x, y).Zone != b.Zone) { throw new Exceptions.BuildingCreationFailedException("Cannot create this type of building in " + grid.ElementAt(x, y).Zone.ToString() + " plot!"); } else { throw new Exceptions.BuildingCreationFailedException("Building creation failed"); } }