Beispiel #1
0
    public void OnEnable()
    {
        mapLocation = GameObject.Find("Main Camera").GetComponent <HeuristicMap>();
        label       = GetComponentInChildren <Text>();
        float xpos      = transform.position.x + mapLocation.fieldLength / 2;
        float ypos      = transform.position.y + mapLocation.fieldHeight / 2;
        float heuristic = mapLocation.nodeHeuristic[(int)xpos, (int)ypos];

        label.text  = heuristic.ToString();
        label.color = new Color(heuristic / 10, 0, 0);
    }
Beispiel #2
0
    public void OnEnable()
    {
        mapLocation = GameObject.Find("Main Camera").GetComponent <HeuristicMap>();
        float xpos      = transform.localPosition.x + mapLocation.fieldLength / 2;
        float ypos      = transform.localPosition.y + mapLocation.fieldHeight / 2;
        float heuristic = mapLocation.nodeHeuristic[(int)xpos, (int)ypos];

        if (heuristic != 0f)
        {
            Vector2 destination = nextMove((int)xpos, (int)ypos);
            mapLocation.pathFind(destination, transform.parent.transform);
        }
    }