private void OnBuildingAdded(object sender, BuildingEventArgs e) { if (this.BuildingAdded != null) { this.BuildingAdded.Invoke(sender, e); } }
private void OnBuildingDeleted(object sender, BuildingEventArgs e) { this.Deselect(); if (this.BuildingDeleted != null) { this.BuildingDeleted.Invoke(sender, e); } }
/// <summary> /// Épület megváltozásának eseménykezelése. /// </summary> private void Model_BuildingChanged(object sender, BuildingEventArgs e) { Int32 index = Buildings.IndexOf(Buildings.FirstOrDefault(building => building.Id == e.BuildingId)); Buildings.RemoveAt(index); // módosítjuk a kollekciót Buildings.Insert(index, _model.Buildings[index]); SelectedBuilding = Buildings[index]; // és az aktuális épületet }
private void OnBuildingDaily(object sender, BuildingEventArgs e) { if (CityManager.ResourceToShow != null) { ColorMaterialWithResource(plotMaterial, this.data.Resources, CityManager.ResourceToShow.GetValueOrDefault()); } else if (CityManager.ResourceToShow == null && this.data.Zone != Zones.Unzoned) { OnZoneChanged(this.data, new EventArgs()); } }
// Keeps track of buildings reclaimed, both to note how many apartments and to decide // the game difficulty (game gets harder the more buildings you have.) void OnBuildingReclaimed(object sender, BuildingEventArgs args) { buildingsReclaimed += 1; Building sentBuilding = args.buildingPayload; switch (sentBuilding.typeName) { case BuildingType.Apartment: this.maxColonists += 2; if (this.currentColonists < this.maxColonists) { canAddColonist = true; } break; } this.UpdateDisplay(); }
public async Task <string> Exec( BuildingEventArgs args, TokenCountDictionary tokens, GameState gameState ) { if (!tokens.HasInvaders()) { return("No invaders"); } BuildingEventArgs.BuildType buildType = args.GetBuildType(tokens.Space); this.tokens = tokens; this.buildType = buildType; this.gameState = gameState; if (await StopBuildWithDiseaseBehavior()) { return(tokens.Space.Label + " build stopped by disease"); } // Determine type to build int townCount = tokens.Sum(Invader.Town); int cityCount = tokens.Sum(Invader.City); HealthTokenClass invaderToAdd = townCount > cityCount ? Invader.City : Invader.Town; // check if we should bool shouldBuild = buildType switch { BuildingEventArgs.BuildType.CitiesOnly => invaderToAdd == Invader.City, BuildingEventArgs.BuildType.TownsOnly => invaderToAdd == Invader.Town, _ => true, }; // build it if (shouldBuild) { await tokens.AddDefault(invaderToAdd, 1, AddReason.Build); } return(invaderToAdd.Label); }
private void MainViewModel_ImageEditingStarted(object sender, BuildingEventArgs e) { try { // egy dialógusablakban bekérjük a fájlnevet OpenFileDialog dialog = new OpenFileDialog(); dialog.CheckFileExists = true; dialog.Filter = "Képfájlok|*.jpg;*.jpeg;*.bmp;*.tif;*.gif;*.png;"; dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); Boolean?result = dialog.ShowDialog(); if (result == true) { // kép létrehozása (a megfelelő méretekkel) _model.CreateImage(e.BuildingId, ImageHandler.OpenAndResize(dialog.FileName, 100), ImageHandler.OpenAndResize(dialog.FileName, 600)); } } catch { } }
// If a task is cancelled on a building, this function finds any tasks it might // have associated with that building and deletes them so they shouldn't resolve. // Again, there shouldn't be two tasks on a building, but for giggles this could // potentially remove multiple tasks for a building if they exist. void OnTaskCancelled(object sender, BuildingEventArgs args) { Building buildingToRemoveTaskFrom = args.buildingPayload; int counter = 0; int target = taskHolder.Count; List <Task> dummyTaskHolder = new List <Task>(); while (counter < target) { if (taskHolder[counter].building == buildingToRemoveTaskFrom) { dummyTaskHolder.Add(taskHolder[counter]); } counter += 1; } foreach (Task badTask in dummyTaskHolder) { badTask.active = false; taskHolder.Remove(badTask); GameEvents.InvokeTaskCompleted(badTask); } }
//This function sets up the UI after the player clicks on a building. void OnBuildingClicked(object sender, BuildingEventArgs args) { building = args.buildingPayload; OpenBuildingUI(); WipeText(); typeText.text = building.typeName.ToString(); if (!building.inTask) { if (building.reclaimed) { SetUpReclaimedUI(); } else { SetUpWildUI(); } } else { SetUpAlreadyTaskedUI(); } }
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); }; }
// Don't click a building and then advance the day, that's weird. void OnBuildingClicked(object sender, BuildingEventArgs args) { advanceDayButton.interactable = false; }
//This function is called by the buildingClicked event and it just stops //the mouse from clicking on buildings more. private void OnBuildingClicked(object sender, BuildingEventArgs args) { inMenu = true; }
//This is called when the reclaimed building event happens. private void OnBuildingReclaimed(object sender, BuildingEventArgs args) { setBuildingReclaimed(args.buildingPayload); }