コード例 #1
0
ファイル: GameMainViewModel.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Refreshs the map.
		/// </summary>
		/// <param name="e">Event arguments.</param>
		private void RefreshMap(DisplayChangedEventArgs e = null)
		{
			if (e == null)
			{
				// Refresh the whole map
			}

			// Task are not interessting
			if (e.UIObject is Task)
			{
				return;
			}

			if (e.What == null || (e.What == "Property" && e.PropertyName == "Points"))
			{
				var polygons = new List<WF.Player.Controls.ExtendedMap.MapPolygon>();

				foreach (var z in App.Game.ActiveVisibleZones)
				{
					polygons.Add(new WF.Player.Controls.ExtendedMap.MapPolygon(z.Points, new WF.Player.Controls.ExtendedMap.MapPoint(z.ObjectLocation, z.Name)));
				}

				MapViewModel.Map.Polygons = polygons;
			}

			// We are only interessted in the following changes
			// Visible
			// Active
			// Name
			// Points
			// ObjectLocation
			if (e.What != "Visible" && e.What != "Active" && e.What != "Name" && e.What != "Points" && e.What != "ObjectLocation")
			{
				return;
			}
		}
コード例 #2
0
ファイル: GameMainViewModel.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Handles the display changed.
		/// </summary>
		/// <param name="sender">Sender of event.</param>
		/// <param name="e">Display changed event arguments.</param>
		private void OnDisplayChanged(object sender = null, DisplayChangedEventArgs e = null)
		{
			if (e == null)
			{
				e = new DisplayChangedEventArgs();
			}

			// If GameState change, update the main screen
			if (e.What == "GameState" && gameModel.GameState == WF.Player.Core.Engines.EngineGameState.Playing)
			{
				Refresh();

				return;
			}

			if (IsMapSelected)
			{
				RefreshMap(e);

				return;
			}

			// Check, if there is something we should update 
			if (e.What == "Property")
			{
				if (e.PropertyName == "Points")
				{
					var entry = GameMainList.FirstOrDefault(obj => obj.UIObject == e.UIObject);

					if (entry != null)
					{
						entry.VectorToObject = null;

						RefreshDirections(false);
					}
				}

				var ret = false;

				ret = ret || (e.PropertyName == "State" && (IsYouSeeSelected || IsOverviewSelected));
				ret = ret || (e.PropertyName == "Active" && (IsYouSeeSelected || IsOverviewSelected));
				ret = ret || (e.PropertyName == "ActiveVisibleZones" && (IsYouSeeSelected || IsOverviewSelected));
				ret = ret || (e.PropertyName == "VisibleObjects" && (IsYouSeeSelected || IsOverviewSelected));
				ret = ret || (e.PropertyName == "VisibleInventory" && (IsInventorySelected || IsOverviewSelected));
				ret = ret || (e.PropertyName == "ActiveVisibleTasks" && (IsTasksSelected || IsOverviewSelected));
				ret = ret || (e.PropertyName == "Name" && IsOverviewSelected);

				if (!ret)
				{
					return;
				}
			}

			if (this.gameModel == null || this.gameModel.GameState != WF.Player.Core.Engines.EngineGameState.Playing)
			{
				return;
			}

			RefreshButtons();

			if (activeScreen != ScreenType.Main && activeScreen != ScreenType.Map)
			{
				RefreshListContent();
			}

			if (activeScreen == ScreenType.Main)
			{
				RefreshMainScreen();
			}

			if (!IsOverviewVisible)
			{
				RefreshDirections(true);
			}
		}