Esempio n. 1
0
    public RoadNode(int idx, Transform prevChunk, float prevRotY, int prevCost, RoadCreator creator, ArrayList pathUntilNow, Transform destiny)
    {
        this.creator = creator;

        this.chunkIdx=idx;

        this.destination = destiny;

        this.pathUntilNow = (ArrayList)pathUntilNow.Clone();
        this.pathUntilNow.Add(chunkIdx);

        GameObject currentChunk = UnityEngine.Object.Instantiate (creator.roadChunks[chunkIdx]) as GameObject;
        currentChunk.collider.enabled=false;
        currentChunk.name= "Astar";
        currentChunk.tag="starchunk";
        this.overlap = creator.putChunk(prevChunk, prevRotY, currentChunk);

        this.mountPoint = currentChunk.GetComponent<RoadChunk>().mountPoint;

        this.costSoFar = prevCost + Mathf.Abs((int)(this.mountPoint.transform.localPosition.x)) + Mathf.Abs((int)(this.mountPoint.transform.localPosition.z));

        this.rotY = prevRotY + mountPoint.localRotation.eulerAngles.y;
    }
Esempio n. 2
0
    public RoadNode(int idx, Transform prevChunk, float prevRotY, int prevCost, RoadCreator creator, ArrayList pathUntilNow, Transform destiny)
    {
        this.creator = creator;

        this.chunkIdx = idx;

        this.destination = destiny;

        this.pathUntilNow = (ArrayList)pathUntilNow.Clone();
        this.pathUntilNow.Add(chunkIdx);

        GameObject currentChunk = UnityEngine.Object.Instantiate(creator.roadChunks[chunkIdx]) as GameObject;

        currentChunk.collider.enabled = false;
        currentChunk.name             = "Astar";
        currentChunk.tag = "starchunk";
        this.overlap     = creator.putChunk(prevChunk, prevRotY, currentChunk);

        this.mountPoint = currentChunk.GetComponent <RoadChunk>().mountPoint;

        this.costSoFar = prevCost + Mathf.Abs((int)(this.mountPoint.transform.localPosition.x)) + Mathf.Abs((int)(this.mountPoint.transform.localPosition.z));

        this.rotY = prevRotY + mountPoint.localRotation.eulerAngles.y;
    }