コード例 #1
0
		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);
		}
コード例 #2
0
		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));
		}
コード例 #3
0
		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);
		}
コード例 #4
0
		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);
		}
コード例 #5
0
		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));
		}
コード例 #6
0
		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);
		}
コード例 #7
0
		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 ();
			});
		}
コード例 #8
0
		public void DestroyBlight (BlightViewModel selectedBlight)
		{
			RemoveBlightViewModel (selectedBlight);

			Task.Run (() => {				
				_parent.BlightService.DestroyBlight (Location, selectedBlight.Blight, Application.CurrentGame);
				Application.SaveCurrentGame ();
			});
		}