public Node(PathFind_AStar finder, Node parent, Position position, int path_cost) { this.finder = finder; this.position = position; this.expect_cost += Mathf.Abs(finder.destination.x - position.x); this.expect_cost += Mathf.Abs(finder.destination.y - position.y); this.path_cost = path_cost; this.parent = parent; }
public virtual void Move() { float chaseWeight = (float)speed / Player.Instance.speed; if (UnityEngine.Random.Range(1, 100) < chaseWeight * 100) { PathFind_AStar path = new PathFind_AStar (); Position next = path.FindNextPath (position, Player.Instance.position); if (null != next) { Move (next); } } state = State.Chase; }