public void DestroyBlight(BlightViewModel sender){ var locationModel = Locations.First(x => x.Spawns.Contains(sender)); _blightService.DestroyBlight (locationModel.Location, sender.Blight, Application.CurrentGame); Application.SaveCurrentGame (); locationModel.RemoveBlightViewModel (sender); }
public void RemoveBlightViewModel(BlightViewModel viewModel){ if (!Blights.Contains (viewModel)) return; Blights.Remove (viewModel); if (Blights.Where (x => !x.IsPlaceHolder).Sum (x => x.Blight.Weight) < 4 && !Blights.Last().IsPlaceHolder) Blights.Add (new BlightViewModel (null)); }
public void AddBlightViewModel(BlightViewModel viewModel){ if (Blights.Any() && Blights.Last().IsPlaceHolder) Blights.Insert (Blights.Count - 1, viewModel); else Blights.Add(viewModel); if (Blights.Where (x => !x.IsPlaceHolder).Sum (x => x.Blight.Weight) >= 4 && Blights.Last().IsPlaceHolder) Blights.RemoveAt (Blights.Count - 1); }
public void MoveBlight(BlightViewModel sender, MoveBlightArgs args) { var currentLocationSection = Locations.First(x => x.Spawns.Contains(sender)); var newLocationSection = Locations.Single(l => l.Location.Name == args.NewLocationName); if (currentLocationSection == newLocationSection) return; //remove from gamestate currentLocationSection.Location.Blights.Remove(args.BlightViewModel.Blight); newLocationSection.Location.Blights.Add(args.BlightViewModel.Blight); Application.SaveCurrentGame(); //update view currentLocationSection.RemoveBlightViewModel(args.BlightViewModel); newLocationSection.AddBlightViewModel(args.BlightViewModel); }
public void RemoveBlightViewModel(BlightViewModel viewModel) { if (!Spawns.Contains(viewModel)) return; Spawns.Remove(viewModel); var blights = Spawns.Where(x => x is BlightViewModel).Select(x => x as BlightViewModel).ToList(); if (Location.Blights.Sum(x => x.Weight) < 4 && !blights.Last().IsPlaceHolder) Spawns.Add(new BlightViewModel(null)); }
public void AddBlightViewModel(BlightViewModel viewModel) { var blights = Spawns.Where(x => x is BlightViewModel).Select(x => x as BlightViewModel).ToList(); if (blights.Any() && blights.Last().IsPlaceHolder) Spawns.Insert(Spawns.Count - 1, viewModel); else Spawns.Add(viewModel); if (Location.Blights.Sum(x => x.Weight) >= 4 && blights.Last().IsPlaceHolder) Spawns.RemoveAt(Spawns.Count - 1); }
public void MoveBlight (BlightViewModel blightToMove, string newLocation) { if (Location.Name == newLocation) return; RemoveBlightViewModel (blightToMove); var newLocationSection = _parent.Rows.Single (l => l is LocationXViewModel && (l as LocationXViewModel).Location.Name == newLocation) as LocationViewModel; newLocationSection.AddBlightViewModel (blightToMove); Task.Run (() => { Location.Blights.Remove (blightToMove.Blight); newLocationSection.Location.Blights.Add (blightToMove.Blight); Application.SaveCurrentGame (); }); }
public void DestroyBlight (BlightViewModel selectedBlight) { RemoveBlightViewModel (selectedBlight); Task.Run (() => { _parent.BlightService.DestroyBlight (Location, selectedBlight.Blight, Application.CurrentGame); Application.SaveCurrentGame (); }); }