Inheritance: MonoBehaviour
    public static HeuristicD heuristic; // Heuristic object containing the dijkstra movement costs

    #endregion Fields

    #region Constructors

    // claim a node at any given time)
    // <summary>
    // Constructor that initializes the data structures necessary for the path planning approach
    // </summary>
    static PathPlanningDataStructures()
    {
        graph = new GenerateGraph();
        heuristic = new HeuristicD(graph);
        globalLock = new object();
        Debug.Log ("Heuristic Finished");
    }
Ejemplo n.º 2
0
    public HeuristicD(GenerateGraph graph)
    {
        heuristicCost = new Dictionary <Node, float>();
        //itemList = new List<GameObject> ();
        //GameObject item = GameObject.Find ("Item1");
        //itemList.Add (item);

        PriorityQueue <Node>     pq          = new PriorityQueue <Node>(graph.Size());
        Dictionary <Node, float> cost_so_far = new Dictionary <Node, float> ();

        pq.queue(0.0f, graph.endNode);
        cost_so_far.Add(graph.endNode, 0.0f);
        while (pq.getSize() > 0)
        {
            Node current = pq.dequeue();
            heuristicCost[current] = cost_so_far[current];
            for (int i = 0; i < current.neighbors.Count; i++)
            {
                float new_cost = cost_so_far[current] + Node.distanceBetweenNodes(current, current.neighbors[i]);
                if (!cost_so_far.ContainsKey(current.neighbors[i]) || new_cost < cost_so_far[current.neighbors[i]])
                {
                    cost_so_far[current.neighbors[i]] = new_cost;
                    pq.queue(new_cost, current.neighbors[i]);
                }
            }
        }
    }
Ejemplo n.º 3
0
    void Start()
    {
        graphGenerator = sceneGod.GetComponent <GenerateGraph>();


        RMMenuItem[] items = new RMMenuItem[3];
        items[0]         = item1.GetComponent <RMMenuItem>();
        items[0].onClick = clicked2D3D;
        items[1]         = item2.GetComponent <RMMenuItem>();
        items[1].onClick = setNodeDegree;
        items[2]         = item3.GetComponent <RMMenuItem>();
        items[2].onClick = onClick;

        menu = menuBox.GetComponent <RMMenu>();
        menu.SetMenuItems(items);


        /*
         *      items[0] = item1;
         *      items[1] = item2;
         *      items[2] = item3;
         *
         *      /*
         *      foreach (string item in items)
         *      {
         *          GameObject menuItem = Instantiate(Resources.Load("MenuItem") as GameObject, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject;
         *          menuBox.gameObject.transform.parent = menuItem.transform;
         *      }
         */
    }
Ejemplo n.º 4
0
    void Start()
    {
        GameObject prefabLineToRender = Resources.Load("Line") as GameObject;
        GameObject lineToRender       = Instantiate(prefabLineToRender, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;

        myLineRenderer         = lineToRender.GetComponent <LineRenderer> ();
        myLineRenderer.enabled = false;

        graphGenerator = sceneGod.GetComponent <GenerateGraph> ();

        //rightPinchDetectorScript = rightPinchDetector.GetComponent<LeapPinchDetector> ();
        //leftPinchDetectorScript = leftPinchDetector.GetComponent<LeapPinchDetector> ();

        //rightCapsuleHandScript = rightCapsuleHandObject.GetComponent<CapsuleHand>();
        //leftCapsuleHandScript = leftCapsuleHandObject.GetComponent<CapsuleHand>();

        toggle3DCollider = toggle3DGameObject.GetComponent <Collider> ();
        toggle3Dscript   = toggle3DGameObject.GetComponent <DiageticToggle>();

        slider1Collider = slider1.GetComponent <Collider> ();
        slider1script   = slider1.GetComponent <DiageticSlider> ();

        sliderFollowersCollider = sliderFollowers.GetComponent <Collider>();
        sliderFollowersScript   = sliderFollowers.GetComponent <DiageticSlider>();
    }
Ejemplo n.º 5
0
        void Start()
        {
            //tileClass = FindObjectOfType<GenerateGraph>().GetComponent<GenerateGraph>();
            player    = FindObjectOfType <PlayerController>().transform;
            tileClass = GenerateGraph.generateGraph;
            // Debug.Log(tileClass);
            graphTools  = GrapthTools.GetInstance();
            visitedTile = new MyTile[tileClass.bounds.size.x, tileClass.bounds.size.y];
            createPath  = new List <CreatePath>();
            rpath       = new List <Path>();
            path        = new List <Path>();
            crossroads  = new List <MyTile>();
            path2       = rpath;
            rb          = GetComponent <Rigidbody2D>();
            patrolPoint = new List <Vector2Int>();

            foreach (var a in GameObject.FindGameObjectsWithTag("PatrolPoint"))
            {
                patrolPoint.Add(graphTools.RoundToTileCoord(a.transform.position.x, a.transform.position.y));
            }

            //Check Pattern Singleton in code
            int tx = graphTools.RoundToTileCoord(transform.position.x, 0).x;
            int ty = graphTools.RoundToTileCoord(0, transform.position.y).y;

            startTileCoord = new Vector2Int(tx, ty);
            endTileCoord   = startTileCoord;
            if (patrolPoint.Count > 0)
            {
                endTileCoord = patrolPoint[patrolPointNumber];
            }
            // Debug.Log(endTileCoord);
            // UpdatePath();
        }
    public static object globalLock;     // Global lock for synchronizing access to nodes (only one car
    // claim a node at any given time)

    // <summary>
    // Constructor that initializes the data structures necessary for the path planning approach
    // </summary>
    static PathPlanningDataStructures()
    {
        graph      = new GenerateGraph();
        heuristic  = new HeuristicD(graph);
        globalLock = new object();
        Debug.Log("Heuristic Finished");
    }
 // <summary>
 // Constructor that initializes the data structures necessary for the path planning approach
 // </summary>
 public static void initializePathPlanning()
 {
     lock (globalLock) {
         if (pathPlanningInitialized == false) {
             graph = new GenerateGraph ();
             heuristic = new HeuristicD (graph);
             pathPlanningInitialized = true;
         }
     }
 }
Ejemplo n.º 8
0
    void Start()
    {
        myGraph = sceneGod.GetComponent <GenerateGraph> ();

        GameObject prefabLineToRender = Resources.Load("Line") as GameObject;
        GameObject lineToRender       = Instantiate(prefabLineToRender, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;

        myLineRenderer         = lineToRender.GetComponent <LineRenderer> ();
        myLineRenderer.enabled = false;
    }
 // <summary>
 // Constructor that initializes the data structures necessary for the path planning approach
 // </summary>
 public static void initializePathPlanning()
 {
     lock (globalLock) {
         if (pathPlanningInitialized == false)
         {
             graph     = new GenerateGraph();
             heuristic = new HeuristicD(graph);
             pathPlanningInitialized = true;
         }
     }
 }
Ejemplo n.º 10
0
 // ONLY YIN !1!!!1
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(this);
     }
 }
