private void ProceedConstruction(Point pos) { var result = from target in this.listOfBuildings where (target.Position == pos && target.state != BuildingState.Ready) select target; if (result.Count() > 0) { BuildingBase b = result.ElementAt(0); if (!this.mayorObject.GetFreeUnits(b.GetWorkersNeeded(), PrivilegesCosts.PrivilegedWorker)) { this.mayorObject.ShowMessageBox(); this.isAboutToProceed = false; return; } this.mayorObject.SendBuilders(b.GetWorkersNeeded()); b.ConstructionPaused = false; } else { MessageBox msgBox = null; MessageBox.Show(this.Game, "Building is ready", "Mayor said: ", MessageBoxButton.OK, this.mayorObject.FaceTex, out msgBox); } this.isAboutToProceed = false; }
private void ConstructBuilding(Type type, params Int16[] list) { Int16 lastX = Convert.ToInt16(list[0] + list[3] - 1); Int16 lastZ = Convert.ToInt16(list[1] + list[2] - 1); if (this.gameField.CheckCoordinates(list[0], list[1], this.buildingTypeToBuild, lastX, lastZ, out this.currentBuildingVertices)) { ConstructorInfo ctor = type.GetConstructors().First(); BuildingBase obj = ctor.Invoke(new Object[] { this.Game }) as BuildingBase; MethodInfo methodLoadTexture = type.GetMethod("LoadTextures"); methodLoadTexture.Invoke(obj, null); MethodInfo methodSetVertices = type.GetMethod("SetVertices"); methodSetVertices.Invoke(obj, new Object[] { this.currentBuildingVertices }); PropertyInfo propertyPoint = type.GetProperty("Position"); propertyPoint.SetValue(obj, new Point(list[0], list[1]), null); MethodInfo methodSetStartConstruction = type.GetMethod("SetStartConstruction"); methodSetStartConstruction.Invoke(obj, new Object[] { true }); MethodInfo methodSetResourcesHUDObject = type.GetMethod("SetResourcesHUDObject"); methodSetResourcesHUDObject.Invoke(obj, new Object[] { this.resourcesHUD }); this.listOfBuildings.Add(obj); this.IncreaseNumberOfConstructions(this.buildingTypeToBuild); this.mayorObject.SendBuilders(this.neededWorkers); this.neededWorkers = 0; obj.OnBuildingConstructed += new BuildingBase.BuildingConstructed(obj_OnBuildingConstructed); } }
private void obj_OnBuildingConstructed(Object o, CellState type) { BuildingBase buildingBase = (o as BuildingBase); this.listOfTypes[type].FreeWorkersInvocation(); if (type == CellState.CityHall) { this.mayorObject.LegalizeAuthority(); } buildingBase.OnBuildingConstructed -= new BuildingBase.BuildingConstructed(obj_OnBuildingConstructed); }
private void PauseConstruction(Point pos) { var result = from target in this.listOfBuildings where (target.Position == pos && target.state != BuildingState.Ready) select target; if (result.Count() > 0) { BuildingBase b = result.ElementAt(0); b.ConstructionPaused = true; this.mayorObject.ReleaseBuilders(b.GetWorkersNeeded()); } else { MessageBox msgBox = null; MessageBox.Show(this.Game, "The construction process cannot be\n interrupted", "Mayor said: ", MessageBoxButton.OK, this.mayorObject.FaceTex, out msgBox); } this.isAboutToPauseConstruction = false; }
public virtual void SetParent(BuildingBase parent) { this.parent = parent; }