/// <summary> /// Initializes a new instance of the AStar class. /// </summary> /// <param name="openSetCapacity">The max capacity of the open set.</param> /// <param name="findDistance">A delegate to find the g distance.</param> /// <param name="heuristic">A delegate to calculate the heuristic value.</param> public AStar(int openSetCapacity, FindDistance findDistance, Heuristic heuristic) { this.closed = new List<Node>(); this.open = new BlueRajaWrapper<Node>(openSetCapacity); this.findDistance = findDistance; this.heuristic = heuristic; }
/// <summary> /// Initializes a new instance of the AStar class. /// </summary> /// <param name="openSetCapacity">The max capacity of the open set.</param> /// <param name="findDistance">A delegate to find the g distance.</param> /// <param name="heuristic">A delegate to calculate the heuristic value.</param> public AStar(int openSetCapacity, FindDistance findDistance, Heuristic heuristic) { this.closed = new List <Node>(); this.open = new BlueRajaWrapper <Node>(openSetCapacity); this.findDistance = findDistance; this.heuristic = heuristic; }
public void FindWithArray2Test() { int result100 = new FindDistance().FindWithArray2(testData(100)); int result10000 = new FindDistance().FindWithArray2(testData(10000)); Assert.Equal(91, result100); Assert.Equal(9992, result10000); }
public void FindWithDictClassAndLinqTest() { int result100 = new FindDistance().FindWithDictClassAndLinq(testData(100)); int result10000 = new FindDistance().FindWithDictClassAndLinq(testData(10000)); Assert.Equal(91, result100); Assert.Equal(9992, result10000); }
public void BaseDividedTest() { int result100 = new FindDistance().BaseDividedFind(testData(100)); int result10000 = new FindDistance().BaseDividedFind(testData(10000)); Assert.Equal(91, result100); Assert.Equal(9992, result10000); }
public void SearchFirstAndLastIndex3Test() { int result100 = new FindDistance().SearchFirstAndLastIndex3(testData(100)); int result10000 = new FindDistance().SearchFirstAndLastIndex3(testData(10000)); Assert.Equal(91, result100); Assert.Equal(9992, result10000); }
/// <summary> /// Initializes a new instance of the Dijkstra class. /// </summary> /// <param name="openSetCapacity">The max capacity of the open set.</param> /// <param name="findDistance">A delegate to find the g distance.</param> public Dijkstra(int openSetCapacity, FindDistance findDistance) { this.pathfinder = new AStar(openSetCapacity, findDistance, (from, to) => 0); }
public void OnInputClicked(InputClickedEventData eventData) { string buttonName = selection.ToString(); GameObject gameObj = GameObject.FindGameObjectWithTag(buttonName); GameObject parentObj; switch (type) { case Type.Lock: parentObj = GameObject.FindGameObjectWithTag(buttonName).transform.parent.gameObject; Text buttonText = gameObject.GetComponentInChildren <Text> (); Debug.Log("4"); if (buttonText.text == "Lock Position") { Debug.Log("5"); buttonText.text = "Unlock Position"; Debug.Log("6"); parentObj.GetComponent <HandDraggable> ().enabled = false; Debug.Log("7"); } else { Debug.Log("8"); buttonText.text = "Lock"; Debug.Log("9"); parentObj.GetComponent <HandDraggable> ().enabled = true; } break; case Type.Hide: if (gameObj == null) { hiddenObjects.Find(item => item.name == buttonName).SetActive(true); hiddenObjects.Remove(gameObj); } else { hiddenObjects.Add(gameObj); gameObj.SetActive(false); } break; case Type.SetFrame: parentObj = GameObject.FindGameObjectWithTag(buttonName).transform.parent.gameObject; FindDistance track = new FindDistance(); float distance = track.getDistanceBetween(Camera.main, parentObj); //heading = parentObj.transform.position - Camera.main.transform.position; //distance = Vector3.Dot (heading, Camera.main.transform.forward); Camera.main.nearClipPlane = distance; Debug.Log("Distance: " + distance); Debug.Log("Near Clip Plane: " + Camera.main.nearClipPlane); break; case Type.ZoomIn: parentObj = GameObject.FindGameObjectWithTag(buttonName).transform.parent.gameObject; heading = parentObj.transform.position - Camera.main.transform.position; distance = Vector3.Dot(heading, Camera.main.transform.forward); Camera.main.nearClipPlane += 0.02f; Debug.Log("Distance: " + distance); Debug.Log("Near Clip Plane: " + Camera.main.nearClipPlane); break; case Type.ZoomOut: parentObj = GameObject.FindGameObjectWithTag(buttonName).transform.parent.gameObject; heading = parentObj.transform.position - Camera.main.transform.position; distance = Vector3.Dot(heading, Camera.main.transform.forward); Camera.main.nearClipPlane -= 0.02f; Debug.Log("Distance: " + distance); Debug.Log("Near Clip Plane: " + Camera.main.nearClipPlane); break; default: /* Optional */ break; } }