Ejemplo n.º 11
0
    void Start()
    {
        GameObject prefabLineToRender = Resources.Load("Line") as GameObject;
        GameObject lineToRender       = Instantiate(prefabLineToRender, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;

        myLineRenderer         = lineToRender.GetComponent <LineRenderer>();
        myLineRenderer.enabled = false;

        graphGenerator = this.gameObject.GetComponent <GenerateGraph>();

        toggle3DCollider = toggle3DGameObject.GetComponent <Collider>();
        toggle3Dscript   = toggle3DGameObject.GetComponent <DiageticToggle>();

        slider1Collider = slider1.GetComponent <Collider>();
        slider1script   = slider1.GetComponent <DiageticSlider>();

        sliderFollowersCollider = sliderFollowers.GetComponent <Collider>();
        sliderFollowersScript   = sliderFollowers.GetComponent <DiageticSlider>();
    }
    public HeuristicD(GenerateGraph graph)
    {
        heuristicCost = new Dictionary<Node, float>();

        PriorityQueue<Node> pq = new PriorityQueue<Node>(graph.Size ());
        Dictionary<Node, float> cost_so_far = new Dictionary<Node, float> ();
        pq.queue(0.0f, graph.endNode);
        cost_so_far.Add (graph.endNode, 0.0f);
        while (pq.getSize() > 0) {
            Node current = pq.dequeue();
            heuristicCost[current] = cost_so_far[current];
            for (int i = 0; i < current.neighbors.Count; i++) {
                float new_cost = cost_so_far[current] + Node.distanceBetweenNodes(current, current.neighbors[i]);
                if (!cost_so_far.ContainsKey(current.neighbors[i]) || new_cost < cost_so_far[current.neighbors[i]]) {
                    cost_so_far[current.neighbors[i]] = new_cost;
                    pq.queue(new_cost, current.neighbors[i]);
                }
            }
        }
    }
Ejemplo n.º 13
0
    void Start()
    {
        graphGenerator = sceneGod.GetComponent<GenerateGraph>();

        RMMenuItem[] items = new RMMenuItem[3];
        items[0] = item1.GetComponent<RMMenuItem>();
        items[0].onClick = clicked2D3D;
        items[1] = item2.GetComponent<RMMenuItem>();
        items[1].onClick = setNodeDegree;
        items[2] = item3.GetComponent<RMMenuItem>();
        items[2].onClick = onClick;

        menu = menuBox.GetComponent<RMMenu>();
        menu.SetMenuItems(items);

        /*
                items[0] = item1;
                items[1] = item2;
                items[2] = item3;

                /*
                foreach (string item in items)
                {
                    GameObject menuItem = Instantiate(Resources.Load("MenuItem") as GameObject, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject;
                    menuBox.gameObject.transform.parent = menuItem.transform;
                }
                */
    }
Ejemplo n.º 14
0
 static AStar()
 {
     graph = new GenerateGraph();
     heuristic = new HeuristicD(graph);
 }
Ejemplo n.º 15
0
    void Start()
    {
        GameObject prefabLineToRender = Resources.Load("Line") as GameObject;
        GameObject lineToRender = Instantiate(prefabLineToRender, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
        myLineRenderer = lineToRender.GetComponent<LineRenderer>();
        myLineRenderer.enabled = false;

        graphGenerator = this.gameObject.GetComponent<GenerateGraph>();

        toggle3DCollider = toggle3DGameObject.GetComponent<Collider>();
        toggle3Dscript = toggle3DGameObject.GetComponent<DiageticToggle>();

        slider1Collider = slider1.GetComponent<Collider>();
        slider1script = slider1.GetComponent<DiageticSlider>();

        sliderFollowersCollider = sliderFollowers.GetComponent<Collider>();
        sliderFollowersScript = sliderFollowers.GetComponent<DiageticSlider>();
    }
Ejemplo n.º 16
0
 static AStar()
 {
     graph     = new GenerateGraph();
     heuristic = new HeuristicD(graph);
 }