コード例 #1
0
ファイル: GOSelectMgr.cs プロジェクト: ray2006/WCell
		/// <summary>
		/// Tries to select the nearest GO that is in front of the character
		/// </summary>
		/// <returns>The newly selected GO.</returns>
		public GameObject SelectClosest(Character chr)
		{
			var gos = chr.GetObjectsInRadius(MaxSearchRadius, ObjectTypes.GameObject, true, 0);

			var sqDist = float.MaxValue;
			GameObject sel = null;
			foreach (GameObject go in gos)
			{
				// TODO: Go by angle instead of distance
				//var angle = chr.GetAngleTowards(go);
				if (sel == null ||
					(go.IsInFrontOf(chr) && chr.GetDistanceSq(go) < sqDist))
				{
					sel = go;
				}
			}

			this[chr] = sel;

			return sel;
		}