Beispiel #1
0
    public void CreatePathNode()
    {
        if (curr_parent != null)
        {
            GameObject child = new GameObject();

            GameObject last_node = GetCurrPathLastNode();

            if (last_node != null)
            {
                child.transform.position = last_node.transform.position;
            }

            child.transform.parent = curr_parent.transform;

            child.name = "Node: " + curr_parent.transform.childCount;

            PathInstance instance = curr_parent.GetComponent <PathInstance>();

            if (instance != null)
            {
                instance.CreatePath();
            }
        }
    }
Beispiel #2
0
 public static int Comparison(PathInstance a, PathInstance b)
 {
     if (a.lastUsed < b.lastUsed) {
         return -1;
     } else if (a.lastUsed > b.lastUsed) {
         return 1;
     } else {
         return 0;
     }
 }
Beispiel #3
0
 private void CachePath(int[] start, int[] end, Vector3[] path)
 {
     Debug.Log ("---------------------- Cache miss -----------------------");
     PathInstance pi = new PathInstance ();
     pi.lastUsed = Time.time;
     Debug.Log ("caching start " + start[0] + "," + start[1] + " end " + end[0] + "," + end[1]);
     pi.start[0] = start[0];
     pi.start[1] = start[1];
     pi.end[0] = end[0];
     pi.end[1] = end[1];
     pi.path = path;
     cache.Add (pi);
     if (cache.Count > cacheLength) {
         cache.Remove (cache.Top);
     }
 }